@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
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
package vn.momo.kits.navigation.bottomtab
|
|
2
|
+
|
|
3
|
+
import androidx.compose.animation.core.CubicBezierEasing
|
|
4
|
+
import androidx.compose.animation.core.tween
|
|
5
|
+
import androidx.compose.ui.graphics.Color
|
|
6
|
+
import androidx.compose.ui.graphics.shadow.Shadow
|
|
7
|
+
import androidx.compose.ui.unit.Dp
|
|
8
|
+
import androidx.compose.ui.unit.DpOffset
|
|
9
|
+
import androidx.compose.ui.unit.dp
|
|
10
|
+
import vn.momo.kits.const.Radius
|
|
11
|
+
import vn.momo.kits.const.Spacing
|
|
12
|
+
import vn.momo.kits.platform.getPlatformName
|
|
13
|
+
|
|
14
|
+
// Navigation bar measurements (Figma "Specs Navigation", DS-984), mirrored from RN BottomTab/metrics.ts.
|
|
15
|
+
// Horizontal: floating container with items split evenly, center action in a notch.
|
|
16
|
+
// Vertical: iPhone Duo rail, center action under the container.
|
|
17
|
+
internal object TabBarMetrics {
|
|
18
|
+
val height = 68.dp
|
|
19
|
+
val margin = Spacing.S
|
|
20
|
+
val paddingVertical = Spacing.S
|
|
21
|
+
val paddingHorizontal = Spacing.M
|
|
22
|
+
val itemGap = Spacing.XS
|
|
23
|
+
val iconSize = 24.dp
|
|
24
|
+
val indicatorHeight = 32.dp
|
|
25
|
+
// active indicator behind the icon: 24 icon + XS·M padding
|
|
26
|
+
val indicatorPaddingHorizontal = Spacing.M
|
|
27
|
+
val indicatorRadius = Radius.XL
|
|
28
|
+
// home indicator / gesture bar area under the container
|
|
29
|
+
val systemIndicatorHeight = 24.dp
|
|
30
|
+
// unfolded foldables (short side from 600, the smallest in the spec) use 65% of the short side,
|
|
31
|
+
// centered; phones and folded outer displays fill the window
|
|
32
|
+
val foldableMinShortSide = 600.dp
|
|
33
|
+
const val FOLDABLE_WIDTH_RATIO = 0.65f
|
|
34
|
+
val ctaSlotWidth = 92.dp
|
|
35
|
+
val ctaSize = 48.dp
|
|
36
|
+
// the icon sits 10 inside the 48 button (prototype .cta: 28 icon), 12 inside the 52 rail one
|
|
37
|
+
val ctaIconSize = 28.dp
|
|
38
|
+
// the button rises 22 above the container top edge
|
|
39
|
+
val ctaLift = 22.dp
|
|
40
|
+
val ctaLabelGap = Spacing.M
|
|
41
|
+
val ctaLabelHeight = 18.dp
|
|
42
|
+
val railContainerWidth = 56.dp
|
|
43
|
+
val railPaddingHorizontal = Spacing.XS
|
|
44
|
+
val railPaddingBottom = Spacing.S
|
|
45
|
+
val railItemWidth = 48.dp
|
|
46
|
+
val railItemHeight = 62.dp
|
|
47
|
+
val railIndicatorHeight = 40.dp
|
|
48
|
+
val railIndicatorRadius = 20.dp
|
|
49
|
+
val railCtaGap = Spacing.L
|
|
50
|
+
val railCtaSize = 52.dp
|
|
51
|
+
val railCtaLabelGap = Spacing.XS
|
|
52
|
+
val railCtaWidth = 68.dp
|
|
53
|
+
val railCtaHeight = 70.dp
|
|
54
|
+
val badgeMaxWidth = 58.dp
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Motion of the navigation bar (MoMo Navigation Prototype): one active indicator slides to the
|
|
58
|
+
// selected item overshooting a little, icon and label tint cross-fade, the center action shrinks while held.
|
|
59
|
+
internal object TabBarMotion {
|
|
60
|
+
val indicator = tween<Float>(durationMillis = 550, easing = CubicBezierEasing(0.34f, 1.4f, 0.5f, 1f))
|
|
61
|
+
const val TINT_MILLIS = 250
|
|
62
|
+
const val CTA_PRESS_MILLIS = 150
|
|
63
|
+
const val CTA_PRESSED_SCALE = 0.92f
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Figma Effect/Popover on the center action button.
|
|
67
|
+
internal val CtaShadows = listOf(
|
|
68
|
+
Shadow(radius = 24.dp, spread = (-12).dp, color = Color.Black, alpha = 0.08f, offset = DpOffset(0.dp, 8.dp)),
|
|
69
|
+
Shadow(radius = 32.dp, spread = (-16).dp, color = Color.Black, alpha = 0.04f, offset = DpOffset(0.dp, 12.dp)),
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
// Inner light and tint of the active indicator: white 12% from below, primary 12% from above.
|
|
73
|
+
internal fun indicatorInnerShadows(primary: Color) = listOf(
|
|
74
|
+
Shadow(radius = 2.dp, color = Color.White, alpha = 0.12f, offset = DpOffset(0.dp, (-2).dp)),
|
|
75
|
+
Shadow(radius = 2.dp, color = primary, alpha = 0.12f, offset = DpOffset(0.dp, 1.dp)),
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
// Notch dipped into the container top edge under the center action (Figma "Backgroud" path): starts
|
|
79
|
+
// NOTCH_HALF_WIDTH left of the center, then cubic segments of control1, control2, end, each point as
|
|
80
|
+
// (dx from the center, dy below the top edge) in dp.
|
|
81
|
+
internal const val NOTCH_HALF_WIDTH = 50.758f
|
|
82
|
+
internal val NOTCH_CURVES = listOf(
|
|
83
|
+
listOf(-39.749f to 0f, -31.231f to 9.765f, -24.563f to 18.526f),
|
|
84
|
+
listOf(-18.928f to 25.93f, -10.022f to 30.709f, 0f to 30.709f),
|
|
85
|
+
listOf(10.022f to 30.709f, 18.928f to 25.93f, 24.563f to 18.526f),
|
|
86
|
+
listOf(31.231f to 9.765f, 39.749f to 0f, NOTCH_HALF_WIDTH to 0f),
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
// Width of the horizontal bar: 65% of the short side on an unfolded foldable, otherwise the window minus
|
|
90
|
+
// the side safe areas and margins.
|
|
91
|
+
internal fun horizontalBarWidth(width: Dp, height: Dp, insetLeft: Dp, insetRight: Dp): Dp {
|
|
92
|
+
val shortSide = minOf(width, height)
|
|
93
|
+
if (shortSide >= TabBarMetrics.foldableMinShortSide) return shortSide * TabBarMetrics.FOLDABLE_WIDTH_RATIO
|
|
94
|
+
return width - insetLeft - insetRight - TabBarMetrics.margin * 2
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Gap under the container: the home indicator / gesture bar area.
|
|
98
|
+
internal fun tabBarBottomGap(navigationBar: Dp): Dp =
|
|
99
|
+
(if (getPlatformName() == "iOS") minOf(navigationBar, TabBarMetrics.systemIndicatorHeight) else navigationBar)
|
|
100
|
+
.coerceAtLeast(Spacing.S)
|
|
101
|
+
|
|
102
|
+
// The center action needs a tab on each side: Special type takes 2 or 4 tabs.
|
|
103
|
+
internal fun hasCenterAction(floatingButton: BottomTabFloatingButton?, tabCount: Int): Boolean =
|
|
104
|
+
floatingButton != null && tabCount % 2 == 0
|
|
@@ -97,7 +97,7 @@ internal fun headerTitleMaxWidth(): Dp {
|
|
|
97
97
|
// Scroll distance over which the Duo glass bar fades in.
|
|
98
98
|
private val DUO_GLASS_FADE_DISTANCE = 16.dp
|
|
99
99
|
|
|
100
|
-
// RN DuoGlassBackground
|
|
100
|
+
// RN DuoGlassBackground: translucent surface with a hairline once content scrolls under it.
|
|
101
101
|
@Suppress("FrequentlyChangingValue")
|
|
102
102
|
@Composable
|
|
103
103
|
private fun Modifier.duoGlassBar(): Modifier {
|
|
@@ -90,7 +90,9 @@ internal fun HeaderBackground() {
|
|
|
90
90
|
.fillMaxWidth()
|
|
91
91
|
.then(if (fillsBox && !theme.isHeaderImage()) Modifier.fillMaxHeight() else Modifier.height(maxHeight))
|
|
92
92
|
.conditional(!theme.isHeaderImage()) {
|
|
93
|
-
|
|
93
|
+
// RN spans the gradient over 375:154 and clips it, so a default header shows only its top
|
|
94
|
+
val endY = if (fillsBox) Float.POSITIVE_INFINITY else with(density) { maxHeight.toPx() }
|
|
95
|
+
background(Brush.verticalGradient(colors = listOf(color, backgroundColor), endY = endY))
|
|
94
96
|
}
|
|
95
97
|
){
|
|
96
98
|
if (!theme.isHeaderImage()) return@Box
|
|
@@ -17,17 +17,6 @@ import androidx.compose.foundation.shape.CircleShape
|
|
|
17
17
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
18
18
|
import androidx.compose.runtime.Composable
|
|
19
19
|
import androidx.compose.runtime.LaunchedEffect
|
|
20
|
-
// AI-GENERATED START: dispose toolkit requests with their UI owner
|
|
21
|
-
import androidx.compose.runtime.DisposableEffect
|
|
22
|
-
import kotlinx.serialization.json.booleanOrNull
|
|
23
|
-
import kotlinx.serialization.json.jsonPrimitive
|
|
24
|
-
import vn.momo.maxapi.contract.navigation.model.DismissTarget
|
|
25
|
-
import vn.momo.maxapi.contract.toolkit.model.ToolAction
|
|
26
|
-
import vn.momo.maxapi.contract.toolkit.model.ToolkitOptions
|
|
27
|
-
import vn.momo.maxapi.contract.toolkit.model.ToolkitToolGroup
|
|
28
|
-
import vn.momo.maxapi.contract.toolkit.model.ToolkitTool
|
|
29
|
-
import vn.momo.maxapi.runtime.ApiResult
|
|
30
|
-
// AI-GENERATED END: dispose toolkit requests with their UI owner
|
|
31
20
|
import androidx.compose.runtime.derivedStateOf
|
|
32
21
|
import androidx.compose.runtime.getValue
|
|
33
22
|
import androidx.compose.runtime.mutableStateOf
|
|
@@ -106,56 +95,53 @@ internal fun Toolkit(
|
|
|
106
95
|
var isFavorite by remember { mutableStateOf(false) }
|
|
107
96
|
val isLoading by remember { mutableStateOf(false) }
|
|
108
97
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
LaunchedEffect(requests) {
|
|
114
|
-
val client = api ?: return@LaunchedEffect
|
|
115
|
-
requests.launch<Boolean>({ callback -> client.checkFavorite(context?.appCode, callback) }) { result ->
|
|
116
|
-
if (result is ApiResult.Success) isFavorite = result.value
|
|
98
|
+
LaunchedEffect(context?.appCode) {
|
|
99
|
+
api?.isFavoriteApp(mapOf("code" to context?.appCode)) { callback ->
|
|
100
|
+
val response = callback?.get("response") as? Boolean
|
|
101
|
+
isFavorite = response == true
|
|
117
102
|
}
|
|
118
103
|
}
|
|
119
104
|
|
|
120
105
|
fun onPressShortcut() {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
result.value.jsonPrimitive.booleanOrNull?.let { isFavorite = it }
|
|
106
|
+
api?.onToolAction(mapOf("item" to mapOf("key" to "onFavorite"), "context" to MiniAppContext.toMap(context))) { callback ->
|
|
107
|
+
val response = callback?.get("response") as? Map<*, *>?
|
|
108
|
+
val success = response?.get("success") as? Boolean
|
|
109
|
+
if (success == true){
|
|
110
|
+
isFavorite = !isFavorite
|
|
127
111
|
}
|
|
128
112
|
}
|
|
129
113
|
}
|
|
130
114
|
|
|
131
115
|
fun onPressMore() {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
116
|
+
api?.showTools(
|
|
117
|
+
mapOf(
|
|
118
|
+
"useSystemTools" to headerRight.useSystemTools,
|
|
119
|
+
"tools" to headerRight.tools.map { it.toMap() },
|
|
120
|
+
"context" to MiniAppContext.toMap(context)
|
|
121
|
+
)
|
|
122
|
+
) { callback ->
|
|
123
|
+
val response = callback?.get("response") as? String
|
|
124
|
+
if (response != null) {
|
|
125
|
+
headerRight.toolCallback?.invoke(response)
|
|
126
|
+
}
|
|
143
127
|
}
|
|
144
128
|
}
|
|
145
|
-
// AI-GENERATED END: retain custom tool data and typed callback outcomes
|
|
146
129
|
|
|
147
130
|
fun onPressHelpCenter() {
|
|
148
131
|
if (context == null) return
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
132
|
+
api?.showHelpCenter(
|
|
133
|
+
mapOf(
|
|
134
|
+
"appId" to context.appId,
|
|
135
|
+
"code" to context.appCode,
|
|
136
|
+
"name" to context.appName,
|
|
137
|
+
"icon" to context.appIcon,
|
|
138
|
+
"description" to context.description
|
|
139
|
+
)
|
|
140
|
+
) {}
|
|
153
141
|
}
|
|
154
142
|
|
|
155
143
|
fun onPressClose() {
|
|
156
|
-
|
|
157
|
-
api?.dismiss(if (headerRight.useCloseIcon) DismissTarget.Current() else DismissTarget.All) {}
|
|
158
|
-
// AI-GENERATED END: preserve current-container and whole-stack dismissal
|
|
144
|
+
if (headerRight.useCloseIcon) api?.dismiss { } else api?.dismissAll { }
|
|
159
145
|
}
|
|
160
146
|
|
|
161
147
|
val useHelpCenter = usesHelpCenter(context)
|
|
@@ -8,13 +8,13 @@ import androidx.compose.ui.text.style.TextAlign
|
|
|
8
8
|
import androidx.compose.ui.text.style.TextOverflow
|
|
9
9
|
import androidx.compose.ui.unit.sp
|
|
10
10
|
import androidx.compose.ui.zIndex
|
|
11
|
+
import vn.momo.kits.application.DesignSystemKits
|
|
11
12
|
import vn.momo.kits.components.Text
|
|
12
|
-
import vn.momo.kits.const.KitDesignSystem
|
|
13
13
|
import vn.momo.kits.const.Typography
|
|
14
14
|
import vn.momo.kits.modifier.setAutomationId
|
|
15
15
|
|
|
16
16
|
internal val headerFontFamily: String?
|
|
17
|
-
get() = if (
|
|
17
|
+
get() = if (DesignSystemKits.getConfigs().isWhiteList) "MoMoTrustDisplay" else null
|
|
18
18
|
|
|
19
19
|
@Composable
|
|
20
20
|
internal fun HeaderTitle(
|
|
@@ -2,12 +2,6 @@ package vn.momo.kits.navigation.tracking
|
|
|
2
2
|
|
|
3
3
|
import vn.momo.kits.application.MiniAppContext
|
|
4
4
|
import vn.momo.maxapi.IMaxApi
|
|
5
|
-
// AI-GENERATED START: serialize tracking attributes with their existing value types
|
|
6
|
-
import kotlinx.serialization.json.JsonNull
|
|
7
|
-
import kotlinx.serialization.json.JsonElement
|
|
8
|
-
import kotlinx.serialization.json.JsonObject
|
|
9
|
-
import kotlinx.serialization.json.JsonPrimitive
|
|
10
|
-
// AI-GENERATED END: serialize tracking attributes with their existing value types
|
|
11
5
|
import kotlin.time.Clock
|
|
12
6
|
import kotlin.time.ExperimentalTime
|
|
13
7
|
|
|
@@ -21,7 +15,6 @@ class ScreenTrackingState {
|
|
|
21
15
|
var action: String = "push"
|
|
22
16
|
}
|
|
23
17
|
|
|
24
|
-
// AI-GENERATED START: retain screen event names and typed tracking attributes
|
|
25
18
|
object ScreenTracker {
|
|
26
19
|
|
|
27
20
|
private var lastScreenName: String? = null
|
|
@@ -38,13 +31,13 @@ object ScreenTracker {
|
|
|
38
31
|
val previousScreen = lastScreenName
|
|
39
32
|
lastScreenName = screenName
|
|
40
33
|
|
|
41
|
-
maxApi?.
|
|
34
|
+
maxApi?.track(
|
|
42
35
|
eventName = "auto_screen_navigated",
|
|
43
|
-
|
|
44
|
-
put("pre_screen_name",
|
|
45
|
-
put("state",
|
|
46
|
-
put("action",
|
|
47
|
-
}
|
|
36
|
+
params = buildBaseParams(context, screenName).apply {
|
|
37
|
+
put("pre_screen_name", previousScreen)
|
|
38
|
+
put("state", "navigated")
|
|
39
|
+
put("action", action)
|
|
40
|
+
}
|
|
48
41
|
)
|
|
49
42
|
|
|
50
43
|
state.releaseNavigated = true
|
|
@@ -60,12 +53,12 @@ object ScreenTracker {
|
|
|
60
53
|
) {
|
|
61
54
|
if (state.releaseLoad) return
|
|
62
55
|
|
|
63
|
-
maxApi?.
|
|
56
|
+
maxApi?.track(
|
|
64
57
|
eventName = "auto_screen_displayed",
|
|
65
|
-
|
|
66
|
-
put("state",
|
|
67
|
-
put("duration",
|
|
68
|
-
}
|
|
58
|
+
params = buildBaseParams(context, screenName).apply {
|
|
59
|
+
put("state", "load")
|
|
60
|
+
put("duration", duration)
|
|
61
|
+
}
|
|
69
62
|
)
|
|
70
63
|
|
|
71
64
|
state.releaseLoad = true
|
|
@@ -81,13 +74,13 @@ object ScreenTracker {
|
|
|
81
74
|
) {
|
|
82
75
|
if (state.releaseInteraction) return
|
|
83
76
|
|
|
84
|
-
maxApi?.
|
|
77
|
+
maxApi?.track(
|
|
85
78
|
eventName = "auto_screen_interacted",
|
|
86
|
-
|
|
87
|
-
put("state",
|
|
88
|
-
put("duration",
|
|
89
|
-
put("total_duration",
|
|
90
|
-
}
|
|
79
|
+
params = buildBaseParams(context, screenName).apply {
|
|
80
|
+
put("state", "interaction")
|
|
81
|
+
put("duration", duration)
|
|
82
|
+
put("total_duration", totalDuration)
|
|
83
|
+
}
|
|
91
84
|
)
|
|
92
85
|
|
|
93
86
|
state.releaseInteraction = true
|
|
@@ -97,13 +90,13 @@ object ScreenTracker {
|
|
|
97
90
|
context: MiniAppContext?,
|
|
98
91
|
screenName: String,
|
|
99
92
|
componentName: String = "Screen"
|
|
100
|
-
): MutableMap<String,
|
|
93
|
+
): MutableMap<String, Any?> {
|
|
101
94
|
return mutableMapOf(
|
|
102
|
-
"app_id" to
|
|
103
|
-
"feature_code" to
|
|
104
|
-
"screen_name" to
|
|
105
|
-
"component_name" to
|
|
106
|
-
"tracking_source" to
|
|
95
|
+
"app_id" to context?.appId,
|
|
96
|
+
"feature_code" to context?.appCode,
|
|
97
|
+
"screen_name" to screenName,
|
|
98
|
+
"component_name" to componentName,
|
|
99
|
+
"tracking_source" to 1
|
|
107
100
|
)
|
|
108
101
|
}
|
|
109
102
|
|
|
@@ -112,16 +105,16 @@ object ScreenTracker {
|
|
|
112
105
|
context: MiniAppContext?,
|
|
113
106
|
parentScreenName: String?
|
|
114
107
|
) {
|
|
115
|
-
maxApi?.
|
|
108
|
+
maxApi?.track(
|
|
116
109
|
eventName = "auto_popup_displayed",
|
|
117
|
-
|
|
118
|
-
"screen_name" to
|
|
119
|
-
"tracking_source" to
|
|
120
|
-
"app_id" to
|
|
121
|
-
"feature_code" to
|
|
122
|
-
"kits_version" to
|
|
123
|
-
"component_name" to
|
|
124
|
-
)
|
|
110
|
+
params = mutableMapOf<String, Any?>(
|
|
111
|
+
"screen_name" to parentScreenName,
|
|
112
|
+
"tracking_source" to 1,
|
|
113
|
+
"app_id" to context?.appId,
|
|
114
|
+
"feature_code" to context?.appCode,
|
|
115
|
+
"kits_version" to null,
|
|
116
|
+
"component_name" to "Modal"
|
|
117
|
+
)
|
|
125
118
|
)
|
|
126
119
|
}
|
|
127
120
|
|
|
@@ -132,4 +125,3 @@ object ScreenTracker {
|
|
|
132
125
|
lastScreenName = null
|
|
133
126
|
}
|
|
134
127
|
}
|
|
135
|
-
// AI-GENERATED END: retain screen event names and typed tracking attributes
|
|
@@ -29,6 +29,7 @@ internal fun ComposeLottieAnimation(
|
|
|
29
29
|
isPlaying: Boolean,
|
|
30
30
|
onEvent: ((String) -> Unit)?,
|
|
31
31
|
modifier: Modifier,
|
|
32
|
+
progress: (() -> Float)? = null,
|
|
32
33
|
) {
|
|
33
34
|
val json = readJson(path)
|
|
34
35
|
|
|
@@ -55,7 +56,7 @@ internal fun ComposeLottieAnimation(
|
|
|
55
56
|
val lottieState = animateLottieCompositionAsState(
|
|
56
57
|
composition = composition,
|
|
57
58
|
iterations = iterations,
|
|
58
|
-
isPlaying = isPlaying,
|
|
59
|
+
isPlaying = isPlaying && progress == null,
|
|
59
60
|
restartOnPlay = false,
|
|
60
61
|
)
|
|
61
62
|
|
|
@@ -77,7 +78,7 @@ internal fun ComposeLottieAnimation(
|
|
|
77
78
|
Image(
|
|
78
79
|
painter = rememberLottiePainter(
|
|
79
80
|
composition = composition,
|
|
80
|
-
progress = lottieState::value,
|
|
81
|
+
progress = progress ?: lottieState::value,
|
|
81
82
|
dynamicProperties = dynamicProperties,
|
|
82
83
|
enableExpressions = false,
|
|
83
84
|
expressionEngineFactory = { _, _ ->
|
|
@@ -66,7 +66,9 @@ expect fun LottieAnimation(
|
|
|
66
66
|
isPlaying: Boolean = true,
|
|
67
67
|
onEvent: ((String) -> Unit)? = null,
|
|
68
68
|
modifier: Modifier = Modifier,
|
|
69
|
-
useCompose: Boolean = false
|
|
69
|
+
useCompose: Boolean = false,
|
|
70
|
+
// drives the animation instead of playing it, so several animations stay in sync; needs useCompose
|
|
71
|
+
progress: (() -> Float)? = null,
|
|
70
72
|
)
|
|
71
73
|
|
|
72
74
|
expect fun NativePaint.setColor(
|
|
@@ -7,7 +7,16 @@ 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
|
-
//
|
|
11
|
-
// iPhone Duo camera, and the status bar cluster as it grows for a call or a Live Activity.
|
|
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
|
+
@Immutable
|
|
15
|
+
internal data class ReservedRegions(
|
|
16
|
+
val occlusion: List<ReservedRegion> = emptyList(),
|
|
17
|
+
val isFoldable: Boolean = false,
|
|
18
|
+
val division: ReservedRegion? = null,
|
|
19
|
+
)
|
|
20
|
+
|
|
12
21
|
@Composable
|
|
13
|
-
internal expect fun rememberReservedRegions():
|
|
22
|
+
internal expect fun rememberReservedRegions(): ReservedRegions
|
|
@@ -5,6 +5,7 @@ package vn.momo.kits.const
|
|
|
5
5
|
import androidx.compose.runtime.Composable
|
|
6
6
|
import androidx.compose.runtime.remember
|
|
7
7
|
import androidx.compose.ui.text.font.FontFamily
|
|
8
|
+
import androidx.compose.ui.text.font.FontWeight
|
|
8
9
|
import androidx.compose.ui.text.platform.Font
|
|
9
10
|
import kotlinx.cinterop.ExperimentalForeignApi
|
|
10
11
|
import kotlinx.cinterop.addressOf
|
|
@@ -15,7 +16,7 @@ import platform.Foundation.dataWithContentsOfFile
|
|
|
15
16
|
import platform.posix.memcpy
|
|
16
17
|
|
|
17
18
|
@Composable
|
|
18
|
-
internal actual fun hostFontFamily(fileName: String): FontFamily? = remember(fileName) {
|
|
19
|
+
internal actual fun hostFontFamily(fileName: String, weight: FontWeight): FontFamily? = remember(fileName, weight) {
|
|
19
20
|
val name = fileName.substringBeforeLast('.')
|
|
20
21
|
val ext = fileName.substringAfterLast('.', "")
|
|
21
22
|
// Font từ font-source nằm rời ở bundle root, không nằm trong compose-resources.
|
|
@@ -26,6 +27,7 @@ internal actual fun hostFontFamily(fileName: String): FontFamily? = remember(fil
|
|
|
26
27
|
getData = {
|
|
27
28
|
NSData.dataWithContentsOfFile(path)?.toByteArray() ?: ByteArray(0)
|
|
28
29
|
},
|
|
30
|
+
weight = weight,
|
|
29
31
|
),
|
|
30
32
|
)
|
|
31
33
|
}
|
|
@@ -12,9 +12,7 @@ private const val STATUS_BAR_TAPPED_NOTIFICATION = "statusBarSelected"
|
|
|
12
12
|
@Composable
|
|
13
13
|
internal actual fun RegisterScrollToTop(callback: (() -> Unit)?) {
|
|
14
14
|
val maxApi = LocalMaxApi.current
|
|
15
|
-
|
|
16
|
-
DisposableEffect(callback, maxApi) {
|
|
17
|
-
// AI-GENERATED END: capture the current typed logger client
|
|
15
|
+
DisposableEffect(callback) {
|
|
18
16
|
val token: NSObjectProtocol? = if (callback != null) {
|
|
19
17
|
NSNotificationCenter.defaultCenter.addObserverForName(
|
|
20
18
|
name = STATUS_BAR_TAPPED_NOTIFICATION,
|
|
@@ -22,9 +20,7 @@ internal actual fun RegisterScrollToTop(callback: (() -> Unit)?) {
|
|
|
22
20
|
queue = NSOperationQueue.mainQueue,
|
|
23
21
|
) { _: NSNotification? ->
|
|
24
22
|
runCatching { callback() }.onFailure {
|
|
25
|
-
|
|
26
|
-
maxApi?.writeLog("[ScrollToTop] callback threw: ${it.message}")
|
|
27
|
-
// AI-GENERATED END: use typed host logging
|
|
23
|
+
maxApi?.logFile("[ScrollToTop] callback threw: ${it.message}") {}
|
|
28
24
|
|
|
29
25
|
}
|
|
30
26
|
}
|
|
@@ -21,6 +21,8 @@ import androidx.compose.ui.backhandler.BackHandler as ComposeBackHandler
|
|
|
21
21
|
import androidx.compose.ui.graphics.Color
|
|
22
22
|
import androidx.compose.ui.graphics.NativePaint
|
|
23
23
|
import androidx.compose.ui.graphics.toArgb
|
|
24
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
25
|
+
import androidx.compose.ui.platform.LocalWindowInfo
|
|
24
26
|
import androidx.compose.ui.unit.Dp
|
|
25
27
|
import androidx.compose.ui.unit.dp
|
|
26
28
|
import androidx.compose.ui.viewinterop.UIKitInteropProperties
|
|
@@ -29,8 +31,6 @@ import cocoapods.lottie_ios.CompatibleAnimation
|
|
|
29
31
|
import cocoapods.lottie_ios.CompatibleAnimationKeypath
|
|
30
32
|
import cocoapods.lottie_ios.CompatibleAnimationView
|
|
31
33
|
import kotlinx.cinterop.ExperimentalForeignApi
|
|
32
|
-
import kotlinx.cinterop.get
|
|
33
|
-
import kotlinx.cinterop.memScoped
|
|
34
34
|
import androidx.navigationevent.NavigationEventDispatcher
|
|
35
35
|
import androidx.navigationevent.NavigationEventDispatcherOwner
|
|
36
36
|
import org.jetbrains.skia.FilterBlurMode
|
|
@@ -38,7 +38,6 @@ import org.jetbrains.skia.MaskFilter
|
|
|
38
38
|
import platform.Foundation.NSBundle
|
|
39
39
|
import platform.UIKit.UIColor
|
|
40
40
|
import platform.UIKit.UIDevice
|
|
41
|
-
import platform.UIKit.UIScreen
|
|
42
41
|
import platform.UIKit.UIUserInterfaceIdiomPhone
|
|
43
42
|
import vn.momo.kits.navigation.AttachHostBackGesture
|
|
44
43
|
import vn.momo.kits.navigation.Navigator
|
|
@@ -48,15 +47,17 @@ actual fun getPlatformName(): String = "iOS"
|
|
|
48
47
|
actual fun isPhoneIdiom(): Boolean =
|
|
49
48
|
UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
// AI-GENERATED START: window size, not UIScreen.main (stays on one display on iPhone Duo); recomposes on fold/unfold
|
|
52
51
|
@Composable
|
|
53
|
-
actual fun getScreenDimensions(): ScreenDimension
|
|
54
|
-
val
|
|
52
|
+
actual fun getScreenDimensions(): ScreenDimension {
|
|
53
|
+
val density = LocalDensity.current
|
|
54
|
+
val size = LocalWindowInfo.current.containerSize
|
|
55
55
|
return ScreenDimension(
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
(size.width / density.density).toInt(),
|
|
57
|
+
(size.height / density.density).toInt()
|
|
58
58
|
)
|
|
59
59
|
}
|
|
60
|
+
// AI-GENERATED END: window size, not UIScreen.main (stays on one display on iPhone Duo); recomposes on fold/unfold
|
|
60
61
|
|
|
61
62
|
actual fun NativePaint.setMaskFilter(blurRadius: Float) {
|
|
62
63
|
this.maskFilter = MaskFilter.makeBlur(FilterBlurMode.NORMAL, blurRadius / 2, true)
|
|
@@ -111,10 +112,11 @@ actual fun LottieAnimation(
|
|
|
111
112
|
isPlaying: Boolean,
|
|
112
113
|
onEvent: ((String) -> Unit)?,
|
|
113
114
|
modifier: Modifier,
|
|
114
|
-
useCompose: Boolean
|
|
115
|
+
useCompose: Boolean,
|
|
116
|
+
progress: (() -> Float)?,
|
|
115
117
|
) {
|
|
116
118
|
if (useCompose) {
|
|
117
|
-
ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier)
|
|
119
|
+
ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier, progress)
|
|
118
120
|
return
|
|
119
121
|
}
|
|
120
122
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
package vn.momo.kits.platform
|
|
2
|
+
|
|
3
|
+
import androidx.compose.runtime.Composable
|
|
4
|
+
import androidx.compose.runtime.DisposableEffect
|
|
5
|
+
import androidx.compose.runtime.mutableStateOf
|
|
6
|
+
import androidx.compose.runtime.remember
|
|
7
|
+
import kotlinx.cinterop.ExperimentalForeignApi
|
|
8
|
+
import kotlinx.cinterop.ObjCAction
|
|
9
|
+
import platform.Foundation.NSNotification
|
|
10
|
+
import platform.Foundation.NSNotificationCenter
|
|
11
|
+
import platform.Foundation.NSSelectorFromString
|
|
12
|
+
import platform.UIKit.UIAccessibilityIsReduceMotionEnabled
|
|
13
|
+
import platform.UIKit.UIAccessibilityReduceMotionStatusDidChangeNotification
|
|
14
|
+
import platform.darwin.NSObject
|
|
15
|
+
|
|
16
|
+
@OptIn(ExperimentalForeignApi::class)
|
|
17
|
+
@Composable
|
|
18
|
+
actual fun rememberReduceMotion(): Boolean {
|
|
19
|
+
val reduceMotion = remember { mutableStateOf(UIAccessibilityIsReduceMotionEnabled()) }
|
|
20
|
+
|
|
21
|
+
val listener = remember {
|
|
22
|
+
object : NSObject() {
|
|
23
|
+
@Suppress("unused")
|
|
24
|
+
@ObjCAction
|
|
25
|
+
fun reduceMotionChanged(arg: NSNotification) {
|
|
26
|
+
reduceMotion.value = UIAccessibilityIsReduceMotionEnabled()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
DisposableEffect(Unit) {
|
|
32
|
+
NSNotificationCenter.defaultCenter.addObserver(
|
|
33
|
+
observer = listener,
|
|
34
|
+
selector = NSSelectorFromString(listener::reduceMotionChanged.name + ":"),
|
|
35
|
+
name = UIAccessibilityReduceMotionStatusDidChangeNotification,
|
|
36
|
+
`object` = null,
|
|
37
|
+
)
|
|
38
|
+
onDispose {
|
|
39
|
+
NSNotificationCenter.defaultCenter.removeObserver(
|
|
40
|
+
observer = listener,
|
|
41
|
+
name = UIAccessibilityReduceMotionStatusDidChangeNotification,
|
|
42
|
+
`object` = null,
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return reduceMotion.value
|
|
48
|
+
}
|