@momo-kits/native-kits 0.169.13-debug → 0.169.14-beta.1

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 (147) hide show
  1. package/ios/Navigation/BottomTab/BottomTab.swift +22 -3
  2. package/ios/Navigation/BottomTab/DuoTabBar.swift +2 -0
  3. package/ios/Navigation/BottomTab/LegacyBottomTabBar.swift +226 -0
  4. package/ios/Navigation/StackScreen.swift +2 -1
  5. package/ios/native-kits.podspec +1 -1
  6. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  7. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +5 -1
  8. package/package.json +1 -1
  9. package/build.gradle.kts +0 -11
  10. package/compose/build.gradle.kts +0 -198
  11. package/compose/compose.podspec +0 -47
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  14. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  15. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  16. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  17. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  18. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -61
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1067
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -268
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -354
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -130
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -482
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -224
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -137
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -473
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -113
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -262
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -237
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -228
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -280
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -183
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -342
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -40
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -82
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -39
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -362
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -304
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -88
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -308
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -218
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -456
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -205
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -89
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -542
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -175
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -201
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -208
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -12
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -291
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -71
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -184
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -315
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -54
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -397
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -118
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -206
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -421
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -750
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -152
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -242
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -406
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -111
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -93
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -208
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -133
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -167
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -446
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -400
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -197
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -114
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -7
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -21
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -117
  132. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -65
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  139. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -143
  140. package/gradle/libs.versions.toml +0 -67
  141. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  142. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  143. package/gradle.properties +0 -24
  144. package/gradlew +0 -252
  145. package/gradlew.bat +0 -94
  146. package/ios-demo/README.md +0 -120
  147. package/settings.gradle.kts +0 -64
