@momo-kits/native-kits 0.157.1-skill.3 → 0.157.1-skill.6-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.
- package/.claude/skills/momo-native-kits-skills/README.md +52 -0
- package/.claude/skills/momo-native-kits-skills/SKILL.md +32 -0
- package/.claude/skills/momo-native-kits-skills/data-display/SKILL.md +42 -0
- package/.claude/skills/momo-native-kits-skills/feedback/SKILL.md +43 -0
- package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/feedback}/references/popup.md +3 -10
- package/.claude/skills/momo-native-kits-skills/form-controls/SKILL.md +42 -0
- package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/form-controls}/references/button.md +2 -3
- package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/form-controls}/references/input.md +3 -7
- package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/form-controls}/references/radio.md +9 -9
- package/.claude/skills/momo-native-kits-skills/layout/SKILL.md +39 -0
- package/.claude/skills/momo-native-kits-skills/navigation/SKILL.md +38 -0
- package/.claude/skills/momo-native-kits-skills/output/test-report.json +12 -0
- package/.claude/skills/momo-native-kits-skills/output/validation-result.json +108 -0
- package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills}/references/constants.md +81 -6
- package/.claude/skills/momo-native-kits-skills/references/design-guidelines.md +130 -0
- package/.claude/skills/momo-native-kits-skills/references/developer/android-compose.md +29 -0
- package/.claude/skills/momo-native-kits-skills/references/developer/code-convention.md +118 -0
- package/.claude/skills/momo-native-kits-skills/references/developer/compose-multiplatform.md +29 -0
- package/.claude/skills/momo-native-kits-skills/scripts/logger.js +63 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/badge.js +32 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/bottomtab.js +19 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/button.js +32 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/card.js +32 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/checkbox.js +32 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/chip.js +59 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/divider.js +19 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/global.js +61 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/index.js +54 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/input.js +32 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/navigation.js +48 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/popup.js +45 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/radio.js +105 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/skeleton.js +20 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/snackbar.js +32 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/state.js +21 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/switch.js +45 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/text.js +19 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/tooltip.js +45 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/trustbanner.js +22 -0
- package/.claude/skills/momo-native-kits-skills/scripts/test-on-device.sh +117 -0
- package/.claude/skills/momo-native-kits-skills/scripts/test-runner.js +167 -0
- package/.claude/skills/momo-native-kits-skills/scripts/validate-kits.js +131 -0
- package/.momo-agent.json +13 -0
- package/build.gradle.kts +11 -0
- package/compose/build.gradle.kts +180 -0
- package/compose/build.gradle.kts.backup +180 -0
- package/compose/compose.podspec +54 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +110 -0
- package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
- package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +107 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +305 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +720 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +121 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +405 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +85 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +340 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +198 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +94 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +136 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +148 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +188 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +116 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +448 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +172 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +255 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +231 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +233 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +254 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +241 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +92 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +352 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +103 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +70 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +96 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +96 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +92 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +130 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +214 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +590 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +177 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +205 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +239 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +185 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +285 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +14 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +239 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +119 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +98 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +161 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +331 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +497 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +162 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +243 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +187 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +279 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +370 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +132 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +42 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +88 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +149 -0
- package/gradle/libs.versions.toml +57 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/gradle.properties +26 -0
- package/gradlew +252 -0
- package/gradlew.bat +94 -0
- package/package.json +1 -1
- package/settings.gradle.kts +52 -0
- package/.claude/momo-native-kits-skill/SKILL.md +0 -51
- package/.claude/momo-native-kits-skill/evals/evals.json +0 -95
- package/.claude/momo-native-kits-skill/workspace/iteration-1/benchmark.json +0 -20
- package/.claude/momo-native-kits-skill/workspace/iteration-1/benchmark.md +0 -13
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-0-button/eval_metadata.json +0 -6
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-0-button/with_skill/outputs/ButtonExample.kt +0 -55
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-0-button/without_skill/outputs/ButtonExample.kt +0 -45
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-1-input/eval_metadata.json +0 -6
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-1-input/with_skill/outputs/InputPhoneExample.kt +0 -40
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-1-input/without_skill/outputs/InputPhoneExample.kt +0 -42
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-2-bottomtab/eval_metadata.json +0 -6
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-2-bottomtab/with_skill/outputs/BottomTabExample.kt +0 -236
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-2-bottomtab/without_skill/outputs/BottomTabExample.kt +0 -152
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-3-checkbox/eval_metadata.json +0 -6
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-3-checkbox/with_skill/outputs/CheckBoxExample.kt +0 -49
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-3-checkbox/without_skill/outputs/CheckBoxExample.kt +0 -123
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-4-datetimepicker/eval_metadata.json +0 -6
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-4-datetimepicker/with_skill/outputs/DateTimePickerExample.kt +0 -318
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-4-datetimepicker/without_skill/outputs/DateTimePickerExample.kt +0 -330
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-card/with_skill/outputs/CardExample.kt +0 -124
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-card/without_skill/outputs/CardExample.kt +0 -71
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-loginform/with_skill/outputs/LoginFormExample.kt +0 -134
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-loginform/without_skill/outputs/LoginFormExample.kt +0 -199
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-navcontainer/with_skill/outputs/NavigationContainerExample.kt +0 -224
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-navcontainer/without_skill/outputs/NavigationContainerExample.kt +0 -225
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-popup/with_skill/outputs/PopupExample.kt +0 -79
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-popup/without_skill/outputs/PopupExample.kt +0 -169
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-setoptions/eval_metadata.json +0 -6
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-setoptions/with_skill/outputs/SetOptionsExample.kt +0 -255
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-setoptions/without_skill/outputs/SetOptionsExample.kt +0 -212
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-skeleton/with_skill/outputs/SkeletonExample.kt +0 -199
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-skeleton/without_skill/outputs/SkeletonExample.kt +0 -229
- package/.claude/momo-native-kits-skill/workspace/iteration-3/benchmark.json +0 -20
- package/.claude/momo-native-kits-skill/workspace/iteration-3/benchmark.md +0 -13
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-button/eval_metadata.json +0 -22
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-button/with_skill/outputs/PrimaryButtonExample.kt +0 -38
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-button/with_skill/timing.json +0 -5
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-button/without_skill/outputs/PrimaryButtonExample.kt +0 -83
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-button/without_skill/timing.json +0 -5
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-navcontainer/eval_metadata.json +0 -22
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-navcontainer/with_skill/outputs/NavigationContainerExample.kt +0 -547
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-navcontainer/with_skill/timing.json +0 -5
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-navcontainer/without_skill/outputs/MoMoNavigationContainer.kt +0 -519
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-navcontainer/without_skill/timing.json +0 -5
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-setoptions/eval_metadata.json +0 -27
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-setoptions/with_skill/outputs/SetOptionsExample.kt +0 -429
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-setoptions/with_skill/timing.json +0 -5
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-setoptions/without_skill/outputs/SetOptionsExample.kt +0 -353
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-setoptions/without_skill/timing.json +0 -5
- package/.claude/settings.local.json +0 -41
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/data-display}/references/badge.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/data-display}/references/chip.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/data-display}/references/skeleton.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/data-display}/references/text.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/feedback}/references/snackbar.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/feedback}/references/tooltip.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/feedback}/references/trustbanner.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/form-controls}/references/checkbox.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/form-controls}/references/switch.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/layout}/references/card.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/layout}/references/divider.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/navigation}/references/navigation.md +0 -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
|
+
}
|
package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt
ADDED
|
@@ -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
|
+
}
|
package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt
ADDED
|
@@ -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
|
+
)
|
package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
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
|
+
}
|