@momo-kits/native-kits 0.157.6 → 0.157.7-debug

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 (130) hide show
  1. package/build.gradle.kts +11 -0
  2. package/compose/build.gradle.kts +180 -0
  3. package/compose/build.gradle.kts.backup +180 -0
  4. package/compose/compose.podspec +54 -0
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +117 -0
  6. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  7. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  8. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  9. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  10. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +107 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +305 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +720 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +121 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +405 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +85 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +340 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +198 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +123 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +94 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +136 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +224 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +76 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +148 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +188 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +116 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +448 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +172 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +255 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +231 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +233 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +254 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +241 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +92 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +352 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +103 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +338 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +70 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +17 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +96 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +348 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +256 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +494 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +131 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +215 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +96 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +531 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +92 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +130 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +214 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +590 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +177 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +192 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +205 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +239 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +188 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +285 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +50 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +14 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +239 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +119 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +98 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +161 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +331 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +497 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +162 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +243 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +187 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +279 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +32 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +370 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +132 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +46 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +62 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +88 -0
  122. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +161 -0
  123. package/gradle/libs.versions.toml +57 -0
  124. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  125. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  126. package/gradle.properties +26 -0
  127. package/gradlew +252 -0
  128. package/gradlew.bat +94 -0
  129. package/package.json +1 -1
  130. package/settings.gradle.kts +52 -0
