@momo-kits/native-kits 0.167.1-beta.13-debug → 0.167.1-beta.14

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 (166) hide show
  1. package/CLAUDE.md +4 -6
  2. package/example/ios/Example.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/Example.xcscheme +32 -0
  3. package/example/ios/Example.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  4. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  5. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/WorkspaceSettings.xcsettings +16 -0
  6. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +6 -0
  7. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +5 -0
  8. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +58 -0
  9. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/Pods-Example.xcscheme +58 -0
  10. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SDWebImage.xcscheme +58 -0
  11. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +58 -0
  12. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SkeletonUI.xcscheme +58 -0
  13. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/lottie-ios-LottiePrivacyInfo.xcscheme +58 -0
  14. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/lottie-ios.xcscheme +58 -0
  15. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +60 -0
  16. package/ios/Application/ApplicationEnvironment.swift +6 -13
  17. package/ios/Template/TrustBanner/TrustBanner.swift +7 -39
  18. package/ios/Typography/FontScale.swift +11 -14
  19. package/ios/Typography/FontScaleStore.swift +58 -0
  20. package/ios/Typography/KitDesignSystem.swift +17 -0
  21. package/ios/Typography/Text.swift +7 -19
  22. package/ios/Typography/Typography.swift +2 -2
  23. package/ios/native-kits.podspec +1 -1
  24. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  25. package/package.json +1 -1
  26. package/build.gradle.kts +0 -11
  27. package/compose/build.gradle.kts +0 -190
  28. package/compose/build.gradle.kts.backup +0 -190
  29. package/compose/compose.podspec +0 -47
  30. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  31. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  32. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  33. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  34. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -151
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -52
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -293
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -831
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -110
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -356
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -113
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -475
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -266
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -240
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -264
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -328
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -97
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -310
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -323
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -199
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -91
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -552
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -88
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -234
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -188
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -16
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -222
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -270
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -51
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -299
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -129
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -106
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -201
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -393
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -595
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -175
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -225
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -357
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -83
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -75
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -309
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -40
  140. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -364
  141. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -132
  142. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  143. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  144. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  145. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  146. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -71
  147. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  148. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  149. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  150. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -105
  151. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -40
  152. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  153. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  154. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  155. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  156. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -213
  157. package/gradle/libs.versions.toml +0 -69
  158. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  159. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  160. package/gradle.properties +0 -26
  161. package/gradlew +0 -252
  162. package/gradlew.bat +0 -94
  163. package/ios/Application/DesignSystemKits.swift +0 -100
  164. package/ios/Application/DesignSystemKitsPayload.swift +0 -68
  165. package/ios-demo/README.md +0 -120
  166. package/settings.gradle.kts +0 -64
