@expo/ui 55.0.4 → 55.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/ui/AlertDialogView.kt +56 -28
  4. package/android/src/main/java/expo/modules/ui/BasicAlertDialogView.kt +9 -1
  5. package/android/src/main/java/expo/modules/ui/CarouselView.kt +93 -67
  6. package/android/src/main/java/expo/modules/ui/DividerView.kt +21 -2
  7. package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +25 -17
  8. package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +6 -0
  9. package/android/src/main/java/expo/modules/ui/PullToRefreshBoxView.kt +20 -3
  10. package/android/src/main/java/expo/modules/ui/SlotView.kt +8 -0
  11. package/android/src/main/java/expo/modules/ui/SurfaceView.kt +88 -11
  12. package/android/src/main/java/expo/modules/ui/TextInputView.kt +15 -3
  13. package/android/src/main/java/expo/modules/ui/TextView.kt +145 -12
  14. package/build/jetpack-compose/AlertDialog/index.d.ts +72 -36
  15. package/build/jetpack-compose/AlertDialog/index.d.ts.map +1 -1
  16. package/build/jetpack-compose/BasicAlertDialog/index.d.ts +7 -2
  17. package/build/jetpack-compose/BasicAlertDialog/index.d.ts.map +1 -1
  18. package/build/jetpack-compose/Card/index.d.ts.map +1 -1
  19. package/build/jetpack-compose/Carousel/index.d.ts +86 -23
  20. package/build/jetpack-compose/Carousel/index.d.ts.map +1 -1
  21. package/build/jetpack-compose/Divider/index.d.ts +20 -5
  22. package/build/jetpack-compose/Divider/index.d.ts.map +1 -1
  23. package/build/jetpack-compose/Progress/index.d.ts +6 -7
  24. package/build/jetpack-compose/Progress/index.d.ts.map +1 -1
  25. package/build/jetpack-compose/PullToRefreshBox/index.d.ts +34 -9
  26. package/build/jetpack-compose/PullToRefreshBox/index.d.ts.map +1 -1
  27. package/build/jetpack-compose/Surface/index.d.ts +52 -2
  28. package/build/jetpack-compose/Surface/index.d.ts.map +1 -1
  29. package/build/jetpack-compose/Text/index.d.ts +77 -89
  30. package/build/jetpack-compose/Text/index.d.ts.map +1 -1
  31. package/build/jetpack-compose/TextInput/index.d.ts +18 -3
  32. package/build/jetpack-compose/TextInput/index.d.ts.map +1 -1
  33. package/build/jetpack-compose/index.d.ts +2 -2
  34. package/build/jetpack-compose/index.d.ts.map +1 -1
  35. package/build/jetpack-compose/modifiers/index.d.ts +5 -0
  36. package/build/jetpack-compose/modifiers/index.d.ts.map +1 -1
  37. package/build/swift-ui/modifiers/index.d.ts +1 -1
  38. package/build/types.d.ts +26 -0
  39. package/build/types.d.ts.map +1 -1
  40. package/expo-module.config.json +1 -1
  41. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.4/expo.modules.ui-55.0.4-sources.jar → 55.0.6/expo.modules.ui-55.0.6-sources.jar} +0 -0
  42. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6-sources.jar.md5 +1 -0
  43. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6-sources.jar.sha1 +1 -0
  44. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6-sources.jar.sha256 +1 -0
  45. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6-sources.jar.sha512 +1 -0
  46. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6.aar +0 -0
  47. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6.aar.md5 +1 -0
  48. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6.aar.sha1 +1 -0
  49. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6.aar.sha256 +1 -0
  50. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6.aar.sha512 +1 -0
  51. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.4/expo.modules.ui-55.0.4.module → 55.0.6/expo.modules.ui-55.0.6.module} +22 -22
  52. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6.module.md5 +1 -0
  53. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6.module.sha1 +1 -0
  54. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6.module.sha256 +1 -0
  55. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6.module.sha512 +1 -0
  56. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.4/expo.modules.ui-55.0.4.pom → 55.0.6/expo.modules.ui-55.0.6.pom} +1 -1
  57. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6.pom.md5 +1 -0
  58. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6.pom.sha1 +1 -0
  59. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6.pom.sha256 +1 -0
  60. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.6/expo.modules.ui-55.0.6.pom.sha512 +1 -0
  61. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml +4 -4
  62. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.md5 +1 -1
  63. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha1 +1 -1
  64. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha256 +1 -1
  65. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha512 +1 -1
  66. package/package.json +2 -2
  67. package/src/jetpack-compose/AlertDialog/index.tsx +94 -41
  68. package/src/jetpack-compose/BasicAlertDialog/index.tsx +9 -2
  69. package/src/jetpack-compose/Card/index.tsx +4 -2
  70. package/src/jetpack-compose/Carousel/index.tsx +118 -30
  71. package/src/jetpack-compose/Divider/index.tsx +34 -14
  72. package/src/jetpack-compose/Progress/index.tsx +11 -9
  73. package/src/jetpack-compose/PullToRefreshBox/index.tsx +35 -18
  74. package/src/jetpack-compose/Surface/index.tsx +75 -4
  75. package/src/jetpack-compose/Text/index.tsx +171 -101
  76. package/src/jetpack-compose/TextInput/index.tsx +38 -8
  77. package/src/jetpack-compose/index.ts +2 -2
  78. package/src/jetpack-compose/modifiers/index.ts +10 -0
  79. package/src/swift-ui/modifiers/index.ts +1 -1
  80. package/src/types.ts +27 -0
  81. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4-sources.jar.md5 +0 -1
  82. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4-sources.jar.sha1 +0 -1
  83. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4-sources.jar.sha256 +0 -1
  84. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4-sources.jar.sha512 +0 -1
  85. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.aar +0 -0
  86. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.aar.md5 +0 -1
  87. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.aar.sha1 +0 -1
  88. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.aar.sha256 +0 -1
  89. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.aar.sha512 +0 -1
  90. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.module.md5 +0 -1
  91. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.module.sha1 +0 -1
  92. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.module.sha256 +0 -1
  93. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.module.sha512 +0 -1
  94. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.pom.md5 +0 -1
  95. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.pom.sha1 +0 -1
  96. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.pom.sha256 +0 -1
  97. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.pom.sha512 +0 -1
