@momo-kits/native-kits 0.168.1-beta.4 → 0.168.1-beta.5-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.
Files changed (144) hide show
  1. package/CLAUDE.md +4 -4
  2. package/README.md +2 -10
  3. package/build.gradle.kts +11 -0
  4. package/compose/build.gradle.kts +198 -0
  5. package/compose/build.gradle.kts.backup +198 -0
  6. package/compose/compose.podspec +47 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +153 -0
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +124 -0
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1071 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +542 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +231 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +189 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +478 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +265 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +235 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +223 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +265 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +185 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +84 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +361 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +308 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +90 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +330 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +220 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +473 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +207 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +92 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +560 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +125 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +501 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +236 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +16 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +18 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +283 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +314 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +338 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +137 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +116 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +205 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +399 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +732 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +228 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +217 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +97 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +377 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +455 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +103 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +399 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +192 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +91 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +74 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +13 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +118 -0
  123. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +40 -0
  124. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  125. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +94 -0
  130. package/gradle/libs.versions.toml +69 -0
  131. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  132. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  133. package/gradle.properties +26 -0
  134. package/gradlew +252 -0
  135. package/gradlew.bat +94 -0
  136. package/ios/Layout/ScreenLayout.swift +5 -0
  137. package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
  138. package/ios/Navigation/BottomTab/DuoTabBar.swift +94 -69
  139. package/ios/Navigation/Component/HeaderBackground.swift +22 -1
  140. package/ios/Navigation/StackScreen.swift +3 -7
  141. package/ios-demo/README.md +120 -0
  142. package/package.json +1 -1
  143. package/publish.sh +2 -33
  144. package/settings.gradle.kts +64 -0
