Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ object ShortNames {
"ai" to "alignItems",
"al" to "alignment",
"as" to "alignSelf",
"a" to "alpha",
"ar" to "aspectRatio",
"an" to "assetName",
"bkg" to "background",
Expand All @@ -33,13 +34,16 @@ object ShortNames {
"bs" to "buttonStyle",
"csa" to "chartScrollableAxes",
"chk" to "checked",
"chc" to "checkedColor",
"clip" to "clipped",
"c" to "color",
"cf" to "colorFilter",
"cls" to "colors",
"cols" to "columns",
"ca" to "contentAlignment",
"cc" to "contentColor",
"cdesc" to "contentDescription",
"csc" to "contentScale",
"cr" to "cornerRadius",
"cd" to "countDown",
"cvl" to "currentValueLabel",
Expand Down Expand Up @@ -78,6 +82,7 @@ object ShortNames {
"halig" to "horizontalAlignment",
"hp" to "horizontalPadding",
"ic" to "icon",
"icc" to "iconColor",
"id" to "id",
"it" to "italic",
"jc" to "justifyContent",
Expand Down Expand Up @@ -128,6 +133,7 @@ object ShortNames {
"pt" to "paddingTop",
"pv" to "paddingVertical",
"pos" to "position",
"prg" to "progress",
"pc" to "progressColor",
"rm" to "resizeMode",
"r" to "right",
Expand All @@ -145,24 +151,31 @@ object ShortNames {
"src" to "source",
"sp" to "spacing",
"start" to "startAtMs",
"sic" to "startIcon",
"stp" to "startPoint",
"sts" to "stops",
"st" to "strikethrough",
"s" to "style",
"si" to "systemImage",
"txt" to "text",
"ta" to "textAlign",
"txc" to "textColor",
"tdl" to "textDecorationLine",
"ts" to "textStyle",
"tt" to "textTemplates",
"th" to "thumb",
"thc" to "thumbCheckedColor",
"thu" to "thumbUncheckedColor",
"tnt" to "tint",
"tc" to "tintColor",
"ttl" to "title",
"t" to "top",
"trkc" to "trackCheckedColor",
"trc" to "trackColor",
"trku" to "trackUncheckedColor",
"tf" to "transform",
"typ" to "type",
"uchc" to "uncheckedColor",
"ul" to "underline",
"v" to "value",
"valig" to "verticalAlignment",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.glance.appwidget.RadioButton
import androidx.glance.appwidget.RadioButtonDefaults
import androidx.glance.appwidget.Switch
import androidx.glance.appwidget.SwitchDefaults
import androidx.glance.unit.ColorProvider
import voltra.glance.LocalVoltraRenderContext
import voltra.glance.renderers.getOnClickAction
import voltra.glance.resolveAndApplyStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fun RenderImage(
)
val alpha = (element.p?.get("alpha") as? Number)?.toFloat() ?: 1.0f

val tintColorString = element.p?.get("tintColor") as? String
val tintColorString = (element.p?.get("colorFilter") ?: element.p?.get("tintColor")) as? String
val colorFilter =
if (tintColorString != null) {
voltra.styling.JSColorParser.parse(tintColorString)?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ data class AndroidCheckBoxParameters(
val id: String,
/** Initial checked state */
val checked: Boolean? = null,
/** Whether the checkbox is enabled */
val enabled: Boolean? = null,
/** Text label */
val text: String? = null,
/** Checked color */
val checkedColor: String? = null,
/** Unchecked color */
val uncheckedColor: String? = null,
/** Maximum lines for text */
val maxLines: Double? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ data class AndroidImageParameters(
val source: String,
/** Resizing mode */
val resizeMode: String? = null,
/** Accessibility description */
val contentDescription: String? = null,
/** How the image should scale within its bounds */
val contentScale: String? = null,
/** Image opacity from 0 to 1 */
val alpha: Double? = null,
/** Tint color filter */
val colorFilter: String? = null,
/** Legacy tint color alias for colorFilter */
val tintColor: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import kotlinx.serialization.Serializable
*/
@Serializable
data class AndroidLinearProgressIndicatorParameters(
/** Progress value from 0 to 1 */
val progress: Double? = null,
/** Progress color */
val color: String? = null,
/** Track background color */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@ data class AndroidRadioButtonParameters(
val checked: Boolean? = null,
/** Whether the radio button is enabled */
val enabled: Boolean? = null,
/** Text label */
val text: String? = null,
/** Checked color */
val checkedColor: String? = null,
/** Unchecked color */
val uncheckedColor: String? = null,
/** Maximum lines for text */
val maxLines: Double? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ data class AndroidSwitchParameters(
val id: String,
/** Initial checked state */
val checked: Boolean? = null,
/** Whether the switch is enabled */
val enabled: Boolean? = null,
/** Text label */
val text: String? = null,
/** Checked thumb color */
val thumbCheckedColor: String? = null,
/** Unchecked thumb color */
val thumbUncheckedColor: String? = null,
/** Checked track color */
val trackCheckedColor: String? = null,
/** Unchecked track color */
val trackUncheckedColor: String? = null,
/** Maximum lines for text */
val maxLines: Double? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ import kotlinx.serialization.Serializable
data class AndroidTitleBarParameters(
/** Title text */
val title: String,
/** Background color */
val backgroundColor: String? = null,
/** Text color */
val contentColor: String? = null,
/** Leading icon */
val startIcon: String,
/** Leading icon tint color */
val iconColor: String? = null,
/** Title text color */
val textColor: String? = null,
/** Title font family */
val fontFamily: String? = null,
)
10 changes: 5 additions & 5 deletions packages/android/src/jsx/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { createVoltraComponent } from './createVoltraComponent.js'
import type { AndroidImageProps as ImageProps } from './props/AndroidImage.js'
import type { AndroidImageProps } from './props/AndroidImage.js'

export type { ImageProps }
export type ImageSource = { assetName: string } | { base64: string }

export type ImagePropsWithSource = Omit<ImageProps, 'source'> & {
export type ImageProps = Omit<AndroidImageProps, 'source'> & {
source: ImageSource
resizeMode?: 'cover' | 'contain' | 'stretch' | 'repeat' | 'center'
}

export const Image = createVoltraComponent<ImagePropsWithSource>('AndroidImage', {
export type ImagePropsWithSource = ImageProps

export const Image = createVoltraComponent<ImageProps>('AndroidImage', {
toJSON: (props) => {
const { source, ...rest } = props

Expand Down
8 changes: 4 additions & 4 deletions packages/android/src/jsx/TitleBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import type { ImageSource } from './Image.js'
import { createVoltraComponent } from './createVoltraComponent.js'
import type { AndroidTitleBarProps } from './props/AndroidTitleBar.js'

/** Wire payload supports an optional leading icon (not yet in generated AndroidTitleBar props). */
export type TitleBarProps = AndroidTitleBarProps & {
startIcon?: ImageSource
export type TitleBarProps = Omit<AndroidTitleBarProps, 'startIcon'> & {
startIcon: ImageSource
}

export const TitleBar = createVoltraComponent<TitleBarProps>('AndroidTitleBar', {
toJSON: (props) => {
const { startIcon, ...rest } = props

return {
...rest,
...(startIcon ? { startIcon: JSON.stringify(startIcon) } : {}),
startIcon: JSON.stringify(startIcon),
}
},
})
10 changes: 8 additions & 2 deletions packages/android/src/jsx/props/AndroidCheckBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export type AndroidCheckBoxProps = VoltraBaseProps & {
id: string
/** Initial checked state */
checked?: boolean
/** Whether the checkbox is enabled */
enabled?: boolean
/** Text label */
text?: string
/** Checked color */
checkedColor?: string
/** Unchecked color */
uncheckedColor?: string
/** Maximum lines for text */
maxLines?: number
}
10 changes: 10 additions & 0 deletions packages/android/src/jsx/props/AndroidImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ export type AndroidImageProps = VoltraBaseProps & {
source: Record<string, any>
/** Resizing mode */
resizeMode?: 'cover' | 'contain' | 'stretch' | 'repeat' | 'center'
/** Accessibility description */
contentDescription?: string
/** How the image should scale within its bounds */
contentScale?: 'crop' | 'cover' | 'fit' | 'contain' | 'fill-bounds' | 'stretch'
/** Image opacity from 0 to 1 */
alpha?: number
/** Tint color filter */
colorFilter?: string
/** Legacy tint color alias for colorFilter */
tintColor?: string
/** Custom fallback content rendered when the image is missing */
fallback?: ReactNode
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import type { VoltraBaseProps } from '../baseProps'

export type AndroidLinearProgressIndicatorProps = VoltraBaseProps & {
/** Progress value from 0 to 1 */
progress?: number
/** Progress color */
color?: string
/** Track background color */
Expand Down
8 changes: 8 additions & 0 deletions packages/android/src/jsx/props/AndroidRadioButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ export type AndroidRadioButtonProps = VoltraBaseProps & {
checked?: boolean
/** Whether the radio button is enabled */
enabled?: boolean
/** Text label */
text?: string
/** Checked color */
checkedColor?: string
/** Unchecked color */
uncheckedColor?: string
/** Maximum lines for text */
maxLines?: number
}
14 changes: 12 additions & 2 deletions packages/android/src/jsx/props/AndroidSwitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ export type AndroidSwitchProps = VoltraBaseProps & {
id: string
/** Initial checked state */
checked?: boolean
/** Whether the switch is enabled */
enabled?: boolean
/** Text label */
text?: string
/** Checked thumb color */
thumbCheckedColor?: string
/** Unchecked thumb color */
thumbUncheckedColor?: string
/** Checked track color */
trackCheckedColor?: string
/** Unchecked track color */
trackUncheckedColor?: string
/** Maximum lines for text */
maxLines?: number
}
12 changes: 8 additions & 4 deletions packages/android/src/jsx/props/AndroidTitleBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import type { VoltraBaseProps } from '../baseProps'
export type AndroidTitleBarProps = VoltraBaseProps & {
/** Title text */
title: string
/** Background color */
backgroundColor?: string
/** Text color */
contentColor?: string
/** Leading icon */
startIcon: Record<string, any>
/** Leading icon tint color */
iconColor?: string
/** Title text color */
textColor?: string
/** Title font family */
fontFamily?: 'monospace' | 'serif' | 'sans-serif' | 'cursive'
}
Loading
Loading