@@ -1,205 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.animation.core.Animatable
4
- import androidx.compose.animation.core.tween
5
- import androidx.compose.foundation.background
6
- import androidx.compose.foundation.border
7
- import androidx.compose.foundation.gestures.detectHorizontalDragGestures
8
- import androidx.compose.foundation.layout.*
9
- import androidx.compose.foundation.shape.RoundedCornerShape
10
- import androidx.compose.runtime.Composable
11
- import androidx.compose.runtime.getValue
12
- import androidx.compose.runtime.remember
13
- import androidx.compose.runtime.rememberCoroutineScope
14
- import androidx.compose.runtime.rememberUpdatedState
15
- import androidx.compose.ui.Alignment
16
- import androidx.compose.ui.Modifier
17
- import androidx.compose.ui.draw.clip
18
- import androidx.compose.ui.graphics.Color
19
- import androidx.compose.ui.input.pointer.pointerInput
20
- import androidx.compose.ui.platform.LocalDensity
21
- import androidx.compose.ui.unit.Dp
22
- import androidx.compose.ui.unit.IntOffset
23
- import androidx.compose.ui.unit.dp
24
- import kotlinx.coroutines.launch
25
- import vn.momo.kits.application.IsShowBaseLineDebug
26
- import vn.momo.kits.const.AppTheme
27
- import vn.momo.kits.const.Colors
28
- import vn.momo.kits.const.Typography
29
- import vn.momo.kits.modifier.activeOpacityClickable
30
- import vn.momo.kits.modifier.conditional
31
- import kotlin.math.roundToInt
32
-
33
- data class SwipeAction(
34
- val label: String = "",
35
- val icon: String = "",
36
- val onPress: () -> Unit = {},
37
- val backgroundColor: Color? = null,
38
- )
39
-
40
- private val ACTION_WIDTH = 56.dp
41
-
42
- @Composable
43
- fun Swipe(
44
- modifier: Modifier = Modifier,
45
- leftActions: List<SwipeAction> = emptyList(),
46
- rightActions: List<SwipeAction> = emptyList(),
47
- height: Dp = 56.dp,
48
- itemRadius: Dp = 0.dp,
49
- onSwipeableOpen: () -> Unit = {},
50
- onSwipeableClose: () -> Unit = {},
51
- onSwipeableLeftOpen: () -> Unit = {},
52
- onSwipeableRightOpen: () -> Unit = {},
53
- content: @Composable () -> Unit = {},
54
- ) {
55
- val theme = AppTheme.current
56
- val density = LocalDensity.current
57
- val scope = rememberCoroutineScope()
58
-
59
- val left = leftActions.take(3)
60
- val right = rightActions.take(3)
61
-
62
- val leftWidthPx = with(density) { (ACTION_WIDTH * left.size).toPx() }
63
- val rightWidthPx = with(density) { (ACTION_WIDTH * right.size).toPx() }
64
-
65
- val offsetX = remember { Animatable(0f) }
66
-
67
- // pointerInput is keyed on the action counts only, so read the latest callbacks.
68
- val currentOnOpen by rememberUpdatedState(onSwipeableOpen)
69
- val currentOnClose by rememberUpdatedState(onSwipeableClose)
70
- val currentOnLeftOpen by rememberUpdatedState(onSwipeableLeftOpen)
71
- val currentOnRightOpen by rememberUpdatedState(onSwipeableRightOpen)
72
-
73
- val shape = remember(itemRadius) {
74
- if (itemRadius > 0.dp) RoundedCornerShape(itemRadius) else RoundedCornerShape(0.dp)
75
- }
76
-
77
- fun snapToClosest() {
78
- scope.launch {
79
- val current = offsetX.value
80
- val target = when {
81
- current > leftWidthPx * 0.5f && left.isNotEmpty() -> {
82
- currentOnLeftOpen()
83
- currentOnOpen()
84
- leftWidthPx
85
- }
86
- current < -rightWidthPx * 0.5f && right.isNotEmpty() -> {
87
- currentOnRightOpen()
88
- currentOnOpen()
89
- -rightWidthPx
90
- }
91
- else -> {
92
- currentOnClose()
93
- 0f
94
- }
95
- }
96
- offsetX.animateTo(target, tween(200))
97
- }
98
- }
99
-
100
- Box(
101
- modifier = modifier
102
- .fillMaxWidth()
103
- .height(height)
104
- .conditional(IsShowBaseLineDebug) { border(1.dp, Colors.blue_03) }
105
- ) {
106
- if (left.isNotEmpty()) {
107
- Row(
108
- modifier = Modifier
109
- .align(Alignment.CenterStart)
110
- .fillMaxHeight()
111
- ) {
112
- left.forEach { action ->
113
- SwipeActionButton(
114
- action = action,
115
- width = ACTION_WIDTH,
116
- height = height,
117
- shape = shape,
118
- defaultColor = theme.colors.primary,
119
- )
120
- }
121
- }
122
- }
123
-
124
- if (right.isNotEmpty()) {
125
- Row(
126
- modifier = Modifier
127
- .align(Alignment.CenterEnd)
128
- .fillMaxHeight()
129
- ) {
130
- right.forEach { action ->
131
- SwipeActionButton(
132
- action = action,
133
- width = ACTION_WIDTH,
134
- height = height,
135
- shape = shape,
136
- defaultColor = theme.colors.error.primary,
137
- )
138
- }
139
- }
140
- }
141
-
142
- // Main content
143
- Box(
144
- modifier = Modifier
145
- .fillMaxWidth()
146
- .height(height)
147
- .offset { IntOffset(offsetX.value.roundToInt(), 0) }
148
- .clip(shape)
149
- .background(theme.colors.background.surface)
150
- .pointerInput(left.size, right.size) {
151
- detectHorizontalDragGestures(
152
- onDragEnd = { snapToClosest() },
153
- onDragCancel = { snapToClosest() },
154
- ) { _, dragAmount ->
155
- scope.launch {
156
- val newOffset = offsetX.value + dragAmount
157
- val clamped = newOffset.coerceIn(-rightWidthPx, leftWidthPx)
158
- offsetX.snapTo(clamped)
159
- }
160
- }
161
- }
162
- ) {
163
- content()
164
- }
165
- }
166
- }
167
-
168
- @Composable
169
- private fun SwipeActionButton(
170
- action: SwipeAction,
171
- width: Dp,
172
- height: Dp,
173
- shape: RoundedCornerShape,
174
- defaultColor: Color,
175
- ) {
176
- val bgColor = action.backgroundColor ?: defaultColor
177
-
178
- Box(
179
- modifier = Modifier
180
- .width(width)
181
- .height(height)
182
- .clip(shape)
183
- .background(bgColor)
184
- .activeOpacityClickable(onClick = action.onPress),
185
- contentAlignment = Alignment.Center,
186
- ) {
187
- Column(horizontalAlignment = Alignment.CenterHorizontally) {
188
- if (action.icon.isNotEmpty()) {
189
- Icon(
190
- source = action.icon,
191
- size = 20.dp,
192
- color = Colors.black_01,
193
- )
194
- }
195
- if (action.label.isNotEmpty()) {
196
- Text(
197
- text = action.label,
198
- style = Typography.labelSMedium,
199
- color = Colors.black_01,
200
- maxLines = 1,
201
- )
202
- }
203
- }
204
- }
205
- }
@@ -1,89 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.foundation.background
4
- import androidx.compose.foundation.border
5
- import androidx.compose.foundation.clickable
6
- import androidx.compose.foundation.layout.*
7
- import androidx.compose.foundation.shape.RoundedCornerShape
8
- import androidx.compose.runtime.Composable
9
- import androidx.compose.runtime.remember
10
- import androidx.compose.ui.Alignment
11
- import androidx.compose.ui.Modifier
12
- import androidx.compose.ui.draw.clip
13
- import androidx.compose.ui.graphics.Color
14
- import androidx.compose.ui.unit.dp
15
- import vn.momo.kits.application.IsShowBaseLineDebug
16
- import vn.momo.kits.const.Colors
17
- import vn.momo.kits.const.Spacing
18
- import vn.momo.kits.modifier.conditional
19
- import vn.momo.kits.modifier.setAutomationId
20
-
21
- private val switchShape = RoundedCornerShape(20.dp)
22
- private val circleShape = RoundedCornerShape(percent = 100)
23
-
24
- @Composable
25
- fun Switch(
26
- value: Boolean = false,
27
- onChange: (Boolean) -> Unit = {},
28
- disabled: Boolean = false,
29
- title: String? = "",
30
- accessibilityId: String? = ""
31
- ) {
32
- val colors = remember(value, disabled) {
33
- val circleColor = if (value) Colors.black_01 else Colors.black_03
34
- val bgColor = when {
35
- disabled && value -> Colors.green_09
36
- disabled && !value -> Colors.black_05
37
- value -> Colors.green_03
38
- else -> Colors.black_07
39
- }
40
- circleColor to bgColor
41
- }
42
-
43
- val (circleBackgroundColor, backgroundColor) = colors
44
-
45
- // Both params default to "", so blank must fall back too or the id is always empty.
46
- val automationIdValue = remember(accessibilityId, title, value) {
47
- accessibilityId?.takeIf { it.isNotEmpty() }
48
- ?: "toggle_${title?.takeIf { it.isNotEmpty() } ?: "unknown"}_$value"
49
- }
50
-
51
- val contentAlignment = remember(value) {
52
- if (value) Alignment.CenterEnd else Alignment.CenterStart
53
- }
54
-
55
- val onClickHandler = remember(onChange, value) {
56
- { onChange(!value) }
57
- }
58
-
59
- Box(modifier = Modifier.setAutomationId(automationIdValue)) {
60
- Box(
61
- modifier = Modifier
62
- .width(38.dp)
63
- .height(20.dp)
64
- .border(0.dp, Color.Unspecified, switchShape)
65
- .background(backgroundColor, switchShape)
66
- .conditional(IsShowBaseLineDebug) {
67
- border(1.dp, Colors.blue_03)
68
- }
69
- .clip(switchShape)
70
- .clickable(enabled = !disabled, onClick = onClickHandler)
71
- .padding(horizontal = Spacing.XS),
72
- contentAlignment = contentAlignment
73
- ) {
74
- Box(
75
- modifier = Modifier
76
- .size(14.dp)
77
- .border(0.dp, Color.Unspecified, circleShape)
78
- .background(circleBackgroundColor, circleShape),
79
- contentAlignment = Alignment.Center
80
- ) {
81
- Box(
82
- Modifier
83
- .size(6.dp)
84
- .background(backgroundColor, circleShape)
85
- )
86
- }
87
- }
88
- }
89
- }