@momo-kits/native-kits 0.157.2-debug → 0.157.2

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 (117) hide show
  1. package/package.json +1 -1
  2. package/build.gradle.kts +0 -11
  3. package/compose/build.gradle.kts +0 -180
  4. package/compose/build.gradle.kts.backup +0 -180
  5. package/compose/compose.podspec +0 -54
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -110
  7. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  8. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  9. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  10. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -57
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -107
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -201
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -222
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -48
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -305
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -720
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -121
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -405
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -85
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -340
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -198
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -94
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -136
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -543
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -148
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -188
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -116
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -448
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -172
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -255
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -231
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -233
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -254
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -241
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -364
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -92
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -352
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -103
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -70
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -17
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -96
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -96
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -92
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -130
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -214
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -576
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -177
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -205
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -239
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -191
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -306
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -13
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -185
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -285
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -2
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -35
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -2
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -59
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -68
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -14
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -50
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -239
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -119
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -98
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -161
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -331
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -497
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -162
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -243
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -187
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -279
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -80
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -306
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -32
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -370
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -132
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -42
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -62
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -88
  110. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -149
  111. package/gradle/libs.versions.toml +0 -57
  112. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  113. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  114. package/gradle.properties +0 -26
  115. package/gradlew +0 -252
  116. package/gradlew.bat +0 -94
  117. package/settings.gradle.kts +0 -52