@@ -0,0 +1,153 @@
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
+ ) {
93
+ if (useCompose) {
94
+ ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier)
95
+ return
96
+ }
97
+
98
+ val json = readJson(path)
99
+
100
+ if (json.isEmpty()) {
101
+ Box(modifier)
102
+ return
103
+ }
104
+
105
+ val composition by rememberLottieComposition(
106
+ LottieCompositionSpec.JsonString(json)
107
+ )
108
+
109
+ val colorFilter = PorterDuffColorFilter(
110
+ tintColor?.toArgb() ?: Color.White.toArgb(),
111
+ PorterDuff.Mode.SRC_ATOP
112
+ )
113
+
114
+ val dynamicProperties = rememberLottieDynamicProperties(
115
+ rememberLottieDynamicProperty(
116
+ property = LottieProperty.COLOR_FILTER,
117
+ value = colorFilter,
118
+ keyPath = arrayOf("**")
119
+ )
120
+ )
121
+
122
+ val lottieState = animateLottieCompositionAsState(
123
+ composition = composition,
124
+ iterations = iterations,
125
+ isPlaying = isPlaying,
126
+ restartOnPlay = false,
127
+ )
128
+
129
+ val currentOnEvent by rememberUpdatedState(onEvent)
130
+
131
+ LaunchedEffect(isPlaying) {
132
+ currentOnEvent?.invoke(if (isPlaying) LottieEvent.Start else LottieEvent.Pause)
133
+ }
134
+
135
+ LaunchedEffect(lottieState) {
136
+ var armed = false
137
+ snapshotFlow { lottieState.isAtEnd }.collect { atEnd ->
138
+ if (!atEnd) armed = true
139
+ else if (armed) { armed = false; currentOnEvent?.invoke(LottieEvent.Finish) }
140
+ }
141
+ }
142
+
143
+ LottieAnimation(
144
+ composition = composition,
145
+ progress = { lottieState.progress },
146
+ dynamicProperties = if (tintColor != null) dynamicProperties else null,
147
+ modifier = modifier
148
+ )
149
+ }
150
+
151
+ actual fun NativePaint.setColor(color: Color){
152
+ this.color = color.toArgb()
153
+ }
@@ -0,0 +1,6 @@
1
+ package vn.momo.kits.platform
2
+
3
+ import androidx.compose.runtime.Composable
4
+
5
+ @Composable
6
+ internal actual fun rememberReservedRegions(): List<ReservedRegion> = emptyList()
@@ -0,0 +1,124 @@
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 androidx.compose.runtime.staticCompositionLocalOf
8
+ import vn.momo.kits.components.TrustBannerData
9
+
10
+ @Immutable
11
+ data class FeatureFlags(
12
+ val showBaseLineDebug: Boolean? = false,
13
+ )
14
+
15
+ @Immutable
16
+ data class DesignSystemConfig(
17
+ val trustBanner: TrustBannerData? = null,
18
+ val headerBar: String? = null,
19
+ val headerGradient: String? = null,
20
+ )
21
+
22
+ // App-wide holder seeded by the host (same pattern as KitFontScale), so direct NavigationContainer
23
+ // callers get the config without passing it. Snapshot state: a config fetched after first frame recomposes.
24
+ object KitDesignSystemConfig {
25
+ var config by mutableStateOf<DesignSystemConfig?>(null)
26
+ private set
27
+
28
+ fun update(config: DesignSystemConfig?) {
29
+ this.config = config
30
+ }
31
+ }
32
+
33
+ @Immutable
34
+ data class MiniAppContext(
35
+ val appIcon: String = "",
36
+ val appName: Any? = null,
37
+ val appId: String = "",
38
+ val appCode: String = "",
39
+ val description: Any? = null,
40
+ val support: Map<String, Any?> = emptyMap(),
41
+ val toolkitConfig: Map<String, Any?> = emptyMap(),
42
+ val providerId: String = "",
43
+ val permissions: List<Map<String, Any>>? = emptyList(),
44
+ val features: FeatureFlags? = null,
45
+ val scaleSizeMaxRate: Float? = null,
46
+ val userScaleRate: Float? = null,
47
+ val useOSScaleRate: Boolean? = null,
48
+ ) {
49
+ companion object {
50
+
51
+ fun toMap(context: MiniAppContext?): Map<String, Any?> = mapOf(
52
+ "icon" to (context?.appIcon ?: ""),
53
+ "name" to context?.appName,
54
+ "appId" to (context?.appId ?: ""),
55
+ "code" to (context?.appCode ?: ""),
56
+ "description" to (context?.description ?: ""),
57
+ "support" to (context?.support ?: emptyMap()),
58
+ "toolkitConfig" to (context?.toolkitConfig ?: emptyMap()),
59
+ "providerId" to (context?.providerId ?: ""),
60
+ "permissions" to (context?.permissions ?: emptyList()),
61
+ )
62
+
63
+ fun merge(parent: MiniAppContext?, child: MiniAppContext?): MiniAppContext? {
64
+ if (parent == null && child == null) return null
65
+ if (parent == null) return child
66
+ if (child == null) return parent
67
+
68
+ return MiniAppContext(
69
+ appIcon = parent.appIcon.ifBlank { child.appIcon },
70
+ appName = parent.appName ?: child.appName,
71
+ appId = parent.appId.ifBlank { child.appId },
72
+ appCode = parent.appCode.ifBlank { child.appCode },
73
+ description = parent.description ?: child.description,
74
+ support = mergeMaps(parent.support, child.support),
75
+ toolkitConfig = mergeMaps(parent.toolkitConfig, child.toolkitConfig),
76
+ providerId = parent.providerId.ifBlank { child.providerId },
77
+ permissions = if (!parent.permissions.isNullOrEmpty()) parent.permissions else child.permissions,
78
+ features = mergeFeatureFlags(parent.features, child.features),
79
+ scaleSizeMaxRate = parent.scaleSizeMaxRate ?: child.scaleSizeMaxRate,
80
+ userScaleRate = parent.userScaleRate ?: child.userScaleRate,
81
+ useOSScaleRate = parent.useOSScaleRate ?: child.useOSScaleRate,
82
+ )
83
+ }
84
+
85
+ private fun mergeMaps(parent: Map<String, Any?>, child: Map<String, Any?>): Map<String, Any?> {
86
+ return child + parent
87
+ }
88
+
89
+ private fun mergeFeatureFlags(parent: FeatureFlags?, child: FeatureFlags?): FeatureFlags? {
90
+ if (parent == null && child == null) return null
91
+ if (parent == null) return child
92
+ if (child == null) return parent
93
+
94
+ return FeatureFlags(
95
+ showBaseLineDebug = parent.showBaseLineDebug ?: child.showBaseLineDebug
96
+ )
97
+ }
98
+ }
99
+ }
100
+
101
+ @Immutable
102
+ data class ComponentInformation(
103
+ val componentName: String? = null,
104
+ val componentId: String? = null,
105
+ val params: Map<String,Any?>? = null,
106
+ val action: String? = null
107
+ )
108
+
109
+ var IsShowBaseLineDebug = false
110
+
111
+ val LocalContext = staticCompositionLocalOf<MiniAppContext?> {
112
+ null
113
+ }
114
+
115
+ val LocalComponentInformation = staticCompositionLocalOf<ComponentInformation?> {
116
+ null
117
+ }
118
+
119
+ val LocalDesignSystemConfig = staticCompositionLocalOf<DesignSystemConfig?> {
120
+ null
121
+ }
122
+
123
+ @Deprecated("Max font scale is fixed at MAX_FONT_SCALE (1.5); this CompositionLocal is no longer read.")
124
+ val ScaleSizeMaxRate = staticCompositionLocalOf<Float?> { null }