@momo-kits/native-kits 0.169.10-beta.1-debug → 0.169.10-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/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +19 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +5 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -59
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +11 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +5 -20
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +5 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +7 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +3 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +18 -20
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +6 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +27 -44
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +13 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +7 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +14 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +39 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +35 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +16 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +3 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +1 -2
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +5 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +1 -2
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +2 -3
- package/gradle.properties +1 -1
- package/ios/Application/DesignSystemKits.swift +2 -3
- package/ios/Application/LanguageSource.swift +2 -3
- package/ios/Application/Localize.swift +4 -7
- package/ios/Application/LocalizeModifier.swift +2 -3
- package/ios/Badge/Badge.swift +5 -7
- package/ios/Button/Button.swift +2 -3
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +3 -5
- package/ios/Carousel/Carousel.swift +2 -3
- package/ios/Collapse/Collapse.swift +17 -11
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
- package/ios/Icon/Icon.swift +2 -3
- package/ios/IconButton/IconButton.swift +2 -3
- package/ios/Input/InputSearch.swift +6 -23
- package/ios/Layout/ModalLayout.swift +2 -3
- package/ios/Layout/ScreenLayout.swift +10 -12
- package/ios/Layout/Section.swift +2 -3
- package/ios/Navigation/BottomSheet.swift +6 -9
- package/ios/Navigation/BottomTab/BottomTab.swift +6 -9
- package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -6
- package/ios/Navigation/BottomTab/CurvedContainer.swift +2 -3
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
- package/ios/Navigation/BottomTab/DuoTabBar.swift +6 -6
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +4 -6
- package/ios/Navigation/Component/Header.swift +46 -31
- package/ios/Navigation/Component/HeaderJourney.swift +1 -2
- package/ios/Navigation/Component/HeaderLocation.swift +1 -2
- package/ios/Navigation/Component/HeaderRight.swift +15 -18
- package/ios/Navigation/Component/HeaderUser.swift +1 -2
- package/ios/Navigation/Component/SideBar.swift +15 -7
- package/ios/Navigation/HostBackGestureBridge.swift +2 -3
- package/ios/Navigation/ModalScreen.swift +13 -11
- package/ios/Navigation/Navigation.swift +3 -9
- package/ios/Navigation/NavigationContainer.swift +4 -6
- package/ios/Navigation/Navigator.swift +12 -18
- package/ios/Navigation/StackScreen.swift +25 -40
- package/ios/Navigation/StackTransition.swift +7 -6
- package/ios/Skeleton/Skeleton.swift +3 -6
- package/ios/Steps/Steps.swift +20 -15
- package/ios/TabView/TabView.swift +2 -3
- package/ios/Title/Title.swift +1 -3
- package/ios/Typography/FontScale.swift +6 -9
- package/ios/Typography/Text.swift +2 -3
- package/ios/Typography/Typography.swift +3 -4
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +2 -11
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -11
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +1 -1
- package/package.json +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -67
- package/ios/Layout/HeaderLayout.swift +0 -67
|
@@ -42,12 +42,8 @@ import vn.momo.kits.const.Colors
|
|
|
42
42
|
import vn.momo.kits.components.PopupNotifyProps
|
|
43
43
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
44
44
|
import vn.momo.kits.const.Spacing
|
|
45
|
-
import vn.momo.kits.layout.
|
|
46
|
-
import vn.momo.kits.layout.HEADER_CLUSTER_WIDTH
|
|
47
|
-
import vn.momo.kits.layout.HEADER_ICON_SIZE
|
|
48
|
-
import vn.momo.kits.layout.HEADER_TITLE_GAP
|
|
45
|
+
import vn.momo.kits.layout.DuoMetrics
|
|
49
46
|
import vn.momo.kits.layout.getScreenLayout
|
|
50
|
-
import vn.momo.kits.layout.rememberHeaderLayout
|
|
51
47
|
import vn.momo.kits.modifier.activeOpacityClickable
|
|
52
48
|
import vn.momo.kits.modifier.conditional
|
|
53
49
|
import vn.momo.kits.modifier.setAutomationId
|
|
@@ -64,8 +60,10 @@ const val HEADER_HEIGHT = 52
|
|
|
64
60
|
internal enum class InputSearchType { None, Header, Animated }
|
|
65
61
|
enum class TitlePosition { LEFT, CENTER }
|
|
66
62
|
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
private val HEADER_ACTIONS_WIDTH = 172.dp
|
|
64
|
+
|
|
65
|
+
// Extra width the 48pt back and toolkit take on the iPhone Duo status bar row.
|
|
66
|
+
private val STATUS_BAR_ROW_ACTIONS_EXTRA = 55.dp
|
|
69
67
|
|
|
70
68
|
@Suppress("FrequentlyChangingValue")
|
|
71
69
|
@Composable
|
|
@@ -93,7 +91,7 @@ internal fun headerTitleMaxWidth(): Dp {
|
|
|
93
91
|
val clearance = layout.statusBarClearance
|
|
94
92
|
val clearanceWidth = clearance?.let { it.left + it.right } ?: 0.dp
|
|
95
93
|
if (layout.sideBar != null) return layout.contentWidth - Spacing.M * 2 - clearanceWidth
|
|
96
|
-
return
|
|
94
|
+
return layout.width - HEADER_ACTIONS_WIDTH - (if (clearance != null) STATUS_BAR_ROW_ACTIONS_EXTRA else 0.dp) - clearanceWidth
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
// Scroll distance over which the Duo glass bar fades in.
|
|
@@ -126,10 +124,10 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
126
124
|
val headerRightWidthPx = LocalHeaderRightWidthPx.current
|
|
127
125
|
val inputSearchType = getInputSearchType(options)
|
|
128
126
|
val layout = getScreenLayout()
|
|
129
|
-
val headerLayout = rememberHeaderLayout(options.contentLayout)
|
|
130
127
|
val useSideBar = layout.sideBar != null
|
|
131
|
-
// iPhone Duo inner portrait: the row sits on the status bar, between its clusters
|
|
128
|
+
// iPhone Duo inner portrait: the row sits on the status bar, between its clusters
|
|
132
129
|
val clearance = layout.statusBarClearance
|
|
130
|
+
val statusBarRow = clearance != null && !useSideBar
|
|
133
131
|
val opacity = headerOpacity()
|
|
134
132
|
|
|
135
133
|
val headerColor = getHeaderColor(options.headerType, opacity, options.tintColor, Colors.black_17)
|
|
@@ -188,22 +186,31 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
188
186
|
.fillMaxWidth()
|
|
189
187
|
.horizontalSafeAreaPadding()
|
|
190
188
|
.padding(
|
|
191
|
-
start =
|
|
192
|
-
end =
|
|
189
|
+
start = Spacing.M + (clearance?.left ?: 0.dp),
|
|
190
|
+
end = Spacing.M + (clearance?.right ?: 0.dp),
|
|
193
191
|
),
|
|
194
192
|
verticalAlignment = Alignment.CenterVertically,
|
|
195
193
|
horizontalArrangement = Arrangement.SpaceBetween
|
|
196
194
|
) {
|
|
197
195
|
if (!options.hiddenBack && !useSideBar) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
navigator.onBackSafe {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
196
|
+
if (statusBarRow) {
|
|
197
|
+
SideBarButton(
|
|
198
|
+
icon = "arrow-back",
|
|
199
|
+
headerColor = headerColor,
|
|
200
|
+
automationId = "btn_navigation_back",
|
|
201
|
+
onClick = { navigator.onBackSafe { } },
|
|
202
|
+
)
|
|
203
|
+
} else {
|
|
204
|
+
BackButton(
|
|
205
|
+
borderColor = headerColor.borderColor,
|
|
206
|
+
backgroundButton = headerColor.backgroundButton,
|
|
207
|
+
tintIconColor = headerColor.tintIconColor,
|
|
208
|
+
onBackHandler = {
|
|
209
|
+
navigator.onBackSafe { }
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
Spacer(Modifier.width(Spacing.S))
|
|
207
214
|
}
|
|
208
215
|
|
|
209
216
|
if (centerTitle) {
|
|
@@ -223,6 +230,12 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
223
230
|
when {
|
|
224
231
|
// on Duo the side bar column holds the header right (toolkit or custom), not this row
|
|
225
232
|
useSideBar -> Unit
|
|
233
|
+
statusBarRow && headerRight is HeaderRight.Toolkit -> Toolkit(
|
|
234
|
+
headerRight = headerRight,
|
|
235
|
+
tintColor = options.tintColor,
|
|
236
|
+
headerColor = headerColor,
|
|
237
|
+
layout = ToolkitLayout.SideBarRow,
|
|
238
|
+
)
|
|
226
239
|
else -> CompositionLocalProvider(LocalHeaderColor provides headerColor) {
|
|
227
240
|
HeaderRight(headerRight, options.tintColor, headerColor)
|
|
228
241
|
}
|
|
@@ -232,7 +245,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
232
245
|
if (centerTitle) {
|
|
233
246
|
// on the status bar row the clusters are lopsided, so both sides keep the wider one's room
|
|
234
247
|
val centerInset = if (clearance != null) {
|
|
235
|
-
val back = if (options.hiddenBack || useSideBar) 0.dp else
|
|
248
|
+
val back = if (options.hiddenBack || useSideBar) 0.dp else DuoMetrics.controlSize + Spacing.S
|
|
236
249
|
val right = with(LocalDensity.current) { headerRightWidthPx.intValue.toDp() }
|
|
237
250
|
maxOf(clearance.left + back, clearance.right + right) + Spacing.S
|
|
238
251
|
} else {
|
|
@@ -242,7 +255,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
242
255
|
modifier = Modifier.height(layout.headerBarHeight)
|
|
243
256
|
.fillMaxWidth()
|
|
244
257
|
.horizontalSafeAreaPadding()
|
|
245
|
-
.padding(horizontal =
|
|
258
|
+
.padding(horizontal = Spacing.M + centerInset),
|
|
246
259
|
contentAlignment = Alignment.Center
|
|
247
260
|
) {
|
|
248
261
|
HeaderContent(
|
|
@@ -262,7 +275,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
262
275
|
private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColor: Color, onBackHandler: () -> Unit){
|
|
263
276
|
Box(
|
|
264
277
|
modifier = Modifier
|
|
265
|
-
.size(
|
|
278
|
+
.size(28.dp)
|
|
266
279
|
.background(backgroundButton, RoundedCornerShape(100))
|
|
267
280
|
.border(width = 0.2.dp, color = borderColor, shape = RoundedCornerShape(100))
|
|
268
281
|
.activeOpacityClickable(onClick = onBackHandler)
|
|
@@ -273,7 +286,7 @@ private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColo
|
|
|
273
286
|
Icon(
|
|
274
287
|
source = "arrow-back",
|
|
275
288
|
color = tintIconColor,
|
|
276
|
-
size =
|
|
289
|
+
size = 20.dp,
|
|
277
290
|
)
|
|
278
291
|
}
|
|
279
292
|
}
|
|
@@ -393,10 +406,7 @@ sealed class HeaderType {
|
|
|
393
406
|
val isSurface: Boolean = true,
|
|
394
407
|
val layoutOffSet: Dp = 56.dp,
|
|
395
408
|
val height: Dp? = null,
|
|
396
|
-
|
|
397
|
-
val bannerBackgroundColor: Color? = null,
|
|
398
|
-
// Last so callers can keep passing it as a trailing lambda.
|
|
399
|
-
val composable: @Composable (scrollState: Int) -> Unit = {},
|
|
409
|
+
val composable: @Composable (scrollState: Int) -> Unit = {}
|
|
400
410
|
) : HeaderType()
|
|
401
411
|
|
|
402
412
|
data class Transparent(
|
|
@@ -8,8 +8,6 @@ import androidx.compose.foundation.layout.Arrangement
|
|
|
8
8
|
import androidx.compose.foundation.layout.Box
|
|
9
9
|
import androidx.compose.foundation.layout.Column
|
|
10
10
|
import androidx.compose.foundation.layout.Row
|
|
11
|
-
import androidx.compose.foundation.layout.RowScope
|
|
12
|
-
import androidx.compose.foundation.layout.fillMaxHeight
|
|
13
11
|
import androidx.compose.foundation.layout.height
|
|
14
12
|
import androidx.compose.foundation.layout.offset
|
|
15
13
|
import androidx.compose.foundation.layout.padding
|
|
@@ -31,9 +29,6 @@ import androidx.compose.ui.graphics.Color
|
|
|
31
29
|
import androidx.compose.ui.unit.Dp
|
|
32
30
|
import androidx.compose.ui.unit.dp
|
|
33
31
|
import vn.momo.kits.layout.DuoMetrics
|
|
34
|
-
import vn.momo.kits.layout.HEADER_BUTTON_SIZE
|
|
35
|
-
import vn.momo.kits.layout.HEADER_ICON_SIZE
|
|
36
|
-
import vn.momo.kits.layout.HEADER_PILL_WIDTH
|
|
37
32
|
import vn.momo.kits.application.LocalContext
|
|
38
33
|
import vn.momo.kits.application.MiniAppContext
|
|
39
34
|
import vn.momo.kits.components.BadgeDot
|
|
@@ -69,11 +64,13 @@ fun HeaderRight(
|
|
|
69
64
|
|
|
70
65
|
private const val HELP_CENTER_APP_ID = "vn.momo.helpcenter"
|
|
71
66
|
|
|
72
|
-
private fun usesHelpCenter(context: MiniAppContext?): Boolean
|
|
73
|
-
context != null && context.appId != HELP_CENTER_APP_ID
|
|
67
|
+
private fun usesHelpCenter(context: MiniAppContext?): Boolean {
|
|
68
|
+
return context != null && context.appId != HELP_CENTER_APP_ID
|
|
69
|
+
}
|
|
74
70
|
|
|
75
|
-
private fun showsShortcut(headerRight: HeaderRight.Toolkit, context: MiniAppContext?): Boolean
|
|
76
|
-
headerRight.useShortcut && !(headerRight.useMore && context == null)
|
|
71
|
+
private fun showsShortcut(headerRight: HeaderRight.Toolkit, context: MiniAppContext?): Boolean {
|
|
72
|
+
return headerRight.useShortcut && !(headerRight.useMore && context == null)
|
|
73
|
+
}
|
|
77
74
|
|
|
78
75
|
// Height of the vertical toolkit: the optional shortcut, then the help/home capsule.
|
|
79
76
|
@Composable
|
|
@@ -84,8 +81,8 @@ internal fun toolkitColumnHeight(headerRight: HeaderRight.Toolkit): Dp {
|
|
|
84
81
|
return shortcut + if (groupCount > 1) DuoMetrics.itemPitch * groupCount else DuoMetrics.controlSize
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
// SideBarColumn: the iPhone Duo side bar
|
|
88
|
-
internal enum class ToolkitLayout { Bar, SideBarColumn }
|
|
84
|
+
// SideBarColumn: the iPhone Duo side bar; SideBarRow: the Duo header row on the status bar, same 48pt controls.
|
|
85
|
+
internal enum class ToolkitLayout { Bar, SideBarColumn, SideBarRow }
|
|
89
86
|
|
|
90
87
|
@Composable
|
|
91
88
|
internal fun Toolkit(
|
|
@@ -172,7 +169,8 @@ internal fun Toolkit(
|
|
|
172
169
|
}
|
|
173
170
|
|
|
174
171
|
if (layout != ToolkitLayout.Bar) {
|
|
175
|
-
|
|
172
|
+
val horizontal = layout == ToolkitLayout.SideBarRow
|
|
173
|
+
val controls = @Composable {
|
|
176
174
|
if (isShowShortcut) {
|
|
177
175
|
SideBarButton(
|
|
178
176
|
icon = icon,
|
|
@@ -182,7 +180,7 @@ internal fun Toolkit(
|
|
|
182
180
|
onClick = navButtonConfig.onPress,
|
|
183
181
|
)
|
|
184
182
|
}
|
|
185
|
-
SideBarGroup(headerColor = headerColor, itemCount = if (useHelpCenter) 2 else 1) { item ->
|
|
183
|
+
SideBarGroup(headerColor = headerColor, itemCount = if (useHelpCenter) 2 else 1, horizontal = horizontal) { item ->
|
|
186
184
|
if (useHelpCenter) {
|
|
187
185
|
SideBarGroupItem(
|
|
188
186
|
icon = "help_center",
|
|
@@ -201,6 +199,13 @@ internal fun Toolkit(
|
|
|
201
199
|
)
|
|
202
200
|
}
|
|
203
201
|
}
|
|
202
|
+
if (horizontal) {
|
|
203
|
+
Row(horizontalArrangement = Arrangement.spacedBy(Spacing.M), verticalAlignment = Alignment.CenterVertically) {
|
|
204
|
+
controls()
|
|
205
|
+
}
|
|
206
|
+
} else {
|
|
207
|
+
Column(verticalArrangement = Arrangement.spacedBy(Spacing.M)) { controls() }
|
|
208
|
+
}
|
|
204
209
|
return
|
|
205
210
|
}
|
|
206
211
|
|
|
@@ -222,14 +227,18 @@ internal fun Toolkit(
|
|
|
222
227
|
horizontalArrangement = Arrangement.Center,
|
|
223
228
|
modifier = Modifier
|
|
224
229
|
.padding(start = Spacing.S)
|
|
225
|
-
.border(0.2.dp, headerColor.borderColor, shape =
|
|
226
|
-
.height(
|
|
227
|
-
.
|
|
228
|
-
.clip(shape = PILL_SHAPE)
|
|
230
|
+
.border(0.2.dp, headerColor.borderColor, shape = RoundedCornerShape(14.dp))
|
|
231
|
+
.height(28.dp)
|
|
232
|
+
.clip(shape = RoundedCornerShape(14.dp))
|
|
229
233
|
.background(headerColor.backgroundButton)
|
|
230
234
|
) {
|
|
231
235
|
if (useHelpCenter) {
|
|
232
|
-
|
|
236
|
+
Icon(
|
|
237
|
+
source = "help_center",
|
|
238
|
+
size = 20.dp,
|
|
239
|
+
color = headerColor.tintIconColor,
|
|
240
|
+
modifier = Modifier.padding(4.dp).activeOpacityClickable(onClick = ::onPressHelpCenter)
|
|
241
|
+
)
|
|
233
242
|
Box(
|
|
234
243
|
modifier = Modifier
|
|
235
244
|
.width(0.5.dp)
|
|
@@ -237,23 +246,17 @@ internal fun Toolkit(
|
|
|
237
246
|
.background(tintColor ?: Colors.black_20)
|
|
238
247
|
)
|
|
239
248
|
}
|
|
240
|
-
|
|
249
|
+
Icon(
|
|
250
|
+
source = closeIcon,
|
|
251
|
+
size = 20.dp,
|
|
252
|
+
color = headerColor.tintIconColor,
|
|
253
|
+
modifier = Modifier.padding(4.dp).activeOpacityClickable(onClick = ::onPressClose)
|
|
254
|
+
)
|
|
241
255
|
}
|
|
242
256
|
}
|
|
243
257
|
}
|
|
244
258
|
|
|
245
|
-
private val PILL_SHAPE = RoundedCornerShape(percent = 50)
|
|
246
259
|
|
|
247
|
-
// One half of the help / home pill; each half takes an equal share of the pill width.
|
|
248
|
-
@Composable
|
|
249
|
-
private fun RowScope.PillItem(icon: String, headerColor: HeaderColor, onClick: () -> Unit) {
|
|
250
|
-
Box(
|
|
251
|
-
modifier = Modifier.weight(1f).fillMaxHeight().activeOpacityClickable(onClick = onClick),
|
|
252
|
-
contentAlignment = Alignment.Center,
|
|
253
|
-
) {
|
|
254
|
-
Icon(source = icon, size = HEADER_ICON_SIZE, color = headerColor.tintIconColor)
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
260
|
|
|
258
261
|
// Colors follow the enclosing header, so it fits a `HeaderRight.Custom` next to the toolkit.
|
|
259
262
|
@Composable
|
|
@@ -285,7 +288,7 @@ internal fun NavigationButton(
|
|
|
285
288
|
) {
|
|
286
289
|
Box(
|
|
287
290
|
modifier = modifier
|
|
288
|
-
.size(
|
|
291
|
+
.size(28.dp)
|
|
289
292
|
.activeOpacityClickable(enabled = !disabled, onClick = onClick)
|
|
290
293
|
) {
|
|
291
294
|
Box(
|
|
@@ -301,7 +304,7 @@ internal fun NavigationButton(
|
|
|
301
304
|
) {
|
|
302
305
|
Icon(
|
|
303
306
|
source = icon,
|
|
304
|
-
size =
|
|
307
|
+
size = 20.dp,
|
|
305
308
|
color = headerColor.tintIconColor
|
|
306
309
|
)
|
|
307
310
|
}
|
|
@@ -150,18 +150,25 @@ internal fun SideBarButton(
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
//
|
|
153
|
+
// Capsule grouping related controls, one item per 50pt: vertical in the side bar, horizontal on a header row.
|
|
154
154
|
@Composable
|
|
155
155
|
internal fun SideBarGroup(
|
|
156
156
|
headerColor: HeaderColor,
|
|
157
157
|
itemCount: Int,
|
|
158
|
+
horizontal: Boolean = false,
|
|
158
159
|
content: @Composable (itemModifier: Modifier) -> Unit,
|
|
159
160
|
) {
|
|
160
161
|
val length = if (itemCount > 1) DuoMetrics.itemPitch * itemCount else DuoMetrics.controlSize
|
|
161
162
|
val item = length / itemCount.coerceAtLeast(1)
|
|
162
163
|
val glass = Modifier.sideBarGlass(headerColor, RoundedCornerShape(Radius.XL))
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
if (horizontal) {
|
|
165
|
+
Row(Modifier.size(width = length, height = DuoMetrics.controlSize).then(glass)) {
|
|
166
|
+
content(Modifier.size(width = item, height = DuoMetrics.controlSize))
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
Column(Modifier.size(width = DuoMetrics.controlSize, height = length).then(glass)) {
|
|
170
|
+
content(Modifier.size(width = DuoMetrics.controlSize, height = item))
|
|
171
|
+
}
|
|
165
172
|
}
|
|
166
173
|
}
|
|
167
174
|
|
|
@@ -185,13 +192,13 @@ internal fun SideBarGroupItem(
|
|
|
185
192
|
|
|
186
193
|
// Dark glass under light icons (banner headers), light glass otherwise. The light one is opaque:
|
|
187
194
|
// Compose has no backdrop blur and a translucent fill shows its own shadow through (RN uses 85% white).
|
|
188
|
-
private fun Modifier.sideBarGlass(headerColor: HeaderColor, shape: Shape): Modifier
|
|
195
|
+
private fun Modifier.sideBarGlass(headerColor: HeaderColor, shape: Shape): Modifier {
|
|
189
196
|
if (headerColor.tintIconColor == Colors.black_01) {
|
|
190
|
-
clip(shape)
|
|
197
|
+
return clip(shape)
|
|
191
198
|
.background(Colors.black_20.copy(alpha = 0.5f))
|
|
192
199
|
.border(0.5.dp, Colors.black_01.copy(alpha = 0.2f), shape)
|
|
193
|
-
} else {
|
|
194
|
-
shadow(3.dp, shape)
|
|
195
|
-
.background(Colors.black_01)
|
|
196
|
-
.border(0.5.dp, Colors.black_20.copy(alpha = 0.08f), shape)
|
|
197
200
|
}
|
|
201
|
+
return shadow(3.dp, shape)
|
|
202
|
+
.background(Colors.black_01)
|
|
203
|
+
.border(0.5.dp, Colors.black_20.copy(alpha = 0.08f), shape)
|
|
204
|
+
}
|
|
@@ -2,8 +2,6 @@ package vn.momo.kits.platform
|
|
|
2
2
|
|
|
3
3
|
import androidx.compose.runtime.Composable
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
// screen is visible. Wrapped inside the containers so every screen is covered, not just callers of
|
|
7
|
-
// the app-level wrappers.
|
|
5
|
+
// Keeps LocalDensity.fontScale on the live OS text size; the containers wrap every screen in it.
|
|
8
6
|
@Composable
|
|
9
7
|
expect fun ProvideOsFontScale(content: @Composable () -> Unit)
|
|
@@ -7,14 +7,13 @@ import androidx.compose.ui.unit.Dp
|
|
|
7
7
|
@Immutable
|
|
8
8
|
internal data class ReservedRegion(val x: Dp, val y: Dp, val width: Dp, val height: Dp)
|
|
9
9
|
|
|
10
|
-
// occlusion: regions the system occludes (iOS 27.1+), in the coordinates of the Compose root view:
|
|
11
|
-
// the iPhone Duo camera, and the status bar cluster as it grows for a call or a Live Activity.
|
|
12
|
-
// isFoldable: the device reports a `.division` (hinge) region, Apple's foldable check.
|
|
13
|
-
// division: that region while active, i.e. the hinge of a half-folded device; null while flat.
|
|
14
10
|
@Immutable
|
|
15
11
|
internal data class ReservedRegions(
|
|
12
|
+
// iOS 27.1+, root-view coordinates: the Duo camera, the status bar cluster grown by a call / Live Activity
|
|
16
13
|
val occlusion: List<ReservedRegion> = emptyList(),
|
|
14
|
+
// a `.division` (hinge) region exists: Apple's foldable check
|
|
17
15
|
val isFoldable: Boolean = false,
|
|
16
|
+
// the hinge while half folded; null while flat
|
|
18
17
|
val division: ReservedRegion? = null,
|
|
19
18
|
)
|
|
20
19
|
|
|
@@ -47,8 +47,7 @@ internal fun Modifier.bottomBorder(strokeWidth: Dp, color: Color) = composed(
|
|
|
47
47
|
)
|
|
48
48
|
|
|
49
49
|
fun <T> Boolean.ifTrue(trueCase: T, falseCase: T): T = if (this) trueCase else falseCase
|
|
50
|
-
fun <T> String.ifNotNull(trueCase: T, falseCase: T): T =
|
|
51
|
-
if (this.isBlank()) falseCase else trueCase
|
|
50
|
+
fun <T> String.ifNotNull(trueCase: T, falseCase: T): T = if (this.isBlank()) falseCase else trueCase
|
|
52
51
|
|
|
53
52
|
fun formatNumberToMoney(number: Long, currency: String = "đ"): String {
|
|
54
53
|
if (number == 0L) {
|
|
@@ -17,15 +17,14 @@ import platform.UIKit.UIFont
|
|
|
17
17
|
import platform.UIKit.UIFontTextStyleBody
|
|
18
18
|
import platform.darwin.NSObject
|
|
19
19
|
|
|
20
|
-
//
|
|
21
|
-
// recompose it when UIContentSizeCategory changes (Android tracks Configuration.fontScale live). We
|
|
22
|
-
// observe the notification and override LocalDensity.fontScale so scaleSize() recomposes live. The
|
|
23
|
-
// formula matches the SwiftUI kit (UIFont body point size / 17) so both iOS surfaces scale alike.
|
|
20
|
+
// Body point size / 17, as in the SwiftUI kit, so both iOS surfaces scale alike.
|
|
24
21
|
private const val DEFAULT_BODY_POINT_SIZE = 17.0
|
|
25
22
|
|
|
26
|
-
private fun currentOsFontScale(): Float
|
|
27
|
-
(UIFont.preferredFontForTextStyle(UIFontTextStyleBody).pointSize / DEFAULT_BODY_POINT_SIZE).toFloat()
|
|
23
|
+
private fun currentOsFontScale(): Float {
|
|
24
|
+
return (UIFont.preferredFontForTextStyle(UIFontTextStyleBody).pointSize / DEFAULT_BODY_POINT_SIZE).toFloat()
|
|
25
|
+
}
|
|
28
26
|
|
|
27
|
+
// Compose MP iOS reads fontScale only once, at ComposeUIViewController creation.
|
|
29
28
|
@OptIn(ExperimentalForeignApi::class)
|
|
30
29
|
@Composable
|
|
31
30
|
actual fun ProvideOsFontScale(content: @Composable () -> Unit) {
|
|
@@ -44,8 +44,7 @@ import vn.momo.kits.navigation.Navigator
|
|
|
44
44
|
|
|
45
45
|
actual fun getPlatformName(): String = "iOS"
|
|
46
46
|
|
|
47
|
-
actual fun isPhoneIdiom(): Boolean =
|
|
48
|
-
UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
|
|
47
|
+
actual fun isPhoneIdiom(): Boolean = UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
|
|
49
48
|
|
|
50
49
|
// Window size, not UIScreen.main (which stays on one display on iPhone Duo); recomposes on fold/unfold.
|
|
51
50
|
@Composable
|
|
@@ -57,9 +57,8 @@ private fun regionKind(name: String): Any? {
|
|
|
57
57
|
private val msgSendRegionsOfKindOptions = dlsym(RTLD_DEFAULT, "objc_msgSend")
|
|
58
58
|
?.reinterpret<CFunction<(COpaquePointer?, COpaquePointer?, COpaquePointer?, ULong) -> COpaquePointer?>>()
|
|
59
59
|
|
|
60
|
-
// Apple's foldable check: only a
|
|
61
|
-
//
|
|
62
|
-
// apart from a large iPhone in landscape or a narrowed window.
|
|
60
|
+
// Apple's foldable check: only a hinge reports `.division`, inactive while flat (hence IncludeInactive).
|
|
61
|
+
// Screen size can't tell a foldable from a large iPhone in landscape or a narrowed window.
|
|
63
62
|
@OptIn(ExperimentalForeignApi::class)
|
|
64
63
|
private fun UIView.hasDivisionRegion(): Boolean {
|
|
65
64
|
if (window == null || !respondsToSelector(regionsOfKindOptions)) return false
|
package/gradle.properties
CHANGED
|
@@ -20,9 +20,8 @@ public struct DesignSystemKitsConfigs: Equatable {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
///
|
|
24
|
-
///
|
|
25
|
-
/// only under `.momoFontScale()` (`NavigationContainer` applies it).
|
|
23
|
+
/// Compose's `DesignSystemKits` without `init(source:)` (Swift reserves `init`): the host pushes `setConfigs(_:)` at
|
|
24
|
+
/// startup and on every change. Also tracks Dynamic Type; views re-render only under `.momoFontScale()`.
|
|
26
25
|
public final class DesignSystemKits: ObservableObject {
|
|
27
26
|
public static let shared = DesignSystemKits()
|
|
28
27
|
|
|
@@ -9,9 +9,8 @@ public protocol LanguageSource: AnyObject {
|
|
|
9
9
|
func stopObserving()
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
///
|
|
13
|
-
///
|
|
14
|
-
/// same key on `UserDefaults.standard` in-process, so KVO on it sees every one of them.
|
|
12
|
+
/// All three host writers (RN bridge `RNResource`, `JSONLocalization`, KMP `LocalizationProvider`) write the same
|
|
13
|
+
/// `UserDefaults.standard` key in-process, so KVO on it sees every language change.
|
|
15
14
|
public final class UserDefaultsLanguageSource: NSObject, LanguageSource {
|
|
16
15
|
public static let defaultKey = "language"
|
|
17
16
|
|
|
@@ -318,9 +318,8 @@ public final class Localize: ObservableObject {
|
|
|
318
318
|
)
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
/// Snapshots `currentLanguage`
|
|
322
|
-
///
|
|
323
|
-
/// `@Environment` does not subscribe to `@Published` the way `@EnvironmentObject` does.
|
|
321
|
+
/// Snapshots `currentLanguage` so `changeLanguage` is an environment *change*: the reference never changes, and
|
|
322
|
+
/// `@Environment` doesn't subscribe to `@Published` the way `@EnvironmentObject` does.
|
|
324
323
|
private struct LocalizeBox: Equatable {
|
|
325
324
|
let localize: Localize
|
|
326
325
|
let language: String
|
|
@@ -339,10 +338,8 @@ private struct LocalizeBox: Equatable {
|
|
|
339
338
|
}
|
|
340
339
|
|
|
341
340
|
private struct LocalizeKey: EnvironmentKey {
|
|
342
|
-
///
|
|
343
|
-
///
|
|
344
|
-
/// A `static let`, never rebuilt: without `.momoLocalize()` (or `NavigationContainer`) the
|
|
345
|
-
/// language is right on first render but does not live-update.
|
|
341
|
+
/// Never traps like `@EnvironmentObject`, but as a `static let` it is never rebuilt: without `.momoLocalize()`
|
|
342
|
+
/// (or `NavigationContainer`) the language is right on first render but does not live-update.
|
|
346
343
|
static let defaultValue = LocalizeBox(Localize.shared)
|
|
347
344
|
}
|
|
348
345
|
|
|
@@ -8,9 +8,8 @@ public extension View {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
/// `@ObservedObject` is load-bearing: `@Environment(\.localize)` only
|
|
12
|
-
///
|
|
13
|
-
/// set `\.localize` would inject a snapshot that never updates.
|
|
11
|
+
/// `@ObservedObject` is load-bearing: `@Environment(\.localize)` invalidates only when *this* body re-runs on a
|
|
12
|
+
/// publish; a helper that just set `\.localize` would inject a snapshot that never updates.
|
|
14
13
|
private struct MomoLocalizeModifier: ViewModifier {
|
|
15
14
|
@ObservedObject var localize: Localize
|
|
16
15
|
|
package/ios/Badge/Badge.swift
CHANGED
|
@@ -41,16 +41,14 @@ public struct Badge: View {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
private var badgeColor: Color {
|
|
44
|
-
|
|
45
|
-
? theme.colors.error.primary
|
|
46
|
-
: theme.colors.warning.primary
|
|
47
|
-
|
|
48
|
-
// Mirror Compose: only apply backgroundColor when it is one of the
|
|
49
|
-
// allowed primaryColors; otherwise fall back to the label-based default.
|
|
44
|
+
// Mirrors Compose: backgroundColor applies only when it is one of primaryColors.
|
|
50
45
|
if let bgColor = backgroundColor, primaryColors.contains(bgColor) {
|
|
51
46
|
return bgColor
|
|
52
47
|
}
|
|
53
|
-
|
|
48
|
+
if isNumber(label) {
|
|
49
|
+
return theme.colors.error.primary
|
|
50
|
+
}
|
|
51
|
+
return theme.colors.warning.primary
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
public var body: some View {
|
package/ios/Button/Button.swift
CHANGED
|
@@ -229,9 +229,8 @@ public struct Button: View {
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
///
|
|
233
|
-
/// horizontal inset and the whole button
|
|
234
|
-
/// matching `animatedPadding`/`alpha` in Button.kt.
|
|
232
|
+
/// Compose's press feedback (`animatedPadding` / `alpha` in Button.kt): the background shrinks by an animated
|
|
233
|
+
/// horizontal inset and the whole button fades to 0.5.
|
|
235
234
|
private struct ButtonPressFeedbackStyle: ButtonStyle {
|
|
236
235
|
let isEnabled: Bool
|
|
237
236
|
let background: Color
|
|
@@ -92,11 +92,9 @@ public struct CalculatorKeyboard: View {
|
|
|
92
92
|
|
|
93
93
|
var result = terms[0]
|
|
94
94
|
for (sign, term) in zip(signs, terms.dropFirst()) {
|
|
95
|
-
let
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if overflow { return nil }
|
|
99
|
-
result = next
|
|
95
|
+
let step = sign == "+" ? result.addingReportingOverflow(term) : result.subtractingReportingOverflow(term)
|
|
96
|
+
if step.overflow { return nil }
|
|
97
|
+
result = step.partialValue
|
|
100
98
|
}
|
|
101
99
|
return result
|
|
102
100
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
/// Compose `Carousel`; `content` and the snap / scroll-index callbacks get the real (modulo) index.
|
|
4
|
-
///
|
|
5
|
-
/// virtualization or the inactive-slide opacity/scale effects.
|
|
3
|
+
/// Compose `Carousel`; `content` and the snap / scroll-index callbacks get the real (modulo) index. A drag-driven
|
|
4
|
+
/// pager, as ScrollView and `TabView(.page)` can't express the loop virtualization or inactive-slide effects.
|
|
6
5
|
public struct Carousel<Content: View>: View {
|
|
7
6
|
// MARK: Lifecycle
|
|
8
7
|
|
|
@@ -94,11 +94,7 @@ public struct Collapse<Content: View>: View {
|
|
|
94
94
|
content()
|
|
95
95
|
}
|
|
96
96
|
.frame(maxWidth: .infinity)
|
|
97
|
-
.overlay(
|
|
98
|
-
showBorder
|
|
99
|
-
? Rectangle().strokeBorder(theme.colors.border.default, lineWidth: 1)
|
|
100
|
-
: nil
|
|
101
|
-
)
|
|
97
|
+
.overlay(contentBorder)
|
|
102
98
|
.transition(.move(edge: .top))
|
|
103
99
|
}
|
|
104
100
|
}
|
|
@@ -108,17 +104,27 @@ public struct Collapse<Content: View>: View {
|
|
|
108
104
|
.frame(maxWidth: .infinity)
|
|
109
105
|
.background(resolvedBackgroundColor)
|
|
110
106
|
.clipShape(RoundedRectangle(cornerRadius: Radius.S, style: .continuous))
|
|
111
|
-
.overlay(
|
|
112
|
-
showBorder
|
|
113
|
-
? RoundedRectangle(cornerRadius: Radius.S, style: .continuous)
|
|
114
|
-
.strokeBorder(theme.colors.border.default, lineWidth: 1)
|
|
115
|
-
: nil
|
|
116
|
-
)
|
|
107
|
+
.overlay(containerBorder)
|
|
117
108
|
// `.contain` keeps the children's own identifiers instead of overriding them.
|
|
118
109
|
.accessibilityElement(children: .contain)
|
|
119
110
|
.accessibilityIdentifier(automationId)
|
|
120
111
|
}
|
|
121
112
|
|
|
113
|
+
@ViewBuilder
|
|
114
|
+
private var contentBorder: some View {
|
|
115
|
+
if showBorder {
|
|
116
|
+
Rectangle().strokeBorder(theme.colors.border.default, lineWidth: 1)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@ViewBuilder
|
|
121
|
+
private var containerBorder: some View {
|
|
122
|
+
if showBorder {
|
|
123
|
+
RoundedRectangle(cornerRadius: Radius.S, style: .continuous)
|
|
124
|
+
.strokeBorder(theme.colors.border.default, lineWidth: 1)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
122
128
|
private var header: some View {
|
|
123
129
|
SwiftUI.Button(action: {
|
|
124
130
|
onPress?(expanded)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
///
|
|
4
|
-
///
|
|
5
|
-
/// relying on a platform-default press indication.
|
|
3
|
+
/// Compose's `Modifier.activeOpacityClickable(activeOpacity:)`: the whole tappable subtree fades to `activeOpacity`
|
|
4
|
+
/// while pressed, instead of a platform-default press indication.
|
|
6
5
|
struct ActiveOpacityButtonStyle: ButtonStyle {
|
|
7
6
|
var activeOpacity: Double = 0.2
|
|
8
7
|
|