@@ -5,32 +5,109 @@ import androidx.compose.material3.MaterialTheme
5
5
  import androidx.compose.material3.Surface
6
6
  import androidx.compose.material3.contentColorFor
7
7
  import androidx.compose.runtime.Composable
8
+ import androidx.compose.runtime.remember
9
+ import androidx.compose.ui.graphics.RectangleShape
8
10
  import androidx.compose.ui.unit.dp
11
+ import expo.modules.kotlin.records.Field
12
+ import expo.modules.kotlin.records.Record
9
13
  import expo.modules.kotlin.views.ComposableScope
10
14
  import expo.modules.kotlin.views.ComposeProps
11
15
  import expo.modules.kotlin.views.FunctionalComposableScope
12
16
 
17
+
18
+ data class SurfaceBorder(
19
+ @Field val width: Float = 1f,
20
+ @Field val color: Color? = null
21
+ ) : Record
22
+
13
23
  data class SurfaceProps(
14
24
  val color: Color? = null,
15
25
  val contentColor: Color? = null,
16
- val tonalElevation: Float = 0f,
17
- val shadowElevation: Float = 0f,
26
+ val tonalElevation: Float? = null,
27
+ val shadowElevation: Float? = null,
28
+ val shape: ShapeRecord? = null,
29
+ val border: SurfaceBorder? = null,
30
+ val clickable: Boolean = false,
31
+ val enabled: Boolean = true,
32
+ val selected: Boolean? = null,
33
+ val checked: Boolean? = null,
18
34
  val modifiers: ModifierList = emptyList()
19
35
  ) : ComposeProps
20
36
 
21
37
  @Composable
