@momo-kits/native-kits 0.167.1-duo.3-debug → 0.167.1-duo.4

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 (189) hide show
  1. package/CLAUDE.md +17 -8
  2. package/ios/Application/ApplicationEnvironment.swift +6 -0
  3. package/ios/Application/Components.swift +1 -3
  4. package/ios/Application/HeaderRight.swift +19 -27
  5. package/ios/Application/Navigation/BottomTab/BottomTab.swift +9 -30
  6. package/ios/Application/Navigation/BottomTab/BottomTabBar.swift +2 -5
  7. package/ios/Application/Navigation/HeaderUser.swift +1 -7
  8. package/ios/Application/Navigation/NavigationContainer.swift +45 -45
  9. package/ios/Application/Navigation/Navigator.swift +122 -29
  10. package/ios/Application/Navigation/NavigatorManager.swift +13 -6
  11. package/ios/Application/Navigation/Overplay/BottomSheet.swift +4 -41
  12. package/ios/Application/Navigation/Overplay/ModalScreen.swift +1 -5
  13. package/ios/Application/Navigation/component/Header.swift +4 -12
  14. package/ios/Application/Navigation/component/HeaderBackground.swift +2 -3
  15. package/ios/Application/Navigation/component/NavigationFooter.swift +1 -1
  16. package/ios/Application/Navigation/component/NavigationHeaderRight.swift +9 -61
  17. package/ios/Application/StackScreen.swift +18 -135
  18. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +59 -5
  19. package/ios/Colors+Radius+Spacing/Colors.swift +1 -1
  20. package/ios/Extensions/Color++.swift +20 -9
  21. package/ios/Extensions/OptionalEnvironmentObject.swift +12 -0
  22. package/ios/Icon/Icon.swift +14 -22
  23. package/ios/Icon/Icons.swift +1329 -0
  24. package/ios/Image/Image.swift +16 -5
  25. package/ios/Lottie/LottieView.swift +4 -2
  26. package/ios/Popup/PopupDisplay.swift +68 -84
  27. package/ios/Popup/PopupNotify.swift +32 -43
  28. package/ios/Popup/PopupPromotion.swift +6 -18
  29. package/ios/Resources/dot_loading.json +558 -0
  30. package/ios/Resources/lottie_circle_loader.json +1 -0
  31. package/ios/Template/TrustBanner/TrustBanner.swift +69 -31
  32. package/ios/native-kits.podspec +1 -1
  33. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  34. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +0 -1
  35. package/package.json +1 -1
  36. package/scripts/gen-ios-icons.mjs +36 -0
  37. package/.claude/scheduled_tasks.lock +0 -1
  38. package/.claude/settings.local.json +0 -185
  39. package/build.gradle.kts +0 -11
  40. package/compose/build.gradle.kts +0 -204
  41. package/compose/build.gradle.kts.backup +0 -204
  42. package/compose/compose.podspec +0 -47
  43. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  44. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  45. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  46. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  47. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -52
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -124
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -293
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -831
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -110
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -356
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -113
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -475
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -266
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -240
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -264
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -361
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -310
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -323
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -199
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -91
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -552
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -88
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -234
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -188
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -16
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -188
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -297
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -187
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -338
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -137
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -106
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  140. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -393
  141. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  142. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -648
  143. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  144. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  145. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -194
  146. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -232
  147. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  148. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -281
  149. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  150. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -408
  151. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -108
  152. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -105
  153. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  154. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -354
  155. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -37
  156. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  157. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -169
  158. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -132
  159. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  160. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  161. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  162. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  163. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
  164. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  165. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  166. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  167. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  168. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -40
  169. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  170. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  171. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  172. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  173. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  174. package/gradle/libs.versions.toml +0 -69
  175. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  176. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  177. package/gradle.properties +0 -26
  178. package/gradlew +0 -252
  179. package/gradlew.bat +0 -94
  180. package/ios/Application/Layout/ScreenLayout.swift +0 -196
  181. package/ios/Application/Navigation/BottomTab/DuoTabBar.swift +0 -275
  182. package/ios/Application/Navigation/component/DuoScrollGradient.swift +0 -55
  183. package/ios/Application/Navigation/component/SideBar.swift +0 -155
  184. package/ios/Popup/PopupLayout.swift +0 -45
  185. package/ios-demo/README.md +0 -120
  186. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DuoTabDemo.swift +0 -76
  187. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IPhoneDuoDemo.swift +0 -170
  188. package/local.properties +0 -8
  189. package/settings.gradle.kts +0 -64
