@momo-kits/native-kits 0.300.7-debug → 0.300.8-beta.1-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 +12 -8
- package/README.md +8 -7
- package/compose/build.gradle.kts +2 -4
- package/compose/build.gradle.kts.backup +1 -3
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +1 -2
- 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/commonMain/kotlin/vn/momo/kits/application/Context.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +60 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +20 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +5 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +7 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +18 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +13 -73
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +1 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -53
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +3 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +12 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +17 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +20 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +83 -82
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +6 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +9 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +13 -35
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +5 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +6 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +3 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +22 -50
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +18 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +123 -64
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +24 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +59 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +69 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +5 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +43 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +330 -149
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +87 -70
- 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 +92 -261
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +31 -40
- 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 +46 -72
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +8 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +29 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +8 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +9 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +26 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
- 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 +4 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +2 -3
- package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +44 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +2 -7
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +9 -18
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +1 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +3 -6
- 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 +12 -12
- 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 +11 -6
- package/gradle/libs.versions.toml +1 -3
- package/gradle.properties +1 -3
- package/ios/Application/ApplicationEnvironment.swift +6 -4
- package/ios/Application/DesignSystemKits.swift +59 -13
- package/ios/Application/DesignSystemKitsPayload.swift +0 -8
- package/ios/Application/LanguageSource.swift +2 -11
- package/ios/Application/Localize.swift +8 -35
- package/ios/Application/LocalizeModifier.swift +2 -11
- package/ios/Application/MaxApi.swift +3 -11
- package/ios/Avatar/Avatar.swift +0 -1
- package/ios/Badge/Badge.swift +5 -8
- package/ios/Badge/BadgeRibbon.swift +2 -5
- package/ios/Button/Button.swift +4 -8
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
- package/ios/Carousel/Carousel.swift +4 -17
- package/ios/Checkbox/Checkbox.swift +0 -2
- package/ios/Collapse/Collapse.swift +17 -11
- package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
- package/ios/DateTimePicker/DateTimePicker.swift +4 -10
- package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
- package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
- package/ios/DateTimePicker/WheelPicker.swift +2 -4
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Extensions/SkeletonUICompat.swift +0 -8
- package/ios/Icon/Icon.swift +3 -6
- package/ios/IconButton/IconButton.swift +2 -5
- package/ios/Input/ErrorView.swift +0 -7
- package/ios/Input/Input.swift +9 -20
- package/ios/Input/InputPhoneNumber.swift +37 -20
- package/ios/Input/InputSearch.swift +23 -12
- package/ios/Input/InputTextArea.swift +4 -13
- package/ios/InputDropDown/InputDropDown.swift +1 -11
- package/ios/InputMoney/InputMoney.swift +9 -28
- package/ios/InputOTP/InputOTP.swift +2 -9
- package/ios/Layout/HeaderLayout.swift +72 -0
- package/ios/Layout/Item.swift +1 -2
- package/ios/Layout/ModalLayout.swift +144 -0
- package/ios/Layout/ScreenLayout.swift +48 -31
- package/ios/Layout/Section.swift +2 -3
- package/ios/Loader/Loader.swift +3 -12
- package/ios/Lottie/LottieView.swift +0 -11
- package/ios/Navigation/BottomSheet.swift +73 -94
- package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
- package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
- package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
- package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
- package/ios/Navigation/Component/FloatingButton.swift +4 -11
- package/ios/Navigation/Component/Header.swift +35 -54
- package/ios/Navigation/Component/HeaderBackground.swift +2 -8
- package/ios/Navigation/Component/HeaderJourney.swift +4 -8
- package/ios/Navigation/Component/HeaderLocation.swift +4 -8
- package/ios/Navigation/Component/HeaderRight.swift +20 -22
- package/ios/Navigation/Component/HeaderTitle.swift +1 -6
- package/ios/Navigation/Component/HeaderUser.swift +4 -10
- package/ios/Navigation/Component/SideBar.swift +6 -21
- package/ios/Navigation/Component/SnackBar.swift +9 -13
- package/ios/Navigation/HostBackGestureBridge.swift +2 -9
- package/ios/Navigation/ModalScreen.swift +24 -13
- package/ios/Navigation/Navigation.swift +35 -19
- package/ios/Navigation/NavigationContainer.swift +4 -15
- package/ios/Navigation/Navigator.swift +21 -39
- package/ios/Navigation/StackScreen.swift +64 -51
- package/ios/Navigation/StackTransition.swift +7 -14
- package/ios/Navigation/SwipeBackHaptic.swift +2 -7
- package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
- package/ios/Pagination/PaginationDot.swift +0 -9
- package/ios/Pagination/PaginationNumber.swift +1 -9
- package/ios/Pagination/PaginationScroll.swift +2 -14
- package/ios/Pagination/PaginationWhiteDot.swift +1 -10
- package/ios/Popup/PopupDisplay.swift +7 -5
- package/ios/Popup/PopupInput.swift +6 -4
- package/ios/Popup/PopupLayout.swift +17 -9
- package/ios/Popup/PopupNotify.swift +32 -25
- package/ios/PopupView/FullscreenPopup.swift +3 -4
- package/ios/PopupView/PopupView.swift +2 -2
- package/ios/PopupView/Utils++.swift +1 -2
- package/ios/ProgressInfo/ProgressInfo.swift +2 -13
- package/ios/Skeleton/Skeleton.swift +5 -16
- package/ios/Slider/Slider.swift +5 -12
- package/ios/StatusBarTap/StatusBarTap.h +2 -3
- package/ios/StatusBarTap/StatusBarTap.m +3 -16
- package/ios/Stepper/Stepper.swift +8 -27
- package/ios/Steps/Steps.swift +29 -26
- package/ios/Swipeable/SwipeCell.swift +2 -2
- package/ios/Swipeable/SwipeCellModel.swift +3 -6
- package/ios/TabView/TabView.swift +14 -28
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
- package/ios/Title/Title.swift +1 -3
- package/ios/Tooltip/Tooltip.swift +4 -9
- package/ios/Typography/FontScale.swift +79 -24
- package/ios/Typography/Text.swift +6 -12
- package/ios/Typography/Typography.swift +8 -11
- package/ios/Uploader/Uploader.swift +2 -17
- 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/AnimatedHeaderDemo.swift +11 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
- package/package.json +1 -1
- package/publish.sh +8 -2
- package/scripts/ci/build-swiftui.sh +22 -0
- package/scripts/ci/resolve-version.mjs +144 -0
- package/settings.gradle.kts +0 -1
|
@@ -15,6 +15,7 @@ import androidx.compose.foundation.layout.width
|
|
|
15
15
|
import androidx.compose.foundation.shape.CircleShape
|
|
16
16
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
17
17
|
import androidx.compose.runtime.Composable
|
|
18
|
+
import androidx.compose.runtime.CompositionLocalProvider
|
|
18
19
|
import androidx.compose.runtime.LaunchedEffect
|
|
19
20
|
import androidx.compose.ui.AbsoluteAlignment
|
|
20
21
|
import androidx.compose.ui.Alignment
|
|
@@ -52,10 +53,18 @@ internal fun BoxScope.HeaderSideBar(bottomInset: Dp, modifier: Modifier = Modifi
|
|
|
52
53
|
val navigator = LocalNavigator.current
|
|
53
54
|
val screenLayout = getScreenLayout()
|
|
54
55
|
val sideBar = screenLayout.sideBar ?: return
|
|
55
|
-
val
|
|
56
|
-
val
|
|
56
|
+
val headerRight = options.headerRight
|
|
57
|
+
val toolkit = headerRight as? HeaderRight.Toolkit
|
|
58
|
+
// a custom header right also lives in the side column on Duo, where the toolkit does
|
|
59
|
+
val hasRight = toolkit != null || headerRight is HeaderRight.Custom
|
|
60
|
+
val empty = options.headerType == HeaderType.None || (options.hiddenBack && !hasRight)
|
|
57
61
|
val compression = LocalDuoBarCompression.current
|
|
58
|
-
val
|
|
62
|
+
val rightHeight = toolkit?.let { toolkitColumnHeight(it) }
|
|
63
|
+
?: if (headerRight is HeaderRight.Custom) DuoMetrics.controlSize else 0.dp
|
|
64
|
+
// with the back button hidden the header right rises to the top of the column, so drop the back slot and its gap
|
|
65
|
+
val backHeight = if (options.hiddenBack) 0.dp else DuoMetrics.controlSize
|
|
66
|
+
val gap = if (!options.hiddenBack && hasRight) Spacing.M else 0.dp
|
|
67
|
+
val fullHeight = if (empty) 0.dp else backHeight + gap + (if (hasRight) rightHeight else 0.dp)
|
|
59
68
|
LaunchedEffect(fullHeight, compression.setToolbarHeight) { compression.setToolbarHeight(fullHeight) }
|
|
60
69
|
if (empty) return
|
|
61
70
|
|
|
@@ -78,10 +87,7 @@ internal fun BoxScope.HeaderSideBar(bottomInset: Dp, modifier: Modifier = Modifi
|
|
|
78
87
|
horizontalAlignment = if (isRight) AbsoluteAlignment.Left else AbsoluteAlignment.Right,
|
|
79
88
|
verticalArrangement = Arrangement.spacedBy(Spacing.M),
|
|
80
89
|
) {
|
|
81
|
-
if (options.hiddenBack) {
|
|
82
|
-
// keep the slot so the toolkit does not jump between root and pushed screens
|
|
83
|
-
Spacer(Modifier.size(DuoMetrics.controlSize))
|
|
84
|
-
} else {
|
|
90
|
+
if (!options.hiddenBack) {
|
|
85
91
|
SideBarButton(
|
|
86
92
|
icon = "arrow-back",
|
|
87
93
|
headerColor = headerColor,
|
|
@@ -90,7 +96,13 @@ internal fun BoxScope.HeaderSideBar(bottomInset: Dp, modifier: Modifier = Modifi
|
|
|
90
96
|
)
|
|
91
97
|
}
|
|
92
98
|
when {
|
|
93
|
-
|
|
99
|
+
!hasRight || compression.toolbarHidden -> Unit
|
|
100
|
+
// a custom header right follows the header colors, centered on the control lane so it lines up with the back button
|
|
101
|
+
toolkit == null -> CompositionLocalProvider(LocalHeaderColor provides headerColor) {
|
|
102
|
+
Box(Modifier.width(DuoMetrics.controlSize), contentAlignment = Alignment.Center) {
|
|
103
|
+
HeaderRight(headerRight, options.tintColor, headerColor)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
94
106
|
// HIG "Toolbar compressed": tools fold into one button, distinct from the useMore icon
|
|
95
107
|
compression.toolbarCompressed -> SideBarButton(
|
|
96
108
|
icon = "navigation_menu",
|
|
@@ -138,25 +150,18 @@ internal fun SideBarButton(
|
|
|
138
150
|
}
|
|
139
151
|
}
|
|
140
152
|
|
|
141
|
-
//
|
|
153
|
+
// Vertical capsule grouping related side bar controls, one item per 50pt.
|
|
142
154
|
@Composable
|
|
143
155
|
internal fun SideBarGroup(
|
|
144
156
|
headerColor: HeaderColor,
|
|
145
157
|
itemCount: Int,
|
|
146
|
-
horizontal: Boolean = false,
|
|
147
158
|
content: @Composable (itemModifier: Modifier) -> Unit,
|
|
148
159
|
) {
|
|
149
160
|
val length = if (itemCount > 1) DuoMetrics.itemPitch * itemCount else DuoMetrics.controlSize
|
|
150
161
|
val item = length / itemCount.coerceAtLeast(1)
|
|
151
162
|
val glass = Modifier.sideBarGlass(headerColor, RoundedCornerShape(Radius.XL))
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
content(Modifier.size(width = item, height = DuoMetrics.controlSize))
|
|
155
|
-
}
|
|
156
|
-
} else {
|
|
157
|
-
Column(Modifier.size(width = DuoMetrics.controlSize, height = length).then(glass)) {
|
|
158
|
-
content(Modifier.size(width = DuoMetrics.controlSize, height = item))
|
|
159
|
-
}
|
|
163
|
+
Column(Modifier.size(width = DuoMetrics.controlSize, height = length).then(glass)) {
|
|
164
|
+
content(Modifier.size(width = DuoMetrics.controlSize, height = item))
|
|
160
165
|
}
|
|
161
166
|
}
|
|
162
167
|
|
|
@@ -180,13 +185,13 @@ internal fun SideBarGroupItem(
|
|
|
180
185
|
|
|
181
186
|
// Dark glass under light icons (banner headers), light glass otherwise. The light one is opaque:
|
|
182
187
|
// Compose has no backdrop blur and a translucent fill shows its own shadow through (RN uses 85% white).
|
|
183
|
-
private fun Modifier.sideBarGlass(headerColor: HeaderColor, shape: Shape): Modifier
|
|
188
|
+
private fun Modifier.sideBarGlass(headerColor: HeaderColor, shape: Shape): Modifier {
|
|
184
189
|
if (headerColor.tintIconColor == Colors.black_01) {
|
|
185
|
-
clip(shape)
|
|
190
|
+
return clip(shape)
|
|
186
191
|
.background(Colors.black_20.copy(alpha = 0.5f))
|
|
187
192
|
.border(0.5.dp, Colors.black_01.copy(alpha = 0.2f), shape)
|
|
188
|
-
} else {
|
|
189
|
-
shadow(3.dp, shape)
|
|
190
|
-
.background(Colors.black_01)
|
|
191
|
-
.border(0.5.dp, Colors.black_20.copy(alpha = 0.08f), shape)
|
|
192
193
|
}
|
|
194
|
+
return shadow(3.dp, shape)
|
|
195
|
+
.background(Colors.black_01)
|
|
196
|
+
.border(0.5.dp, Colors.black_20.copy(alpha = 0.08f), shape)
|
|
197
|
+
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
// File: ToolkitRequests.kt
|
|
2
2
|
// Created At: 2026-10-12 +07:00 | Created By: AI | AI Agent: Codex | Model: GPT-6
|
|
3
|
-
// AI-GENERATED START: cancel only toolkit requests owned by this composition
|
|
4
3
|
package vn.momo.kits.navigation.component
|
|
5
4
|
|
|
6
|
-
import vn.momo.
|
|
7
|
-
import vn.momo.maxapi.runtime.ApiRequestHandle
|
|
5
|
+
import vn.momo.kits.application.KitsRequest
|
|
8
6
|
|
|
7
|
+
// Cancels only the toolkit requests owned by this composition and drops their late callbacks.
|
|
9
8
|
internal class ToolkitRequests {
|
|
10
9
|
private var active = true
|
|
11
|
-
private val handles = mutableSetOf<
|
|
10
|
+
private val handles = mutableSetOf<KitsRequest>()
|
|
12
11
|
|
|
13
|
-
fun <T> launch(request: (
|
|
12
|
+
fun <T> launch(request: ((T) -> Unit) -> KitsRequest, onResult: (T) -> Unit) {
|
|
14
13
|
if (!active) return
|
|
15
14
|
var completed = false
|
|
16
|
-
var handle:
|
|
15
|
+
var handle: KitsRequest? = null
|
|
17
16
|
val created = request { result ->
|
|
18
17
|
completed = true
|
|
19
18
|
handle?.let(handles::remove)
|
|
@@ -23,13 +22,12 @@ internal class ToolkitRequests {
|
|
|
23
22
|
if (!active) created.cancel() else if (!completed) handles.add(created)
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
//
|
|
27
|
-
fun
|
|
25
|
+
// Subscriptions outlive nonterminal sheet events, so they are released only on close.
|
|
26
|
+
fun observe(request: () -> KitsRequest) {
|
|
28
27
|
if (!active) return
|
|
29
|
-
val handle = request
|
|
28
|
+
val handle = request()
|
|
30
29
|
if (active) handles.add(handle) else handle.cancel()
|
|
31
30
|
}
|
|
32
|
-
// AI-GENERATED END: retain subscriptions across nonterminal sheet events
|
|
33
31
|
|
|
34
32
|
fun close() {
|
|
35
33
|
active = false
|
|
@@ -38,4 +36,3 @@ internal class ToolkitRequests {
|
|
|
38
36
|
pending.forEach { it.cancel() }
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
|
-
// AI-GENERATED END: cancel only toolkit requests owned by this composition
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
package vn.momo.kits.navigation.tracking
|
|
2
2
|
|
|
3
3
|
import vn.momo.kits.application.MiniAppContext
|
|
4
|
-
import vn.momo.
|
|
4
|
+
import vn.momo.kits.application.KitsBinding
|
|
5
5
|
// AI-GENERATED START: serialize tracking attributes with their existing value types
|
|
6
6
|
import kotlinx.serialization.json.JsonNull
|
|
7
7
|
import kotlinx.serialization.json.JsonElement
|
|
@@ -27,7 +27,7 @@ object ScreenTracker {
|
|
|
27
27
|
private var lastScreenName: String? = null
|
|
28
28
|
|
|
29
29
|
fun trackScreenNavigated(
|
|
30
|
-
|
|
30
|
+
binding: KitsBinding?,
|
|
31
31
|
context: MiniAppContext?,
|
|
32
32
|
screenName: String,
|
|
33
33
|
action: String,
|
|
@@ -38,7 +38,7 @@ object ScreenTracker {
|
|
|
38
38
|
val previousScreen = lastScreenName
|
|
39
39
|
lastScreenName = screenName
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
binding?.trackEvent(
|
|
42
42
|
eventName = "auto_screen_navigated",
|
|
43
43
|
attributes = JsonObject(buildBaseParams(context, screenName).apply {
|
|
44
44
|
put("pre_screen_name", JsonPrimitive(previousScreen))
|
|
@@ -52,7 +52,7 @@ object ScreenTracker {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
fun trackScreenDisplayed(
|
|
55
|
-
|
|
55
|
+
binding: KitsBinding?,
|
|
56
56
|
context: MiniAppContext?,
|
|
57
57
|
screenName: String,
|
|
58
58
|
duration: Long,
|
|
@@ -60,7 +60,7 @@ object ScreenTracker {
|
|
|
60
60
|
) {
|
|
61
61
|
if (state.releaseLoad) return
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
binding?.trackEvent(
|
|
64
64
|
eventName = "auto_screen_displayed",
|
|
65
65
|
attributes = JsonObject(buildBaseParams(context, screenName).apply {
|
|
66
66
|
put("state", JsonPrimitive("load"))
|
|
@@ -72,7 +72,7 @@ object ScreenTracker {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
fun trackScreenInteracted(
|
|
75
|
-
|
|
75
|
+
binding: KitsBinding?,
|
|
76
76
|
context: MiniAppContext?,
|
|
77
77
|
screenName: String,
|
|
78
78
|
duration: Long,
|
|
@@ -81,7 +81,7 @@ object ScreenTracker {
|
|
|
81
81
|
) {
|
|
82
82
|
if (state.releaseInteraction) return
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
binding?.trackEvent(
|
|
85
85
|
eventName = "auto_screen_interacted",
|
|
86
86
|
attributes = JsonObject(buildBaseParams(context, screenName).apply {
|
|
87
87
|
put("state", JsonPrimitive("interaction"))
|
|
@@ -108,11 +108,11 @@ object ScreenTracker {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
fun trackPopupDisplayed(
|
|
111
|
-
|
|
111
|
+
binding: KitsBinding?,
|
|
112
112
|
context: MiniAppContext?,
|
|
113
113
|
parentScreenName: String?
|
|
114
114
|
) {
|
|
115
|
-
|
|
115
|
+
binding?.trackEvent(
|
|
116
116
|
eventName = "auto_popup_displayed",
|
|
117
117
|
attributes = JsonObject(mapOf(
|
|
118
118
|
"screen_name" to JsonPrimitive(parentScreenName),
|
|
@@ -7,8 +7,12 @@ import androidx.compose.foundation.layout.fillMaxSize
|
|
|
7
7
|
import androidx.compose.runtime.Composable
|
|
8
8
|
import androidx.compose.runtime.LaunchedEffect
|
|
9
9
|
import androidx.compose.runtime.getValue
|
|
10
|
+
import androidx.compose.runtime.produceState
|
|
10
11
|
import androidx.compose.runtime.rememberUpdatedState
|
|
11
12
|
import androidx.compose.runtime.snapshotFlow
|
|
13
|
+
import io.ktor.client.HttpClient
|
|
14
|
+
import io.ktor.client.request.get
|
|
15
|
+
import io.ktor.client.statement.bodyAsText
|
|
12
16
|
import androidx.compose.ui.Modifier
|
|
13
17
|
import androidx.compose.ui.graphics.Color
|
|
14
18
|
import io.github.alexzhirkevich.compottie.ExperimentalCompottieApi
|
|
@@ -29,8 +33,14 @@ internal fun ComposeLottieAnimation(
|
|
|
29
33
|
isPlaying: Boolean,
|
|
30
34
|
onEvent: ((String) -> Unit)?,
|
|
31
35
|
modifier: Modifier,
|
|
36
|
+
progress: (() -> Float)? = null,
|
|
32
37
|
) {
|
|
33
|
-
|
|
38
|
+
// a URL is fetched from the CDN (like the Swift LottieView(url:)); otherwise it is a bundled resource
|
|
39
|
+
val json = if (path.startsWith("http", ignoreCase = true)) {
|
|
40
|
+
produceState("", path) { value = fetchLottieJson(path) }.value
|
|
41
|
+
} else {
|
|
42
|
+
readJson(path)
|
|
43
|
+
}
|
|
34
44
|
|
|
35
45
|
if (json.isEmpty()) {
|
|
36
46
|
Box(modifier.background(bgColor ?: Color.Transparent))
|
|
@@ -55,7 +65,7 @@ internal fun ComposeLottieAnimation(
|
|
|
55
65
|
val lottieState = animateLottieCompositionAsState(
|
|
56
66
|
composition = composition,
|
|
57
67
|
iterations = iterations,
|
|
58
|
-
isPlaying = isPlaying,
|
|
68
|
+
isPlaying = isPlaying && progress == null,
|
|
59
69
|
restartOnPlay = false,
|
|
60
70
|
)
|
|
61
71
|
|
|
@@ -77,7 +87,7 @@ internal fun ComposeLottieAnimation(
|
|
|
77
87
|
Image(
|
|
78
88
|
painter = rememberLottiePainter(
|
|
79
89
|
composition = composition,
|
|
80
|
-
progress = lottieState::value,
|
|
90
|
+
progress = progress ?: lottieState::value,
|
|
81
91
|
dynamicProperties = dynamicProperties,
|
|
82
92
|
enableExpressions = false,
|
|
83
93
|
expressionEngineFactory = { _, _ ->
|
|
@@ -89,3 +99,16 @@ internal fun ComposeLottieAnimation(
|
|
|
89
99
|
)
|
|
90
100
|
}
|
|
91
101
|
}
|
|
102
|
+
|
|
103
|
+
private val lottieHttpClient by lazy { HttpClient() }
|
|
104
|
+
private val lottieUrlCache = mutableMapOf<String, String>()
|
|
105
|
+
|
|
106
|
+
/** Downloads a Lottie JSON once per URL (cached); empty on failure so the view just renders nothing. */
|
|
107
|
+
internal suspend fun fetchLottieJson(url: String): String {
|
|
108
|
+
lottieUrlCache[url]?.let { return it }
|
|
109
|
+
return try {
|
|
110
|
+
lottieHttpClient.get(url).bodyAsText().also { lottieUrlCache[url] = it }
|
|
111
|
+
} catch (_: Exception) {
|
|
112
|
+
""
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -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)
|
|
@@ -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,13 +7,14 @@ 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
10
|
@Immutable
|
|
14
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
|
|
15
13
|
val occlusion: List<ReservedRegion> = emptyList(),
|
|
14
|
+
// a `.division` (hinge) region exists: Apple's foldable check
|
|
16
15
|
val isFoldable: Boolean = false,
|
|
16
|
+
// the hinge while half folded; null while flat
|
|
17
|
+
val division: ReservedRegion? = null,
|
|
17
18
|
)
|
|
18
19
|
|
|
19
20
|
@Composable
|
|
@@ -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) {
|
|
@@ -61,7 +60,7 @@ fun formatNumberToMoney(number: Long, currency: String = "đ"): String {
|
|
|
61
60
|
if (number < 0) {
|
|
62
61
|
isNegative = true
|
|
63
62
|
}
|
|
64
|
-
val numberString = abs(number).toString()
|
|
63
|
+
val numberString = abs(number).toString()
|
|
65
64
|
if (numberString.length < 3) {
|
|
66
65
|
return numberString + currency
|
|
67
66
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
package vn.momo.kits.application
|
|
2
|
+
|
|
3
|
+
import kotlinx.serialization.json.JsonObject
|
|
4
|
+
import kotlin.test.AfterTest
|
|
5
|
+
import kotlin.test.Test
|
|
6
|
+
import kotlin.test.assertEquals
|
|
7
|
+
import kotlin.test.assertSame
|
|
8
|
+
|
|
9
|
+
class KitsHostTest {
|
|
10
|
+
@AfterTest
|
|
11
|
+
fun reset() = KitsHost.uninstall()
|
|
12
|
+
|
|
13
|
+
@Test
|
|
14
|
+
fun withoutAnInstallTheBindingDoesNothing() {
|
|
15
|
+
val binding = KitsHost.binding
|
|
16
|
+
binding.dismiss(KitsDismissTarget.Current)
|
|
17
|
+
binding.trackEvent("event", JsonObject(emptyMap()))
|
|
18
|
+
var called = false
|
|
19
|
+
assertSame(KitsRequest.None, binding.getLanguage { called = true })
|
|
20
|
+
assertEquals(false, called)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Test
|
|
24
|
+
fun theLastInstalledBindingIsUsedUntilUninstalled() {
|
|
25
|
+
val first = RecordingBinding()
|
|
26
|
+
val second = RecordingBinding()
|
|
27
|
+
KitsHost.install(first)
|
|
28
|
+
KitsHost.install(second)
|
|
29
|
+
KitsHost.binding.dismiss(KitsDismissTarget.All)
|
|
30
|
+
assertEquals(emptyList(), first.dismissed)
|
|
31
|
+
assertEquals(listOf(KitsDismissTarget.All), second.dismissed)
|
|
32
|
+
KitsHost.uninstall()
|
|
33
|
+
assertSame(NoOpKitsBinding, KitsHost.binding)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private class RecordingBinding : KitsBinding {
|
|
37
|
+
val dismissed = mutableListOf<KitsDismissTarget>()
|
|
38
|
+
override fun dismiss(target: KitsDismissTarget) {
|
|
39
|
+
dismissed += target
|
|
40
|
+
}
|
|
41
|
+
override fun trackEvent(eventName: String, attributes: JsonObject) = Unit
|
|
42
|
+
override fun getLanguage(callback: (String) -> Unit): KitsRequest = KitsRequest.None
|
|
43
|
+
}
|
|
44
|
+
}
|
package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// File: HelpCenterRequestTest.kt
|
|
2
2
|
// Created At: 2026-10-19 +07:00
|
|
3
3
|
// Created By: AI | AI Agent: Codex | Model: GPT-6
|
|
4
|
-
// AI-GENERATED START: verify Help Center identity and localized payload preservation
|
|
5
4
|
package vn.momo.kits.navigation.component
|
|
6
5
|
|
|
7
6
|
import kotlinx.serialization.json.JsonObject
|
|
@@ -21,7 +20,7 @@ class HelpCenterRequestTest {
|
|
|
21
20
|
appName = mapOf("vi" to "Tên ứng dụng", "en" to "App name"),
|
|
22
21
|
description = mapOf("vi" to "Mô tả", "en" to "Description"),
|
|
23
22
|
)
|
|
24
|
-
val request = context.helpCenterRequest()
|
|
23
|
+
val request = context.helpCenterRequest()
|
|
25
24
|
assertEquals(context.appId, request.appId)
|
|
26
25
|
assertEquals(context.appCode, request.code)
|
|
27
26
|
assertEquals(context.appIcon, request.icon)
|
|
@@ -29,16 +28,12 @@ class HelpCenterRequestTest {
|
|
|
29
28
|
"en" to JsonPrimitive("App name"))), request.name)
|
|
30
29
|
assertEquals(JsonObject(mapOf("vi" to JsonPrimitive("Mô tả"),
|
|
31
30
|
"en" to JsonPrimitive("Description"))), request.description)
|
|
32
|
-
assertNull(request.support)
|
|
33
|
-
assertNull(request.toolkitConfig)
|
|
34
|
-
assertNull(request.permissions)
|
|
35
31
|
}
|
|
36
32
|
|
|
37
33
|
@Test
|
|
38
34
|
fun preservesPlainStringsAndAbsentValues() {
|
|
39
|
-
val request = MiniAppContext(appName = "App name").helpCenterRequest()
|
|
35
|
+
val request = MiniAppContext(appName = "App name").helpCenterRequest()
|
|
40
36
|
assertEquals(JsonPrimitive("App name"), request.name)
|
|
41
37
|
assertNull(request.description)
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
|
-
// AI-GENERATED END: verify Help Center identity and localized payload preservation
|
package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
// File: ToolkitRequestsTest.kt
|
|
2
2
|
// Created At: 2026-10-12 +07:00 | Created By: AI | AI Agent: Codex | Model: GPT-6
|
|
3
|
-
// AI-GENERATED START: verify cancellation and late callback suppression for toolkit UI
|
|
4
3
|
package vn.momo.kits.navigation.component
|
|
5
4
|
|
|
6
5
|
import kotlin.test.Test
|
|
7
6
|
import kotlin.test.assertEquals
|
|
8
|
-
import vn.momo.
|
|
9
|
-
import vn.momo.maxapi.runtime.ApiRequestHandle
|
|
10
|
-
import vn.momo.maxapi.runtime.ApiResult
|
|
7
|
+
import vn.momo.kits.application.KitsRequest
|
|
11
8
|
|
|
12
9
|
class ToolkitRequestsTest {
|
|
13
10
|
@Test
|
|
14
11
|
fun closingCancelsPendingRequestsAndSuppressesLateCallbacks() {
|
|
15
12
|
val owner = ToolkitRequests()
|
|
16
13
|
val handle = Handle()
|
|
17
|
-
var callback:
|
|
14
|
+
var callback: (Boolean) -> Unit = {}
|
|
18
15
|
var results = 0
|
|
19
16
|
owner.launch<Boolean>({ callback = it; handle }) { results++ }
|
|
20
17
|
owner.close()
|
|
21
18
|
owner.close()
|
|
22
|
-
callback(
|
|
19
|
+
callback(true)
|
|
23
20
|
assertEquals(1, handle.cancellations)
|
|
24
21
|
assertEquals(0, results)
|
|
25
22
|
}
|
|
@@ -30,7 +27,7 @@ class ToolkitRequestsTest {
|
|
|
30
27
|
val handle = Handle()
|
|
31
28
|
var starts = 0
|
|
32
29
|
var results = 0
|
|
33
|
-
owner.launch<Boolean>({ callback -> starts++; callback(
|
|
30
|
+
owner.launch<Boolean>({ callback -> starts++; callback(false); handle }) { results++ }
|
|
34
31
|
owner.close()
|
|
35
32
|
owner.launch<Boolean>({ starts++; handle }) { results++ }
|
|
36
33
|
assertEquals(0, handle.cancellations)
|
|
@@ -39,24 +36,18 @@ class ToolkitRequestsTest {
|
|
|
39
36
|
}
|
|
40
37
|
|
|
41
38
|
@Test
|
|
42
|
-
fun
|
|
39
|
+
fun subscriptionsStayOpenUntilTheOwnerCloses() {
|
|
43
40
|
val owner = ToolkitRequests()
|
|
44
41
|
val handle = Handle()
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
owner.observe<Boolean>({ callback = it; handle }) { results++ }
|
|
48
|
-
callback(ApiResult.Success(true))
|
|
49
|
-
callback(ApiResult.Success(false))
|
|
42
|
+
owner.observe { handle }
|
|
43
|
+
assertEquals(0, handle.cancellations)
|
|
50
44
|
owner.close()
|
|
51
|
-
|
|
52
|
-
assertEquals(2, results)
|
|
45
|
+
owner.observe { handle }
|
|
53
46
|
assertEquals(1, handle.cancellations)
|
|
54
47
|
}
|
|
55
48
|
|
|
56
|
-
private class Handle :
|
|
57
|
-
override val requestId = "toolkit-test"
|
|
49
|
+
private class Handle : KitsRequest {
|
|
58
50
|
var cancellations = 0
|
|
59
51
|
override fun cancel() { cancellations++ }
|
|
60
52
|
}
|
|
61
53
|
}
|
|
62
|
-
// AI-GENERATED END: verify cancellation and late callback suppression for toolkit UI
|
|
@@ -19,7 +19,7 @@ import platform.posix.memcpy
|
|
|
19
19
|
internal actual fun hostFontFamily(fileName: String, weight: FontWeight): FontFamily? = remember(fileName, weight) {
|
|
20
20
|
val name = fileName.substringBeforeLast('.')
|
|
21
21
|
val ext = fileName.substringAfterLast('.', "")
|
|
22
|
-
//
|
|
22
|
+
// Host fonts sit loose at the bundle root, not in compose-resources.
|
|
23
23
|
val path = NSBundle.mainBundle.pathForResource(name, ext) ?: return@remember null
|
|
24
24
|
FontFamily(
|
|
25
25
|
Font(
|
|
@@ -6,15 +6,13 @@ import platform.Foundation.NSNotification
|
|
|
6
6
|
import platform.Foundation.NSNotificationCenter
|
|
7
7
|
import platform.Foundation.NSOperationQueue
|
|
8
8
|
import platform.darwin.NSObjectProtocol
|
|
9
|
-
import vn.momo.maxapi.contract.observability.logging.model.LogLevel
|
|
10
9
|
|
|
11
10
|
private const val STATUS_BAR_TAPPED_NOTIFICATION = "statusBarSelected"
|
|
12
11
|
|
|
13
12
|
@Composable
|
|
14
13
|
internal actual fun RegisterScrollToTop(callback: (() -> Unit)?) {
|
|
15
|
-
val
|
|
16
|
-
DisposableEffect(callback,
|
|
17
|
-
val logger = if (callback != null) maxApi?.openLogger() else null
|
|
14
|
+
val binding = LocalKitsBinding.current
|
|
15
|
+
DisposableEffect(callback, binding) {
|
|
18
16
|
val token: NSObjectProtocol? = if (callback != null) {
|
|
19
17
|
NSNotificationCenter.defaultCenter.addObserverForName(
|
|
20
18
|
name = STATUS_BAR_TAPPED_NOTIFICATION,
|
|
@@ -22,13 +20,12 @@ internal actual fun RegisterScrollToTop(callback: (() -> Unit)?) {
|
|
|
22
20
|
queue = NSOperationQueue.mainQueue,
|
|
23
21
|
) { _: NSNotification? ->
|
|
24
22
|
runCatching { callback() }.onFailure {
|
|
25
|
-
|
|
23
|
+
binding?.logError("[ScrollToTop] callback failed")
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
} else null
|
|
29
27
|
onDispose {
|
|
30
28
|
token?.let { NSNotificationCenter.defaultCenter.removeObserver(it) }
|
|
31
|
-
logger?.close()
|
|
32
29
|
}
|
|
33
30
|
}
|
|
34
31
|
}
|
|
@@ -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) {
|
|
@@ -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,23 +38,22 @@ 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
|
|
45
44
|
|
|
46
45
|
actual fun getPlatformName(): String = "iOS"
|
|
47
46
|
|
|
48
|
-
actual fun isPhoneIdiom(): Boolean =
|
|
49
|
-
UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
|
|
47
|
+
actual fun isPhoneIdiom(): Boolean = UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
// Window size, not UIScreen.main (which stays on one display on iPhone Duo); recomposes on fold/unfold.
|
|
52
50
|
@Composable
|
|
53
|
-
actual fun getScreenDimensions(): ScreenDimension
|
|
54
|
-
val
|
|
51
|
+
actual fun getScreenDimensions(): ScreenDimension {
|
|
52
|
+
val density = LocalDensity.current
|
|
53
|
+
val size = LocalWindowInfo.current.containerSize
|
|
55
54
|
return ScreenDimension(
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
(size.width / density.density).toInt(),
|
|
56
|
+
(size.height / density.density).toInt()
|
|
58
57
|
)
|
|
59
58
|
}
|
|
60
59
|
|
|
@@ -111,10 +110,11 @@ actual fun LottieAnimation(
|
|
|
111
110
|
isPlaying: Boolean,
|
|
112
111
|
onEvent: ((String) -> Unit)?,
|
|
113
112
|
modifier: Modifier,
|
|
114
|
-
useCompose: Boolean
|
|
113
|
+
useCompose: Boolean,
|
|
114
|
+
progress: (() -> Float)?,
|
|
115
115
|
) {
|
|
116
116
|
if (useCompose) {
|
|
117
|
-
ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier)
|
|
117
|
+
ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier, progress)
|
|
118
118
|
return
|
|
119
119
|
}
|
|
120
120
|
|