22
- fun FunctionalComposableScope.SurfaceContent(props: SurfaceProps) {
38
+ fun FunctionalComposableScope.SurfaceContent(
39
+ props: SurfaceProps,
40
+ onClick: () -> Unit,
41
+ onCheckedChange: (Boolean) -> Unit
42
+ ) {
23
43
  val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
24
44
  val color = props.color?.compose ?: MaterialTheme.colorScheme.surface
25
45
  val contentColor = props.contentColor?.compose ?: contentColorFor(color)
46
+ val shape = remember(props.shape) { shapeFromShapeRecord(props.shape) ?: RectangleShape }
47
+ val tonalElevation = (props.tonalElevation ?: 0f).dp
48
+ val shadowElevation = (props.shadowElevation ?: 0f).dp
49
+ val outlineColor = MaterialTheme.colorScheme.outline
50
+ val border = remember(props.border, outlineColor) {
51
+ props.border?.let { b ->
52
+ val bColor = b.color.composeOrNull ?: outlineColor
53
+ androidx.compose.foundation.BorderStroke(b.width.dp, bColor)
54
+ }
55
+ }
56
+
57
+ val content: @Composable () -> Unit = { Children(ComposableScope()) }
26
58
 
27
- Surface(
28
- modifier = modifier,
29
- color = color,
30
- contentColor = contentColor,
31
- tonalElevation = props.tonalElevation.dp,
32
- shadowElevation = props.shadowElevation.dp
33
- ) {
34
- Children(ComposableScope())
59
+ when {
60
+ // Toggleable variant
61
+ props.checked != null -> Surface(
62
+ checked = props.checked,
63
+ onCheckedChange = { onCheckedChange(it) },
64
+ modifier = modifier,
65
+ enabled = props.enabled,
66
+ shape = shape,
67
+ color = color,
68
+ contentColor = contentColor,
69
+ tonalElevation = tonalElevation,
70
+ shadowElevation = shadowElevation,
71
+ border = border,
72
+ content = content
73
+ )
74
+ // Selectable variant
75
+ props.selected != null -> Surface(
76
+ selected = props.selected,
77
+ onClick = { onClick() },
78
+ modifier = modifier,
79
+ enabled = props.enabled,
80
+ shape = shape,
81
+ color = color,
82
+ contentColor = contentColor,
83
+ tonalElevation = tonalElevation,
84
+ shadowElevation = shadowElevation,
85
+ border = border,
86
+ content = content
87
+ )
88
+ // Clickable variant
89
+ props.clickable -> Surface(
90
+ onClick = { onClick() },
91
+ modifier = modifier,
92
+ enabled = props.enabled,
93
+ shape = shape,
94
+ color = color,
95
+ contentColor = contentColor,
96
+ tonalElevation = tonalElevation,
97
+ shadowElevation = shadowElevation,
98
+ border = border,
99
+ content = content
100
+ )
101
+ // Basic (non-interactive) variant
102
+ else -> Surface(
103
+ modifier = modifier,
104
+ shape = shape,
105
+ color = color,
106
+ contentColor = contentColor,
107
+ tonalElevation = tonalElevation,
108
+ shadowElevation = shadowElevation,
109
+ border = border,
110
+ content = content
111
+ )
35
112
  }
36
113
  }
@@ -12,21 +12,27 @@ import androidx.compose.runtime.mutableStateOf
12
12
  import androidx.compose.ui.text.input.KeyboardCapitalization
13
13
  import androidx.compose.ui.text.input.KeyboardType
14
14
  import expo.modules.kotlin.AppContext
15
+ import expo.modules.kotlin.types.Enumerable
15
16
  import expo.modules.kotlin.viewevent.EventDispatcher
16
17
  import expo.modules.kotlin.views.ComposableScope
17
18
  import expo.modules.kotlin.views.ComposeProps
18
19
  import expo.modules.kotlin.views.ExpoComposeView
19
20
 
21
+ enum class TextInputViewVariant(val value: String) : Enumerable {
22
+ FILLED("filled"),
23
+ OUTLINED("outlined"),
24
+ }
25
+
20
26
  data class TextInputProps(
21
27
  val defaultValue: MutableState<String> = mutableStateOf(""),
22
28
  val placeholder: MutableState<String> = mutableStateOf(""),
23
- val variant: MutableState<String> = mutableStateOf("filled"),
29
+ val variant: MutableState<TextInputViewVariant> = mutableStateOf(TextInputViewVariant.FILLED),
24
30
  val multiline: MutableState<Boolean> = mutableStateOf(false),
25
31
  val numberOfLines: MutableState<Int?> = mutableStateOf(null),
26
32
  val keyboardType: MutableState<String> = mutableStateOf("default"),
27
33
  val autocorrection: MutableState<Boolean> = mutableStateOf(true),
28
34
  val autoCapitalize: MutableState<String> = mutableStateOf("none"),
29
- val modifiers: MutableState<ModifierList> = mutableStateOf(emptyList())
35
+ val modifiers: MutableState<ModifierList> = mutableStateOf(emptyList()),
30
36
  ) : ComposeProps
31
37
 
32
38
  private fun String.keyboardType(): KeyboardType {
@@ -85,9 +91,13 @@ class TextInputView(context: Context, appContext: AppContext) :
85
91
  autoCorrectEnabled = props.autocorrection.value,
86
92
  capitalization = props.autoCapitalize.value.autoCapitalize()
87
93
  )
94
+ val labelSlotView = findChildSlotView(this@TextInputView, "label")
95
+ val label: (@Composable () -> Unit)? = labelSlotView?.let {
96
+ { with(ComposableScope()) { with(it) { Content() } } }
97
+ }
88
98
  val modifier = ModifierRegistry.applyModifiers(props.modifiers.value, appContext, this@Content, globalEventDispatcher)
89
99
 
90
- if (props.variant.value == "outlined") {
100
+ if (props.variant.value == TextInputViewVariant.OUTLINED) {
91
101
  OutlinedTextField(
92
102
  value = value,
93
103
  onValueChange = onValueChange,
@@ -95,6 +105,7 @@ class TextInputView(context: Context, appContext: AppContext) :
95
105
  maxLines = maxLines,
96
106
  singleLine = singleLine,
97
107
  keyboardOptions = keyboardOptions,
108
+ label = label,
98
109
  modifier = modifier
99
110
  )
100
111
  } else {
@@ -105,6 +116,7 @@ class TextInputView(context: Context, appContext: AppContext) :
105
116
  maxLines = maxLines,
106
117
  singleLine = singleLine,
107
118
  keyboardOptions = keyboardOptions,
119
+ label = label,
108
120
  modifier = modifier
109
121
  )
110
122
  }
@@ -1,16 +1,28 @@
1
1
  package expo.modules.ui
2
2
 
3
+ import android.content.Context
3
4
  import android.graphics.Color
5
+ import android.graphics.Typeface
4
6
  import androidx.compose.material3.MaterialTheme
5
7
  import androidx.compose.material3.Text
6
8
  import androidx.compose.runtime.Composable
9
+ import androidx.compose.ui.geometry.Offset
10
+ import androidx.compose.ui.graphics.Shadow
11
+ import androidx.compose.ui.text.AnnotatedString
12
+ import androidx.compose.ui.text.SpanStyle
7
13
  import androidx.compose.ui.text.TextStyle
14
+ import androidx.compose.ui.text.buildAnnotatedString
15
+ import androidx.compose.ui.text.font.FontFamily
8
16
  import androidx.compose.ui.text.font.FontStyle
9
17
  import androidx.compose.ui.text.font.FontWeight
10
18
  import androidx.compose.ui.text.style.TextAlign
11
19
  import androidx.compose.ui.text.style.TextDecoration
12
20
  import androidx.compose.ui.text.style.TextOverflow
21
+ import androidx.compose.ui.text.withStyle
13
22
  import androidx.compose.ui.unit.sp
23
+ import com.facebook.react.common.assets.ReactFontManager
24
+ import expo.modules.kotlin.records.Field
25
+ import expo.modules.kotlin.records.Record
14
26
  import expo.modules.kotlin.types.Enumerable
15
27
  import expo.modules.kotlin.views.ComposeProps
16
28
  import expo.modules.kotlin.views.FunctionalComposableScope
@@ -105,6 +117,50 @@ enum class TextOverflowType(val value: String) : Enumerable {
105
117
  }
106
118
  }
107
119
 
120
+ enum class TextLineBreakType(val value: String) : Enumerable {
121
+ SIMPLE("simple"),
122
+ HEADING("heading"),
123
+ PARAGRAPH("paragraph");
124
+
125
+ fun toComposeLineBreak(): androidx.compose.ui.text.style.LineBreak {
126
+ return when (this) {
127
+ SIMPLE -> androidx.compose.ui.text.style.LineBreak.Simple
128
+ HEADING -> androidx.compose.ui.text.style.LineBreak.Heading
129
+ PARAGRAPH -> androidx.compose.ui.text.style.LineBreak.Paragraph
130
+ }
131
+ }
132
+ }
133
+
134
+ fun resolveFontFamily(name: String?, context: Context): FontFamily? {
135
+ if (name == null) return null
136
+ return when (name) {
137
+ "default" -> FontFamily.Default
138
+ "sansSerif" -> FontFamily.SansSerif
139
+ "serif" -> FontFamily.Serif
140
+ "monospace" -> FontFamily.Monospace
141
+ "cursive" -> FontFamily.Cursive
142
+ else -> {
143
+ val typeface = ReactFontManager.getInstance().getTypeface(name, Typeface.NORMAL, context.assets)
144
+ FontFamily(typeface)
145
+ }
146
+ }
147
+ }
148
+
149
+ data class TextShadowRecord(
150
+ @Field val color: Color? = null,
151
+ @Field val offsetX: Float? = null,
152
+ @Field val offsetY: Float? = null,
153
+ @Field val blurRadius: Float? = null
154
+ ) : Record {
155
+ fun toComposeShadow(): Shadow {
156
+ return Shadow(
157
+ color = colorToComposeColorOrNull(color) ?: androidx.compose.ui.graphics.Color.Black,
158
+ offset = Offset(offsetX ?: 0f, offsetY ?: 0f),
159
+ blurRadius = blurRadius ?: 0f
160
+ )
161
+ }
162
+ }
163
+
108
164
  enum class TypographyStyle(val value: String) : Enumerable {
109
165
  DISPLAY_LARGE("displayLarge"),
110
166
  DISPLAY_MEDIUM("displayMedium"),
@@ -145,23 +201,85 @@ enum class TypographyStyle(val value: String) : Enumerable {
145
201
  }
146
202
  }
147
203
 
204
+ /**
205
+ * Shared text and span-level style properties.
206
+ * Both TextSpanRecord and TextProps implement this to ensure style properties
207
+ * are consistent across parent text and nested spans.
208
+ */
209
+ interface TextSpanStyle {
210
+ val text: String
211
+ val color: Color?
212
+ val fontSize: Float?
213
+ val fontWeight: TextFontWeight?
214
+ val fontStyle: TextFontStyle?
215
+ val fontFamily: String?
216
+ val textDecoration: TextDecorationType?
217
+ val letterSpacing: Float?
218
+ val background: Color?
219
+ val shadow: TextShadowRecord?
220
+ }
221
+
222
+ data class TextSpanRecord(
223
+ @Field override val text: String = "",
224
+ @Field val children: List<TextSpanRecord>? = null,
225
+ @Field override val color: Color? = null,
226
+ @Field override val fontSize: Float? = null,
227
+ @Field override val fontWeight: TextFontWeight? = null,
228
+ @Field override val fontStyle: TextFontStyle? = null,
229
+ @Field override val fontFamily: String? = null,
230
+ @Field override val textDecoration: TextDecorationType? = null,
231
+ @Field override val letterSpacing: Float? = null,
232
+ @Field override val background: Color? = null,
233
+ @Field override val shadow: TextShadowRecord? = null
234
+ ) : Record, TextSpanStyle
235
+
148
236
  data class TextProps(
149
- val text: String = "",
150
- val color: Color? = null,
237
+ override val text: String = "",
238
+ val spans: List<TextSpanRecord>? = null,
239
+ override val color: Color? = null,
151
240
  val typography: TypographyStyle? = null,
152
- val fontSize: Float? = null,
153
- val fontWeight: TextFontWeight? = null,
154
- val fontStyle: TextFontStyle? = null,
241
+ override val fontSize: Float? = null,
242
+ override val fontWeight: TextFontWeight? = null,
243
+ override val fontStyle: TextFontStyle? = null,
244
+ override val fontFamily: String? = null,
155
245
  val textAlign: TextAlignType? = null,
156
- val textDecoration: TextDecorationType? = null,
157
- val letterSpacing: Float? = null,
246
+ override val textDecoration: TextDecorationType? = null,
247
+ override val letterSpacing: Float? = null,
158
248
  val lineHeight: Float? = null,
249
+ val lineBreak: TextLineBreakType? = null,
250
+ override val background: Color? = null,
251
+ override val shadow: TextShadowRecord? = null,
159
252
  val overflow: TextOverflowType? = null,
160
253
  val softWrap: Boolean? = null,
161
254
  val maxLines: Int? = null,
162
255
  val minLines: Int? = null,
163
256
  val modifiers: ModifierList = emptyList()
164
- ) : ComposeProps
257
+ ) : ComposeProps, TextSpanStyle
258
+
259
+ private fun AnnotatedString.Builder.appendSpans(spans: List<TextSpanRecord>, context: Context?) {
260
+ for (span in spans) {
261
+ val style = SpanStyle(
262
+ color = colorToComposeColorOrNull(span.color) ?: androidx.compose.ui.graphics.Color.Unspecified,
263
+ fontSize = span.fontSize?.sp ?: androidx.compose.ui.unit.TextUnit.Unspecified,
264
+ fontWeight = span.fontWeight?.toComposeFontWeight(),
265
+ fontStyle = span.fontStyle?.toComposeFontStyle(),
266
+ fontFamily = context?.let { resolveFontFamily(span.fontFamily, it) },
267
+ textDecoration = span.textDecoration?.toComposeTextDecoration(),
268
+ letterSpacing = span.letterSpacing?.sp ?: androidx.compose.ui.unit.TextUnit.Unspecified,
269
+ background = colorToComposeColorOrNull(span.background) ?: androidx.compose.ui.graphics.Color.Unspecified,
270
+ shadow = span.shadow?.toComposeShadow()
271
+ )
272
+ if (span.children != null) {
273
+ withStyle(style) {
274
+ appendSpans(span.children, context)
275
+ }
276
+ } else {
277
+ withStyle(style) {
278
+ append(span.text)
279
+ }
280
+ }
281
+ }
282
+ }
165
283
 