@@ -1,199 +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.remember
12
- import androidx.compose.runtime.rememberCoroutineScope
13
- import androidx.compose.ui.Alignment
14
- import androidx.compose.ui.Modifier
15
- import androidx.compose.ui.draw.clip
16
- import androidx.compose.ui.graphics.Color
17
- import androidx.compose.ui.input.pointer.pointerInput
18
- import androidx.compose.ui.platform.LocalDensity
19
- import androidx.compose.ui.unit.Dp
20
- import androidx.compose.ui.unit.IntOffset
21
- import androidx.compose.ui.unit.dp
22
- import kotlinx.coroutines.launch
23
- import vn.momo.kits.application.IsShowBaseLineDebug
24
- import vn.momo.kits.const.AppTheme
25
- import vn.momo.kits.const.Colors
26
- import vn.momo.kits.const.Typography
27
- import vn.momo.kits.modifier.activeOpacityClickable
28
- import vn.momo.kits.modifier.conditional
29
- import kotlin.math.roundToInt
30
-
31
- data class SwipeAction(
32
- val label: String = "",
33
- val icon: String = "",
34
- val onPress: () -> Unit = {},
35
- val backgroundColor: Color? = null,
36
- )
37
-
38
- private val ACTION_WIDTH = 56.dp
39
-
40
- @Composable
41
- fun Swipe(
42
- modifier: Modifier = Modifier,
43
- leftActions: List<SwipeAction> = emptyList(),
44
- rightActions: List<SwipeAction> = emptyList(),
45
- height: Dp = 56.dp,
46
- itemRadius: Dp = 0.dp,
47
- onSwipeableOpen: () -> Unit = {},
48
- onSwipeableClose: () -> Unit = {},
49
- onSwipeableLeftOpen: () -> Unit = {},
50
- onSwipeableRightOpen: () -> Unit = {},
51
- content: @Composable () -> Unit = {},
52
- ) {
53
- val theme = AppTheme.current
54
- val density = LocalDensity.current
55
- val scope = rememberCoroutineScope()
56
-
57
- val left = leftActions.take(3)
58
- val right = rightActions.take(3)
59
-
60
- val leftWidthPx = with(density) { (ACTION_WIDTH * left.size).toPx() }
61
- val rightWidthPx = with(density) { (ACTION_WIDTH * right.size).toPx() }
62
-
63
- val offsetX = remember { Animatable(0f) }
64
-
65
- val shape = remember(itemRadius) {
66
- if (itemRadius > 0.dp) RoundedCornerShape(itemRadius) else RoundedCornerShape(0.dp)
67
- }
68
-
69
- fun snapToClosest() {
70
- scope.launch {
71
- val current = offsetX.value
72
- val target = when {
73
- current > leftWidthPx * 0.5f && left.isNotEmpty() -> {
74
- onSwipeableLeftOpen()
75
- onSwipeableOpen()
76
- leftWidthPx
77
- }
78
- current < -rightWidthPx * 0.5f && right.isNotEmpty() -> {
79
- onSwipeableRightOpen()
80
- onSwipeableOpen()
81
- -rightWidthPx
82
- }
83
- else -> {
84
- onSwipeableClose()
85
- 0f
86
- }
87
- }
88
- offsetX.animateTo(target, tween(200))
89
- }
90
- }
91
-
92
- Box(
93
- modifier = modifier
94
- .fillMaxWidth()
95
- .height(height)
96
- .conditional(IsShowBaseLineDebug) { border(1.dp, Colors.blue_03) }
97
- ) {
98
- // Left actions
99
- if (left.isNotEmpty()) {
100
- Row(
101
- modifier = Modifier
102
- .align(Alignment.CenterStart)
103
- .fillMaxHeight()
104
- ) {
105
- left.forEach { action ->
106
- SwipeActionButton(
107
- action = action,
108
- width = ACTION_WIDTH,
109
- height = height,
110
- shape = shape,
111
- defaultColor = theme.colors.primary,
112
- )
113
- }
114
- }
115
- }
116
-
117
- // Right actions
118
- if (right.isNotEmpty()) {
119
- Row(
120
- modifier = Modifier
121
- .align(Alignment.CenterEnd)
122
- .fillMaxHeight()
123
- ) {
124
- right.forEach { action ->
125
- SwipeActionButton(
126
- action = action,
127
- width = ACTION_WIDTH,
128
- height = height,
129
- shape = shape,
130
- defaultColor = theme.colors.error.primary,
131
- )
132
- }
133
- }
134
- }
135
-
136
- // Main content
137
- Box(
138
- modifier = Modifier
139
- .fillMaxWidth()
140
- .height(height)
141
- .offset { IntOffset(offsetX.value.roundToInt(), 0) }
142
- .clip(shape)
143
- .background(theme.colors.background.surface)
144
- .pointerInput(left.size, right.size) {
145
- detectHorizontalDragGestures(
146
- onDragEnd = { snapToClosest() },
147
- onDragCancel = { snapToClosest() },
148
- ) { _, dragAmount ->
149
- scope.launch {
150
- val newOffset = offsetX.value + dragAmount
151
- val clamped = newOffset.coerceIn(-rightWidthPx, leftWidthPx)
152
- offsetX.snapTo(clamped)
153
- }
154
- }
155
- }
156
- ) {
157
- content()
158
- }
159
- }
160
- }
161
-
162
- @Composable
163
- private fun SwipeActionButton(
164
- action: SwipeAction,
165
- width: Dp,
166
- height: Dp,
167
- shape: RoundedCornerShape,
168
- defaultColor: Color,
169
- ) {
170
- val bgColor = action.backgroundColor ?: defaultColor
171
-
172
- Box(
173
- modifier = Modifier
174
- .width(width)
175
- .height(height)
176
- .clip(shape)
177
- .background(bgColor)
178
- .activeOpacityClickable(onClick = action.onPress),
179
- contentAlignment = Alignment.Center,
180
- ) {
181
- Column(horizontalAlignment = Alignment.CenterHorizontally) {
182
- if (action.icon.isNotEmpty()) {
183
- Icon(
184
- source = action.icon,
185
- size = 20.dp,
186
- color = Colors.black_01,
187
- )
188
- }
189
- if (action.label.isNotEmpty()) {
190
- Text(
191
- text = action.label,
192
- style = Typography.labelSMedium,
193
- color = Colors.black_01,
194
- maxLines = 1,
195
- )
196
- }
197
- }
198
- }
199
- }
@@ -1,91 +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
- // Memoize color calculations to avoid repeated conditional logic
33
- val colors = remember(value, disabled) {
34
- val circleColor = if (value) Colors.black_01 else Colors.black_03
35
- val bgColor = when {
36
- disabled && value -> Colors.green_09
37
- disabled && !value -> Colors.black_05
38
- value -> Colors.green_03
39
- else -> Colors.black_07
40
- }
41
- circleColor to bgColor
42
- }
43
-
44
- val (circleBackgroundColor, backgroundColor) = colors
45
-
46
- // Memoize automation ID to avoid string concatenation on every render
47
- val automationIdValue = remember(accessibilityId, title, value) {
48
- accessibilityId ?: "toggle_${title ?: "unknown"}_$value"
49
- }
50
-
51
- // Memoize alignment calculation
52
- val contentAlignment = remember(value) {
53
- if (value) Alignment.CenterEnd else Alignment.CenterStart
54
- }
55
-
56
- // Memoize click handler to avoid lambda recreation
57
- val onClickHandler = remember(onChange, value) {
58
- { onChange(!value) }
59
- }
60
-
61
- Box(modifier = Modifier.setAutomationId(automationIdValue)) {
62
- Box(
63
- modifier = Modifier
64
- .width(38.dp)
65
- .height(20.dp)
66
- .border(0.dp, Color.Unspecified, switchShape)
67
- .background(backgroundColor, switchShape)
68
- .conditional(IsShowBaseLineDebug) {
69
- border(1.dp, Colors.blue_03)
70
- }
71
- .clip(switchShape)
72
- .clickable(enabled = !disabled, onClick = onClickHandler)
73
- .padding(horizontal = Spacing.XS),
74
- contentAlignment = contentAlignment
75
- ) {
76
- Box(
77
- modifier = Modifier
78
- .size(14.dp)
79
- .border(0.dp, Color.Unspecified, circleShape)
80
- .background(circleBackgroundColor, circleShape),
81
- contentAlignment = Alignment.Center
82
- ) {
83
- Box(
84
- Modifier
85
- .size(6.dp)
86
- .background(backgroundColor, circleShape)
87
- )
88
- }
89
- }
90
- }
91
- }