@momo-kits/native-kits 0.300.7 → 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/build.gradle.kts +13 -0
- package/compose/build.gradle.kts +195 -0
- package/compose/build.gradle.kts.backup +195 -0
- package/compose/compose.podspec +47 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +154 -0
- 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 +6 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +61 -0
- 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 +1067 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +268 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +55 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +354 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +130 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +482 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +224 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +137 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +473 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +113 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +262 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +237 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +228 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +280 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +183 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +342 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +82 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +362 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +304 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +88 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +308 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +218 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +456 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +205 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +542 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +201 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +208 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +291 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -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 +315 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +54 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +397 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +153 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +118 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +212 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +422 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +750 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +152 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +244 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +398 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +103 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +93 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +208 -0
- 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 +167 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +446 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +387 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +33 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +197 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +38 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +135 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +114 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +21 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +117 -0
- 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 +39 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +53 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +31 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +65 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
- 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 +143 -0
- package/gradle/libs.versions.toml +66 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/gradle.properties +24 -0
- package/gradlew +252 -0
- package/gradlew.bat +94 -0
- 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/README.md +120 -0
- 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 +63 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
package vn.momo.kits.platform
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.content.res.Resources
|
|
5
|
+
import android.graphics.BlurMaskFilter
|
|
6
|
+
import android.graphics.PorterDuff
|
|
7
|
+
import android.graphics.PorterDuffColorFilter
|
|
8
|
+
import android.os.Build
|
|
9
|
+
import androidx.compose.foundation.layout.Box
|
|
10
|
+
import androidx.compose.runtime.Composable
|
|
11
|
+
import androidx.compose.runtime.LaunchedEffect
|
|
12
|
+
import androidx.compose.runtime.getValue
|
|
13
|
+
import androidx.compose.runtime.rememberUpdatedState
|
|
14
|
+
import androidx.compose.runtime.snapshotFlow
|
|
15
|
+
import androidx.compose.ui.Modifier
|
|
16
|
+
import androidx.compose.ui.graphics.Color
|
|
17
|
+
import androidx.compose.ui.graphics.NativePaint
|
|
18
|
+
import androidx.compose.ui.graphics.toArgb
|
|
19
|
+
import androidx.compose.ui.platform.LocalConfiguration
|
|
20
|
+
import androidx.compose.ui.semantics.contentDescription
|
|
21
|
+
import androidx.compose.ui.semantics.semantics
|
|
22
|
+
import androidx.compose.ui.unit.Dp
|
|
23
|
+
import androidx.compose.ui.unit.dp
|
|
24
|
+
import com.airbnb.lottie.LottieProperty
|
|
25
|
+
import com.airbnb.lottie.compose.LottieAnimation
|
|
26
|
+
import com.airbnb.lottie.compose.LottieCompositionSpec
|
|
27
|
+
import com.airbnb.lottie.compose.animateLottieCompositionAsState
|
|
28
|
+
import com.airbnb.lottie.compose.rememberLottieComposition
|
|
29
|
+
import com.airbnb.lottie.compose.rememberLottieDynamicProperties
|
|
30
|
+
import com.airbnb.lottie.compose.rememberLottieDynamicProperty
|
|
31
|
+
import vn.momo.kits.const.AppNavigationBar
|
|
32
|
+
import vn.momo.kits.const.AppStatusBar
|
|
33
|
+
import vn.momo.kits.navigation.Navigator
|
|
34
|
+
import vn.momo.kits.utils.readJson
|
|
35
|
+
import androidx.activity.compose.BackHandler as AndroidBackHandler
|
|
36
|
+
|
|
37
|
+
actual fun getPlatformName(): String = "Android"
|
|
38
|
+
|
|
39
|
+
actual fun isPhoneIdiom(): Boolean = false
|
|
40
|
+
|
|
41
|
+
@Composable
|
|
42
|
+
actual fun getScreenDimensions(): ScreenDimension {
|
|
43
|
+
val config = LocalConfiguration.current
|
|
44
|
+
return ScreenDimension(
|
|
45
|
+
config.screenWidthDp, config.screenHeightDp
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
actual fun NativePaint.setMaskFilter(blurRadius: Float) {
|
|
50
|
+
this.maskFilter = BlurMaskFilter(blurRadius, BlurMaskFilter.Blur.NORMAL)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@SuppressLint("InternalInsetResource")
|
|
54
|
+
@Composable
|
|
55
|
+
actual fun getStatusBarHeight(): Dp {
|
|
56
|
+
val resourceId = Resources.getSystem().getIdentifier(
|
|
57
|
+
"status_bar_height",
|
|
58
|
+
"dimen",
|
|
59
|
+
"android"
|
|
60
|
+
)
|
|
61
|
+
return if(resourceId > 0) Resources.getSystem().getDimensionPixelSize(resourceId).dp else 0.dp
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Composable
|
|
65
|
+
actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) {
|
|
66
|
+
AndroidBackHandler(enabled = enabled, onBack = onBack)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@Composable
|
|
70
|
+
actual fun ProvideNavigationEventDispatcherOwner(navigator: Navigator, content: @Composable () -> Unit) {
|
|
71
|
+
content()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@Composable
|
|
75
|
+
actual fun getScreenHeight(): Dp {
|
|
76
|
+
return getScreenDimensions().height.dp + if (getOSVersion() >= 35) 0.dp else AppStatusBar.current + AppNavigationBar.current
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
actual fun getOSVersion(): OSVersion = OSVersion.Android(sdk = Build.VERSION.SDK_INT)
|
|
80
|
+
|
|
81
|
+
@Composable
|
|
82
|
+
actual fun LottieAnimation(
|
|
83
|
+
path: String,
|
|
84
|
+
tintColor: Color?,
|
|
85
|
+
bgColor: Color?,
|
|
86
|
+
placedAsOverlay: Boolean,
|
|
87
|
+
iterations: Int,
|
|
88
|
+
isPlaying: Boolean,
|
|
89
|
+
onEvent: ((String) -> Unit)?,
|
|
90
|
+
modifier: Modifier,
|
|
91
|
+
useCompose: Boolean,
|
|
92
|
+
progress: (() -> Float)?,
|
|
93
|
+
) {
|
|
94
|
+
if (useCompose) {
|
|
95
|
+
ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier, progress)
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
val json = readJson(path)
|
|
100
|
+
|
|
101
|
+
if (json.isEmpty()) {
|
|
102
|
+
Box(modifier)
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
val composition by rememberLottieComposition(
|
|
107
|
+
LottieCompositionSpec.JsonString(json)
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
val colorFilter = PorterDuffColorFilter(
|
|
111
|
+
tintColor?.toArgb() ?: Color.White.toArgb(),
|
|
112
|
+
PorterDuff.Mode.SRC_ATOP
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
val dynamicProperties = rememberLottieDynamicProperties(
|
|
116
|
+
rememberLottieDynamicProperty(
|
|
117
|
+
property = LottieProperty.COLOR_FILTER,
|
|
118
|
+
value = colorFilter,
|
|
119
|
+
keyPath = arrayOf("**")
|
|
120
|
+
)
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
val lottieState = animateLottieCompositionAsState(
|
|
124
|
+
composition = composition,
|
|
125
|
+
iterations = iterations,
|
|
126
|
+
isPlaying = isPlaying,
|
|
127
|
+
restartOnPlay = false,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
val currentOnEvent by rememberUpdatedState(onEvent)
|
|
131
|
+
|
|
132
|
+
LaunchedEffect(isPlaying) {
|
|
133
|
+
currentOnEvent?.invoke(if (isPlaying) LottieEvent.Start else LottieEvent.Pause)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
LaunchedEffect(lottieState) {
|
|
137
|
+
var armed = false
|
|
138
|
+
snapshotFlow { lottieState.isAtEnd }.collect { atEnd ->
|
|
139
|
+
if (!atEnd) armed = true
|
|
140
|
+
else if (armed) { armed = false; currentOnEvent?.invoke(LottieEvent.Finish) }
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
LottieAnimation(
|
|
145
|
+
composition = composition,
|
|
146
|
+
progress = { lottieState.progress },
|
|
147
|
+
dynamicProperties = if (tintColor != null) dynamicProperties else null,
|
|
148
|
+
modifier = modifier
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
actual fun NativePaint.setColor(color: Color){
|
|
153
|
+
this.color = color.toArgb()
|
|
154
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package vn.momo.kits.platform
|
|
2
|
+
|
|
3
|
+
import android.provider.Settings
|
|
4
|
+
import androidx.compose.runtime.Composable
|
|
5
|
+
import androidx.compose.runtime.remember
|
|
6
|
+
import androidx.compose.ui.platform.LocalConfiguration
|
|
7
|
+
import androidx.compose.ui.platform.LocalContext
|
|
8
|
+
|
|
9
|
+
@Composable
|
|
10
|
+
actual fun rememberReduceMotion(): Boolean {
|
|
11
|
+
val context = LocalContext.current
|
|
12
|
+
// re-read on configuration changes; the setting has no observer of its own
|
|
13
|
+
val configuration = LocalConfiguration.current
|
|
14
|
+
return remember(context, configuration) {
|
|
15
|
+
Settings.Global.getFloat(context.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f) == 0f
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
package vn.momo.kits.application
|
|
2
|
+
|
|
3
|
+
import androidx.compose.runtime.Immutable
|
|
4
|
+
import androidx.compose.runtime.staticCompositionLocalOf
|
|
5
|
+
import vn.momo.kits.components.TrustBannerData
|
|
6
|
+
|
|
7
|
+
@Immutable
|
|
8
|
+
data class FeatureFlags(
|
|
9
|
+
val showBaseLineDebug: Boolean? = false,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
@Immutable
|
|
13
|
+
data class DesignSystemConfig(
|
|
14
|
+
val trustBanner: TrustBannerData? = null,
|
|
15
|
+
val headerBar: String? = null,
|
|
16
|
+
val headerGradient: String? = null,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
@Immutable
|
|
20
|
+
data class MiniAppContext(
|
|
21
|
+
val appIcon: String = "",
|
|
22
|
+
val appName: Any? = null,
|
|
23
|
+
val appId: String = "",
|
|
24
|
+
val appCode: String = "",
|
|
25
|
+
val description: Any? = null,
|
|
26
|
+
val support: Map<String, Any?> = emptyMap(),
|
|
27
|
+
val toolkitConfig: Map<String, Any?> = emptyMap(),
|
|
28
|
+
val providerId: String = "",
|
|
29
|
+
val permissions: List<Map<String, Any>>? = emptyList(),
|
|
30
|
+
val features: FeatureFlags? = null,
|
|
31
|
+
val scaleSizeMaxRate: Float? = null,
|
|
32
|
+
val userScaleRate: Float? = null,
|
|
33
|
+
val useOSScaleRate: Boolean? = null,
|
|
34
|
+
) {
|
|
35
|
+
companion object {
|
|
36
|
+
|
|
37
|
+
fun toMap(context: MiniAppContext?): Map<String, Any?> = mapOf(
|
|
38
|
+
"icon" to (context?.appIcon ?: ""),
|
|
39
|
+
"name" to context?.appName,
|
|
40
|
+
"appId" to (context?.appId ?: ""),
|
|
41
|
+
"code" to (context?.appCode ?: ""),
|
|
42
|
+
"description" to (context?.description ?: ""),
|
|
43
|
+
"support" to (context?.support ?: emptyMap()),
|
|
44
|
+
"toolkitConfig" to (context?.toolkitConfig ?: emptyMap()),
|
|
45
|
+
"providerId" to (context?.providerId ?: ""),
|
|
46
|
+
"permissions" to (context?.permissions ?: emptyList()),
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
fun merge(parent: MiniAppContext?, child: MiniAppContext?): MiniAppContext? {
|
|
50
|
+
if (parent == null && child == null) return null
|
|
51
|
+
if (parent == null) return child
|
|
52
|
+
if (child == null) return parent
|
|
53
|
+
|
|
54
|
+
return MiniAppContext(
|
|
55
|
+
appIcon = parent.appIcon.ifBlank { child.appIcon },
|
|
56
|
+
appName = parent.appName ?: child.appName,
|
|
57
|
+
appId = parent.appId.ifBlank { child.appId },
|
|
58
|
+
appCode = parent.appCode.ifBlank { child.appCode },
|
|
59
|
+
description = parent.description ?: child.description,
|
|
60
|
+
support = mergeMaps(parent.support, child.support),
|
|
61
|
+
toolkitConfig = mergeMaps(parent.toolkitConfig, child.toolkitConfig),
|
|
62
|
+
providerId = parent.providerId.ifBlank { child.providerId },
|
|
63
|
+
permissions = if (!parent.permissions.isNullOrEmpty()) parent.permissions else child.permissions,
|
|
64
|
+
features = mergeFeatureFlags(parent.features, child.features),
|
|
65
|
+
scaleSizeMaxRate = parent.scaleSizeMaxRate ?: child.scaleSizeMaxRate,
|
|
66
|
+
userScaleRate = parent.userScaleRate ?: child.userScaleRate,
|
|
67
|
+
useOSScaleRate = parent.useOSScaleRate ?: child.useOSScaleRate,
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private fun mergeMaps(parent: Map<String, Any?>, child: Map<String, Any?>): Map<String, Any?> {
|
|
72
|
+
return child + parent
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private fun mergeFeatureFlags(parent: FeatureFlags?, child: FeatureFlags?): FeatureFlags? {
|
|
76
|
+
if (parent == null && child == null) return null
|
|
77
|
+
if (parent == null) return child
|
|
78
|
+
if (child == null) return parent
|
|
79
|
+
|
|
80
|
+
return FeatureFlags(
|
|
81
|
+
showBaseLineDebug = parent.showBaseLineDebug ?: child.showBaseLineDebug
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@Immutable
|
|
88
|
+
data class ComponentInformation(
|
|
89
|
+
val componentName: String? = null,
|
|
90
|
+
val componentId: String? = null,
|
|
91
|
+
val params: Map<String,Any?>? = null,
|
|
92
|
+
val action: String? = null
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
var IsShowBaseLineDebug = false
|
|
96
|
+
|
|
97
|
+
val LocalContext = staticCompositionLocalOf<MiniAppContext?> {
|
|
98
|
+
null
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
val LocalComponentInformation = staticCompositionLocalOf<ComponentInformation?> {
|
|
102
|
+
null
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
val LocalDesignSystemConfig = staticCompositionLocalOf<DesignSystemConfig?> {
|
|
106
|
+
null
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@Deprecated("No longer read; wrap content in ScaleSizeScope(scaleSizeMaxRate) to cap the font scale.")
|
|
110
|
+
val ScaleSizeMaxRate = staticCompositionLocalOf<Float?> { null }
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
package vn.momo.kits.application
|
|
2
|
+
|
|
3
|
+
import androidx.compose.runtime.Immutable
|
|
4
|
+
import androidx.compose.runtime.getValue
|
|
5
|
+
import androidx.compose.runtime.mutableStateOf
|
|
6
|
+
import androidx.compose.runtime.setValue
|
|
7
|
+
import kotlinx.coroutines.CoroutineScope
|
|
8
|
+
import kotlinx.coroutines.Dispatchers
|
|
9
|
+
import kotlinx.coroutines.Job
|
|
10
|
+
import kotlinx.coroutines.SupervisorJob
|
|
11
|
+
import kotlinx.coroutines.flow.Flow
|
|
12
|
+
import kotlinx.coroutines.flow.MutableStateFlow
|
|
13
|
+
import kotlinx.coroutines.flow.StateFlow
|
|
14
|
+
import kotlinx.coroutines.flow.asStateFlow
|
|
15
|
+
import kotlinx.coroutines.launch
|
|
16
|
+
|
|
17
|
+
@Immutable
|
|
18
|
+
data class DesignSystemKitsConfigs(
|
|
19
|
+
val userScaleRate: Float = 1f,
|
|
20
|
+
val useOSScaleRate: Boolean = true,
|
|
21
|
+
val isWhiteList: Boolean = false,
|
|
22
|
+
val designSystemConfig: DesignSystemConfig? = null,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
// The kit is sandboxed from the host's storage/config, so the host implements this and hands it to init().
|
|
26
|
+
interface DesignSystemKitsSource {
|
|
27
|
+
// Sync read: seeds the kit before the first frame, so there is no default-then-real flicker.
|
|
28
|
+
fun getConfigs(): DesignSystemKitsConfigs
|
|
29
|
+
|
|
30
|
+
val configsFlow: Flow<DesignSystemKitsConfigs>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// App-wide design-system inputs (font scale, whitelist, remote config). scaleSize(), defaultTheme and
|
|
34
|
+
// NavigationContainer fall back to these when no MiniAppContext / LocalDesignSystemConfig is provided.
|
|
35
|
+
object DesignSystemKits {
|
|
36
|
+
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
|
37
|
+
private var observeJob: Job? = null
|
|
38
|
+
|
|
39
|
+
// Snapshot state recomposes Compose readers; the StateFlow serves non-Compose observers (the host
|
|
40
|
+
// SwiftUI bridge), where Compose's global snapshot apply loop may never have started.
|
|
41
|
+
private var currentConfigs by mutableStateOf(DesignSystemKitsConfigs())
|
|
42
|
+
private val mutableConfigsFlow = MutableStateFlow(currentConfigs)
|
|
43
|
+
val configsFlow: StateFlow<DesignSystemKitsConfigs> = mutableConfigsFlow.asStateFlow()
|
|
44
|
+
|
|
45
|
+
// Idempotent: a repeated call (e.g. Activity re-creation) replaces the previous observer.
|
|
46
|
+
fun init(source: DesignSystemKitsSource) {
|
|
47
|
+
observeJob?.cancel()
|
|
48
|
+
setConfigs(source.getConfigs())
|
|
49
|
+
observeJob = scope.launch {
|
|
50
|
+
source.configsFlow.collect { setConfigs(it) }
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// While init() is observing a source, its next emission overrides a value set here.
|
|
55
|
+
fun setConfigs(configs: DesignSystemKitsConfigs) {
|
|
56
|
+
currentConfigs = configs
|
|
57
|
+
mutableConfigsFlow.value = configs
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
fun getConfigs(): DesignSystemKitsConfigs = currentConfigs
|
|
61
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
package vn.momo.kits.application
|
|
2
|
+
|
|
3
|
+
import kotlinx.serialization.json.JsonElement
|
|
4
|
+
import kotlinx.serialization.json.JsonObject
|
|
5
|
+
import vn.momo.kits.navigation.component.ToolGroup
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Host services the kit calls. The host adapts its own bridge (MaxApi) to this, so the kit ships no host SDK.
|
|
9
|
+
* Callbacks fire only on success; the kit drops late ones after cancelling their [KitsRequest].
|
|
10
|
+
* Containers borrow the binding and never close it.
|
|
11
|
+
*/
|
|
12
|
+
interface KitsBinding {
|
|
13
|
+
fun dismiss(target: KitsDismissTarget)
|
|
14
|
+
|
|
15
|
+
fun trackEvent(eventName: String, attributes: JsonObject)
|
|
16
|
+
|
|
17
|
+
fun getLanguage(callback: (String) -> Unit): KitsRequest
|
|
18
|
+
|
|
19
|
+
fun vibrateLight() {}
|
|
20
|
+
|
|
21
|
+
fun checkFavorite(appCode: String?, callback: (Boolean) -> Unit): KitsRequest = KitsRequest.None
|
|
22
|
+
|
|
23
|
+
/** [callback] gets whether the app is a favorite afterwards. */
|
|
24
|
+
fun toggleFavorite(appCode: String?, callback: (Boolean) -> Unit): KitsRequest = KitsRequest.None
|
|
25
|
+
|
|
26
|
+
fun showToolkit(
|
|
27
|
+
tools: List<ToolGroup>,
|
|
28
|
+
useSystemTools: Boolean,
|
|
29
|
+
onAction: (actionKey: String) -> Unit,
|
|
30
|
+
): KitsRequest = KitsRequest.None
|
|
31
|
+
|
|
32
|
+
/** The request stays open while the sheet may still emit events; cancel releases it. */
|
|
33
|
+
fun showHelpCenter(request: KitsHelpCenterRequest): KitsRequest = KitsRequest.None
|
|
34
|
+
|
|
35
|
+
fun logError(message: String) {}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
enum class KitsDismissTarget {
|
|
39
|
+
/** Only the current mini app. */
|
|
40
|
+
Current,
|
|
41
|
+
|
|
42
|
+
/** Back to the host home, closing every mini app. */
|
|
43
|
+
All,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fun interface KitsRequest {
|
|
47
|
+
fun cancel()
|
|
48
|
+
|
|
49
|
+
companion object {
|
|
50
|
+
val None = KitsRequest {}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
data class KitsHelpCenterRequest(
|
|
55
|
+
val appId: String?,
|
|
56
|
+
val code: String?,
|
|
57
|
+
val name: JsonElement?,
|
|
58
|
+
val icon: String?,
|
|
59
|
+
val description: JsonElement?,
|
|
60
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package vn.momo.kits.application
|
|
2
|
+
|
|
3
|
+
import kotlin.concurrent.Volatile
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The host installs its [KitsBinding] here once; containers use it unless a caller passes or provides another.
|
|
7
|
+
* Packages that only render kit screens never need a binding of their own.
|
|
8
|
+
*/
|
|
9
|
+
object KitsHost {
|
|
10
|
+
@Volatile
|
|
11
|
+
private var installed: KitsBinding? = null
|
|
12
|
+
|
|
13
|
+
/** The installed binding, or one that does nothing while the host has not installed it yet. */
|
|
14
|
+
val binding: KitsBinding get() = installed ?: NoOpKitsBinding
|
|
15
|
+
|
|
16
|
+
/** The last install wins. The kit borrows the binding and never closes it. */
|
|
17
|
+
fun install(binding: KitsBinding) {
|
|
18
|
+
installed = binding
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fun uninstall() {
|
|
22
|
+
installed = null
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
internal object NoOpKitsBinding : KitsBinding {
|
|
27
|
+
override fun dismiss(target: KitsDismissTarget) = Unit
|
|
28
|
+
|
|
29
|
+
override fun trackEvent(eventName: String, attributes: kotlinx.serialization.json.JsonObject) = Unit
|
|
30
|
+
|
|
31
|
+
override fun getLanguage(callback: (String) -> Unit): KitsRequest = KitsRequest.None
|
|
32
|
+
}
|