@momo-kits/native-kits 0.167.1-duo.21 → 0.167.1-duo.22-debug

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/build.gradle.kts +11 -0
  2. package/compose/build.gradle.kts +204 -0
  3. package/compose/build.gradle.kts.backup +204 -0
  4. package/compose/compose.podspec +47 -0
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +153 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +124 -0
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +951 -0
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +542 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +231 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +189 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +478 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +265 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +235 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +223 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +265 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +185 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +84 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +361 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +308 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +90 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +330 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +220 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +473 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +207 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +92 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +560 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +125 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +501 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +236 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +20 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +18 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +283 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +309 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +338 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +137 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +116 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +205 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +399 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +727 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +218 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +231 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +98 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +312 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +455 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +103 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +399 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +192 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +91 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +74 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +13 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +118 -0
  121. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +78 -0
  122. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  123. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
  124. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  125. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +94 -0
  128. package/gradle/libs.versions.toml +69 -0
  129. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  130. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  131. package/gradle.properties +26 -0
  132. package/gradlew +252 -0
  133. package/gradlew.bat +94 -0
  134. package/ios/Application/MaxApi.swift +20 -2
  135. package/ios/Input/InputSearch.swift +5 -2
  136. package/ios/Navigation/BottomSheet.swift +58 -37
  137. package/ios/Navigation/BottomTab/BottomTab.swift +165 -18
  138. package/ios/Navigation/BottomTab/BottomTabBar.swift +3 -0
  139. package/ios/Navigation/Component/FloatingButton.swift +29 -51
  140. package/ios/Navigation/Component/Header.swift +19 -5
  141. package/ios/Navigation/Component/HeaderRight.swift +48 -19
  142. package/ios/Navigation/Component/SnackBar.swift +3 -2
  143. package/ios/Navigation/ModalScreen.swift +2 -1
  144. package/ios/Navigation/NavigationContainer.swift +3 -2
  145. package/ios/Navigation/Navigator.swift +30 -16
  146. package/ios/Navigation/StackScreen.swift +151 -37
  147. package/ios-demo/README.md +120 -0
  148. package/package.json +1 -1
  149. package/settings.gradle.kts +64 -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,283 @@
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.LocalContext
12
+ import vn.momo.kits.platform.getScreenDimensions
13
+ import kotlin.math.max
14
+ import kotlin.math.min
15
+
16
+ const val DEFAULT_SCREEN_SIZE = 375f
17
+ const val MAX_FONT_SCALE = 1.5f
18
+ const val MAX_DEVICE_SCALE = 5
19
+
20
+ @Composable
21
+ fun scaleSize(size: Float): Float {
22
+ val context = LocalContext.current
23
+ // Host-pushed context wins; otherwise fall back to the app-wide KitFontScale holder.
24
+ val useOsScale = context?.useOSScaleRate ?: KitFontScale.useOSScaleRate
25
+ if (!useOsScale) {
26
+ return size * (context?.userScaleRate ?: KitFontScale.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
+ /**
88
+ * Tên file font trong tài nguyên native của app host (xem [hostFontFamily]).
89
+ *
90
+ * SDK không đóng gói font riêng nữa: app host đã bundle sẵn toàn bộ font từ `font-source`
91
+ * cho cả React Native lẫn native, nên bản copy trong `composeResources` chỉ làm phình app.
92
+ */
93
+ private const val LEGACY_DEFAULT_FONT_FILE = "SFProText-Regular.ttf"
94
+ private const val NEW_DEFAULT_FONT_FILE = "MomoTrustSans-Regular.ttf"
95
+
96
+ private val hostFontFiles: Map<String, String> = mapOf(
97
+ "SFProText-100" to "SFProText-Thin.ttf",
98
+ "SFProText-200" to "SFProText-Ultralight.ttf",
99
+ "SFProText-300" to "SFProText-Light.ttf",
100
+ "SFProText-400" to LEGACY_DEFAULT_FONT_FILE,
101
+ "SFProText-500" to "SFProText-Medium.ttf",
102
+ "SFProText-600" to "SFProText-Semibold.ttf",
103
+ "SFProText-700" to "SFProText-Bold.ttf",
104
+ "SFProText-800" to "SFProText-Heavy.ttf",
105
+ "SFProText-900" to "SFProText-Black.ttf",
106
+
107
+ "MomoTrustSans-100" to "MomoTrustSans-ExtraLight.ttf",
108
+ "MomoTrustSans-200" to "MomoTrustSans-ExtraLight.ttf",
109
+ "MomoTrustSans-300" to "MomoTrustSans-Light.ttf",
110
+ "MomoTrustSans-400" to "MomoTrustSans-Regular.ttf",
111
+ "MomoTrustSans-500" to "MomoTrustSans-Medium.ttf",
112
+ "MomoTrustSans-600" to "MomoTrustSans-SemiBold.ttf",
113
+ "MomoTrustSans-700" to "MomoTrustSans-Bold.ttf",
114
+ "MomoTrustSans-800" to "MomoTrustSans-ExtraBold.ttf",
115
+ "MomoTrustSans-900" to "MomoTrustSans-ExtraBold.ttf",
116
+ ) + (1..9).flatMap { step ->
117
+ val weight = step * 100
118
+ listOf(
119
+ "MoMoSignature-$weight" to "MoMoSignature.otf",
120
+ "MoMoTrustDisplay-$weight" to "MoMoTrustDisplay.otf",
121
+ )
122
+ }
123
+
124
+ private const val NEW_DEFAULT_FONT_FAMILY = "MomoTrustSans"
125
+ private const val LEGACY_DEFAULT_FONT_FAMILY = "SFProText"
126
+
127
+ internal val defaultFontFamily: String
128
+ get() = if (KitDesignSystem.isWhiteList) NEW_DEFAULT_FONT_FAMILY else LEGACY_DEFAULT_FONT_FAMILY
129
+
130
+ @Composable
131
+ fun getFontFamily(fontFamily: String, fontWeight: FontWeight? = FontWeight.Normal): FontFamily {
132
+ val isWhiteList = KitDesignSystem.isWhiteList
133
+ val defaultFile = if (isWhiteList) NEW_DEFAULT_FONT_FILE else LEGACY_DEFAULT_FONT_FILE
134
+ val key = "$fontFamily-${fontWeight?.weight}"
135
+ val fileName = hostFontFiles[key] ?: defaultFile
136
+ return hostFontFamily(fileName)
137
+ ?: hostFontFamily(defaultFile)
138
+ ?: FontFamily.Default
139
+ }
140
+
141
+ @Immutable
142
+ class AppTypography internal constructor(
143
+ val headlineDefaultBold: TextStyle,
144
+ val headerMBold: TextStyle,
145
+ val headerDefaultBold: TextStyle,
146
+ val headerSSemibold: TextStyle,
147
+ val headerXsSemibold: TextStyle,
148
+ val bodyDefaultRegular: TextStyle,
149
+ val bodyDefaultRegularStrikethrough: TextStyle,
150
+ val descriptionDefaultRegular: TextStyle,
151
+ val descriptionDefaultRegularStrikethrough: TextStyle,
152
+ val descriptionXsRegular: TextStyle,
153
+ val descriptionXsRegularStrikethrough: TextStyle,
154
+ val labelDefaultMedium: TextStyle,
155
+ val labelSMedium: TextStyle,
156
+ val labelXsMedium: TextStyle,
157
+ val actionDefaultBold: TextStyle,
158
+ val actionSBold: TextStyle,
159
+ val actionXsBold: TextStyle,
160
+ val actionXxsBold: TextStyle,
161
+ ) {
162
+ constructor(
163
+ default: TextStyle = TextStyle(
164
+ fontSize = 14.sp,
165
+ lineHeight = 20.sp,
166
+ fontWeight = FontWeight.Normal
167
+ ),
168
+ headlineDefaultBold: TextStyle = TextStyle(
169
+ fontSize = 24.sp,
170
+ lineHeight = 34.sp,
171
+ fontWeight = FontWeight.Bold
172
+ ),
173
+ headerMBold: TextStyle = TextStyle(
174
+ fontSize = 18.sp,
175
+ lineHeight = 26.sp,
176
+ fontWeight = FontWeight.Bold
177
+ ),
178
+ headerDefaultBold: TextStyle = TextStyle(
179
+ fontSize = 16.sp,
180
+ lineHeight = 22.sp,
181
+ fontWeight = FontWeight.Bold
182
+ ),
183
+ headerSSemibold: TextStyle = TextStyle(
184
+ fontSize = 14.sp,
185
+ lineHeight = 20.sp,
186
+ fontWeight = FontWeight.SemiBold
187
+ ),
188
+ headerXsSemibold: TextStyle = TextStyle(
189
+ fontSize = 12.sp,
190
+ lineHeight = 18.sp,
191
+ fontWeight = FontWeight.SemiBold
192
+ ),
193
+ bodyDefaultRegular: TextStyle = TextStyle(
194
+ fontSize = 14.sp,
195
+ lineHeight = 20.sp,
196
+ fontWeight = FontWeight.Normal
197
+ ),
198
+ bodyDefaultRegularStrikethrough: TextStyle = TextStyle(
199
+ fontSize = 14.sp,
200
+ lineHeight = 20.sp,
201
+ fontWeight = FontWeight.Normal,
202
+ textDecoration = TextDecoration.LineThrough
203
+ ),
204
+ descriptionDefaultRegular: TextStyle = TextStyle(
205
+ fontSize = 12.sp,
206
+ lineHeight = 18.sp,
207
+ fontWeight = FontWeight.Normal
208
+ ),
209
+ descriptionDefaultRegularStrikethrough: TextStyle = TextStyle(
210
+ fontSize = 12.sp,
211
+ lineHeight = 18.sp,
212
+ fontWeight = FontWeight.Normal,
213
+ textDecoration = TextDecoration.LineThrough
214
+ ),
215
+ descriptionXsRegular: TextStyle = TextStyle(
216
+ fontSize = 10.sp,
217
+ lineHeight = 14.sp,
218
+ fontWeight = FontWeight.Normal
219
+ ),
220
+ descriptionXsRegularStrikethrough: TextStyle = TextStyle(
221
+ fontSize = 10.sp,
222
+ lineHeight = 14.sp,
223
+ fontWeight = FontWeight.Normal,
224
+ textDecoration = TextDecoration.LineThrough
225
+ ),
226
+ labelDefaultMedium: TextStyle = TextStyle(
227
+ fontSize = 14.sp,
228
+ lineHeight = 20.sp,
229
+ fontWeight = FontWeight.Medium
230
+ ),
231
+ labelSMedium: TextStyle = TextStyle(
232
+ fontSize = 12.sp,
233
+ lineHeight = 18.sp,
234
+ fontWeight = FontWeight.Medium
235
+ ),
236
+ labelXsMedium: TextStyle = TextStyle(
237
+ fontSize = 10.sp,
238
+ lineHeight = 14.sp,
239
+ fontWeight = FontWeight.Medium
240
+ ),
241
+ actionDefaultBold: TextStyle = TextStyle(
242
+ fontSize = 16.sp,
243
+ lineHeight = 22.sp,
244
+ fontWeight = FontWeight.Bold
245
+ ),
246
+ actionSBold: TextStyle = TextStyle(
247
+ fontSize = 14.sp,
248
+ lineHeight = 20.sp,
249
+ fontWeight = FontWeight.Bold
250
+ ),
251
+ actionXsBold: TextStyle = TextStyle(
252
+ fontSize = 12.sp,
253
+ lineHeight = 18.sp,
254
+ fontWeight = FontWeight.Bold
255
+ ),
256
+ actionXxsBold: TextStyle = TextStyle(
257
+ fontSize = 10.sp,
258
+ lineHeight = 14.sp,
259
+ fontWeight = FontWeight.Bold
260
+ ),
261
+ ) : this(
262
+ headlineDefaultBold = headlineDefaultBold,
263
+ headerMBold = headerMBold,
264
+ headerDefaultBold = headerDefaultBold,
265
+ headerSSemibold = headerSSemibold,
266
+ headerXsSemibold = headerXsSemibold,
267
+ bodyDefaultRegular = bodyDefaultRegular,
268
+ bodyDefaultRegularStrikethrough = bodyDefaultRegularStrikethrough,
269
+ descriptionDefaultRegular = descriptionDefaultRegular,
270
+ descriptionDefaultRegularStrikethrough = descriptionDefaultRegularStrikethrough,
271
+ descriptionXsRegular = descriptionXsRegular,
272
+ descriptionXsRegularStrikethrough = descriptionXsRegularStrikethrough,
273
+ labelDefaultMedium = labelDefaultMedium,
274
+ labelSMedium = labelSMedium,
275
+ labelXsMedium = labelXsMedium,
276
+ actionDefaultBold = actionDefaultBold,
277
+ actionSBold = actionSBold,
278
+ actionXsBold = actionXsBold,
279
+ actionXxsBold = actionXxsBold
280
+ )
281
+ }
282
+
283
+ 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
+ }