@momo-kits/native-kits 0.168.1-beta.4-debug → 0.168.1-beta.40-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 +15 -10
- package/README.md +2 -10
- package/build.gradle.kts +1 -3
- package/compose/build.gradle.kts +20 -19
- package/compose/build.gradle.kts.backup +19 -18
- package/compose/compose.podspec +1 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +4 -3
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +14 -23
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +21 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +84 -82
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +18 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +187 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +20 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +117 -62
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +22 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -26
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +54 -36
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +18 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +1 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +35 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +321 -149
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +79 -71
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +89 -198
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +30 -44
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +32 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +12 -3
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +3 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +2 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -10
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +60 -10
- package/gradle/libs.versions.toml +4 -11
- package/gradle/wrapper/gradle-wrapper.properties +1 -3
- package/gradle.properties +3 -3
- package/ios/Application/ApplicationEnvironment.swift +7 -6
- package/ios/Application/DesignSystemKits.swift +163 -0
- package/ios/Application/DesignSystemKitsPayload.swift +68 -0
- package/ios/Badge/BadgeRibbon.swift +8 -1
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Input/Input.swift +16 -4
- package/ios/Input/InputPhoneNumber.swift +1 -3
- package/ios/Input/InputSearch.swift +1 -2
- package/ios/Input/InputTextArea.swift +8 -4
- package/ios/InputMoney/InputMoney.swift +6 -7
- package/ios/Layout/ModalLayout.swift +152 -0
- package/ios/Layout/ScreenLayout.swift +77 -18
- package/ios/Navigation/BottomSheet.swift +56 -53
- package/ios/Navigation/BottomTab/BottomTab.swift +46 -52
- package/ios/Navigation/BottomTab/BottomTabBar.swift +281 -115
- package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
- package/ios/Navigation/BottomTab/DuoTabBar.swift +64 -172
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
- package/ios/Navigation/Component/HeaderBackground.swift +22 -1
- package/ios/Navigation/Component/HeaderRight.swift +1 -1
- package/ios/Navigation/Component/SnackBar.swift +4 -0
- package/ios/Navigation/ModalScreen.swift +20 -5
- package/ios/Navigation/StackScreen.swift +6 -8
- package/ios/Popup/PopupDisplay.swift +6 -4
- package/ios/Popup/PopupInput.swift +6 -4
- package/ios/Popup/PopupLayout.swift +17 -11
- package/ios/Popup/PopupNotify.swift +32 -25
- package/ios/Stepper/Stepper.swift +1 -2
- package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
- package/ios/Typography/FontScale.swift +29 -15
- package/ios/Typography/Text.swift +88 -14
- package/ios/Typography/Typography.swift +2 -2
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
- package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +103 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
- package/package.json +1 -1
- package/publish.sh +2 -33
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +0 -37
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +0 -41
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +0 -44
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +0 -62
- package/ios/Typography/FontScaleStore.swift +0 -58
- package/ios/Typography/KitDesignSystem.swift +0 -17
|
@@ -2,8 +2,6 @@ package vn.momo.kits.components
|
|
|
2
2
|
|
|
3
3
|
import androidx.compose.foundation.background
|
|
4
4
|
import androidx.compose.foundation.border
|
|
5
|
-
import androidx.compose.foundation.clickable
|
|
6
|
-
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
7
5
|
import androidx.compose.foundation.rememberScrollState
|
|
8
6
|
import androidx.compose.foundation.verticalScroll
|
|
9
7
|
import androidx.compose.foundation.layout.*
|
|
@@ -22,7 +20,9 @@ import vn.momo.kits.application.LocalLocalize
|
|
|
22
20
|
import vn.momo.kits.const.*
|
|
23
21
|
import vn.momo.kits.modifier.conditional
|
|
24
22
|
import vn.momo.kits.modifier.setAutomationId
|
|
25
|
-
import vn.momo.kits.layout.
|
|
23
|
+
import vn.momo.kits.layout.MODAL_ICON_BUTTON_SIZE
|
|
24
|
+
import vn.momo.kits.layout.ModalIconButton
|
|
25
|
+
import vn.momo.kits.layout.rememberModalLayout
|
|
26
26
|
import kotlin.math.min
|
|
27
27
|
|
|
28
28
|
data class PopupAction(
|
|
@@ -36,21 +36,24 @@ enum class PopupActionDirection {
|
|
|
36
36
|
AUTO
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
//
|
|
40
|
-
|
|
39
|
+
// Card width on foldables (ModalLayout, RN Popup/utils.ts); unbounded on phones, where each popup's padding sets it.
|
|
40
|
+
@Composable
|
|
41
|
+
internal fun popupMaxWidth(): Dp {
|
|
42
|
+
val modal = rememberModalLayout()
|
|
43
|
+
return if (modal.isFoldable) modal.popup.maxWidth else Dp.Unspecified
|
|
44
|
+
}
|
|
41
45
|
|
|
42
|
-
//
|
|
46
|
+
// The placement already keeps foldable popups off the edges, so their own side padding goes.
|
|
43
47
|
@Composable
|
|
44
|
-
internal fun
|
|
45
|
-
if (
|
|
48
|
+
internal fun popupHorizontalPadding(padding: Dp): Dp =
|
|
49
|
+
if (rememberModalLayout().isFoldable) 0.dp else padding
|
|
46
50
|
|
|
47
|
-
//
|
|
51
|
+
// Tallest a popup gets on foldables; null on phones.
|
|
48
52
|
@Composable
|
|
49
|
-
internal fun popupMaxHeight(): Dp?
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
53
|
+
internal fun popupMaxHeight(): Dp? = rememberModalLayout().popup.maxHeight
|
|
54
|
+
|
|
55
|
+
@Composable
|
|
56
|
+
internal fun popupRadius(): Dp = rememberModalLayout().popup.radius
|
|
54
57
|
|
|
55
58
|
private fun heightForLines(
|
|
56
59
|
layout: TextLayoutResult,
|
|
@@ -84,6 +87,7 @@ data class PopupNotifyProps(
|
|
|
84
87
|
val buttonDirection: PopupActionDirection = PopupActionDirection.ROW,
|
|
85
88
|
val onIconClose: () -> Unit,
|
|
86
89
|
val isShowCloseIcon: Boolean = true,
|
|
90
|
+
val highlightText: List<String> = emptyList(),
|
|
87
91
|
)
|
|
88
92
|
|
|
89
93
|
@Composable
|
|
@@ -95,6 +99,7 @@ fun PopupNotify(
|
|
|
95
99
|
|
|
96
100
|
val density = LocalDensity.current
|
|
97
101
|
var scrollHeight: Dp by remember { mutableStateOf(0.dp) }
|
|
102
|
+
val description = rememberHighlightDescription(props.description, props.highlightText)
|
|
98
103
|
|
|
99
104
|
LaunchedEffect(layoutResult.value) {
|
|
100
105
|
if ((layoutResult.value?.lineCount ?: 0) > 3) {
|
|
@@ -120,7 +125,7 @@ fun PopupNotify(
|
|
|
120
125
|
) {
|
|
121
126
|
item {
|
|
122
127
|
Text(
|
|
123
|
-
text =
|
|
128
|
+
text = description,
|
|
124
129
|
onTextLayout = { layoutResult.value = it },
|
|
125
130
|
style = Typography.bodyDefaultRegular
|
|
126
131
|
)
|
|
@@ -131,7 +136,7 @@ fun PopupNotify(
|
|
|
131
136
|
{ modifier ->
|
|
132
137
|
Box(modifier = modifier) {
|
|
133
138
|
Text(
|
|
134
|
-
text =
|
|
139
|
+
text = description,
|
|
135
140
|
onTextLayout = { layoutResult.value = it },
|
|
136
141
|
style = Typography.bodyDefaultRegular
|
|
137
142
|
)
|
|
@@ -143,22 +148,23 @@ fun PopupNotify(
|
|
|
143
148
|
callback?.invoke()
|
|
144
149
|
}
|
|
145
150
|
|
|
146
|
-
val
|
|
147
|
-
val
|
|
151
|
+
val popup = rememberModalLayout().popup
|
|
152
|
+
val maxHeight = popup.maxHeight
|
|
153
|
+
val descriptionScrollState = rememberScrollState()
|
|
154
|
+
val shape = RoundedCornerShape(popup.radius)
|
|
148
155
|
|
|
149
156
|
Box(
|
|
150
|
-
Modifier
|
|
157
|
+
Modifier
|
|
158
|
+
.widthIn(min = popup.minWidth, max = popup.maxWidth)
|
|
159
|
+
.fillMaxWidth()
|
|
160
|
+
.setAutomationId("popup_notify"),
|
|
161
|
+
contentAlignment = Alignment.TopEnd
|
|
151
162
|
) {
|
|
152
163
|
Column(
|
|
153
164
|
modifier = Modifier
|
|
154
|
-
.widthIn(max = popupMaxWidth(horizontalPadding = 12.dp))
|
|
155
165
|
.fillMaxWidth()
|
|
156
|
-
.
|
|
157
|
-
.
|
|
158
|
-
.background(
|
|
159
|
-
AppTheme.current.colors.background.surface,
|
|
160
|
-
RoundedCornerShape(Radius.L)
|
|
161
|
-
)
|
|
166
|
+
.clip(shape)
|
|
167
|
+
.background(AppTheme.current.colors.background.surface, shape)
|
|
162
168
|
.conditional(IsShowBaseLineDebug) {
|
|
163
169
|
border(1.dp, Colors.blue_03)
|
|
164
170
|
}
|
|
@@ -166,37 +172,56 @@ fun PopupNotify(
|
|
|
166
172
|
heightIn(max = maxHeight ?: Dp.Unspecified)
|
|
167
173
|
}
|
|
168
174
|
) {
|
|
169
|
-
|
|
175
|
+
if(props.image.isNotEmpty()) {
|
|
176
|
+
Image(
|
|
177
|
+
source = props.image,
|
|
178
|
+
modifier = Modifier.fillMaxWidth().aspectRatio(1.777f),
|
|
179
|
+
options = Options(alignment = Alignment.Center)
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// with a max height only the description scrolls; image, title and actions stay
|
|
170
184
|
Column(
|
|
171
|
-
|
|
172
|
-
weight(1f, fill = false)
|
|
173
|
-
|
|
185
|
+
modifier = Modifier
|
|
186
|
+
.conditional(maxHeight != null) { weight(1f, fill = false) }
|
|
187
|
+
.padding(Spacing.XL)
|
|
174
188
|
) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
Text(
|
|
190
|
+
style = Typography.headerDefaultBold,
|
|
191
|
+
maxLines = 2,
|
|
192
|
+
text = props.title,
|
|
193
|
+
modifier = Modifier
|
|
194
|
+
.conditional(props.isShowCloseIcon && props.image.isEmpty()) {
|
|
195
|
+
padding(end = MODAL_ICON_BUTTON_SIZE + Spacing.M - Spacing.XL)
|
|
196
|
+
}
|
|
197
|
+
.setAutomationId("title_popup_permission")
|
|
198
|
+
)
|
|
199
|
+
if (maxHeight != null) {
|
|
200
|
+
// still capped at ~8.5 lines, then shrinks further when the popup reaches its max height
|
|
201
|
+
Box(
|
|
202
|
+
Modifier
|
|
203
|
+
.padding(top = Spacing.S)
|
|
204
|
+
.weight(1f, fill = false)
|
|
205
|
+
.conditional(isScroll) { heightIn(max = scrollHeight) }
|
|
206
|
+
.verticalScroll(descriptionScrollState)
|
|
207
|
+
) {
|
|
192
208
|
Text(
|
|
193
|
-
text =
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
maxLines = 1,
|
|
197
|
-
modifier = Modifier.padding(top = Spacing.S)
|
|
209
|
+
text = props.description,
|
|
210
|
+
onTextLayout = { layoutResult.value = it },
|
|
211
|
+
style = Typography.bodyDefaultRegular
|
|
198
212
|
)
|
|
199
213
|
}
|
|
214
|
+
} else {
|
|
215
|
+
content(Modifier.padding(top = Spacing.S))
|
|
216
|
+
}
|
|
217
|
+
if (props.error.isNotEmpty()) {
|
|
218
|
+
Text(
|
|
219
|
+
text = LocalLocalize.current.translate("errorCode") + props.error,
|
|
220
|
+
style = Typography.descriptionXsRegular,
|
|
221
|
+
color = AppTheme.current.colors.text.hint,
|
|
222
|
+
maxLines = 1,
|
|
223
|
+
modifier = Modifier.padding(top = Spacing.S)
|
|
224
|
+
)
|
|
200
225
|
}
|
|
201
226
|
}
|
|
202
227
|
|
|
@@ -210,36 +235,13 @@ fun PopupNotify(
|
|
|
210
235
|
}
|
|
211
236
|
}
|
|
212
237
|
|
|
213
|
-
if(props.isShowCloseIcon) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
color = AppTheme.current.colors.text.default,
|
|
221
|
-
shape = RoundedCornerShape(Radius.M)
|
|
222
|
-
)
|
|
223
|
-
.border(
|
|
224
|
-
width = 2.dp,
|
|
225
|
-
color = AppTheme.current.colors.background.surface,
|
|
226
|
-
shape = RoundedCornerShape(Radius.M)
|
|
227
|
-
)
|
|
228
|
-
.clip(RoundedCornerShape(100))
|
|
229
|
-
.clickable(
|
|
230
|
-
interactionSource = remember { MutableInteractionSource() },
|
|
231
|
-
indication = null,
|
|
232
|
-
onClick = { onClose { props.onIconClose() } }
|
|
233
|
-
),
|
|
234
|
-
contentAlignment = Alignment.Center
|
|
235
|
-
) {
|
|
236
|
-
Icon(
|
|
237
|
-
source = "navigation_close",
|
|
238
|
-
color = AppTheme.current.colors.background.surface,
|
|
239
|
-
size = 16.dp,
|
|
240
|
-
modifier = Modifier.setAutomationId("ic_popup_close")
|
|
241
|
-
)
|
|
242
|
-
}
|
|
238
|
+
if (props.isShowCloseIcon) {
|
|
239
|
+
ModalIconButton(
|
|
240
|
+
icon = "navigation_close",
|
|
241
|
+
automationId = "ic_popup_close",
|
|
242
|
+
onClick = { onClose { props.onIconClose() } },
|
|
243
|
+
modifier = Modifier.padding(top = Spacing.M, end = Spacing.M),
|
|
244
|
+
)
|
|
243
245
|
}
|
|
244
246
|
}
|
|
245
247
|
}
|
|
@@ -32,15 +32,15 @@ fun PopupPromotion(
|
|
|
32
32
|
onClose: (() -> Unit) = {},
|
|
33
33
|
) {
|
|
34
34
|
val maxHeight = popupMaxHeight()
|
|
35
|
-
var maxWidth = popupMaxWidth(
|
|
35
|
+
var maxWidth = popupMaxWidth()
|
|
36
36
|
if (maxHeight != null) {
|
|
37
37
|
// fit the portrait image by height when iPhone Duo leaves too little room
|
|
38
|
-
maxWidth = minOf(maxWidth, (maxHeight - CLOSE_ROW_HEIGHT) * ASPECT_RATIO
|
|
38
|
+
maxWidth = minOf(maxWidth, (maxHeight - CLOSE_ROW_HEIGHT) * ASPECT_RATIO)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
Column(Modifier
|
|
42
42
|
.widthIn(max = maxWidth)
|
|
43
|
-
.padding(horizontal = Spacing.M)
|
|
43
|
+
.padding(horizontal = popupHorizontalPadding(Spacing.M))
|
|
44
44
|
.conditional(IsShowBaseLineDebug) {
|
|
45
45
|
border(1.dp, Colors.blue_03)
|
|
46
46
|
}
|
|
@@ -2,6 +2,7 @@ package vn.momo.kits.const
|
|
|
2
2
|
|
|
3
3
|
import androidx.compose.runtime.Composable
|
|
4
4
|
import androidx.compose.ui.text.font.FontFamily
|
|
5
|
+
import androidx.compose.ui.text.font.FontWeight
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Nạp font từ tài nguyên native của app host thay vì đóng gói bản copy riêng trong SDK.
|
|
@@ -13,4 +14,4 @@ import androidx.compose.ui.text.font.FontFamily
|
|
|
13
14
|
* Trả về `null` nếu host không có font đó — caller tự fallback [FontFamily.Default].
|
|
14
15
|
*/
|
|
15
16
|
@Composable
|
|
16
|
-
internal expect fun hostFontFamily(fileName: String): FontFamily?
|
|
17
|
+
internal expect fun hostFontFamily(fileName: String, weight: FontWeight): FontFamily?
|
|
@@ -8,6 +8,7 @@ import androidx.compose.ui.text.font.FontFamily
|
|
|
8
8
|
import androidx.compose.ui.text.font.FontWeight
|
|
9
9
|
import androidx.compose.ui.text.style.TextDecoration
|
|
10
10
|
import androidx.compose.ui.unit.*
|
|
11
|
+
import vn.momo.kits.application.DesignSystemKits
|
|
11
12
|
import vn.momo.kits.application.LocalContext
|
|
12
13
|
import vn.momo.kits.platform.getScreenDimensions
|
|
13
14
|
import kotlin.math.max
|
|
@@ -20,10 +21,9 @@ const val MAX_DEVICE_SCALE = 5
|
|
|
20
21
|
@Composable
|
|
21
22
|
fun scaleSize(size: Float): Float {
|
|
22
23
|
val context = LocalContext.current
|
|
23
|
-
|
|
24
|
-
val useOsScale = context?.useOSScaleRate ?: KitFontScale.useOSScaleRate
|
|
24
|
+
val useOsScale = context?.useOSScaleRate ?: DesignSystemKits.getConfigs().useOSScaleRate
|
|
25
25
|
if (!useOsScale) {
|
|
26
|
-
return size * (context?.userScaleRate ?:
|
|
26
|
+
return size * (context?.userScaleRate ?: DesignSystemKits.getConfigs().userScaleRate)
|
|
27
27
|
}
|
|
28
28
|
val scaleSizeMaxRate: Float = MAX_FONT_SCALE
|
|
29
29
|
// Short side, not width: landscape must not inflate every font.
|
|
@@ -84,12 +84,6 @@ fun scaleSize(textStyle: TextStyle): TextStyle {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
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
87
|
private const val LEGACY_DEFAULT_FONT_FILE = "SFProText-Regular.ttf"
|
|
94
88
|
private const val NEW_DEFAULT_FONT_FILE = "MomoTrustSans-Regular.ttf"
|
|
95
89
|
|
|
@@ -124,17 +118,27 @@ private val hostFontFiles: Map<String, String> = mapOf(
|
|
|
124
118
|
private const val NEW_DEFAULT_FONT_FAMILY = "MomoTrustSans"
|
|
125
119
|
private const val LEGACY_DEFAULT_FONT_FAMILY = "SFProText"
|
|
126
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
|
+
|
|
127
124
|
internal val defaultFontFamily: String
|
|
128
|
-
get() = if (
|
|
125
|
+
get() = if (DesignSystemKits.getConfigs().isWhiteList) NEW_DEFAULT_FONT_FAMILY else LEGACY_DEFAULT_FONT_FAMILY
|
|
129
126
|
|
|
130
127
|
@Composable
|
|
131
128
|
fun getFontFamily(fontFamily: String, fontWeight: FontWeight? = FontWeight.Normal): FontFamily {
|
|
132
|
-
val isWhiteList =
|
|
129
|
+
val isWhiteList = DesignSystemKits.getConfigs().isWhiteList
|
|
133
130
|
val defaultFile = if (isWhiteList) NEW_DEFAULT_FONT_FILE else LEGACY_DEFAULT_FONT_FILE
|
|
134
131
|
val key = "$fontFamily-${fontWeight?.weight}"
|
|
135
|
-
val
|
|
136
|
-
|
|
137
|
-
|
|
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)
|
|
138
142
|
?: FontFamily.Default
|
|
139
143
|
}
|
|
140
144
|
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
package vn.momo.kits.layout
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.background
|
|
4
|
+
import androidx.compose.foundation.border
|
|
5
|
+
import androidx.compose.foundation.layout.Box
|
|
6
|
+
import androidx.compose.foundation.layout.size
|
|
7
|
+
import androidx.compose.foundation.shape.CircleShape
|
|
8
|
+
import androidx.compose.runtime.Composable
|
|
9
|
+
import androidx.compose.runtime.Immutable
|
|
10
|
+
import androidx.compose.runtime.remember
|
|
11
|
+
import androidx.compose.ui.Alignment
|
|
12
|
+
import androidx.compose.ui.Modifier
|
|
13
|
+
import androidx.compose.ui.draw.clip
|
|
14
|
+
import androidx.compose.ui.unit.Dp
|
|
15
|
+
import androidx.compose.ui.unit.DpRect
|
|
16
|
+
import androidx.compose.ui.unit.dp
|
|
17
|
+
import androidx.compose.ui.unit.height
|
|
18
|
+
import androidx.compose.ui.unit.width
|
|
19
|
+
import vn.momo.kits.components.Icon
|
|
20
|
+
import vn.momo.kits.const.AppTheme
|
|
21
|
+
import vn.momo.kits.const.Radius
|
|
22
|
+
import vn.momo.kits.const.Spacing
|
|
23
|
+
import vn.momo.kits.modifier.noFeedbackClickable
|
|
24
|
+
import vn.momo.kits.modifier.setAutomationId
|
|
25
|
+
|
|
26
|
+
// Foldable spec for Popup and BottomSheet (Figma "Modal - Foldable Guideline"); mirrors RN and SwiftUI, keep in sync.
|
|
27
|
+
// Public so host apps can size their own (non-kits) popups and sheets the same way.
|
|
28
|
+
val POPUP_MAX_WIDTH = 450.dp
|
|
29
|
+
val POPUP_MIN_WIDTH = 280.dp
|
|
30
|
+
val POPUP_MAX_HEIGHT = 600.dp
|
|
31
|
+
val SHEET_MAX_WIDTH = 653.dp
|
|
32
|
+
val SHEET_MIN_WIDTH = 296.dp
|
|
33
|
+
val SHEET_MIN_HEIGHT = 230.dp
|
|
34
|
+
val FOLDABLE_MIN_WIDTH = 600.dp
|
|
35
|
+
internal val MODAL_ICON_BUTTON_SIZE = 32.dp
|
|
36
|
+
private val CLOSE_ICON_SIZE = 20.dp
|
|
37
|
+
private const val PHONE_SCRIM_OPACITY = 0.6f
|
|
38
|
+
private const val FOLDABLE_SCRIM_OPACITY = 0.2f
|
|
39
|
+
|
|
40
|
+
@Immutable
|
|
41
|
+
data class PopupGeometry(
|
|
42
|
+
val minWidth: Dp,
|
|
43
|
+
val maxWidth: Dp,
|
|
44
|
+
// null: as tall as the content, phones keep their own caps
|
|
45
|
+
val maxHeight: Dp?,
|
|
46
|
+
val margin: Dp,
|
|
47
|
+
val radius: Dp,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
@Immutable
|
|
51
|
+
data class SheetGeometry(
|
|
52
|
+
// null: spans the window
|
|
53
|
+
val width: Dp?,
|
|
54
|
+
// null: phones keep their own cap
|
|
55
|
+
val maxHeight: Dp?,
|
|
56
|
+
val minHeight: Dp,
|
|
57
|
+
val margin: Dp,
|
|
58
|
+
val radius: Dp,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
/** Popup / bottom sheet geometry for the current window; see [modalLayoutOf]. */
|
|
62
|
+
@Immutable
|
|
63
|
+
data class ModalLayout(
|
|
64
|
+
val isFoldable: Boolean,
|
|
65
|
+
// window coordinates of the area popups center in and sheets rest on the bottom of
|
|
66
|
+
val placement: DpRect,
|
|
67
|
+
val popup: PopupGeometry,
|
|
68
|
+
val sheet: SheetGeometry,
|
|
69
|
+
val scrimOpacity: Float,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
// Foldable = iPhone Duo or a window whose short side is at least FOLDABLE_MIN_WIDTH (RN parity),
|
|
73
|
+
// so phones in landscape keep their look.
|
|
74
|
+
@Composable
|
|
75
|
+
internal fun rememberModalLayout(): ModalLayout {
|
|
76
|
+
val layout = getScreenLayout()
|
|
77
|
+
return remember(layout) { modalLayoutOf(layout) }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
internal fun modalLayoutOf(layout: ScreenLayout): ModalLayout = modalLayoutOf(
|
|
81
|
+
width = layout.width,
|
|
82
|
+
height = layout.height,
|
|
83
|
+
insetLeft = layout.insetLeft,
|
|
84
|
+
insetTop = layout.insetTop,
|
|
85
|
+
insetRight = layout.insetRight,
|
|
86
|
+
insetBottom = layout.insetBottom,
|
|
87
|
+
isIPhoneDuoDevice = layout.isIPhoneDuoDevice,
|
|
88
|
+
hinge = layout.hinge,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Resolves popup / bottom sheet geometry from plain window metrics, for hosts without a kits screen.
|
|
93
|
+
*
|
|
94
|
+
* All values are in dp and window coordinates. The insets are the raw safe area (system bars and
|
|
95
|
+
* display cutout); on iPhone Duo they also carry the control column. [hinge] is the vertical hinge of
|
|
96
|
+
* a half-folded iPhone Duo, null while flat. Pure: no composition needed.
|
|
97
|
+
*/
|
|
98
|
+
fun modalLayoutOf(
|
|
99
|
+
width: Dp,
|
|
100
|
+
height: Dp,
|
|
101
|
+
insetLeft: Dp = 0.dp,
|
|
102
|
+
insetTop: Dp = 0.dp,
|
|
103
|
+
insetRight: Dp = 0.dp,
|
|
104
|
+
insetBottom: Dp = 0.dp,
|
|
105
|
+
isIPhoneDuoDevice: Boolean = false,
|
|
106
|
+
hinge: DpRect? = null,
|
|
107
|
+
): ModalLayout {
|
|
108
|
+
val isFoldable = isIPhoneDuoDevice || minOf(width, height) >= FOLDABLE_MIN_WIDTH
|
|
109
|
+
if (!isFoldable) {
|
|
110
|
+
val placement = DpRect(0.dp, 0.dp, width, height)
|
|
111
|
+
return ModalLayout(
|
|
112
|
+
isFoldable = false,
|
|
113
|
+
placement = placement,
|
|
114
|
+
popup = popupGeometry(placement.width, null, Spacing.XL, Radius.L),
|
|
115
|
+
sheet = SheetGeometry(width = null, maxHeight = null, minHeight = 0.dp, margin = 0.dp, radius = Radius.M),
|
|
116
|
+
scrimOpacity = PHONE_SCRIM_OPACITY,
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// the safe area keeps overlays clear of the iPhone Duo control column; half folded they move to the right half
|
|
121
|
+
val hinge = hinge?.takeIf { isIPhoneDuoDevice && it.left > 0.dp && it.right < width }
|
|
122
|
+
val placement = DpRect(
|
|
123
|
+
left = maxOf(insetLeft, hinge?.right ?: 0.dp),
|
|
124
|
+
top = insetTop,
|
|
125
|
+
right = width - insetRight,
|
|
126
|
+
bottom = height - insetBottom,
|
|
127
|
+
)
|
|
128
|
+
// outer display and half fold leave little room, so the margins tighten
|
|
129
|
+
val isCompact = isIPhoneDuoDevice && (hinge != null || minOf(width, height) < FOLDABLE_MIN_WIDTH)
|
|
130
|
+
val popupMargin = if (isCompact) Spacing.M else Spacing.XL
|
|
131
|
+
val sheetMargin = Spacing.M
|
|
132
|
+
val sheetMaxHeight = height - insetTop - sheetMargin
|
|
133
|
+
val sheetMinWidth = minOf(SHEET_MIN_WIDTH, placement.width)
|
|
134
|
+
return ModalLayout(
|
|
135
|
+
isFoldable = true,
|
|
136
|
+
placement = placement,
|
|
137
|
+
popup = popupGeometry(
|
|
138
|
+
placementWidth = placement.width,
|
|
139
|
+
maxHeight = minOf(POPUP_MAX_HEIGHT, placement.height - Spacing.XL * 2),
|
|
140
|
+
margin = popupMargin,
|
|
141
|
+
radius = Radius.XL,
|
|
142
|
+
),
|
|
143
|
+
sheet = SheetGeometry(
|
|
144
|
+
width = minOf(placement.width - sheetMargin * 2, SHEET_MAX_WIDTH).coerceAtLeast(sheetMinWidth),
|
|
145
|
+
maxHeight = sheetMaxHeight,
|
|
146
|
+
minHeight = minOf(SHEET_MIN_HEIGHT, sheetMaxHeight),
|
|
147
|
+
margin = sheetMargin,
|
|
148
|
+
radius = Radius.XL,
|
|
149
|
+
),
|
|
150
|
+
scrimOpacity = FOLDABLE_SCRIM_OPACITY,
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// clamp(placement - 2 margin, 280, 450); the 280 floor gives way to a narrower placement
|
|
155
|
+
private fun popupGeometry(placementWidth: Dp, maxHeight: Dp?, margin: Dp, radius: Dp): PopupGeometry {
|
|
156
|
+
val minWidth = minOf(POPUP_MIN_WIDTH, placementWidth)
|
|
157
|
+
return PopupGeometry(
|
|
158
|
+
minWidth = minWidth,
|
|
159
|
+
maxWidth = (placementWidth - margin * 2).coerceIn(minWidth, POPUP_MAX_WIDTH.coerceAtLeast(minWidth)),
|
|
160
|
+
maxHeight = maxHeight,
|
|
161
|
+
margin = margin,
|
|
162
|
+
radius = radius,
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Popup close and sheet header back / close: 32 circle on the surface with a border, 20 icon.
|
|
167
|
+
@Composable
|
|
168
|
+
fun ModalIconButton(
|
|
169
|
+
icon: String,
|
|
170
|
+
automationId: String,
|
|
171
|
+
onClick: () -> Unit,
|
|
172
|
+
modifier: Modifier = Modifier,
|
|
173
|
+
) {
|
|
174
|
+
val colors = AppTheme.current.colors
|
|
175
|
+
Box(
|
|
176
|
+
modifier
|
|
177
|
+
.size(MODAL_ICON_BUTTON_SIZE)
|
|
178
|
+
.clip(CircleShape)
|
|
179
|
+
.background(colors.background.surface)
|
|
180
|
+
.border(1.dp, colors.border.default, CircleShape)
|
|
181
|
+
.noFeedbackClickable(onClick = onClick)
|
|
182
|
+
.setAutomationId(automationId),
|
|
183
|
+
contentAlignment = Alignment.Center,
|
|
184
|
+
) {
|
|
185
|
+
Icon(source = icon, size = CLOSE_ICON_SIZE, color = colors.text.default)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -10,11 +10,11 @@ import androidx.compose.ui.platform.LocalDensity
|
|
|
10
10
|
import androidx.compose.ui.platform.LocalLayoutDirection
|
|
11
11
|
import androidx.compose.ui.platform.LocalWindowInfo
|
|
12
12
|
import androidx.compose.ui.unit.Dp
|
|
13
|
+
import androidx.compose.ui.unit.DpRect
|
|
13
14
|
import androidx.compose.ui.unit.dp
|
|
14
15
|
import vn.momo.kits.const.Spacing
|
|
15
16
|
import vn.momo.kits.navigation.component.HEADER_HEIGHT
|
|
16
17
|
import vn.momo.kits.platform.ReservedRegion
|
|
17
|
-
import vn.momo.kits.platform.getScreenDimensions
|
|
18
18
|
import vn.momo.kits.platform.isPhoneIdiom
|
|
19
19
|
import vn.momo.kits.platform.rememberReservedRegions
|
|
20
20
|
import vn.momo.kits.utils.getAppStatusBarHeight
|
|
@@ -52,13 +52,16 @@ data class ScreenLayout(
|
|
|
52
52
|
val headerStatusBarHeight: Dp,
|
|
53
53
|
// iPhone Duo moves back and toolkit into a column in the side safe area; null while they stay in the bar.
|
|
54
54
|
val sideBar: SideBarLayout? = null,
|
|
55
|
-
//
|
|
55
|
+
// iPhone Duo folded or not, whatever the window size (its hinge, or the outer display's one-sided strip);
|
|
56
|
+
// drives popups, modal and bottom sheet.
|
|
56
57
|
val isIPhoneDuoDevice: Boolean = isIPhoneDuo,
|
|
57
58
|
// Portrait iPhone Duo puts the status bar in the side strip, about twice as tall as the strip is wide.
|
|
58
59
|
// Stored so it survives consumeHorizontalInsets().
|
|
59
60
|
val duoTopInset: Dp = insetTop,
|
|
60
61
|
// iPhone Duo inner display in portrait: the header row shares the status bar band, between its clusters.
|
|
61
62
|
val statusBarClearance: StatusBarClearance? = null,
|
|
63
|
+
// Half-folded iPhone Duo: the hinge in window coordinates, running top to bottom; null while flat.
|
|
64
|
+
val hinge: DpRect? = null,
|
|
62
65
|
) {
|
|
63
66
|
val headerBarHeight: Dp get() = headerHeight - headerStatusBarHeight
|
|
64
67
|
}
|
|
@@ -86,11 +89,13 @@ internal object DuoMetrics {
|
|
|
86
89
|
// (x 550–643 of 669, clock digits centered on y 47); its reserved region is taller than the glyphs.
|
|
87
90
|
val innerStatusBarCenterY = 47.dp
|
|
88
91
|
val innerStatusBarWidth = 120.dp
|
|
92
|
+
// Host app's iOS 26 tab bar on the inner display in portrait: a 62pt glass pill sized to its tabs,
|
|
93
|
+
// QR as a 62pt platter beside it, ≥ 20pt from the sides, 13pt into the home indicator inset.
|
|
94
|
+
val floatingTabBarHeight = 62.dp
|
|
95
|
+
val floatingTabBarMargin = 20.dp
|
|
96
|
+
val floatingTabBarInsetOverlap = 13.dp
|
|
89
97
|
}
|
|
90
98
|
|
|
91
|
-
// Widest short side of any single-display iPhone.
|
|
92
|
-
private val IPHONE_MAX_SHORT_SIDE = 440.dp
|
|
93
|
-
|
|
94
99
|
private val IPHONE_HEADER_MIN_HEIGHT = 72.dp
|
|
95
100
|
|
|
96
101
|
// A smaller top inset means the status bar is not on the top edge.
|
|
@@ -129,10 +134,9 @@ internal fun calculateScreenLayout(topInset: Dp, parent: ScreenLayout? = null):
|
|
|
129
134
|
val leftPx = insets.getLeft(density, layoutDirection)
|
|
130
135
|
val rightPx = insets.getRight(density, layoutDirection)
|
|
131
136
|
val bottomPx = WindowInsets.systemBars.getBottom(density)
|
|
132
|
-
val screen = getScreenDimensions()
|
|
133
137
|
val reservedRegions = rememberReservedRegions()
|
|
134
138
|
|
|
135
|
-
return remember(size, leftPx, rightPx, bottomPx, topInset,
|
|
139
|
+
return remember(size, leftPx, rightPx, bottomPx, topInset, density, reservedRegions) {
|
|
136
140
|
with(density) {
|
|
137
141
|
val width = size.width.toDp()
|
|
138
142
|
val height = size.height.toDp()
|
|
@@ -145,11 +149,9 @@ internal fun calculateScreenLayout(topInset: Dp, parent: ScreenLayout? = null):
|
|
|
145
149
|
bottomInset = bottomPx.toDp(),
|
|
146
150
|
isPhone = isPhone,
|
|
147
151
|
asymmetricInsets = leftPx != rightPx,
|
|
148
|
-
isDuoDevice = isPhone &&
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
) > IPHONE_MAX_SHORT_SIDE,
|
|
152
|
-
reservedRegions = reservedRegions,
|
|
152
|
+
isDuoDevice = isPhone && reservedRegions.isFoldable,
|
|
153
|
+
reservedRegions = reservedRegions.occlusion,
|
|
154
|
+
division = reservedRegions.division,
|
|
153
155
|
)
|
|
154
156
|
}
|
|
155
157
|
}
|
|
@@ -245,6 +247,7 @@ private fun screenLayoutOf(
|
|
|
245
247
|
asymmetricInsets: Boolean,
|
|
246
248
|
isDuoDevice: Boolean,
|
|
247
249
|
reservedRegions: List<ReservedRegion>,
|
|
250
|
+
division: ReservedRegion?,
|
|
248
251
|
): ScreenLayout {
|
|
249
252
|
val isIPhoneDuo = isPhone && isIPhoneDuoWindow(width, height, asymmetricInsets)
|
|
250
253
|
val isInnerPortrait = height > width && width >= DuoMetrics.innerMinHeight
|
|
@@ -302,8 +305,12 @@ private fun screenLayoutOf(
|
|
|
302
305
|
headerHeight = headerHeight,
|
|
303
306
|
headerStatusBarHeight = headerStatusBarHeight,
|
|
304
307
|
sideBar = sideBar,
|
|
305
|
-
|
|
308
|
+
// the outer display reports no hinge; its one-sided strip still gives it away
|
|
309
|
+
isIPhoneDuoDevice = isDuoDevice || (isPhone && asymmetricInsets),
|
|
306
310
|
duoTopInset = maxOf(topInset, if (height > width) sideInset * 2 else 0.dp),
|
|
307
311
|
statusBarClearance = statusBarClearance,
|
|
312
|
+
// only a hinge splitting the window into left and right halves moves overlays
|
|
313
|
+
hinge = division?.takeIf { isPhone && it.height > it.width }
|
|
314
|
+
?.let { DpRect(it.x, it.y, it.x + it.width, it.y + it.height) },
|
|
308
315
|
)
|
|
309
316
|
}
|