@momo-kits/native-kits 0.300.3 → 0.300.4-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.md +51 -7
- package/README.md +2 -2
- package/build.gradle.kts +13 -0
- package/compose/build.gradle.kts +197 -0
- package/compose/build.gradle.kts.backup +197 -0
- package/compose/compose.podspec +47 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +20 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +153 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1071 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +65 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -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 +338 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +542 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +231 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +189 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +478 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +265 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +235 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +223 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +265 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +185 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -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 +84 -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 +361 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +308 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +90 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +330 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +220 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +473 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +207 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +92 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +560 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +501 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -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 +236 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +17 -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 +16 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +287 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -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 +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -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 +338 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +137 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +116 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +215 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +404 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +732 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +233 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +217 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +97 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +377 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +455 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +103 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +413 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +37 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +192 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +135 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +91 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +74 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +20 -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 +55 -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 +118 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +44 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +62 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +36 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +138 -0
- package/gradle/libs.versions.toml +68 -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/ios/Application/ApplicationEnvironment.swift +24 -6
- package/ios/Application/DesignSystemKits.swift +100 -0
- package/ios/Application/DesignSystemKitsPayload.swift +68 -0
- package/ios/Application/MaxApi.swift +30 -3
- package/ios/Avatar/Avatar.swift +4 -3
- package/ios/Badge/Badge.swift +6 -4
- package/ios/Badge/BadgeDot.swift +1 -1
- package/ios/Badge/BadgeRibbon.swift +8 -2
- package/ios/Button/Button.swift +15 -12
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +64 -18
- package/ios/Carousel/Carousel.swift +29 -12
- package/ios/Checkbox/Checkbox.swift +7 -3
- package/ios/Chip/Chip.swift +5 -4
- package/ios/Collapse/Collapse.swift +70 -19
- package/ios/Colors+Radius+Spacing/Colors.swift +10 -1
- package/ios/Colors+Radius+Spacing/Radius.swift +6 -0
- package/ios/DateTimePicker/DateTimePicker.swift +54 -20
- package/ios/DateTimePicker/WheelPicker.swift +103 -105
- package/ios/Divider/Divider.swift +37 -4
- package/ios/Extensions/Color++.swift +38 -9
- package/ios/Extensions/OptionalEnvironmentObject.swift +12 -0
- package/ios/Extensions/SkeletonUICompat.swift +11 -0
- package/ios/Icon/Icon.swift +21 -23
- package/ios/Icon/Icons.swift +1329 -0
- package/ios/IconButton/IconButton.swift +15 -7
- package/ios/Image/Image.swift +7 -23
- package/ios/Information/Information.swift +27 -9
- package/ios/Input/ErrorView.swift +2 -2
- package/ios/Input/Input.swift +171 -148
- package/ios/Input/InputPhoneNumber.swift +10 -9
- package/ios/Input/InputSearch.swift +107 -78
- package/ios/Input/InputTextArea.swift +133 -148
- package/ios/InputDropDown/InputDropDown.swift +10 -7
- package/ios/InputMoney/InputMoney.swift +32 -11
- package/ios/InputOTP/InputOTP.swift +22 -12
- package/ios/Layout/Card.swift +50 -0
- package/ios/Layout/GridContext.swift +187 -3
- package/ios/Layout/Item.swift +5 -4
- package/ios/Layout/ScreenLayout.swift +415 -0
- package/ios/Layout/Section.swift +4 -100
- package/ios/Loader/Loader.swift +5 -9
- package/ios/Lottie/LottieView.swift +14 -2
- package/ios/{Application/Navigation/Overplay → Navigation}/BottomSheet.swift +169 -29
- package/ios/Navigation/BottomTab/BottomTab.swift +332 -0
- package/ios/{Application/Navigation → Navigation}/BottomTab/BottomTabBar.swift +18 -7
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +104 -0
- package/ios/Navigation/BottomTab/DuoTabBar.swift +329 -0
- package/ios/{Application → Navigation/Component}/FloatingButton.swift +43 -54
- package/ios/Navigation/Component/Header.swift +545 -0
- package/ios/Navigation/Component/HeaderBackground.swift +154 -0
- package/ios/Navigation/Component/HeaderJourney.swift +73 -0
- package/ios/Navigation/Component/HeaderLocation.swift +48 -0
- package/ios/Navigation/Component/HeaderRight.swift +425 -0
- package/ios/Navigation/Component/HeaderTitle.swift +36 -0
- package/ios/{Application/Navigation → Navigation/Component}/HeaderUser.swift +21 -24
- package/ios/Navigation/Component/SideBar.swift +183 -0
- package/ios/{Application/Navigation/Overplay → Navigation/Component}/SnackBar.swift +8 -8
- package/ios/Navigation/HostBackGestureBridge.swift +78 -0
- package/ios/{Application/Navigation/Overplay → Navigation}/ModalScreen.swift +9 -2
- package/ios/Navigation/Navigation.swift +204 -0
- package/ios/Navigation/NavigationContainer.swift +195 -0
- package/ios/{Application/Navigation → Navigation}/Navigator.swift +207 -107
- package/ios/Navigation/StackScreen.swift +930 -0
- package/ios/Navigation/StackTransition.swift +400 -0
- package/ios/Navigation/SwipeBackHaptic.swift +33 -0
- package/ios/{Application/Navigation → Navigation}/Tracking/ScreenTracker.swift +12 -5
- package/ios/OTPKeyboard/OTPKeyboard.swift +8 -11
- package/ios/Pagination/PaginationScroll.swift +2 -2
- package/ios/Popup/PopupDisplay.swift +72 -135
- package/ios/Popup/PopupInput.swift +10 -13
- package/ios/Popup/PopupLayout.swift +138 -0
- package/ios/Popup/PopupNotify.swift +59 -69
- package/ios/Popup/PopupPromotion.swift +31 -47
- package/ios/PopupView/FullscreenPopup.swift +13 -19
- package/ios/PopupView/PopupView.swift +1 -1
- package/ios/PopupView/Utils++.swift +0 -8
- package/ios/ProgressInfo/ProgressInfo.swift +4 -2
- package/ios/Radio/Radio.swift +2 -1
- package/ios/Rating/Rating.swift +9 -1
- package/ios/Resources/dot_loading.json +558 -0
- package/ios/Resources/lottie_circle_loader.json +1 -0
- package/ios/ScrollIndicator/ScrollIndicator.swift +11 -10
- package/ios/Skeleton/Skeleton.swift +22 -27
- package/ios/Slider/Slider.swift +16 -18
- package/ios/Stepper/Stepper.swift +7 -3
- package/ios/Steps/Steps.swift +8 -6
- package/ios/SuggestAction/SuggestAction.swift +5 -0
- package/ios/Swipeable/SwipeCell.swift +10 -6
- package/ios/Switch/Switch.swift +22 -20
- package/ios/TabView/TabView.swift +102 -21
- package/ios/Tag/Tag.swift +15 -4
- package/ios/Template/Logo/Logo.swift +2 -1
- package/ios/Template/TrustBanner/TrustBanner.swift +109 -55
- package/ios/Title/Title.swift +6 -17
- package/ios/Tooltip/Tooltip.swift +29 -14
- package/ios/Typography/FontScale.swift +17 -14
- package/ios/Typography/Text.swift +156 -20
- package/ios/Typography/Typography.swift +2 -2
- package/ios/Uploader/Uploader.swift +3 -1
- package/ios/native-kits.podspec +2 -3
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -3
- package/ios-demo/README.md +120 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ContentView.swift +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DuoTabDemo.swift +80 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +2 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IPhoneDuoDemo.swift +173 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +77 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupDisplayDemo.swift +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +2 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +2 -0
- package/package.json +1 -1
- package/publish.sh +19 -2
- package/scripts/gen-ios-icons.mjs +36 -0
- package/settings.gradle.kts +64 -0
- package/ios/Application/Components.swift +0 -270
- package/ios/Application/ComposeApi.swift +0 -22
- package/ios/Application/HeaderRight.swift +0 -306
- package/ios/Application/Navigation/BottomTab/BottomTab.swift +0 -104
- package/ios/Application/Navigation/HeaderBackProps.swift +0 -66
- package/ios/Application/Navigation/HeaderTitle.swift +0 -57
- package/ios/Application/Navigation/NavigationContainer.swift +0 -213
- package/ios/Application/Navigation/NavigationOptions.swift +0 -109
- package/ios/Application/Navigation/NavigatorManager.swift +0 -22
- package/ios/Application/Navigation/component/Header.swift +0 -178
- package/ios/Application/Navigation/component/HeaderBackground.swift +0 -83
- package/ios/Application/Navigation/component/HeaderColor.swift +0 -65
- package/ios/Application/Navigation/component/HeaderRightWidthKey.swift +0 -11
- package/ios/Application/Navigation/component/NavigationFooter.swift +0 -90
- package/ios/Application/Navigation/component/NavigationHeaderRight.swift +0 -196
- package/ios/Application/Screen.swift +0 -250
- package/ios/Application/StackScreen.swift +0 -492
- package/ios/Typography/FontScaleStore.swift +0 -58
- package/ios/Typography/KitDesignSystem.swift +0 -17
- /package/ios/{Application/Navigation → Navigation}/BottomTab/CurvedContainer.swift +0 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
package vn.momo.kits.const
|
|
2
|
+
|
|
3
|
+
import androidx.compose.runtime.Stable
|
|
4
|
+
import androidx.compose.runtime.staticCompositionLocalOf
|
|
5
|
+
import androidx.compose.ui.graphics.Color
|
|
6
|
+
import androidx.compose.ui.unit.dp
|
|
7
|
+
|
|
8
|
+
@Stable
|
|
9
|
+
data class Background(
|
|
10
|
+
val default: Color,
|
|
11
|
+
val surface: Color,
|
|
12
|
+
val tonal: Color,
|
|
13
|
+
val pressed: Color,
|
|
14
|
+
val selected: Color,
|
|
15
|
+
val disable: Color
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
@Stable
|
|
19
|
+
data class ColorScheme(
|
|
20
|
+
val primary: Color,
|
|
21
|
+
val secondary: Color,
|
|
22
|
+
val gradient: Color,
|
|
23
|
+
val background: Background,
|
|
24
|
+
val text: TextColors,
|
|
25
|
+
val border: BorderColors,
|
|
26
|
+
val success: ColorSet,
|
|
27
|
+
val warning: ColorSet,
|
|
28
|
+
val error: ColorSet,
|
|
29
|
+
val highlight: ColorSet,
|
|
30
|
+
val interactive: ColorSet
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
@Stable
|
|
34
|
+
data class TextColors(
|
|
35
|
+
val default: Color,
|
|
36
|
+
val secondary: Color,
|
|
37
|
+
val hint: Color,
|
|
38
|
+
val disable: Color
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
@Stable
|
|
42
|
+
data class BorderColors(
|
|
43
|
+
val default: Color,
|
|
44
|
+
val disable: Color
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
@Stable
|
|
48
|
+
data class ColorSet(
|
|
49
|
+
val primary: Color,
|
|
50
|
+
val secondary: Color,
|
|
51
|
+
val container: Color
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
@Stable
|
|
55
|
+
data class ThemeAssets(
|
|
56
|
+
val headerBackground: String? = null
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
@Stable
|
|
60
|
+
data class Theme(
|
|
61
|
+
val dark: Boolean,
|
|
62
|
+
val colors: ColorScheme,
|
|
63
|
+
val font: String,
|
|
64
|
+
val assets: ThemeAssets
|
|
65
|
+
) {
|
|
66
|
+
fun isHeaderImage(): Boolean {
|
|
67
|
+
return !assets.headerBackground.isNullOrEmpty()
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
private val lightBaseTheme = Theme(
|
|
71
|
+
dark = false,
|
|
72
|
+
colors = ColorScheme(
|
|
73
|
+
primary = Colors.pink_03,
|
|
74
|
+
secondary = Colors.pink_07,
|
|
75
|
+
gradient = Color(0xFFFDCADE),
|
|
76
|
+
background = Background(
|
|
77
|
+
default = Color(0xFFF2F2F6),
|
|
78
|
+
surface = Colors.black_01,
|
|
79
|
+
tonal = Colors.pink_09,
|
|
80
|
+
pressed = Color(0xFFDFDFE6),
|
|
81
|
+
selected = Colors.pink_10,
|
|
82
|
+
disable = Color(0xFFEBEBF2)
|
|
83
|
+
),
|
|
84
|
+
text = TextColors(
|
|
85
|
+
default = Colors.black_17,
|
|
86
|
+
secondary = Colors.black_15,
|
|
87
|
+
hint = Colors.black_12,
|
|
88
|
+
disable = Colors.black_08
|
|
89
|
+
),
|
|
90
|
+
border = BorderColors(
|
|
91
|
+
default = Colors.black_04,
|
|
92
|
+
disable = Colors.black_02
|
|
93
|
+
),
|
|
94
|
+
success = ColorSet(
|
|
95
|
+
primary = Colors.green_03,
|
|
96
|
+
secondary = Colors.green_07,
|
|
97
|
+
container = Colors.green_08
|
|
98
|
+
),
|
|
99
|
+
warning = ColorSet(
|
|
100
|
+
primary = Colors.orange_03,
|
|
101
|
+
secondary = Colors.orange_07,
|
|
102
|
+
container = Colors.orange_08
|
|
103
|
+
),
|
|
104
|
+
error = ColorSet(
|
|
105
|
+
primary = Colors.red_03,
|
|
106
|
+
secondary = Colors.red_07,
|
|
107
|
+
container = Colors.red_08,
|
|
108
|
+
),
|
|
109
|
+
highlight = ColorSet(
|
|
110
|
+
primary = Colors.mint_03,
|
|
111
|
+
secondary = Colors.mint_07,
|
|
112
|
+
container = Colors.mint_08
|
|
113
|
+
),
|
|
114
|
+
interactive = ColorSet(
|
|
115
|
+
primary = Colors.blue_03,
|
|
116
|
+
secondary = Colors.blue_07,
|
|
117
|
+
container = Colors.blue_08
|
|
118
|
+
)
|
|
119
|
+
),
|
|
120
|
+
font = "SFProText",
|
|
121
|
+
assets = ThemeAssets(
|
|
122
|
+
headerBackground = null
|
|
123
|
+
)
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
private val darkBaseTheme = Theme(
|
|
128
|
+
dark = true,
|
|
129
|
+
colors = ColorScheme(
|
|
130
|
+
primary = Colors.pink_04,
|
|
131
|
+
secondary = Colors.pink_08,
|
|
132
|
+
gradient = Color(0xFFFDCADE),
|
|
133
|
+
background = Background(
|
|
134
|
+
default = Color(0xFF121212),
|
|
135
|
+
surface = Color(0xFF1E1E1E),
|
|
136
|
+
tonal = Colors.pink_10,
|
|
137
|
+
pressed = Color(0xFF1A1A1A),
|
|
138
|
+
selected = Colors.pink_11,
|
|
139
|
+
disable = Color(0xFF303030)
|
|
140
|
+
),
|
|
141
|
+
text = TextColors(
|
|
142
|
+
default = Color.White,
|
|
143
|
+
secondary = Color(0xFFB0B0B0),
|
|
144
|
+
hint = Color(0xFF727272),
|
|
145
|
+
disable = Color(0xFF505050)
|
|
146
|
+
),
|
|
147
|
+
border = BorderColors(
|
|
148
|
+
default = Color(0xFF2A2A2A),
|
|
149
|
+
disable = Color(0xFF242424)
|
|
150
|
+
),
|
|
151
|
+
success = ColorSet(
|
|
152
|
+
primary = Colors.green_03,
|
|
153
|
+
secondary = Colors.green_07,
|
|
154
|
+
container = Colors.green_08
|
|
155
|
+
),
|
|
156
|
+
warning = ColorSet(
|
|
157
|
+
primary = Colors.orange_03,
|
|
158
|
+
secondary = Colors.orange_07,
|
|
159
|
+
container = Colors.orange_08
|
|
160
|
+
),
|
|
161
|
+
error = ColorSet(
|
|
162
|
+
primary = Colors.red_03,
|
|
163
|
+
secondary = Colors.red_07,
|
|
164
|
+
container = Colors.red_08,
|
|
165
|
+
),
|
|
166
|
+
highlight = ColorSet(
|
|
167
|
+
primary = Colors.mint_03,
|
|
168
|
+
secondary = Colors.mint_07,
|
|
169
|
+
container = Colors.mint_08
|
|
170
|
+
),
|
|
171
|
+
interactive = ColorSet(
|
|
172
|
+
primary = Colors.blue_03,
|
|
173
|
+
secondary = Colors.blue_07,
|
|
174
|
+
container = Colors.blue_08
|
|
175
|
+
)
|
|
176
|
+
),
|
|
177
|
+
font = "SFProText",
|
|
178
|
+
assets = ThemeAssets(
|
|
179
|
+
headerBackground = null
|
|
180
|
+
)
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
val defaultTheme: Theme
|
|
185
|
+
get() = lightBaseTheme.copy(font = defaultFontFamily)
|
|
186
|
+
|
|
187
|
+
val darkTheme: Theme
|
|
188
|
+
get() = darkBaseTheme.copy(font = defaultFontFamily)
|
|
189
|
+
|
|
190
|
+
val AppTheme = staticCompositionLocalOf { defaultTheme }
|
|
191
|
+
|
|
192
|
+
val AppStatusBar = staticCompositionLocalOf { 0.dp }
|
|
193
|
+
|
|
194
|
+
val AppNavigationBar = staticCompositionLocalOf { 0.dp }
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
package vn.momo.kits.const
|
|
2
|
+
|
|
3
|
+
import androidx.compose.runtime.Composable
|
|
4
|
+
import androidx.compose.runtime.Immutable
|
|
5
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
6
|
+
import androidx.compose.ui.text.TextStyle
|
|
7
|
+
import androidx.compose.ui.text.font.FontFamily
|
|
8
|
+
import androidx.compose.ui.text.font.FontWeight
|
|
9
|
+
import androidx.compose.ui.text.style.TextDecoration
|
|
10
|
+
import androidx.compose.ui.unit.*
|
|
11
|
+
import vn.momo.kits.application.DesignSystemKits
|
|
12
|
+
import vn.momo.kits.application.LocalContext
|
|
13
|
+
import vn.momo.kits.platform.getScreenDimensions
|
|
14
|
+
import kotlin.math.max
|
|
15
|
+
import kotlin.math.min
|
|
16
|
+
|
|
17
|
+
const val DEFAULT_SCREEN_SIZE = 375f
|
|
18
|
+
const val MAX_FONT_SCALE = 1.5f
|
|
19
|
+
const val MAX_DEVICE_SCALE = 5
|
|
20
|
+
|
|
21
|
+
@Composable
|
|
22
|
+
fun scaleSize(size: Float): Float {
|
|
23
|
+
val context = LocalContext.current
|
|
24
|
+
val useOsScale = context?.useOSScaleRate ?: DesignSystemKits.getConfigs().useOSScaleRate
|
|
25
|
+
if (!useOsScale) {
|
|
26
|
+
return size * (context?.userScaleRate ?: DesignSystemKits.getConfigs().userScaleRate)
|
|
27
|
+
}
|
|
28
|
+
val scaleSizeMaxRate: Float = MAX_FONT_SCALE
|
|
29
|
+
// Short side, not width: landscape must not inflate every font.
|
|
30
|
+
val deviceWidth = getScreenDimensions().let { minOf(it.width, it.height) }
|
|
31
|
+
val deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE
|
|
32
|
+
|
|
33
|
+
val density = LocalDensity.current
|
|
34
|
+
val fontScale = density.fontScale
|
|
35
|
+
|
|
36
|
+
var fontSizeScaleDevice = size
|
|
37
|
+
var fontSizeScaleOS = size
|
|
38
|
+
|
|
39
|
+
if (deviceScale > 1) {
|
|
40
|
+
fontSizeScaleDevice =
|
|
41
|
+
min(deviceScale * fontSizeScaleDevice, fontSizeScaleDevice + MAX_DEVICE_SCALE)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (fontScale > 1) {
|
|
45
|
+
fontSizeScaleOS = min(fontScale * fontSizeScaleOS, fontSizeScaleOS * scaleSizeMaxRate)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return max(
|
|
49
|
+
fontSizeScaleDevice,
|
|
50
|
+
fontSizeScaleOS
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Composable
|
|
55
|
+
fun scaleSize(size: TextUnit): TextUnit {
|
|
56
|
+
if (!size.isSp) return size
|
|
57
|
+
|
|
58
|
+
val density = LocalDensity.current
|
|
59
|
+
|
|
60
|
+
val scaled = scaleSize(size.value)
|
|
61
|
+
val spValue = scaled / density.fontScale
|
|
62
|
+
|
|
63
|
+
return TextUnit(value = spValue, type = TextUnitType.Sp)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Composable
|
|
67
|
+
fun scaleSize(size: Dp): Dp {
|
|
68
|
+
return scaleSize(size.value).dp
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@Composable
|
|
72
|
+
fun scaleSize(textStyle: TextStyle): TextStyle {
|
|
73
|
+
return textStyle.copy(
|
|
74
|
+
fontSize = if (textStyle.fontSize != TextUnit.Unspecified)
|
|
75
|
+
scaleSize(textStyle.fontSize)
|
|
76
|
+
else
|
|
77
|
+
TextUnit.Unspecified,
|
|
78
|
+
|
|
79
|
+
lineHeight = if (textStyle.lineHeight != TextUnit.Unspecified)
|
|
80
|
+
scaleSize(textStyle.lineHeight)
|
|
81
|
+
else
|
|
82
|
+
TextUnit.Unspecified,
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
private const val LEGACY_DEFAULT_FONT_FILE = "SFProText-Regular.ttf"
|
|
88
|
+
private const val NEW_DEFAULT_FONT_FILE = "MomoTrustSans-Regular.ttf"
|
|
89
|
+
|
|
90
|
+
private val hostFontFiles: Map<String, String> = mapOf(
|
|
91
|
+
"SFProText-100" to "SFProText-Thin.ttf",
|
|
92
|
+
"SFProText-200" to "SFProText-Ultralight.ttf",
|
|
93
|
+
"SFProText-300" to "SFProText-Light.ttf",
|
|
94
|
+
"SFProText-400" to LEGACY_DEFAULT_FONT_FILE,
|
|
95
|
+
"SFProText-500" to "SFProText-Medium.ttf",
|
|
96
|
+
"SFProText-600" to "SFProText-Semibold.ttf",
|
|
97
|
+
"SFProText-700" to "SFProText-Bold.ttf",
|
|
98
|
+
"SFProText-800" to "SFProText-Heavy.ttf",
|
|
99
|
+
"SFProText-900" to "SFProText-Black.ttf",
|
|
100
|
+
|
|
101
|
+
"MomoTrustSans-100" to "MomoTrustSans-ExtraLight.ttf",
|
|
102
|
+
"MomoTrustSans-200" to "MomoTrustSans-ExtraLight.ttf",
|
|
103
|
+
"MomoTrustSans-300" to "MomoTrustSans-Light.ttf",
|
|
104
|
+
"MomoTrustSans-400" to "MomoTrustSans-Regular.ttf",
|
|
105
|
+
"MomoTrustSans-500" to "MomoTrustSans-Medium.ttf",
|
|
106
|
+
"MomoTrustSans-600" to "MomoTrustSans-SemiBold.ttf",
|
|
107
|
+
"MomoTrustSans-700" to "MomoTrustSans-Bold.ttf",
|
|
108
|
+
"MomoTrustSans-800" to "MomoTrustSans-ExtraBold.ttf",
|
|
109
|
+
"MomoTrustSans-900" to "MomoTrustSans-ExtraBold.ttf",
|
|
110
|
+
) + (1..9).flatMap { step ->
|
|
111
|
+
val weight = step * 100
|
|
112
|
+
listOf(
|
|
113
|
+
"MoMoSignature-$weight" to "MoMoSignature.otf",
|
|
114
|
+
"MoMoTrustDisplay-$weight" to "MoMoTrustDisplay.otf",
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private const val NEW_DEFAULT_FONT_FAMILY = "MomoTrustSans"
|
|
119
|
+
private const val LEGACY_DEFAULT_FONT_FAMILY = "SFProText"
|
|
120
|
+
|
|
121
|
+
// Families that ship one file per weight; the others map every weight to a single file.
|
|
122
|
+
private val weightedFontFamilies = setOf(NEW_DEFAULT_FONT_FAMILY, LEGACY_DEFAULT_FONT_FAMILY)
|
|
123
|
+
|
|
124
|
+
internal val defaultFontFamily: String
|
|
125
|
+
get() = if (DesignSystemKits.getConfigs().isWhiteList) NEW_DEFAULT_FONT_FAMILY else LEGACY_DEFAULT_FONT_FAMILY
|
|
126
|
+
|
|
127
|
+
@Composable
|
|
128
|
+
fun getFontFamily(fontFamily: String, fontWeight: FontWeight? = FontWeight.Normal): FontFamily {
|
|
129
|
+
val isWhiteList = DesignSystemKits.getConfigs().isWhiteList
|
|
130
|
+
val defaultFile = if (isWhiteList) NEW_DEFAULT_FONT_FILE else LEGACY_DEFAULT_FONT_FILE
|
|
131
|
+
val key = "$fontFamily-${fontWeight?.weight}"
|
|
132
|
+
val mappedFile = hostFontFiles[key]
|
|
133
|
+
val fileName = mappedFile ?: defaultFile
|
|
134
|
+
// Declaring the file's real weight keeps Compose from synthesizing bold on top of a bold file.
|
|
135
|
+
val fileWeight = if (mappedFile != null && fontFamily in weightedFontFamilies) {
|
|
136
|
+
fontWeight ?: FontWeight.Normal
|
|
137
|
+
} else {
|
|
138
|
+
FontWeight.Normal
|
|
139
|
+
}
|
|
140
|
+
return hostFontFamily(fileName, fileWeight)
|
|
141
|
+
?: hostFontFamily(defaultFile, FontWeight.Normal)
|
|
142
|
+
?: FontFamily.Default
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@Immutable
|
|
146
|
+
class AppTypography internal constructor(
|
|
147
|
+
val headlineDefaultBold: TextStyle,
|
|
148
|
+
val headerMBold: TextStyle,
|
|
149
|
+
val headerDefaultBold: TextStyle,
|
|
150
|
+
val headerSSemibold: TextStyle,
|
|
151
|
+
val headerXsSemibold: TextStyle,
|
|
152
|
+
val bodyDefaultRegular: TextStyle,
|
|
153
|
+
val bodyDefaultRegularStrikethrough: TextStyle,
|
|
154
|
+
val descriptionDefaultRegular: TextStyle,
|
|
155
|
+
val descriptionDefaultRegularStrikethrough: TextStyle,
|
|
156
|
+
val descriptionXsRegular: TextStyle,
|
|
157
|
+
val descriptionXsRegularStrikethrough: TextStyle,
|
|
158
|
+
val labelDefaultMedium: TextStyle,
|
|
159
|
+
val labelSMedium: TextStyle,
|
|
160
|
+
val labelXsMedium: TextStyle,
|
|
161
|
+
val actionDefaultBold: TextStyle,
|
|
162
|
+
val actionSBold: TextStyle,
|
|
163
|
+
val actionXsBold: TextStyle,
|
|
164
|
+
val actionXxsBold: TextStyle,
|
|
165
|
+
) {
|
|
166
|
+
constructor(
|
|
167
|
+
default: TextStyle = TextStyle(
|
|
168
|
+
fontSize = 14.sp,
|
|
169
|
+
lineHeight = 20.sp,
|
|
170
|
+
fontWeight = FontWeight.Normal
|
|
171
|
+
),
|
|
172
|
+
headlineDefaultBold: TextStyle = TextStyle(
|
|
173
|
+
fontSize = 24.sp,
|
|
174
|
+
lineHeight = 34.sp,
|
|
175
|
+
fontWeight = FontWeight.Bold
|
|
176
|
+
),
|
|
177
|
+
headerMBold: TextStyle = TextStyle(
|
|
178
|
+
fontSize = 18.sp,
|
|
179
|
+
lineHeight = 26.sp,
|
|
180
|
+
fontWeight = FontWeight.Bold
|
|
181
|
+
),
|
|
182
|
+
headerDefaultBold: TextStyle = TextStyle(
|
|
183
|
+
fontSize = 16.sp,
|
|
184
|
+
lineHeight = 22.sp,
|
|
185
|
+
fontWeight = FontWeight.Bold
|
|
186
|
+
),
|
|
187
|
+
headerSSemibold: TextStyle = TextStyle(
|
|
188
|
+
fontSize = 14.sp,
|
|
189
|
+
lineHeight = 20.sp,
|
|
190
|
+
fontWeight = FontWeight.SemiBold
|
|
191
|
+
),
|
|
192
|
+
headerXsSemibold: TextStyle = TextStyle(
|
|
193
|
+
fontSize = 12.sp,
|
|
194
|
+
lineHeight = 18.sp,
|
|
195
|
+
fontWeight = FontWeight.SemiBold
|
|
196
|
+
),
|
|
197
|
+
bodyDefaultRegular: TextStyle = TextStyle(
|
|
198
|
+
fontSize = 14.sp,
|
|
199
|
+
lineHeight = 20.sp,
|
|
200
|
+
fontWeight = FontWeight.Normal
|
|
201
|
+
),
|
|
202
|
+
bodyDefaultRegularStrikethrough: TextStyle = TextStyle(
|
|
203
|
+
fontSize = 14.sp,
|
|
204
|
+
lineHeight = 20.sp,
|
|
205
|
+
fontWeight = FontWeight.Normal,
|
|
206
|
+
textDecoration = TextDecoration.LineThrough
|
|
207
|
+
),
|
|
208
|
+
descriptionDefaultRegular: TextStyle = TextStyle(
|
|
209
|
+
fontSize = 12.sp,
|
|
210
|
+
lineHeight = 18.sp,
|
|
211
|
+
fontWeight = FontWeight.Normal
|
|
212
|
+
),
|
|
213
|
+
descriptionDefaultRegularStrikethrough: TextStyle = TextStyle(
|
|
214
|
+
fontSize = 12.sp,
|
|
215
|
+
lineHeight = 18.sp,
|
|
216
|
+
fontWeight = FontWeight.Normal,
|
|
217
|
+
textDecoration = TextDecoration.LineThrough
|
|
218
|
+
),
|
|
219
|
+
descriptionXsRegular: TextStyle = TextStyle(
|
|
220
|
+
fontSize = 10.sp,
|
|
221
|
+
lineHeight = 14.sp,
|
|
222
|
+
fontWeight = FontWeight.Normal
|
|
223
|
+
),
|
|
224
|
+
descriptionXsRegularStrikethrough: TextStyle = TextStyle(
|
|
225
|
+
fontSize = 10.sp,
|
|
226
|
+
lineHeight = 14.sp,
|
|
227
|
+
fontWeight = FontWeight.Normal,
|
|
228
|
+
textDecoration = TextDecoration.LineThrough
|
|
229
|
+
),
|
|
230
|
+
labelDefaultMedium: TextStyle = TextStyle(
|
|
231
|
+
fontSize = 14.sp,
|
|
232
|
+
lineHeight = 20.sp,
|
|
233
|
+
fontWeight = FontWeight.Medium
|
|
234
|
+
),
|
|
235
|
+
labelSMedium: TextStyle = TextStyle(
|
|
236
|
+
fontSize = 12.sp,
|
|
237
|
+
lineHeight = 18.sp,
|
|
238
|
+
fontWeight = FontWeight.Medium
|
|
239
|
+
),
|
|
240
|
+
labelXsMedium: TextStyle = TextStyle(
|
|
241
|
+
fontSize = 10.sp,
|
|
242
|
+
lineHeight = 14.sp,
|
|
243
|
+
fontWeight = FontWeight.Medium
|
|
244
|
+
),
|
|
245
|
+
actionDefaultBold: TextStyle = TextStyle(
|
|
246
|
+
fontSize = 16.sp,
|
|
247
|
+
lineHeight = 22.sp,
|
|
248
|
+
fontWeight = FontWeight.Bold
|
|
249
|
+
),
|
|
250
|
+
actionSBold: TextStyle = TextStyle(
|
|
251
|
+
fontSize = 14.sp,
|
|
252
|
+
lineHeight = 20.sp,
|
|
253
|
+
fontWeight = FontWeight.Bold
|
|
254
|
+
),
|
|
255
|
+
actionXsBold: TextStyle = TextStyle(
|
|
256
|
+
fontSize = 12.sp,
|
|
257
|
+
lineHeight = 18.sp,
|
|
258
|
+
fontWeight = FontWeight.Bold
|
|
259
|
+
),
|
|
260
|
+
actionXxsBold: TextStyle = TextStyle(
|
|
261
|
+
fontSize = 10.sp,
|
|
262
|
+
lineHeight = 14.sp,
|
|
263
|
+
fontWeight = FontWeight.Bold
|
|
264
|
+
),
|
|
265
|
+
) : this(
|
|
266
|
+
headlineDefaultBold = headlineDefaultBold,
|
|
267
|
+
headerMBold = headerMBold,
|
|
268
|
+
headerDefaultBold = headerDefaultBold,
|
|
269
|
+
headerSSemibold = headerSSemibold,
|
|
270
|
+
headerXsSemibold = headerXsSemibold,
|
|
271
|
+
bodyDefaultRegular = bodyDefaultRegular,
|
|
272
|
+
bodyDefaultRegularStrikethrough = bodyDefaultRegularStrikethrough,
|
|
273
|
+
descriptionDefaultRegular = descriptionDefaultRegular,
|
|
274
|
+
descriptionDefaultRegularStrikethrough = descriptionDefaultRegularStrikethrough,
|
|
275
|
+
descriptionXsRegular = descriptionXsRegular,
|
|
276
|
+
descriptionXsRegularStrikethrough = descriptionXsRegularStrikethrough,
|
|
277
|
+
labelDefaultMedium = labelDefaultMedium,
|
|
278
|
+
labelSMedium = labelSMedium,
|
|
279
|
+
labelXsMedium = labelXsMedium,
|
|
280
|
+
actionDefaultBold = actionDefaultBold,
|
|
281
|
+
actionSBold = actionSBold,
|
|
282
|
+
actionXsBold = actionXsBold,
|
|
283
|
+
actionXxsBold = actionXxsBold
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
val Typography = AppTypography()
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
package vn.momo.kits.layout
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.background
|
|
4
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
5
|
+
import androidx.compose.foundation.layout.Box
|
|
6
|
+
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
7
|
+
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
|
8
|
+
import androidx.compose.foundation.layout.FlowRow
|
|
9
|
+
import androidx.compose.foundation.layout.PaddingValues
|
|
10
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
11
|
+
import androidx.compose.foundation.layout.padding
|
|
12
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
13
|
+
import androidx.compose.runtime.Composable
|
|
14
|
+
import androidx.compose.runtime.CompositionLocalProvider
|
|
15
|
+
import androidx.compose.ui.Modifier
|
|
16
|
+
import androidx.compose.ui.draw.clip
|
|
17
|
+
import androidx.compose.ui.draw.shadow
|
|
18
|
+
import androidx.compose.ui.graphics.Color
|
|
19
|
+
import androidx.compose.ui.unit.dp
|
|
20
|
+
import vn.momo.kits.components.Image
|
|
21
|
+
import vn.momo.kits.const.AppTheme
|
|
22
|
+
import vn.momo.kits.const.Radius
|
|
23
|
+
import vn.momo.kits.const.Spacing
|
|
24
|
+
|
|
25
|
+
@Composable
|
|
26
|
+
@OptIn(ExperimentalLayoutApi::class)
|
|
27
|
+
fun Card(
|
|
28
|
+
useShadow: Boolean = false,
|
|
29
|
+
backgroundImage: String? = null,
|
|
30
|
+
backgroundColor: Color? = null,
|
|
31
|
+
contentPadding: PaddingValues = PaddingValues(Spacing.M),
|
|
32
|
+
modifier: Modifier = Modifier,
|
|
33
|
+
content: @Composable () -> Unit,
|
|
34
|
+
) {
|
|
35
|
+
val columns = gridColumns()
|
|
36
|
+
val gap = Spacing.S
|
|
37
|
+
val shape = RoundedCornerShape(Radius.M)
|
|
38
|
+
var surface = modifier.fillMaxWidth().padding(horizontal = Spacing.M)
|
|
39
|
+
if (useShadow) surface = surface.shadow(6.dp, shape)
|
|
40
|
+
surface = surface.clip(shape).background(backgroundColor ?: AppTheme.current.colors.background.surface)
|
|
41
|
+
Box(modifier = surface) {
|
|
42
|
+
if (backgroundImage != null) {
|
|
43
|
+
Image(source = backgroundImage, modifier = Modifier.matchParentSize())
|
|
44
|
+
}
|
|
45
|
+
BoxWithConstraints(modifier = Modifier.fillMaxWidth().padding(contentPadding)) {
|
|
46
|
+
CompositionLocalProvider(LocalGridContext provides gridContext(constraints.maxWidth, columns, gap)) {
|
|
47
|
+
FlowRow(
|
|
48
|
+
horizontalArrangement = Arrangement.spacedBy(gap),
|
|
49
|
+
verticalArrangement = Arrangement.spacedBy(gap),
|
|
50
|
+
) { content() }
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
package vn.momo.kits.layout
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.layout.Column
|
|
4
|
+
import androidx.compose.foundation.layout.height
|
|
5
|
+
import androidx.compose.foundation.layout.width
|
|
6
|
+
import androidx.compose.runtime.Composable
|
|
7
|
+
import androidx.compose.runtime.compositionLocalOf
|
|
8
|
+
import androidx.compose.ui.Modifier
|
|
9
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
10
|
+
import androidx.compose.ui.unit.Dp
|
|
11
|
+
import androidx.compose.ui.unit.dp
|
|
12
|
+
import kotlin.math.floor
|
|
13
|
+
|
|
14
|
+
internal data class GridContext(
|
|
15
|
+
val numberOfColumns: Int = 12,
|
|
16
|
+
val gutterPx: Int = 0,
|
|
17
|
+
val columnPx: Float = 0f,
|
|
18
|
+
val density: Float = 1f,
|
|
19
|
+
) {
|
|
20
|
+
fun sizeForSpan(span: Int): Dp = (floor(columnPx * span + gutterPx * (span - 1)) / density).dp
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
internal val LocalGridContext = compositionLocalOf<GridContext?> { null }
|
|
24
|
+
|
|
25
|
+
@Composable
|
|
26
|
+
internal fun gridColumns(): Int = if (getScreenLayout().contentWidth > 600.dp) 24 else 12
|
|
27
|
+
|
|
28
|
+
@Composable
|
|
29
|
+
internal fun gridContext(maxWidthPx: Int, columns: Int, gap: Dp): GridContext {
|
|
30
|
+
val density = LocalDensity.current
|
|
31
|
+
val gutterPx = with(density) { gap.roundToPx() }
|
|
32
|
+
return GridContext(columns, gutterPx, (maxWidthPx - gutterPx * (columns - 1)).toFloat() / columns, density.density)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Composable
|
|
36
|
+
fun Item(
|
|
37
|
+
widthSpan: Int? = null,
|
|
38
|
+
heightSpan: Int = 0,
|
|
39
|
+
modifier: Modifier = Modifier,
|
|
40
|
+
contentModifier: Modifier = Modifier,
|
|
41
|
+
content: @Composable () -> Unit,
|
|
42
|
+
) {
|
|
43
|
+
val grid = LocalGridContext.current
|
|
44
|
+
var m = modifier
|
|
45
|
+
if (grid != null) {
|
|
46
|
+
m = m.width(grid.sizeForSpan(widthSpan ?: grid.numberOfColumns))
|
|
47
|
+
if (heightSpan > 0) m = m.height(grid.sizeForSpan(heightSpan))
|
|
48
|
+
}
|
|
49
|
+
Column(modifier = m.then(contentModifier)) { content() }
|
|
50
|
+
}
|