@@ -0,0 +1,177 @@
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.Arrangement
7
+ import androidx.compose.foundation.layout.Column
8
+ import androidx.compose.foundation.layout.Row
9
+ import androidx.compose.foundation.layout.fillMaxWidth
10
+ import androidx.compose.foundation.layout.height
11
+ import androidx.compose.foundation.layout.padding
12
+ import androidx.compose.foundation.layout.width
13
+ import androidx.compose.foundation.shape.RoundedCornerShape
14
+ import androidx.compose.runtime.Composable
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.layout.ContentScale
20
+ import androidx.compose.ui.unit.dp
21
+ import vn.momo.kits.application.AppConfig
22
+ import vn.momo.kits.application.AppLanguage
23
+ import vn.momo.kits.application.IsShowBaseLineDebug
24
+ import vn.momo.kits.const.Colors
25
+ import vn.momo.kits.const.Typography
26
+ import vn.momo.kits.modifier.conditional
27
+ import vn.momo.kits.modifier.noFeedbackClickable
28
+
29
+ val defaultBanner = TrustBannerData(
30
+ content = mapOf(
31
+ "vi" to "An toàn tài sản & Bảo mật thông tin của bạn là ưu tiên hàng đầu của MoMo.",
32
+ "en" to "Ensuring financial security and data privacy is MoMo's highest priority."
33
+ ),
34
+ subContent = mapOf(
35
+ "vi" to "Tìm hiểu thêm",
36
+ "en" to "Learn more"
37
+ ),
38
+ pciImage = "https://static.momocdn.net/app/img/kits/trustBanner/pci_dss.png",
39
+ sslImage = "https://static.momocdn.net/app/img/kits/trustBanner/ssl.png",
40
+ urlConfig = "login_and_security",
41
+ icons = listOf(
42
+ "https://static.momocdn.net/app/img/kits/trustBanner/ic_viettinbank.png",
43
+ "https://static.momocdn.net/app/img/kits/trustBanner/ic_agribank.png",
44
+ "https://static.momocdn.net/app/img/kits/trustBanner/ic_vietcombank.png",
45
+ "https://static.momocdn.net/app/img/kits/trustBanner/ic_bidv.png"
46
+ ),
47
+ momoImage = "https://static.momocdn.net/app/img/kits/trustBanner/ic_secu.png"
48
+ )
49
+
50
+ const val backgroundBlue = 0xFFF2F8FF
51
+ const val contentColor = 0xFF484848
52
+ const val subContentColor = 0xFFEB2F96
53
+
54
+ data class TrustBannerData(
55
+ val content: Map<String, String> = mapOf("vi" to "", "en" to ""),
56
+ val subContent: Map<String, String> = mapOf("vi" to "", "en" to ""),
57
+ val pciImage: String? = null,
58
+ val momoImage: String? = null,
59
+ val sslImage: String? = null,
60
+ val icons: List<String>? = null,
61
+ val urlConfig: String = ""
62
+ )
63
+
64
+ @Composable
65
+ fun TrustBanner(
66
+ serviceName: String = "",
67
+ screenName: String = "",
68
+ onPress: ((Map<String, String>) -> Unit)? = null,
69
+ trackEvent: ((String, Map<String, String>) -> Unit)? = null
70
+ ) {
71
+ val appConfig = AppConfig.current
72
+ val language = AppLanguage.current ?: "vi"
73
+ val trustBanner = appConfig?.trustBanner ?: defaultBanner
74
+ val trackParams = mapOf(
75
+ "service_name" to serviceName,
76
+ "screen_name" to screenName,
77
+ "component_name" to "logo_trust",
78
+ "url_config" to trustBanner.urlConfig
79
+ )
80
+
81
+ Row(
82
+ modifier = Modifier
83
+ .clip(RoundedCornerShape(12.dp))
84
+ .background(color = Color(backgroundBlue))
85
+ .conditional(IsShowBaseLineDebug) {
86
+ border(1.dp, Colors.blue_03)
87
+ }
88
+ .padding(12.dp)
89
+ .then(
90
+ if (onPress != null) {
91
+ Modifier.clickable {
92
+ trackEvent?.invoke(
93
+ "service_component_clicked", trackParams
94
+ )
95
+
96
+ onPress(
97
+ mapOf(
98
+ "service_name" to serviceName,
99
+ "screen_name" to screenName,
100
+ "url_config" to trustBanner.urlConfig,
101
+ )
102
+ )
103
+
104
+ }
105
+ } else {
106
+ Modifier.noFeedbackClickable {
107
+ trackEvent?.invoke(
108
+ "service_component_clicked", trackParams
109
+ )
110
+ }
111
+ }
112
+ )
113
+ ) {
114
+ if (trustBanner.momoImage != null) {
115
+ Image(
116
+ source = trustBanner.momoImage,
117
+ modifier = Modifier
118
+ .width(64.dp)
119
+ .height(64.dp)
120
+ )
121
+ }
122
+ Column(
123
+ modifier = Modifier
124
+ .padding(start = 10.dp)
125
+ ) {
126
+ Text(
127
+ text = trustBanner.content[language] ?: "",
128
+ modifier = Modifier.padding(bottom = 8.dp),
129
+ color = Color(contentColor),
130
+ style = Typography.descriptionDefaultRegular,
131
+ maxLines = 2
132
+ )
133
+ Row(
134
+ modifier = Modifier.fillMaxWidth(),
135
+ horizontalArrangement = Arrangement.SpaceBetween
136
+ ) {
137
+ Row(
138
+ verticalAlignment = Alignment.CenterVertically,
139
+ ) {
140
+ Text(
141
+ text = trustBanner.subContent[language] ?: "",
142
+ color = Color(subContentColor),
143
+ style = Typography.actionXsBold,
144
+ maxLines = 2
145
+ )
146
+ Icon(
147
+ source = "https://img.mservice.io/momo_app_v2/new_version/img/appx_icon/16_arrow_chevron_right_small.png",
148
+ color = Color(subContentColor),
149
+ )
150
+ }
151
+ Row {
152
+ if (trustBanner.pciImage != null) {
153
+ Image(
154
+ source = trustBanner.pciImage, modifier = Modifier
155
+ .padding(end = 4.dp)
156
+ .width(27.dp)
157
+ .height(20.dp), options = Options(
158
+ contentScale = ContentScale.Fit,
159
+ )
160
+ )
161
+ }
162
+ if (trustBanner.sslImage != null) {
163
+ Image(
164
+ source = trustBanner.sslImage, modifier = Modifier
165
+ .width(52.dp)
166
+ .height(20.dp),
167
+ options = Options(
168
+ contentScale = ContentScale.Fit,
169
+ )
170
+ )
171
+ }
172
+
173
+ }
174
+ }
175
+ }
176
+ }
177
+ }
@@ -0,0 +1,192 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.border
5
+ import androidx.compose.foundation.horizontalScroll
6
+ import androidx.compose.foundation.layout.Arrangement
7
+ import androidx.compose.foundation.layout.Box
8
+ import androidx.compose.foundation.layout.Column
9
+ import androidx.compose.foundation.layout.Row
10
+ import androidx.compose.foundation.layout.fillMaxSize
11
+ import androidx.compose.foundation.layout.padding
12
+ import androidx.compose.foundation.layout.size
13
+ import androidx.compose.foundation.rememberScrollState
14
+ import androidx.compose.foundation.shape.RoundedCornerShape
15
+ import androidx.compose.runtime.Composable
16
+ import androidx.compose.runtime.remember
17
+ import androidx.compose.ui.Alignment
18
+ import androidx.compose.ui.Modifier
19
+ import androidx.compose.ui.draw.clip
20
+ import androidx.compose.ui.draw.drawBehind
21
+ import androidx.compose.ui.geometry.CornerRadius
22
+ import androidx.compose.ui.graphics.Color
23
+ import androidx.compose.ui.graphics.PathEffect
24
+ import androidx.compose.ui.graphics.drawscope.Stroke
25
+ import androidx.compose.ui.unit.Dp
26
+ import androidx.compose.ui.unit.dp
27
+ import vn.momo.kits.application.IsShowBaseLineDebug
28
+ import vn.momo.kits.const.AppTheme
29
+ import vn.momo.kits.const.Colors
30
+ import vn.momo.kits.const.Radius
31
+ import vn.momo.kits.const.Spacing
32
+ import vn.momo.kits.const.Typography
33
+ import vn.momo.kits.modifier.activeOpacityClickable
34
+ import vn.momo.kits.modifier.conditional
35
+
36
+ data class UploadImage(
37
+ val uri: String? = null,
38
+ val loading: Boolean = false,
39
+ )
40
+
41
+ @Composable
42
+ fun Uploader(
43
+ images: List<UploadImage>,
44
+ modifier: Modifier = Modifier,
45
+ numberOfImages: Int = 1,
46
+ disabled: Boolean = false,
47
+ width: Dp = 64.dp,
48
+ height: Dp = 64.dp,
49
+ onAdd: () -> Unit = {},
50
+ onCancel: ((image: UploadImage, index: Int) -> Unit)? = null,
51
+ onPressImage: (image: UploadImage, index: Int) -> Unit = { _, _ -> },
52
+ ) {
53
+ val shouldShowPicker = remember(images.size, numberOfImages) {
54
+ images.size < numberOfImages
55
+ }
56
+
57
+ Row(
58
+ modifier = modifier
59
+ .conditional(IsShowBaseLineDebug) { border(1.dp, Colors.blue_03) },
60
+ horizontalArrangement = Arrangement.spacedBy(Spacing.S),
61
+ verticalAlignment = Alignment.Top,
62
+ ) {
63
+ if (shouldShowPicker) {
64
+ UploaderPickerCell(
65
+ disabled = disabled,
66
+ width = width,
67
+ height = height,
68
+ onAdd = onAdd,
69
+ )
70
+ }
71
+
72
+ Row(
73
+ modifier = Modifier.horizontalScroll(rememberScrollState()),
74
+ horizontalArrangement = Arrangement.spacedBy(Spacing.S),
75
+ ) {
76
+ images.forEachIndexed { index, image ->
77
+ UploaderImageItem(
78
+ image = image,
79
+ width = width,
80
+ height = height,
81
+ index = index,
82
+ onCancel = onCancel,
83
+ onPressImage = { onPressImage(image, index) },
84
+ )
85
+ }
86
+ }
87
+ }
88
+ }
89
+
90
+ @Composable
91
+ private fun UploaderPickerCell(
92
+ disabled: Boolean,
93
+ width: Dp,
94
+ height: Dp,
95
+ onAdd: () -> Unit,
96
+ ) {
97
+ val theme = AppTheme.current
98
+ val mainColor = if (disabled) theme.colors.text.disable else theme.colors.text.hint
99
+ val borderColor = if (disabled) theme.colors.border.disable else theme.colors.border.default
100
+
101
+ Box(
102
+ modifier = Modifier
103
+ .size(width = width, height = height)
104
+ .clip(RoundedCornerShape(Radius.XS))
105
+ .dashedBorder(color = borderColor, radius = Radius.XS)
106
+ .activeOpacityClickable(enabled = !disabled, onClick = onAdd),
107
+ contentAlignment = Alignment.Center,
108
+ ) {
109
+ Column(
110
+ horizontalAlignment = Alignment.CenterHorizontally,
111
+ verticalArrangement = Arrangement.spacedBy(Spacing.XXS),
112
+ ) {
113
+ Icon(
114
+ source = "16_navigation_plus",
115
+ color = mainColor,
116
+ size = 16.dp,
117
+ )
118
+ Text(
119
+ text = "Thêm hình",
120
+ style = Typography.descriptionXsRegular,
121
+ color = mainColor,
122
+ )
123
+ }
124
+ }
125
+ }
126
+
127
+ @Composable
128
+ private fun UploaderImageItem(
129
+ image: UploadImage,
130
+ width: Dp,
131
+ height: Dp,
132
+ index: Int,
133
+ onCancel: ((image: UploadImage, index: Int) -> Unit)?,
134
+ onPressImage: () -> Unit,
135
+ ) {
136
+ Box(
137
+ modifier = Modifier
138
+ .size(width = width, height = height)
139
+ .activeOpacityClickable(onClick = onPressImage),
140
+ ) {
141
+ Image(
142
+ source = image.uri ?: "",
143
+ modifier = Modifier
144
+ .fillMaxSize()
145
+ .clip(RoundedCornerShape(Radius.XS)),
146
+ )
147
+
148
+ if (onCancel != null && !image.loading) {
149
+ Icon(
150
+ source = "navigation_close_circle_full",
151
+ size = 16.dp,
152
+ color = null,
153
+ modifier = Modifier
154
+ .align(Alignment.TopEnd)
155
+ .padding(top = Spacing.XXS, end = Spacing.XXS)
156
+ .activeOpacityClickable { onCancel(image, index) },
157
+ )
158
+ }
159
+
160
+ if (image.loading) {
161
+ Box(
162
+ modifier = Modifier
163
+ .fillMaxSize()
164
+ .clip(RoundedCornerShape(Radius.XS))
165
+ .background(Color(0x66FFFFFF)),
166
+ contentAlignment = Alignment.Center,
167
+ ) {
168
+ Skeleton()
169
+ }
170
+ }
171
+ }
172
+ }
173
+
174
+ private fun Modifier.dashedBorder(
175
+ color: Color,
176
+ radius: Dp,
177
+ strokeWidth: Dp = 1.dp,
178
+ dashWidth: Float = 10f,
179
+ dashGap: Float = 6f,
180
+ ): Modifier = this.drawBehind {
181
+ val strokePx = strokeWidth.toPx()
182
+ val pathEffect = PathEffect.dashPathEffect(floatArrayOf(dashWidth, dashGap), 0f)
183
+ val cornerRadiusPx = radius.toPx()
184
+ drawRoundRect(
185
+ color = color,
186
+ style = Stroke(
187
+ width = strokePx,
188
+ pathEffect = pathEffect,
189
+ ),
190
+ cornerRadius = CornerRadius(cornerRadiusPx, cornerRadiusPx),
191
+ )
192
+ }
@@ -0,0 +1,205 @@
1
+ package vn.momo.kits.components.datetimepicker
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.border
5
+ import androidx.compose.foundation.layout.Column
6
+ import androidx.compose.foundation.layout.Row
7
+ import androidx.compose.foundation.layout.Spacer
8
+ import androidx.compose.foundation.layout.fillMaxWidth
9
+ import androidx.compose.foundation.layout.height
10
+ import androidx.compose.foundation.layout.padding
11
+ import androidx.compose.foundation.layout.width
12
+ import androidx.compose.runtime.Composable
13
+ import androidx.compose.runtime.LaunchedEffect
14
+ import androidx.compose.runtime.getValue
15
+ import androidx.compose.runtime.mutableStateOf
16
+ import androidx.compose.runtime.remember
17
+ import androidx.compose.runtime.setValue
18
+ import androidx.compose.runtime.snapshotFlow
19
+ import androidx.compose.ui.Alignment
20
+ import androidx.compose.ui.Modifier
21
+ import androidx.compose.ui.unit.dp
22
+ import kotlinx.coroutines.flow.collect
23
+ import kotlinx.coroutines.flow.mapNotNull
24
+ import kotlinx.coroutines.flow.onEach
25
+ import kotlinx.datetime.LocalDateTime
26
+ import kotlinx.datetime.number
27
+ import vn.momo.kits.application.IsShowBaseLineDebug
28
+ import vn.momo.kits.components.Text
29
+ import vn.momo.kits.const.AppTheme
30
+ import vn.momo.kits.const.Colors
31
+ import vn.momo.kits.const.Spacing
32
+ import vn.momo.kits.const.Typography
33
+ import vn.momo.kits.modifier.conditional
34
+
35
+ private val datePickerHeight = 210.dp
36
+ private val datePickerWithLabelsHeight = 238.dp
37
+
38
+ @Composable
39
+ fun DateTimePicker(
40
+ modifier: Modifier = Modifier,
41
+ format: String = "DD-MM-YYYY",
42
+ minuteInterval: Int = 1,
43
+ onChange: (LocalDateTime) -> Unit,
44
+ selectedValue: LocalDateTime? = null,
45
+ minDate: LocalDateTime? = null,
46
+ maxDate: LocalDateTime? = null,
47
+ arrayLabelTime: List<String> = emptyList()
48
+ ) {
49
+ val effectiveSelectedValue = remember(selectedValue) {
50
+ selectedValue ?: getCurrentDateTime()
51
+ }
52
+
53
+ val effectiveMinDate = remember(minDate) {
54
+ minDate ?: createRelativeDate(-10)
55
+ }
56
+
57
+ val effectiveMaxDate = remember(maxDate) {
58
+ maxDate ?: createRelativeDate(10)
59
+ }
60
+
61
+ val needCheckRange = remember(minDate, maxDate) {
62
+ minDate == null && maxDate == null
63
+ }
64
+
65
+ val initialValue = remember(effectiveMinDate, effectiveMaxDate, effectiveSelectedValue) {
66
+ when {
67
+ !needCheckRange -> effectiveSelectedValue
68
+ effectiveSelectedValue < effectiveMinDate -> effectiveMinDate
69
+ effectiveSelectedValue > effectiveMaxDate -> effectiveMaxDate
70
+ else -> effectiveSelectedValue
71
+ }
72
+ }
73
+
74
+ var currentDate by remember(initialValue) {
75
+ mutableStateOf(
76
+ PickerData(
77
+ day = initialValue.dayOfMonth,
78
+ month = initialValue.month.number,
79
+ year = initialValue.year,
80
+ hour = initialValue.hour,
81
+ minute = initialValue.minute
82
+ )
83
+ )
84
+ }
85
+
86
+ val onWheelChangeValue = remember(currentDate, effectiveMinDate, effectiveMaxDate) {
87
+ { name: String, value: String ->
88
+ var day = if (name == "day") value.toInt() else currentDate.day
89
+ var month = if (name == "month") value.toInt() else currentDate.month
90
+ val year = if (name == "year") value.toInt() else currentDate.year
91
+ val hour = if (name == "hour") value.toInt() else currentDate.hour
92
+ val minute = if (name == "minute") value.toInt() else currentDate.minute
93
+ val timeMode = if (name == "timeMode") value else currentDate.timeMode
94
+ if (name == "year") {
95
+ month = when (year) {
96
+ effectiveMaxDate.year -> month.coerceIn(
97
+ 1,
98
+ effectiveMaxDate.monthNumber
99
+ )
100
+ effectiveMinDate.year -> month.coerceIn(
101
+ effectiveMinDate.monthNumber,
102
+ 12,
103
+ )
104
+ else -> month
105
+ }
106
+ }
107
+ if (name == "month" || name == "year") {
108
+ val maxDayOfMonth = when (month) {
109
+ 4, 6, 9, 11 -> 30
110
+ 2 -> if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) 29 else 28
111
+ else -> 31
112
+ }
113
+
114
+ day = when {
115
+ year == effectiveMaxDate.year && month == effectiveMaxDate.monthNumber ->
116
+ day.coerceIn(1, effectiveMaxDate.dayOfMonth)
117
+
118
+ year == effectiveMinDate.year && month == effectiveMinDate.monthNumber ->
119
+ day.coerceIn(effectiveMinDate.dayOfMonth, maxDayOfMonth)
120
+
121
+ day > maxDayOfMonth -> maxDayOfMonth
122
+ else -> day
123
+ }
124
+ }
125
+ currentDate = PickerData(
126
+ day = day,
127
+ month = month,
128
+ year = year,
129
+ hour = hour,
130
+ minute = minute,
131
+ timeMode = timeMode,
132
+ )
133
+ }
134
+ }
135
+
136
+ LaunchedEffect(effectiveMinDate, effectiveMaxDate) {
137
+ snapshotFlow { currentDate }
138
+ .mapNotNull {
139
+ val dateTime = it.toLocalDateTime()
140
+ if (!needCheckRange || dateTime in effectiveMinDate..effectiveMaxDate) dateTime
141
+ else null
142
+ }
143
+ .onEach(onChange)
144
+ .collect()
145
+ }
146
+
147
+ val pickerHeight = if (arrayLabelTime.isNotEmpty())
148
+ datePickerWithLabelsHeight else
149
+ datePickerHeight
150
+
151
+ Row(
152
+ modifier = modifier
153
+ .fillMaxWidth()
154
+ .height(pickerHeight)
155
+ .background(AppTheme.current.colors.background.surface)
156
+ .conditional(IsShowBaseLineDebug) {
157
+ border(1.dp, Colors.blue_03)
158
+ }
159
+ .padding(horizontal = Spacing.M),
160
+ verticalAlignment = Alignment.CenterVertically
161
+ ) {
162
+ val dateComponents = getDateComponents(
163
+ format,
164
+ currentDate,
165
+ effectiveMinDate,
166
+ effectiveMaxDate,
167
+ minuteInterval,
168
+ )
169
+ dateComponents.forEachIndexed { index, component ->
170
+ val hasLabel = index < arrayLabelTime.size && arrayLabelTime[index].isNotEmpty()
171
+
172
+ Column(
173
+ horizontalAlignment = Alignment.CenterHorizontally,
174
+ modifier = Modifier.weight(1f)
175
+ ) {
176
+ if (hasLabel) {
177
+ Text(
178
+ text = arrayLabelTime[index],
179
+ style = Typography.actionSBold,
180
+ modifier = Modifier.padding(bottom = Spacing.S)
181
+ )
182
+ }
183
+
184
+ WheelPicker(
185
+ name = component.name,
186
+ data = component.data,
187
+ selectedData = when (component.name) {
188
+ "day" -> paddingNum(currentDate.day)
189
+ "month" -> paddingNum(currentDate.month)
190
+ "year" -> currentDate.year.toString()
191
+ "hour" -> paddingNum(currentDate.hour)
192
+ "minute" -> paddingNum(currentDate.minute)
193
+ "timeMode" -> currentDate.timeMode
194
+ else -> ""
195
+ },
196
+ onChange = onWheelChangeValue,
197
+ )
198
+ }
199
+
200
+ if (index < dateComponents.size - 1) {
201
+ Spacer(modifier = Modifier.width(Spacing.M))
202
+ }
203
+ }
204
+ }
205
+ }
@@ -0,0 +1,29 @@
1
+ package vn.momo.kits.components.datetimepicker
2
+
3
+ import kotlinx.datetime.LocalDateTime
4
+
5
+ data class PickerData(
6
+ var day: Int,
7
+ var month: Int,
8
+ var year: Int,
9
+ var hour: Int = 0,
10
+ var minute: Int = 0,
11
+ var timeMode: String = ""
12
+ ) {
13
+ fun toLocalDateTime(): LocalDateTime {
14
+ return LocalDateTime(
15
+ year = year,
16
+ monthNumber = month,
17
+ dayOfMonth = day,
18
+ hour = hour,
19
+ minute = minute,
20
+ second = 0,
21
+ nanosecond = 0
22
+ )
23
+ }
24
+ }
25
+
26
+ data class DateComponent(
27
+ val name: String,
28
+ val data: List<String>
29
+ )