166
284
  @Composable
167
285
  fun FunctionalComposableScope.TextContent(props: TextProps) {
@@ -171,19 +289,34 @@ fun FunctionalComposableScope.TextContent(props: TextProps) {
171
289
  // Merge base style with custom properties
172
290
  val mergedStyle = baseStyle.merge(
173
291
  TextStyle(
292
+ color = colorToComposeColor(props.color),
174
293
  fontSize = props.fontSize?.sp ?: androidx.compose.ui.unit.TextUnit.Unspecified,
175
294
  fontWeight = props.fontWeight?.toComposeFontWeight(),
176
295
  fontStyle = props.fontStyle?.toComposeFontStyle(),
296
+ fontFamily = appContext.reactContext?.let { resolveFontFamily(props.fontFamily, it) },
177
297
  textDecoration = props.textDecoration?.toComposeTextDecoration(),
178
298
  letterSpacing = props.letterSpacing?.sp ?: androidx.compose.ui.unit.TextUnit.Unspecified,
179
- lineHeight = props.lineHeight?.sp ?: androidx.compose.ui.unit.TextUnit.Unspecified
299
+ lineHeight = props.lineHeight?.sp ?: androidx.compose.ui.unit.TextUnit.Unspecified,
300
+ lineBreak = props.lineBreak?.toComposeLineBreak() ?: androidx.compose.ui.text.style.LineBreak.Unspecified,
301
+ background = colorToComposeColorOrNull(props.background) ?: androidx.compose.ui.graphics.Color.Unspecified,
302
+ shadow = props.shadow?.toComposeShadow()
180
303
  )
181
304
  )
182
305
 
306
+ val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
307
+
308
+ val textValue = if (props.spans != null) {
309
+ val context = appContext.reactContext
310
+ buildAnnotatedString {
311
+ appendSpans(props.spans, context)
312
+ }
313
+ } else {
314
+ AnnotatedString(props.text)
315
+ }
316
+
183
317
  Text(
184
- text = props.text,
185
- modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher),
186
- color = colorToComposeColor(props.color),
318
+ text = textValue,
319
+ modifier = modifier,
187
320
  textAlign = props.textAlign?.toComposeTextAlign(),
188
321
  overflow = props.overflow?.toComposeTextOverflow() ?: TextOverflow.Clip,
189
322
  softWrap = props.softWrap ?: true,
@@ -1,62 +1,98 @@
1
1
  import { type ColorValue } from 'react-native';
2
- import { ExpoModifier } from '../../types';
3
- export type AlertDialogButtonColors = {
2
+ import { type ModifierConfig, type DialogProperties } from '../../types';
3
+ /**
4
+ * Colors for the alert dialog, matching `AlertDialogDefaults` in Compose.
5
+ */
6
+ export type AlertDialogColors = {
4
7
  /**
5
- * The background color of the button.
8
+ * The background color of the dialog.
6
9
  */
7
10
  containerColor?: ColorValue;
8
11
  /**
9
- * The text color of the button.
10
- */
11
- contentColor?: ColorValue;
12
- };
13
- export type AlertDialogProps = {
14
- /**
15
- * The title of the alert dialog.
12
+ * The color of the icon.
16
13
  */
17
- title?: string;
14
+ iconContentColor?: ColorValue;
18
15
  /**
19
- * The text of the alert dialog.
16
+ * The color of the title text.
20
17
  */
21
- text?: string;
18
+ titleContentColor?: ColorValue;
22
19
  /**
23
- * The text of the confirm button of the alert dialog.
20
+ * The color of the body text.
24
21
  */
25
- confirmButtonText?: string;
26
- /**
27
- * The text of the dismiss button of the alert dialog.
28
- */
29
- dismissButtonText?: string;
22
+ textContentColor?: ColorValue;
23
+ };
24
+ export type AlertDialogProps = {
30
25
  /**
31
- * The colors for the confirm button.
26
+ * Colors for the alert dialog.
32
27
  */
33
- confirmButtonColors?: AlertDialogButtonColors;
28
+ colors?: AlertDialogColors;
34
29
  /**
35
- * The colors for the dismiss button.
30
+ * The tonal elevation of the dialog in dp, which affects its background color
31
+ * based on the color scheme.
36
32
  */
37
- dismissButtonColors?: AlertDialogButtonColors;
33
+ tonalElevation?: number;
38
34
  /**
39
- * Whether the alert dialog is visible.
40
- *
41
- * @default false
35
+ * Properties for the dialog window.
42
36
  */
43
- visible?: boolean;
37
+ properties?: DialogProperties;
44
38
  /**
45
- * Callback that is called when the user tries to confirm the dialog.
39
+ * Callback that is called when the user tries to dismiss the dialog
40
+ * (for example, by tapping outside of it or pressing the back button).
46
41
  */
47
- onConfirmPressed?: () => void;
42
+ onDismissRequest?: () => void;
48
43
  /**
49
- * Callback that is called when the user tries to dismiss the dialog.
44
+ * Modifiers for the component.
50
45
  */
51
- onDismissPressed?: () => void;
46
+ modifiers?: ModifierConfig[];
52
47
  /**
53
- * Modifiers for the component.
48
+ * Children containing slot sub-components (`AlertDialog.Title`, `AlertDialog.Text`,
49
+ * `AlertDialog.ConfirmButton`, `AlertDialog.DismissButton`, `AlertDialog.Icon`).
54
50
  */
55
- modifiers?: ExpoModifier[];
51
+ children?: React.ReactNode;
56
52
  };
57
- export type NativeAlertDialogProps = AlertDialogProps;
58
53
  /**
59
- * Renders an `AlertDialog` component.
54
+ * The title slot of the `AlertDialog`.
55
+ */
56
+ declare function AlertDialogTitle(props: {
57
+ children: React.ReactNode;
58
+ }): import("react").JSX.Element;
59
+ /**
60
+ * The text (body) slot of the `AlertDialog`.
61
+ */
62
+ declare function AlertDialogText(props: {
63
+ children: React.ReactNode;
64
+ }): import("react").JSX.Element;
65
+ /**
66
+ * The confirm button slot of the `AlertDialog`.
67
+ */
68
+ declare function AlertDialogConfirmButton(props: {
69
+ children: React.ReactNode;
70
+ }): import("react").JSX.Element;
71
+ /**
72
+ * The dismiss button slot of the `AlertDialog`.
73
+ */
74
+ declare function AlertDialogDismissButton(props: {
75
+ children: React.ReactNode;
76
+ }): import("react").JSX.Element;
77
+ /**
78
+ * The icon slot of the `AlertDialog`.
79
+ */
80
+ declare function AlertDialogIcon(props: {
81
+ children: React.ReactNode;
82
+ }): import("react").JSX.Element;
83
+ /**
84
+ * Renders an `AlertDialog` component with slot-based content matching the Compose API.
85
+ * Content is provided via slot sub-components: `AlertDialog.Title`, `AlertDialog.Text`,
86
+ * `AlertDialog.ConfirmButton`, `AlertDialog.DismissButton`, and `AlertDialog.Icon`.
60
87
  */
61
- export declare function AlertDialog(props: AlertDialogProps): import("react").JSX.Element;
88
+ declare function AlertDialogComponent(props: AlertDialogProps): import("react").JSX.Element;
89
+ declare namespace AlertDialogComponent {
90
+ var Title: typeof AlertDialogTitle;
91
+ var Text: typeof AlertDialogText;
92
+ var ConfirmButton: typeof AlertDialogConfirmButton;
93
+ var DismissButton: typeof AlertDialogDismissButton;
94
+ var Icon: typeof AlertDialogIcon;
95
+ }
96
+ export { AlertDialogComponent as AlertDialog };
97
+ export type { DialogProperties };
62
98
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jetpack-compose/AlertDialog/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B;;OAEG;IACH,YAAY,CAAC,EAAE,UAAU,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,mBAAmB,CAAC,EAAE,uBAAuB,CAAC;IAC9C;;OAEG;IACH,mBAAmB,CAAC,EAAE,uBAAuB,CAAC;IAC9C;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAE9B;;OAEG;IACH,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAgBtD;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,+BAElD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jetpack-compose/Alert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;GAEG;AACH,iBAAS,eAAe,CAAC,KAAK,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,+BAE5D;AAED;;;;GAIG;AACH,iBAAS,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,+BAGpD;kBAHQ,oBAAoB;;;;;;;AAW7B,OAAO,EAAE,oBAAoB,IAAI,WAAW,EAAE,CAAC;AAG/C,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { type ExpoModifier } from '../../types';
1
+ import { type ModifierConfig, type DialogProperties } from '../../types';
2
2
  export type BasicAlertDialogProps = {
3
3
  /**
4
4
  * The content to display inside the dialog.
@@ -9,14 +9,19 @@ export type BasicAlertDialogProps = {
9
9
  * (e.g. by tapping outside of it or pressing the back button).
10
10
  */
11
11
  onDismissRequest?: () => void;
12
+ /**
13
+ * Properties for the dialog window.
14
+ */
15
+ properties?: DialogProperties;
12
16
  /**
13
17
  * Modifiers for the component.
14
18
  */
15
- modifiers?: ExpoModifier[];
19
+ modifiers?: ModifierConfig[];
16
20
  };
17
21
  /**
18
22
  * A basic alert dialog that provides a blank container for custom content.
19
23
  * Unlike `AlertDialog`, this component does not have structured title/text/buttons slots.
20
24
  */
21
25
  export declare function BasicAlertDialog(props: BasicAlertDialogProps): import("react").JSX.Element;
26
+ export type { DialogProperties };
22
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jetpack-compose/BasicAlertDialog/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhE,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B;;OAEG;IACH,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;CAC5B,CAAC;AAyBF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,+BAE5D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jetpack-compose/BasicAlertDialog/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGzF,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B;;OAEG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B;;OAEG;IACH,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;CAC9B,CAAC;AAyBF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,+BAE5D;AAGD,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jetpack-compose/Card/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,YAAY,CAAC,EAAE,UAAU,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,CAAC;AAsBF,MAAM,MAAM,SAAS,GAAG;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3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