@@ -1,55 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- import androidx.compose.runtime.*
4
- import org.jetbrains.compose.resources.DrawableResource
5
- import org.jetbrains.compose.resources.InternalResourceApi
6
- import org.jetbrains.compose.resources.ResourceItem
7
- import org.jetbrains.compose.resources.readResourceBytes
8
- @OptIn(InternalResourceApi::class)
9
- @Composable
10
- internal fun readJson(name: String): String {
11
- val path = name.plus(".json")
12
- val candidatePaths = listOf(
13
- path,
14
- "composeResources/vn.momo.compose.resources/$path",
15
- )
16
-
17
- val jsonContent by rememberState(path, { "" }) {
18
- val cached = resourceCache.getOrPut(path) {
19
- var content = ""
20
- for (candidate in candidatePaths) {
21
- try {
22
- content = readResourceBytes(candidate).decodeToString()
23
- break
24
- } catch (_: Exception) {
25
- // try next candidate
26
- }
27
- }
28
- ResourceCache.JSON(content)
29
- } as ResourceCache.JSON
30
-
31
- cached.json
32
- }
33
-
34
- return jsonContent
35
- }
36
-
37
-
38
- private val resourceCache = mutableMapOf<String, ResourceCache>()
39
-
40
- private sealed interface ResourceCache {
41
- class JSON(val json: String) : ResourceCache
42
- }
43
-
44
- @Composable
45
- fun <T> rememberState(
46
- key: Any,
47
- getDefault: () -> T,
48
- block: suspend () -> T
49
- ): MutableState<T> {
50
- val state = remember(key) { mutableStateOf(getDefault()) }
51
- LaunchedEffect(key) {
52
- state.value = block()
53
- }
54
- return state
55
- }
@@ -1,15 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- import androidx.compose.runtime.Composable
4
- import vn.momo.kits.application.LocalComponentInformation
5
-
6
- @Composable
7
- internal fun getComponentId(
8
- componentName: String? = null,
9
- accessibilityLabel: String? = null,
10
- ): String {
11
- val componentInformation = LocalComponentInformation.current
12
- if (accessibilityLabel != null) return accessibilityLabel
13
- if (componentInformation?.componentId != null) return componentInformation.componentId
14
- return ""
15
- }
@@ -1,118 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- import androidx.compose.foundation.layout.WindowInsets
4
- import androidx.compose.foundation.layout.WindowInsetsSides
5
- import androidx.compose.foundation.layout.displayCutout
6
- import androidx.compose.foundation.layout.only
7
- import androidx.compose.foundation.layout.union
8
- import androidx.compose.foundation.layout.windowInsetsPadding
9
- import androidx.compose.foundation.layout.asPaddingValues
10
- import androidx.compose.foundation.layout.systemBars
11
- import androidx.compose.runtime.Composable
12
- import androidx.compose.ui.Modifier
13
- import androidx.compose.ui.composed
14
- import androidx.compose.ui.draw.drawBehind
15
- import androidx.compose.ui.geometry.Offset
16
- import androidx.compose.ui.graphics.Color
17
- import androidx.compose.ui.platform.LocalDensity
18
- import androidx.compose.ui.unit.Dp
19
- import androidx.compose.ui.unit.dp
20
- import androidx.compose.ui.unit.min
21
- import vn.momo.kits.const.AppNavigationBar
22
- import vn.momo.kits.const.AppStatusBar
23
- import vn.momo.kits.platform.getPlatformName
24
- import kotlin.math.abs
25
-
26
-
27
- internal fun Modifier.bottomBorder(strokeWidth: Dp, color: Color) = composed(
28
- factory = {
29
- val density = LocalDensity.current
30
- val strokeWidthPx = density.run { strokeWidth.toPx() }
31
- if (strokeWidth > 0.dp) {
32
- Modifier.drawBehind {
33
- val width = size.width
34
- val height = size.height - strokeWidthPx / 2
35
-
36
- drawLine(
37
- color = color,
38
- start = Offset(x = 0f, y = height),
39
- end = Offset(x = width, y = height),
40
- strokeWidth = strokeWidthPx
41
- )
42
- }
43
- } else {
44
- Modifier
45
- }
46
- }
47
- )
48
-
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
52
-
53
- fun formatNumberToMoney(number: Long, currency: String = "đ"): String {
54
- if (number == 0L) {
55
- return "0$currency"
56
- }
57
- val array = mutableListOf<Char>()
58
- var result = ""
59
- var isNegative = false
60
-
61
- if (number < 0) {
62
- isNegative = true
63
- }
64
- val numberString = abs(number).toString() // Convert to Int to avoid decimal places
65
- if (numberString.length < 3) {
66
- return numberString + currency
67
- }
68
- var count = 0
69
- for (i in numberString.length - 1 downTo 0) {
70
- count += 1
71
- array.add(numberString[i])
72
- if (count == 3 && i >= 1) {
73
- array.add('.')
74
- count = 0
75
- }
76
- }
77
-
78
- for (i in array.size - 1 downTo 0) {
79
- result += array[i]
80
- }
81
-
82
- if (isNegative) {
83
- result = "-$result"
84
- }
85
-
86
- return result + currency
87
- }
88
-
89
- @Composable
90
- fun getAppStatusBarHeight(): Dp {
91
- return if (AppStatusBar.current == 0.dp) {
92
- WindowInsets.systemBars.asPaddingValues().calculateTopPadding()
93
- } else {
94
- AppStatusBar.current
95
- }
96
- }
97
-
98
- internal val horizontalSafeAreaInsets: WindowInsets
99
- @Composable get() = WindowInsets.systemBars.union(WindowInsets.displayCutout).only(WindowInsetsSides.Horizontal)
100
-
101
- // Left/right safe area like SwiftUI (landscape camera/notch); consumed, so nested StackScreens don't pad twice.
102
- internal fun Modifier.horizontalSafeAreaPadding(): Modifier = composed {
103
- windowInsetsPadding(horizontalSafeAreaInsets)
104
- }
105
-
106
- @Composable
107
- internal fun getNavigationBarHeight(): Dp {
108
- return if (AppNavigationBar.current == 0.dp) {
109
- val systemBottomPadding = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
110
- if (getPlatformName() == "iOS") {
111
- min(systemBottomPadding, 21.dp)
112
- } else {
113
- systemBottomPadding
114
- }
115
- } else {
116
- AppNavigationBar.current
117
- }
118
- }
@@ -1,40 +0,0 @@
1
- @file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
2
-
3
- package vn.momo.kits.const
4
-
5
- import androidx.compose.runtime.Composable
6
- import androidx.compose.runtime.remember
7
- import androidx.compose.ui.text.font.FontFamily
8
- import androidx.compose.ui.text.platform.Font
9
- import kotlinx.cinterop.ExperimentalForeignApi
10
- import kotlinx.cinterop.addressOf
11
- import kotlinx.cinterop.usePinned
12
- import platform.Foundation.NSBundle
13
- import platform.Foundation.NSData
14
- import platform.Foundation.dataWithContentsOfFile
15
- import platform.posix.memcpy
16
-
17
- @Composable
18
- internal actual fun hostFontFamily(fileName: String): FontFamily? = remember(fileName) {
19
- val name = fileName.substringBeforeLast('.')
20
- val ext = fileName.substringAfterLast('.', "")
21
- // Font từ font-source nằm rời ở bundle root, không nằm trong compose-resources.
22
- val path = NSBundle.mainBundle.pathForResource(name, ext) ?: return@remember null
23
- FontFamily(
24
- Font(
25
- identity = fileName,
26
- getData = {
27
- NSData.dataWithContentsOfFile(path)?.toByteArray() ?: ByteArray(0)
28
- },
29
- ),
30
- )
31
- }
32
-
33
- @OptIn(ExperimentalForeignApi::class)
34
- private fun NSData.toByteArray(): ByteArray {
35
- val size = length.toInt()
36
- if (size == 0) return ByteArray(0)
37
- return ByteArray(size).apply {
38
- usePinned { pinned -> memcpy(pinned.addressOf(0), bytes, length) }
39
- }
40
- }
@@ -1,45 +0,0 @@
1
- package vn.momo.kits.navigation
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.runtime.DisposableEffect
5
- import androidx.compose.runtime.remember
6
- import androidx.navigationevent.NavigationEvent
7
- import androidx.navigationevent.NavigationEventDispatcher
8
- import androidx.navigationevent.NavigationEventInput
9
-
10
- @Suppress("ParamsComparedByRef")
11
- @Composable
12
- internal fun AttachHostBackGesture(dispatcher: NavigationEventDispatcher, navigator: Navigator) {
13
- val input = remember(dispatcher) { HostNavigationEventInput() }
14
- val target = remember(input, navigator) {
15
- object : HostBackTarget {
16
- override fun canPop() = navigator.canPop()
17
- override fun onBack() = navigator.onBackSafe()
18
- override fun backStarted() = input.backStarted()
19
- override fun backProgressed(progress: Float) = input.backProgressed(progress)
20
- override fun backCompleted() = input.backCompleted()
21
- override fun backCancelled() = input.backCancelled()
22
- }
23
- }
24
-
25
- DisposableEffect(dispatcher, target) {
26
- dispatcher.addInput(input)
27
- HostBackGestureBridge.attach(target)
28
- onDispose {
29
- HostBackGestureBridge.detach(target)
30
- dispatcher.removeInput(input)
31
- }
32
- }
33
- }
34
-
35
- internal class HostNavigationEventInput : NavigationEventInput() {
36
- fun backStarted() = dispatchOnBackStarted(NavigationEvent(swipeEdge = NavigationEvent.EDGE_LEFT))
37
-
38
- fun backProgressed(progress: Float) = dispatchOnBackProgressed(
39
- NavigationEvent(swipeEdge = NavigationEvent.EDGE_LEFT, progress = progress)
40
- )
41
-
42
- fun backCancelled() = dispatchOnBackCancelled()
43
-
44
- fun backCompleted() = dispatchOnBackCompleted()
45
- }
@@ -1,32 +0,0 @@
1
- package vn.momo.kits.navigation
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.runtime.DisposableEffect
5
- import platform.Foundation.NSNotification
6
- import platform.Foundation.NSNotificationCenter
7
- import platform.Foundation.NSOperationQueue
8
- import platform.darwin.NSObjectProtocol
9
-
10
- private const val STATUS_BAR_TAPPED_NOTIFICATION = "statusBarSelected"
11
-
12
- @Composable
13
- internal actual fun RegisterScrollToTop(callback: (() -> Unit)?) {
14
- val maxApi = LocalMaxApi.current
15
- DisposableEffect(callback) {
16
- val token: NSObjectProtocol? = if (callback != null) {
17
- NSNotificationCenter.defaultCenter.addObserverForName(
18
- name = STATUS_BAR_TAPPED_NOTIFICATION,
19
- `object` = null,
20
- queue = NSOperationQueue.mainQueue,
21
- ) { _: NSNotification? ->
22
- runCatching { callback() }.onFailure {
23
- maxApi?.logFile("[ScrollToTop] callback threw: ${it.message}") {}
24
-
25
- }
26
- }
27
- } else null
28
- onDispose {
29
- token?.let { NSNotificationCenter.defaultCenter.removeObserver(it) }
30
- }
31
- }
32
- }
@@ -1,38 +0,0 @@
1
- package vn.momo.kits.platform
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.runtime.LaunchedEffect
5
- import androidx.compose.runtime.State
6
- import androidx.compose.runtime.mutableStateOf
7
- import androidx.compose.runtime.remember
8
- import androidx.compose.ui.InternalComposeUiApi
9
- import androidx.compose.ui.backhandler.LocalCompatNavigationEventDispatcherOwner
10
- import androidx.navigationevent.NavigationEventTransitionState
11
- import vn.momo.kits.navigation.HostBackGestureBridge
12
-
13
- // transitionState is a passive observer; its progress is touch.x / view width.
14
- @OptIn(InternalComposeUiApi::class)
15
- @Composable
16
- actual fun rememberBackGestureProgress(): State<Float?> {
17
- val dispatcher = LocalCompatNavigationEventDispatcherOwner.current?.navigationEventDispatcher
18
- val progress = remember { mutableStateOf<Float?>(null) }
19
-
20
- LaunchedEffect(dispatcher) {
21
- if (dispatcher == null) {
22
- progress.value = null
23
- return@LaunchedEffect
24
- }
25
- dispatcher.transitionState.collect { state ->
26
- progress.value = (state as? NavigationEventTransitionState.InProgress)
27
- ?.takeIf { it.direction == NavigationEventTransitionState.TRANSITIONING_BACK }
28
- ?.latestEvent
29
- ?.progress
30
- }
31
- }
32
-
33
- return progress
34
- }
35
-
36
- actual fun reportFloatingArrowBack(shouldUse: Boolean) {
37
- HostBackGestureBridge.shouldUseFloatingArrowBack = shouldUse
38
- }
@@ -1,66 +0,0 @@
1
- package vn.momo.kits.platform
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.runtime.CompositionLocalProvider
5
- import androidx.compose.runtime.DisposableEffect
6
- import androidx.compose.runtime.mutableStateOf
7
- import androidx.compose.runtime.remember
8
- import androidx.compose.ui.platform.LocalDensity
9
- import androidx.compose.ui.unit.Density
10
- import kotlinx.cinterop.ExperimentalForeignApi
11
- import kotlinx.cinterop.ObjCAction
12
- import platform.Foundation.NSNotification
13
- import platform.Foundation.NSNotificationCenter
14
- import platform.Foundation.NSSelectorFromString
15
- import platform.UIKit.UIContentSizeCategoryDidChangeNotification
16
- import platform.UIKit.UIFont
17
- import platform.UIKit.UIFontTextStyleBody
18
- import platform.darwin.NSObject
19
-
20
- // Compose MP iOS reads LocalDensity.fontScale once at ComposeUIViewController creation and does not
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.
24
- private const val DEFAULT_BODY_POINT_SIZE = 17.0
25
-
26
- private fun currentOsFontScale(): Float =
27
- (UIFont.preferredFontForTextStyle(UIFontTextStyleBody).pointSize / DEFAULT_BODY_POINT_SIZE).toFloat()
28
-
29
- @OptIn(ExperimentalForeignApi::class)
30
- @Composable
31
- actual fun ProvideOsFontScale(content: @Composable () -> Unit) {
32
- val osFontScale = remember { mutableStateOf(currentOsFontScale()) }
33
-
34
- val listener = remember {
35
- object : NSObject() {
36
- @Suppress("unused")
37
- @ObjCAction
38
- fun contentSizeChanged(arg: NSNotification) {
39
- osFontScale.value = currentOsFontScale()
40
- }
41
- }
42
- }
43
-
44
- DisposableEffect(Unit) {
45
- NSNotificationCenter.defaultCenter.addObserver(
46
- observer = listener,
47
- selector = NSSelectorFromString(listener::contentSizeChanged.name + ":"),
48
- name = UIContentSizeCategoryDidChangeNotification,
49
- `object` = null,
50
- )
51
- onDispose {
52
- NSNotificationCenter.defaultCenter.removeObserver(
53
- observer = listener,
54
- name = UIContentSizeCategoryDidChangeNotification,
55
- `object` = null,
56
- )
57
- }
58
- }
59
-
60
- val density = LocalDensity.current
61
- CompositionLocalProvider(
62
- LocalDensity provides Density(density.density, osFontScale.value),
63
- ) {
64
- content()
65
- }
66
- }
@@ -1,217 +0,0 @@
1
- package vn.momo.kits.platform
2
-
3
- import androidx.compose.foundation.layout.Box
4
- import androidx.compose.foundation.layout.WindowInsets
5
- import androidx.compose.foundation.layout.asPaddingValues
6
- import androidx.compose.foundation.layout.fillMaxSize
7
- import androidx.compose.foundation.layout.systemBars
8
- import androidx.compose.runtime.Composable
9
- import androidx.compose.runtime.CompositionLocalProvider
10
- import androidx.compose.runtime.LaunchedEffect
11
- import androidx.compose.runtime.getValue
12
- import androidx.compose.runtime.mutableStateOf
13
- import androidx.compose.runtime.remember
14
- import androidx.compose.runtime.rememberUpdatedState
15
- import androidx.compose.runtime.setValue
16
- import androidx.compose.ui.ExperimentalComposeUiApi
17
- import androidx.compose.ui.InternalComposeUiApi
18
- import androidx.compose.ui.Modifier
19
- import androidx.compose.ui.backhandler.LocalCompatNavigationEventDispatcherOwner
20
- import androidx.compose.ui.backhandler.BackHandler as ComposeBackHandler
21
- import androidx.compose.ui.graphics.Color
22
- import androidx.compose.ui.graphics.NativePaint
23
- import androidx.compose.ui.graphics.toArgb
24
- import androidx.compose.ui.unit.Dp
25
- import androidx.compose.ui.unit.dp
26
- import androidx.compose.ui.viewinterop.UIKitInteropProperties
27
- import androidx.compose.ui.viewinterop.UIKitView
28
- import cocoapods.lottie_ios.CompatibleAnimation
29
- import cocoapods.lottie_ios.CompatibleAnimationKeypath
30
- import cocoapods.lottie_ios.CompatibleAnimationView
31
- import kotlinx.cinterop.ExperimentalForeignApi
32
- import kotlinx.cinterop.get
33
- import kotlinx.cinterop.memScoped
34
- import androidx.navigationevent.NavigationEventDispatcher
35
- import androidx.navigationevent.NavigationEventDispatcherOwner
36
- import org.jetbrains.skia.FilterBlurMode
37
- import org.jetbrains.skia.MaskFilter
38
- import platform.Foundation.NSBundle
39
- import platform.UIKit.UIColor
40
- import platform.UIKit.UIDevice
41
- import platform.UIKit.UIScreen
42
- import platform.UIKit.UIUserInterfaceIdiomPhone
43
- import vn.momo.kits.navigation.AttachHostBackGesture
44
- import vn.momo.kits.navigation.Navigator
45
-
46
- actual fun getPlatformName(): String = "iOS"
47
-
48
- actual fun isPhoneIdiom(): Boolean =
49
- UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
50
-
51
- @OptIn(ExperimentalForeignApi::class)
52
- @Composable
53
- actual fun getScreenDimensions(): ScreenDimension = memScoped {
54
- val config = UIScreen.mainScreen.bounds.ptr[0]
55
- return ScreenDimension(
56
- config.size.width.toInt(),
57
- config.size.height.toInt()
58
- )
59
- }
60
-
61
- actual fun NativePaint.setMaskFilter(blurRadius: Float) {
62
- this.maskFilter = MaskFilter.makeBlur(FilterBlurMode.NORMAL, blurRadius / 2, true)
63
- }
64
-
65
- @Composable
66
- actual fun getStatusBarHeight(): Dp {
67
- return WindowInsets.systemBars.asPaddingValues().calculateTopPadding()
68
- }
69
-
70
- @Suppress("DEPRECATION")
71
- @OptIn(ExperimentalComposeUiApi::class)
72
- @Composable
73
- actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) {
74
- ComposeBackHandler(enabled = enabled, onBack = onBack)
75
- }
76
-
77
- @OptIn(InternalComposeUiApi::class)
78
- @Composable
79
- actual fun ProvideNavigationEventDispatcherOwner(navigator: Navigator, content: @Composable () -> Unit) {
80
- val navigationEventDispatcherOwner = remember {
81
- object : NavigationEventDispatcherOwner {
82
- override val navigationEventDispatcher = NavigationEventDispatcher()
83
- }
84
- }
85
-
86
- AttachHostBackGesture(navigationEventDispatcherOwner.navigationEventDispatcher, navigator)
87
-
88
- CompositionLocalProvider(
89
- LocalCompatNavigationEventDispatcherOwner provides navigationEventDispatcherOwner,
90
- content = content
91
- )
92
- }
93
-
94
- @Composable
95
- actual fun getScreenHeight(): Dp {
96
- return getScreenDimensions().height.dp
97
- }
98
-
99
- actual fun getOSVersion(): OSVersion = OSVersion.IOS(
100
- major = UIDevice.currentDevice.systemVersion.substringBefore(".").toIntOrNull() ?: 0
101
- )
102
-
103
- @OptIn(ExperimentalForeignApi::class, ExperimentalComposeUiApi::class)
104
- @Composable
105
- actual fun LottieAnimation(
106
- path: String,
107
- tintColor: Color?,
108
- bgColor: Color?,
109
- placedAsOverlay: Boolean,
110
- iterations: Int,
111
- isPlaying: Boolean,
112
- onEvent: ((String) -> Unit)?,
113
- modifier: Modifier,
114
- useCompose: Boolean
115
- ) {
116
- if (useCompose) {
117
- ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier)
118
- return
119
- }
120
-
121
- val loopCount = if (iterations == LottieIterateForever) -1.0 else iterations.toDouble()
122
-
123
- var animation by remember { mutableStateOf<CompatibleAnimation?>(null) }
124
- val animationView = remember { mutableStateOf<CompatibleAnimationView?>(null) }
125
-
126
- LaunchedEffect(Unit) {
127
- animation = CompatibleAnimation(name = "compose-resources/composeResources/vn.momo.compose.resources/".plus(path), subdirectory = null, NSBundle.mainBundle)
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(animationView.value, isPlaying) {
137
- val view = animationView.value ?: return@LaunchedEffect
138
- if (isPlaying) {
139
- view.playWithCompletion(completion = { finished -> if (finished) currentOnEvent?.invoke(LottieEvent.Finish) })
140
- } else {
141
- view.pause()
142
- }
143
- }
144
-
145
- when (val value = animation) {
146
- null -> {
147
- Box(modifier)
148
- }
149
-
150
- else -> {
151
- Box(modifier) {
152
- UIKitView(
153
- modifier = Modifier.fillMaxSize(),
154
- properties = UIKitInteropProperties(placedAsOverlay = placedAsOverlay),
155
- factory = {
156
- CompatibleAnimationView(value).apply {
157
- translatesAutoresizingMaskIntoConstraints = true
158
-
159
- setBackgroundColor(bgColor?.toUIColor() ?: UIColor.clearColor)
160
-
161
- setLoopAnimationCount(loopCount)
162
- setAnimationSpeed(1.0)
163
-
164
- if (tintColor != null) {
165
- val uiColor = tintColor.toUIColor()
166
- setColorValue(uiColor,
167
- CompatibleAnimationKeypath("**.Fill 1.Color")
168
- )
169
- setColorValue(uiColor, CompatibleAnimationKeypath("**.Fill.Color"))
170
- setColorValue(uiColor, CompatibleAnimationKeypath("**.Color"))
171
- setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke 1.Color"))
172
- setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke.Color"))
173
- }
174
-
175
- animationView.value = this
176
- }
177
- },
178
-
179
- update = { view ->
180
- view.setBackgroundColor(bgColor?.toUIColor() ?: UIColor.clearColor)
181
- view.setLoopAnimationCount(loopCount)
182
-
183
- if (tintColor != null) {
184
- val uiColor = tintColor.toUIColor()
185
-
186
- view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Fill 1.Color"))
187
- view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Fill.Color"))
188
- view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Color"))
189
- view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke 1.Color"))
190
- view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke.Color"))
191
- }
192
- }
193
- )
194
- }
195
- }
196
- }
197
- }
198
-
199
- fun Color.toUIColor(): UIColor {
200
- val argb = this.toArgb()
201
-
202
- val a = ((argb shr 24) and 0xFF) / 255.0
203
- val r = ((argb shr 16) and 0xFF) / 255.0
204
- val g = ((argb shr 8) and 0xFF) / 255.0
205
- val b = (argb and 0xFF) / 255.0
206
-
207
- return UIColor(
208
- red = r,
209
- green = g,
210
- blue = b,
211
- alpha = a
212
- )
213
- }
214
-
215
- actual fun NativePaint.setColor(color: Color){
216
- this.color = color.toArgb()
217
- }