@momo-kits/native-kits 0.169.15-beta.2-debug → 0.169.15-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/package.json +1 -1
  2. package/build.gradle.kts +0 -11
  3. package/compose/build.gradle.kts +0 -198
  4. package/compose/compose.podspec +0 -47
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -61
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1067
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -268
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -354
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -130
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -482
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -224
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -137
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -473
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -113
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -262
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -237
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -228
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -280
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -183
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -342
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -40
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -82
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -39
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -362
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -304
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -88
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -308
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -218
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -456
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -205
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -89
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -542
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -175
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -201
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -208
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -12
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -291
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -71
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -184
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -315
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -54
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -397
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -118
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -206
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -421
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -758
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -152
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -260
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -406
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -111
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -93
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -208
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/LegacyBottomTabBar.kt +0 -262
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/LegacyCurvedContainer.kt +0 -86
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -133
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -167
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -446
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -400
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -197
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -114
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -7
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -21
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -117
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -65
  132. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -143
  135. package/gradle/libs.versions.toml +0 -67
  136. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  137. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  138. package/gradle.properties +0 -24
  139. package/gradlew +0 -252
  140. package/gradlew.bat +0 -94
  141. package/ios-demo/README.md +0 -120
  142. package/settings.gradle.kts +0 -64
@@ -1,194 +0,0 @@
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 }
@@ -1,291 +0,0 @@
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
- // Opt-in ceiling: a set scaleSizeMaxRate caps both the userScaleRate and the OS path at size × capRate.
25
- val capRate = context?.scaleSizeMaxRate
26
- fun cap(scaled: Float): Float = if (capRate != null) min(scaled, size * capRate) else scaled
27
- val useOsScale = context?.useOSScaleRate ?: DesignSystemKits.getConfigs().useOSScaleRate
28
- if (!useOsScale) {
29
- return cap(size * (context?.userScaleRate ?: DesignSystemKits.getConfigs().userScaleRate))
30
- }
31
- val scaleSizeMaxRate: Float = capRate ?: MAX_FONT_SCALE
32
- // Short side, not width: landscape must not inflate every font.
33
- val deviceWidth = getScreenDimensions().let { minOf(it.width, it.height) }
34
- val deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE
35
-
36
- val density = LocalDensity.current
37
- val fontScale = density.fontScale
38
-
39
- var fontSizeScaleDevice = size
40
- var fontSizeScaleOS = size
41
-
42
- if (deviceScale > 1) {
43
- fontSizeScaleDevice = min(deviceScale * fontSizeScaleDevice, fontSizeScaleDevice + MAX_DEVICE_SCALE)
44
- }
45
-
46
- if (fontScale > 1) {
47
- fontSizeScaleOS = min(fontScale * fontSizeScaleOS, fontSizeScaleOS * scaleSizeMaxRate)
48
- }
49
-
50
- return cap(
51
- max(
52
- fontSizeScaleDevice,
53
- fontSizeScaleOS
54
- )
55
- )
56
- }
57
-
58
- @Composable
59
- fun scaleSize(size: TextUnit): TextUnit {
60
- if (!size.isSp) return size
61
-
62
- val density = LocalDensity.current
63
-
64
- val scaled = scaleSize(size.value)
65
- val spValue = scaled / density.fontScale
66
-
67
- return TextUnit(value = spValue, type = TextUnitType.Sp)
68
- }
69
-
70
- @Composable
71
- fun scaleSize(size: Dp): Dp {
72
- return scaleSize(size.value).dp
73
- }
74
-
75
- @Composable
76
- fun scaleSize(textStyle: TextStyle): TextStyle {
77
- return textStyle.copy(
78
- fontSize = if (textStyle.fontSize != TextUnit.Unspecified)
79
- scaleSize(textStyle.fontSize)
80
- else
81
- TextUnit.Unspecified,
82
-
83
- lineHeight = if (textStyle.lineHeight != TextUnit.Unspecified)
84
- scaleSize(textStyle.lineHeight)
85
- else
86
- TextUnit.Unspecified,
87
- )
88
- }
89
-
90
-
91
- private const val LEGACY_DEFAULT_FONT_FILE = "SFProText-Regular.ttf"
92
- private const val NEW_DEFAULT_FONT_FILE = "MomoTrustSans-Regular.ttf"
93
-
94
- private val hostFontFiles: Map<String, String> = mapOf(
95
- "SFProText-100" to "SFProText-Thin.ttf",
96
- "SFProText-200" to "SFProText-Ultralight.ttf",
97
- "SFProText-300" to "SFProText-Light.ttf",
98
- "SFProText-400" to LEGACY_DEFAULT_FONT_FILE,
99
- "SFProText-500" to "SFProText-Medium.ttf",
100
- "SFProText-600" to "SFProText-Semibold.ttf",
101
- "SFProText-700" to "SFProText-Bold.ttf",
102
- "SFProText-800" to "SFProText-Heavy.ttf",
103
- "SFProText-900" to "SFProText-Black.ttf",
104
-
105
- "MomoTrustSans-100" to "MomoTrustSans-ExtraLight.ttf",
106
- "MomoTrustSans-200" to "MomoTrustSans-ExtraLight.ttf",
107
- "MomoTrustSans-300" to "MomoTrustSans-Light.ttf",
108
- "MomoTrustSans-400" to "MomoTrustSans-Regular.ttf",
109
- "MomoTrustSans-500" to "MomoTrustSans-Medium.ttf",
110
- "MomoTrustSans-600" to "MomoTrustSans-SemiBold.ttf",
111
- "MomoTrustSans-700" to "MomoTrustSans-Bold.ttf",
112
- "MomoTrustSans-800" to "MomoTrustSans-ExtraBold.ttf",
113
- "MomoTrustSans-900" to "MomoTrustSans-ExtraBold.ttf",
114
- ) + (1..9).flatMap { step ->
115
- val weight = step * 100
116
- listOf(
117
- "MoMoSignature-$weight" to "MoMoSignature.otf",
118
- "MoMoTrustDisplay-$weight" to "MoMoTrustDisplay.otf",
119
- )
120
- }
121
-
122
- private const val NEW_DEFAULT_FONT_FAMILY = "MomoTrustSans"
123
- private const val LEGACY_DEFAULT_FONT_FAMILY = "SFProText"
124
-
125
- // Families that ship one file per weight; the others map every weight to a single file.
126
- private val weightedFontFamilies = setOf(NEW_DEFAULT_FONT_FAMILY, LEGACY_DEFAULT_FONT_FAMILY)
127
-
128
- internal val defaultFontFamily: String
129
- get() = if (DesignSystemKits.getConfigs().isWhiteList) NEW_DEFAULT_FONT_FAMILY else LEGACY_DEFAULT_FONT_FAMILY
130
-
131
- @Composable
132
- fun getFontFamily(fontFamily: String, fontWeight: FontWeight? = FontWeight.Normal): FontFamily {
133
- val isWhiteList = DesignSystemKits.getConfigs().isWhiteList
134
- val defaultFile = if (isWhiteList) NEW_DEFAULT_FONT_FILE else LEGACY_DEFAULT_FONT_FILE
135
- val key = "$fontFamily-${fontWeight?.weight}"
136
- val mappedFile = hostFontFiles[key]
137
- val fileName = mappedFile ?: defaultFile
138
- // Declaring the file's real weight keeps Compose from synthesizing bold on top of a bold file.
139
- val fileWeight = if (mappedFile != null && fontFamily in weightedFontFamilies) {
140
- fontWeight ?: FontWeight.Normal
141
- } else {
142
- FontWeight.Normal
143
- }
144
- return hostFontFamily(fileName, fileWeight)
145
- ?: hostFontFamily(defaultFile, FontWeight.Normal)
146
- ?: FontFamily.Default
147
- }
148
-
149
- @Immutable
150
- class AppTypography internal constructor(
151
- val headlineDefaultBold: TextStyle,
152
- val headerMBold: TextStyle,
153
- val headerDefaultBold: TextStyle,
154
- val headerSSemibold: TextStyle,
155
- val headerXsSemibold: TextStyle,
156
- val bodyDefaultRegular: TextStyle,
157
- val bodyDefaultRegularStrikethrough: TextStyle,
158
- val descriptionDefaultRegular: TextStyle,
159
- val descriptionDefaultRegularStrikethrough: TextStyle,
160
- val descriptionXsRegular: TextStyle,
161
- val descriptionXsRegularStrikethrough: TextStyle,
162
- val labelDefaultMedium: TextStyle,
163
- val labelSMedium: TextStyle,
164
- val labelXsMedium: TextStyle,
165
- val actionDefaultBold: TextStyle,
166
- val actionSBold: TextStyle,
167
- val actionXsBold: TextStyle,
168
- val actionXxsBold: TextStyle,
169
- ) {
170
- constructor(
171
- default: TextStyle = TextStyle(
172
- fontSize = 14.sp,
173
- lineHeight = 20.sp,
174
- fontWeight = FontWeight.Normal
175
- ),
176
- headlineDefaultBold: TextStyle = TextStyle(
177
- fontSize = 24.sp,
178
- lineHeight = 34.sp,
179
- fontWeight = FontWeight.Bold
180
- ),
181
- headerMBold: TextStyle = TextStyle(
182
- fontSize = 18.sp,
183
- lineHeight = 26.sp,
184
- fontWeight = FontWeight.Bold
185
- ),
186
- headerDefaultBold: TextStyle = TextStyle(
187
- fontSize = 16.sp,
188
- lineHeight = 22.sp,
189
- fontWeight = FontWeight.Bold
190
- ),
191
- headerSSemibold: TextStyle = TextStyle(
192
- fontSize = 14.sp,
193
- lineHeight = 20.sp,
194
- fontWeight = FontWeight.SemiBold
195
- ),
196
- headerXsSemibold: TextStyle = TextStyle(
197
- fontSize = 12.sp,
198
- lineHeight = 18.sp,
199
- fontWeight = FontWeight.SemiBold
200
- ),
201
- bodyDefaultRegular: TextStyle = TextStyle(
202
- fontSize = 14.sp,
203
- lineHeight = 20.sp,
204
- fontWeight = FontWeight.Normal
205
- ),
206
- bodyDefaultRegularStrikethrough: TextStyle = TextStyle(
207
- fontSize = 14.sp,
208
- lineHeight = 20.sp,
209
- fontWeight = FontWeight.Normal,
210
- textDecoration = TextDecoration.LineThrough
211
- ),
212
- descriptionDefaultRegular: TextStyle = TextStyle(
213
- fontSize = 12.sp,
214
- lineHeight = 18.sp,
215
- fontWeight = FontWeight.Normal
216
- ),
217
- descriptionDefaultRegularStrikethrough: TextStyle = TextStyle(
218
- fontSize = 12.sp,
219
- lineHeight = 18.sp,
220
- fontWeight = FontWeight.Normal,
221
- textDecoration = TextDecoration.LineThrough
222
- ),
223
- descriptionXsRegular: TextStyle = TextStyle(
224
- fontSize = 10.sp,
225
- lineHeight = 14.sp,
226
- fontWeight = FontWeight.Normal
227
- ),
228
- descriptionXsRegularStrikethrough: TextStyle = TextStyle(
229
- fontSize = 10.sp,
230
- lineHeight = 14.sp,
231
- fontWeight = FontWeight.Normal,
232
- textDecoration = TextDecoration.LineThrough
233
- ),
234
- labelDefaultMedium: TextStyle = TextStyle(
235
- fontSize = 14.sp,
236
- lineHeight = 20.sp,
237
- fontWeight = FontWeight.Medium
238
- ),
239
- labelSMedium: TextStyle = TextStyle(
240
- fontSize = 12.sp,
241
- lineHeight = 18.sp,
242
- fontWeight = FontWeight.Medium
243
- ),
244
- labelXsMedium: TextStyle = TextStyle(
245
- fontSize = 10.sp,
246
- lineHeight = 14.sp,
247
- fontWeight = FontWeight.Medium
248
- ),
249
- actionDefaultBold: TextStyle = TextStyle(
250
- fontSize = 16.sp,
251
- lineHeight = 22.sp,
252
- fontWeight = FontWeight.Bold
253
- ),
254
- actionSBold: TextStyle = TextStyle(
255
- fontSize = 14.sp,
256
- lineHeight = 20.sp,
257
- fontWeight = FontWeight.Bold
258
- ),
259
- actionXsBold: TextStyle = TextStyle(
260
- fontSize = 12.sp,
261
- lineHeight = 18.sp,
262
- fontWeight = FontWeight.Bold
263
- ),
264
- actionXxsBold: TextStyle = TextStyle(
265
- fontSize = 10.sp,
266
- lineHeight = 14.sp,
267
- fontWeight = FontWeight.Bold
268
- ),
269
- ) : this(
270
- headlineDefaultBold = headlineDefaultBold,
271
- headerMBold = headerMBold,
272
- headerDefaultBold = headerDefaultBold,
273
- headerSSemibold = headerSSemibold,
274
- headerXsSemibold = headerXsSemibold,
275
- bodyDefaultRegular = bodyDefaultRegular,
276
- bodyDefaultRegularStrikethrough = bodyDefaultRegularStrikethrough,
277
- descriptionDefaultRegular = descriptionDefaultRegular,
278
- descriptionDefaultRegularStrikethrough = descriptionDefaultRegularStrikethrough,
279
- descriptionXsRegular = descriptionXsRegular,
280
- descriptionXsRegularStrikethrough = descriptionXsRegularStrikethrough,
281
- labelDefaultMedium = labelDefaultMedium,
282
- labelSMedium = labelSMedium,
283
- labelXsMedium = labelXsMedium,
284
- actionDefaultBold = actionDefaultBold,
285
- actionSBold = actionSBold,
286
- actionXsBold = actionXsBold,
287
- actionXxsBold = actionXxsBold
288
- )
289
- }
290
-
291
- val Typography = AppTypography()
@@ -1,54 +0,0 @@
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
- }
@@ -1,71 +0,0 @@
1
- package vn.momo.kits.layout
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.runtime.Immutable
5
- import androidx.compose.runtime.remember
6
- import androidx.compose.ui.unit.Dp
7
- import androidx.compose.ui.unit.dp
8
- import vn.momo.kits.const.DEFAULT_SCREEN_SIZE
9
- import vn.momo.kits.const.Spacing
10
-
11
- // Top navigation spec (Figma "Top Navigation · Màn hình gập"); mirrors RN and SwiftUI, keep in sync.
12
- val HEADER_BUTTON_SIZE = 32.dp
13
- val HEADER_ICON_SIZE = 20.dp
14
- val HEADER_PILL_WIDTH = 72.dp
15
- val HEADER_SEARCH_HEIGHT = 32.dp
16
- val HEADER_FRAME_MAX_WIDTH = 600.dp
17
- // Stretch frame on hold until design confirms it: Stretch lays out like Grid.
18
- private const val IS_STRETCH_FRAME_ENABLED = false
19
- // Banner image width on every device: wide windows keep the phone size, centered.
20
- val HEADER_BANNER_WIDTH = DEFAULT_SCREEN_SIZE.dp
21
- internal val HEADER_TITLE_GAP = Spacing.S
22
- internal val HEADER_SIDE_PADDING = Spacing.M
23
- // shortcut + gap + help/home pill
24
- val HEADER_CLUSTER_WIDTH = HEADER_BUTTON_SIZE + HEADER_TITLE_GAP + HEADER_PILL_WIDTH
25
-
26
- /** How a screen lays out its content on wide windows; the header row follows it. */
27
- enum class ContentLayout {
28
- // 12 column grid: the header keeps the 12pt side padding.
29
- Grid,
30
- // One column of at most HEADER_FRAME_MAX_WIDTH, centered: the header row sits in the same frame.
31
- // On hold: same as Grid for now.
32
- Stretch,
33
- }
34
-
35
- /** Header geometry for the current window; see [headerLayoutOf]. */
36
- @Immutable
37
- data class HeaderLayout(
38
- // short side >= FOLDABLE_MIN_WIDTH, iPhone Duo excluded (it has its own layout)
39
- val isWide: Boolean,
40
- // banner kept at HEADER_BANNER_WIDTH, centered: wide windows plus the iPhone Duo inner display
41
- val isBannerCentered: Boolean,
42
- // padding from each side of the safe area to the header row (back, title / search, right cluster)
43
- val frameInset: Dp,
44
- // width of the header row, so tabs and other header extensions can line up with it
45
- val frameWidth: Dp,
46
- )
47
-
48
- // Pass the screen's NavigationOptions.contentLayout so tabs and extensions line up with its header.
49
- @Composable
50
- fun rememberHeaderLayout(contentLayout: ContentLayout = ContentLayout.Grid): HeaderLayout {
51
- val layout = getScreenLayout()
52
- return remember(layout, contentLayout) { headerLayoutOf(layout, contentLayout) }
53
- }
54
-
55
- fun headerLayoutOf(layout: ScreenLayout, contentLayout: ContentLayout): HeaderLayout {
56
- val isDuo = layout.isIPhoneDuo || layout.isIPhoneDuoDevice
57
- val isLargeWindow = minOf(layout.width, layout.height) >= FOLDABLE_MIN_WIDTH
58
- val isWide = !isDuo && isLargeWindow
59
- val isStretch = IS_STRETCH_FRAME_ENABLED && contentLayout == ContentLayout.Stretch
60
- val frameInset = if (isWide && isStretch) {
61
- maxOf(HEADER_SIDE_PADDING, (layout.contentWidth - HEADER_FRAME_MAX_WIDTH) / 2)
62
- } else {
63
- HEADER_SIDE_PADDING
64
- }
65
- return HeaderLayout(
66
- isWide = isWide,
67
- isBannerCentered = isLargeWindow,
68
- frameInset = frameInset,
69
- frameWidth = layout.contentWidth - frameInset * 2,
70
- )
71
- }
@@ -1,50 +0,0 @@
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
- }