@@ -1,177 +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.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
- }
@@ -1,205 +0,0 @@
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
- }
@@ -1,29 +0,0 @@
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
- )
@@ -1,239 +0,0 @@
1
- package vn.momo.kits.components.datetimepicker
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.runtime.remember
5
- import kotlin.time.Clock
6
- import kotlin.time.ExperimentalTime
7
- import kotlinx.datetime.DatePeriod
8
- import kotlinx.datetime.LocalDateTime
9
- import kotlinx.datetime.TimeZone
10
- import kotlinx.datetime.minus
11
- import kotlinx.datetime.number
12
- import kotlinx.datetime.plus
13
- import kotlinx.datetime.toLocalDateTime
14
-
15
- /**
16
- * Format a LocalDateTime object into a string
17
- */
18
- fun formatLocalDateTime(dateTime: LocalDateTime, format: String = "yyyy-MM-dd HH:mm"): String {
19
- return when (format) {
20
- "yyyy-MM-dd HH:mm" -> "${dateTime.year}-${paddingNum(dateTime.month.number)}-${
21
- paddingNum(
22
- dateTime.dayOfMonth
23
- )
24
- } ${paddingNum(dateTime.hour)}:${paddingNum(dateTime.minute)}"
25
-
26
- "dd-MM-yyyy" -> "${paddingNum(dateTime.dayOfMonth)}-${paddingNum(dateTime.month.number)}-${dateTime.year}"
27
- "HH:mm" -> "${paddingNum(dateTime.hour)}:${paddingNum(dateTime.minute)}"
28
- else -> "${dateTime.year}-${paddingNum(dateTime.month.number)}-${paddingNum(dateTime.dayOfMonth)} ${
29
- paddingNum(
30
- dateTime.hour
31
- )
32
- }:${paddingNum(dateTime.minute)}"
33
- }
34
- }
35
-
36
- /**
37
- * Pad a number with a leading zero if it's less than 10
38
- */
39
- fun paddingNum(num: Int): String {
40
- return if (num > 9) num.toString() else "0$num"
41
- }
42
-
43
- /**
44
- * Get a list of days in a month
45
- */
46
- fun getDaysInMonth(
47
- year: Int,
48
- month: Int,
49
- minDate: LocalDateTime,
50
- maxDate: LocalDateTime
51
- ): List<String> {
52
- val daysInMonth = when (month) {
53
- 1, 3, 5, 7, 8, 10, 12 -> 31
54
- 4, 6, 9, 11 -> 30
55
- 2 -> if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) 29 else 28
56
- else -> throw IllegalArgumentException("Invalid month: $month")
57
- }
58
-
59
- var startDay = 1
60
- var endDay = daysInMonth
61
-
62
- if (year == minDate.year && month == minDate.month.number) {
63
- startDay = minDate.dayOfMonth
64
- }
65
-
66
- if (year == maxDate.year && month == maxDate.month.number) {
67
- endDay = maxDate.dayOfMonth
68
- }
69
-
70
- val days = mutableListOf<String>()
71
- for (day in startDay..endDay) {
72
- days.add(paddingNum(day))
73
- }
74
-
75
- return days
76
- }
77
-
78
- /**
79
- * Get a list of months
80
- */
81
- fun getMonths(
82
- minDate: LocalDateTime,
83
- maxDate: LocalDateTime,
84
- currentYear: Int
85
- ): List<String> {
86
- var startMonth = 1
87
- var endMonth = 12
88
-
89
- if (currentYear == minDate.year) {
90
- startMonth = minDate.month.number
91
- }
92
-
93
- if (currentYear == maxDate.year) {
94
- endMonth = maxDate.month.number
95
- }
96
-
97
- val months = mutableListOf<String>()
98
- for (month in startMonth..endMonth) {
99
- months.add(paddingNum(month))
100
- }
101
-
102
- return months
103
- }
104
-
105
- /**
106
- * Get a list of years
107
- */
108
- fun getYears(minDate: LocalDateTime, maxDate: LocalDateTime): List<String> {
109
- val startYear = minDate.year
110
- val endYear = maxDate.year
111
- val years = mutableListOf<String>()
112
-
113
- for (year in startYear..endYear) {
114
- years.add(year.toString())
115
- }
116
-
117
- return years
118
- }
119
-
120
- /**
121
- * Get a list of hours
122
- */
123
- fun getHours(hourMode: Int): List<String> {
124
- val hours = mutableListOf<String>()
125
- for (i in 0 until hourMode) {
126
- val hour = if (hourMode == 12) i + 1 else i
127
- hours.add(paddingNum(hour))
128
- }
129
- return hours
130
- }
131
-
132
- /**
133
- * Get a list of minutes
134
- */
135
- fun getMinutes(interval: Int): List<String> {
136
- val minutes = mutableListOf<String>()
137
- var min = 0
138
- while (min < 60) {
139
- minutes.add(paddingNum(min))
140
- min += interval
141
- }
142
- return minutes
143
- }
144
-
145
- /**
146
- * Time mode for 12-hour clock
147
- */
148
- val timeMode = listOf("AM", "PM")
149
-
150
- /**
151
- * Get today's date
152
- */
153
- @OptIn(ExperimentalTime::class)
154
- fun getCurrentDateTime(): LocalDateTime {
155
- return Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault())
156
- }
157
-
158
- /**
159
- * Create a date that's a certain number of years before or after the current date
160
- */
161
- fun createRelativeDate(years: Int): LocalDateTime {
162
- val currentDateTime = getCurrentDateTime()
163
- val period = DatePeriod(years = if (years < 0) -years else years)
164
-
165
- val adjustedDate = if (years < 0) {
166
- currentDateTime.date.minus(period)
167
- } else {
168
- currentDateTime.date.plus(period)
169
- }
170
-
171
- return LocalDateTime(
172
- adjustedDate.year,
173
- adjustedDate.monthNumber,
174
- adjustedDate.dayOfMonth,
175
- currentDateTime.hour,
176
- currentDateTime.minute
177
- )
178
- }
179
-
180
- @Composable
181
- internal fun getDateComponents(
182
- format: String,
183
- currentDate: PickerData,
184
- effectiveMinDate: LocalDateTime,
185
- effectiveMaxDate: LocalDateTime,
186
- minuteInterval: Int,
187
- ): List<DateComponent> {
188
- val formatParts = remember(format) {
189
- format.split(Regex("[^A-Za-z]+"))
190
- }
191
-
192
- val isOnlyHour = remember(formatParts) {
193
- formatParts.size == 1 && formatParts[0] == "HH"
194
- }
195
-
196
- val dayData =
197
- remember(currentDate.year, currentDate.month, effectiveMinDate, effectiveMaxDate) {
198
- getDaysInMonth(currentDate.year, currentDate.month, effectiveMinDate, effectiveMaxDate)
199
- }
200
-
201
- val monthData = remember(currentDate.year, effectiveMinDate, effectiveMaxDate) {
202
- getMonths(effectiveMinDate, effectiveMaxDate, currentDate.year)
203
- }
204
-
205
- val yearData = remember(effectiveMinDate, effectiveMaxDate) {
206
- getYears(effectiveMinDate, effectiveMaxDate)
207
- }
208
-
209
- val hourData = remember(isOnlyHour) {
210
- getHours(if (isOnlyHour) 12 else 24)
211
- }
212
-
213
- val minData = remember(minuteInterval) {
214
- getMinutes(minuteInterval)
215
- }
216
-
217
- val dateComponents =
218
- remember(formatParts, dayData, monthData, yearData, hourData, minData, isOnlyHour) {
219
- val components = mutableListOf<DateComponent>()
220
-
221
- formatParts.forEach { part ->
222
- when (part) {
223
- "DD" -> components.add(DateComponent("day", dayData))
224
- "MM" -> components.add(DateComponent("month", monthData))
225
- "YYYY" -> components.add(DateComponent("year", yearData))
226
- "HH" -> components.add(DateComponent("hour", hourData))
227
- "mm" -> components.add(DateComponent("minute", minData))
228
- }
229
- }
230
-
231
- if (isOnlyHour) {
232
- components.add(DateComponent("timeMode", timeMode))
233
- }
234
-
235
- components
236
- }
237
-
238
- return dateComponents
239
- }