@momo-kits/native-kits 0.168.1-beta.31 → 0.168.1-beta.32-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 (149) hide show
  1. package/CLAUDE.md +1 -2
  2. package/build.gradle.kts +11 -0
  3. package/compose/build.gradle.kts +198 -0
  4. package/compose/build.gradle.kts.backup +198 -0
  5. package/compose/compose.podspec +47 -0
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +20 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +154 -0
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +62 -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 +370 -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 +17 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +287 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +321 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +502 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +148 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +116 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +205 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +422 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +732 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +240 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +389 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +94 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +97 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +203 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +106 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +455 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +399 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +192 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +92 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +20 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +118 -0
  122. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
  123. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  124. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
  125. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +219 -0
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +138 -0
  129. package/gradle/libs.versions.toml +69 -0
  130. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  131. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  132. package/gradle.properties +26 -0
  133. package/gradlew +252 -0
  134. package/gradlew.bat +94 -0
  135. package/ios/Input/Input.swift +1 -3
  136. package/ios/Input/InputTextArea.swift +1 -3
  137. package/ios/Navigation/BottomTab/BottomTab.swift +48 -67
  138. package/ios/Navigation/BottomTab/BottomTabBar.swift +281 -131
  139. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  140. package/ios/Navigation/BottomTab/DuoTabBar.swift +72 -292
  141. package/ios/Navigation/BottomTab/TabBarMetrics.swift +88 -0
  142. package/ios/Navigation/StackScreen.swift +3 -1
  143. package/ios-demo/README.md +120 -0
  144. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  145. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  146. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
  147. package/package.json +1 -1
  148. package/settings.gradle.kts +64 -0
  149. package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +0 -364
@@ -2,77 +2,294 @@
2
2
  // BottomTabDemo.swift
3
3
  // Example
4
4
  //
5
- // Usage demo for the bottom-tab navigation. Mirrors Compose's `BottomTabUsage`:
6
- // four tabs (each with its own header title + badge) and a center floating
7
- // button. Must be hosted inside a `NavigationContainer` (uses the Navigator).
5
+ // Usage demo for the bottom-tab navigation, same as RN app/screens/Navigation/BottomTab and
6
+ // Compose's `BottomTabUsage`: the bar shows right away, every tab holds the options and each
7
+ // change rebuilds the bar below. Must be hosted inside a `NavigationContainer`.
8
8
  //
9
9
 
10
+ import Lottie
10
11
  import MoMoUIKits
11
12
  import SwiftUI
12
13
 
13
- @available(iOS 16.0, *)
14
+ private struct TabConfig: Hashable {
15
+ let name: String
16
+ var label: String
17
+ var icon: String
18
+ // nil = no badge, "" = dot, "0" = hidden, numbers > 99 = 99+, text = text badge
19
+ var badgeLabel: String?
20
+ var showDot = false
21
+ }
22
+
23
+ private struct DemoConfig: Hashable {
24
+ var tabs: [TabConfig] = [
25
+ TabConfig(name: "Momo", label: "Momo", icon: "home_momo_active"),
26
+ TabConfig(name: "UuDai", label: "Ưu đãi", icon: "home_promotions_active", badgeLabel: "Mới"),
27
+ TabConfig(name: "GiaoDich", label: "Giao dịch", icon: "home_history_active", badgeLabel: "5"),
28
+ TabConfig(name: "Toi", label: "Tôi", icon: "home_friends_active", badgeLabel: ""),
29
+ TabConfig(name: "Vi", label: "Ví", icon: "home_wallet_inactive", badgeLabel: "1999"),
30
+ ]
31
+ var tabCount = 4
32
+ var longLabels = false
33
+ var special = true
34
+ var ctaLabel = "Quét mọi QR"
35
+ var ctaIcon = "momomain_scan_code"
36
+ // the Home Lottie, split into its button and label parts, instead of icon and label
37
+ var ctaLottie = false
38
+ var initialRouteName = "Momo"
39
+ var compressionBehavior: DuoBarCompressionBehavior = .toolbar
40
+ var backToInitialTab = true
41
+
42
+ var visibleTabs: [TabConfig] { Array(tabs.prefix(tabCount)) }
43
+ }
44
+
45
+ private let icons = [
46
+ "home_momo_active", "home_promotions_active", "home_history_active", "home_friends_active",
47
+ "home_wallet_inactive", "notifications_bell", "basic_setting",
48
+ ]
49
+ private let ctaIcons = ["momomain_scan_code", "navigation_scan", "navigation_qrcode"]
50
+ // The Home "Quét mọi QR" animation in two files on a 160 canvas: pink circle 100 centered at y 70, label
51
+ // centered at y 138. At 77 the circle is the 48 button; the button part moves down 5 onto the button center,
52
+ // the label part up 28 onto the label line.
53
+ private let ctaLottieSize: CGFloat = 77
54
+ private let ctaLottieButtonOffset: CGFloat = 5
55
+ private let ctaLottieLabelOffset: CGFloat = 28
56
+
57
+ /// A Lottie bundled with the demo: in the app bundle (sample iosApp) or the demo pod's resource bundle.
58
+ private func demoLottie(_ name: String) -> LottieAnimation? {
59
+ let podBundle = Bundle.main.url(forResource: "MoMoUIKitsDemoResources", withExtension: "bundle").flatMap(Bundle.init(url:))
60
+ return LottieAnimation.named(name, bundle: .main) ?? podBundle.flatMap { LottieAnimation.named(name, bundle: $0) }
61
+ }
62
+
63
+ private let ctaLottieButton = demoLottie("tabbar_scan_qr_button")
64
+ private let ctaLottieLabel = demoLottie("tabbar_scan_qr_label")
65
+
66
+ // both parts read their progress from the same clock, two playing views start at different times
67
+ private func ctaLottie(_ animation: LottieAnimation?, offset: CGFloat) -> some View {
68
+ TimelineView(.animation) { timeline in
69
+ let duration = animation?.duration ?? 1
70
+ let elapsed = timeline.date.timeIntervalSinceReferenceDate
71
+ LottieView(animation: animation)
72
+ .currentProgress(elapsed.truncatingRemainder(dividingBy: duration) / duration)
73
+ .resizable()
74
+ .frame(width: ctaLottieSize, height: ctaLottieSize)
75
+ .offset(y: offset)
76
+ }
77
+ }
78
+ private let badges: [(String, String?)] = [
79
+ ("Không", nil), ("Dot \"\"", ""), ("\"0\"", "0"), ("\"5\"", "5"),
80
+ ("\"1999\"", "1999"), ("\"Mới\"", "Mới"), ("Chữ dài", "Khuyến mãi lớn"),
81
+ ]
82
+
14
83
  struct BottomTabDemoContent: View {
15
- @EnvironmentObject private var navigator: Navigator
84
+ @State private var config = DemoConfig()
85
+ // the bar is rebuilt on every change: reopen it on the tab the user is on
86
+ @State private var focused = DemoConfig().initialRouteName
16
87
 
17
88
  var body: some View {
89
+ let tabs = config.visibleTabs
90
+ let initial = tabs.contains { $0.name == focused } ? focused : tabs[0].name
18
91
  BottomTab(
19
- items: [
20
- BottomTabItem(
21
- name: "Tab1",
22
- label: "Option 1",
23
- icon: "16_basic_home",
24
- badgeLabel: "",
25
- options: NavigationOptions(headerTitle: .default("Option 1"), hiddenBack: false),
26
- screen: { tabBody("Option 1", Colors.blue09) }
27
- ),
92
+ items: tabs.map { tab in
28
93
  BottomTabItem(
29
- name: "Tab2",
30
- label: "Option 2",
31
- icon: "help_center",
32
- badgeLabel: "0", // hidden (mirrors Compose's "0" → no badge)
33
- options: NavigationOptions(headerTitle: .default("Option 2")),
34
- screen: { tabBody("Option 2", Colors.pink09) }
35
- ),
36
- BottomTabItem(
37
- name: "Tab3",
38
- label: "Option 3 with a very long label",
39
- icon: "pin_star",
40
- badgeLabel: "New",
41
- options: NavigationOptions(headerTitle: .default("Option 3")),
42
- screen: { tabBody("Option 3", Colors.yellow09) }
43
- ),
44
- BottomTabItem(
45
- name: "Tab4",
46
- label: "Option 4 also quite long here",
47
- icon: "navigation_more_icon",
48
- badgeLabel: "9999",
49
- options: NavigationOptions(headerTitle: .default("Option 4")),
50
- screen: { tabBody("Option 4", Colors.blue10) }
94
+ name: tab.name,
95
+ label: config.longLabels ? "\(tab.label) dài quá" : tab.label,
96
+ icon: tab.icon,
97
+ showDot: tab.showDot,
98
+ badgeLabel: tab.badgeLabel,
99
+ options: NavigationOptions(headerTitle: .default(tab.label)),
100
+ screen: { TabContent(name: tab.name, config: $config, focused: $focused) }
51
101
  )
52
- ],
53
- floatingButton: BottomTabFloatingButton(
54
- icon: "16_basic_home",
55
- label: "Quét QR",
56
- onPress: { navigator.push({ qrScreen }, options: NavigationOptions(title: "QR")) }
57
- )
102
+ },
103
+ floatingButton: floatingButton,
104
+ compressionBehavior: config.compressionBehavior,
105
+ initialRouteName: initial,
106
+ onTabPress: { index, switchTab in
107
+ focused = tabs[index].name
108
+ switchTab()
109
+ },
110
+ backToInitialTab: config.backToInitialTab
58
111
  )
112
+ .id(config)
113
+ }
114
+
115
+ private var floatingButton: BottomTabFloatingButton? {
116
+ guard config.special else { return nil }
117
+ guard config.ctaLottie else {
118
+ return BottomTabFloatingButton(icon: config.ctaIcon, label: config.ctaLabel, onPress: {})
119
+ }
120
+ return BottomTabFloatingButton(
121
+ label: config.ctaLabel,
122
+ onPress: {},
123
+ iconContent: { ctaLottie(ctaLottieButton, offset: ctaLottieButtonOffset) },
124
+ labelContent: { ctaLottie(ctaLottieLabel, offset: -ctaLottieLabelOffset) }
125
+ )
126
+ }
127
+ }
128
+
129
+ /// Content of every tab: this tab's own props, the bar props, then the center action. The tab's
130
+ /// StackScreen scrolls it under the floating bar and keeps its end clear of it.
131
+ private struct TabContent: View {
132
+ let name: String
133
+ @Binding var config: DemoConfig
134
+ @Binding var focused: String
135
+
136
+ private var tab: TabConfig { config.tabs.first { $0.name == name }! }
137
+
138
+ private func updateTab(_ change: (inout TabConfig) -> Void) {
139
+ guard let index = config.tabs.firstIndex(where: { $0.name == name }) else { return }
140
+ change(&config.tabs[index])
141
+ }
142
+
143
+ private func yesNo(_ value: Bool, _ onChange: @escaping (Bool) -> Void) -> [Option] {
144
+ [Option(title: "Có", selected: value) { onChange(true) },
145
+ Option(title: "Không", selected: !value) { onChange(false) }]
59
146
  }
60
147
 
61
- @ViewBuilder
62
- private func tabBody(_ title: String, _ color: Color) -> some View {
63
- VStack {
64
- MomoText(title, typography: .headerDefaultBold)
65
- .padding(.top, 24)
66
- Spacer()
148
+ var body: some View {
149
+ let ctaHidden = config.special && config.tabCount % 2 != 0
150
+ VStack(alignment: .leading, spacing: Spacing.M) {
151
+ MomoText("Chạm các tab bên dưới để xem indicator chạy qua lại. Mỗi thay đổi áp dụng ngay lên thanh tab.",
152
+ typography: .bodyDefaultRegular)
153
+
154
+ Section(title: "Tab đang mở · \(name)") {
155
+ IconOptions(title: "icon", icons: icons, value: tab.icon) { icon in updateTab { $0.icon = icon } }
156
+ Options(title: "badgeLabel",
157
+ hint: "\"\" là dot, \"0\" ẩn badge, số > 99 hiện 99+, chữ dài bị cắt ở 58",
158
+ options: badges.map { title, value in
159
+ Option(title: title, selected: tab.badgeLabel == value) { updateTab { $0.badgeLabel = value } }
160
+ })
161
+ Options(title: "showDot",
162
+ hint: "Hiện dot khi không có badgeLabel hoặc badgeLabel là \"0\"",
163
+ options: yesNo(tab.showDot) { value in updateTab { $0.showDot = value } })
164
+ }
165
+
166
+ Section(title: "Thanh tab") {
167
+ Options(title: "Số tab (items)", options: (2...5).map { count in
168
+ Option(title: "\(count)", selected: config.tabCount == count) { config.tabCount = count }
169
+ })
170
+ Options(title: "label", options: [
171
+ Option(title: "Ngắn", selected: !config.longLabels) { config.longLabels = false },
172
+ Option(title: "Dài", selected: config.longLabels) { config.longLabels = true },
173
+ ])
174
+ Options(title: "initialRouteName", hint: "Tab được chọn khi BottomTab mở",
175
+ options: config.visibleTabs.map { item in
176
+ Option(title: item.name, selected: config.initialRouteName == item.name) {
177
+ focused = item.name
178
+ config.initialRouteName = item.name
179
+ }
180
+ })
181
+ Options(title: "compressionBehavior",
182
+ hint: "iPhone Duo: bar nào thu gọn trước khi side bar không đủ chỗ",
183
+ options: [
184
+ Option(title: "toolbar", selected: config.compressionBehavior == .toolbar) {
185
+ config.compressionBehavior = .toolbar
186
+ },
187
+ Option(title: "tabBar", selected: config.compressionBehavior == .tabBar) {
188
+ config.compressionBehavior = .tabBar
189
+ },
190
+ ])
191
+ Options(title: "backToInitialTab", hint: "Back ở tab khác quay về tab đầu trước khi rời màn",
192
+ options: yesNo(config.backToInitialTab) { config.backToInitialTab = $0 })
193
+ }
194
+
195
+ Section(title: "Nút giữa (floatingButton)") {
196
+ Options(title: "floatingButton",
197
+ hint: ctaHidden
198
+ ? "Đang ẩn: nút giữa chỉ hiện khi có 2 hoặc 4 tab"
199
+ : "Có = Special (nút giữa trong notch), Không = Default",
200
+ options: yesNo(config.special) { config.special = $0 })
201
+ if config.special {
202
+ Options(title: "label", options: ["Quét mọi QR", "Quét mã thanh toán"].map { label in
203
+ Option(title: label, selected: config.ctaLabel == label) { config.ctaLabel = label }
204
+ })
205
+ Options(title: "icon dạng", hint: "Lottie: animation Quét mọi QR của Home, 2 phần nút và chữ", options: [
206
+ Option(title: "Icon", selected: !config.ctaLottie) { config.ctaLottie = false },
207
+ Option(title: "Lottie", selected: config.ctaLottie) { config.ctaLottie = true },
208
+ ])
209
+ if !config.ctaLottie {
210
+ IconOptions(title: "icon", icons: ctaIcons, value: config.ctaIcon) { config.ctaIcon = $0 }
211
+ }
212
+ }
213
+ }
214
+
215
+ MoMoUIKits.Button(title: "Khôi phục mặc định", action: { config = DemoConfig() }, type: .outline)
216
+ }
217
+ .padding(Spacing.M)
218
+ }
219
+ }
220
+
221
+ private struct Option: Identifiable {
222
+ var id: String { title }
223
+ let title: String
224
+ let selected: Bool
225
+ let onPress: () -> Void
226
+ }
227
+
228
+ private struct Section<Content: View>: View {
229
+ let title: String
230
+ @ViewBuilder let content: () -> Content
231
+
232
+ @Environment(\.appTheme) private var theme
233
+
234
+ var body: some View {
235
+ VStack(alignment: .leading, spacing: Spacing.M) {
236
+ MomoText(title, typography: .headerSSemibold)
237
+ content()
67
238
  }
68
- .frame(maxWidth: .infinity, maxHeight: .infinity)
69
- .background(color)
239
+ .padding(Spacing.M)
240
+ .frame(maxWidth: .infinity, alignment: .leading)
241
+ .background(RoundedRectangle(cornerRadius: Radius.M).fill(theme.colors.background.surface))
70
242
  }
243
+ }
71
244
 
72
- private var qrScreen: some View {
73
- VStack { MomoText("QR scanner placeholder") }
74
- .frame(maxWidth: .infinity)
75
- .padding(24)
245
+ private struct Options: View {
246
+ let title: String
247
+ var hint: String? = nil
248
+ let options: [Option]
249
+
250
+ var body: some View {
251
+ VStack(alignment: .leading, spacing: Spacing.XS) {
252
+ MomoText(title, typography: .labelDefaultMedium)
253
+ if let hint {
254
+ MomoText(hint, typography: .descriptionXsRegular)
255
+ }
256
+ LazyVGrid(columns: [GridItem(.adaptive(minimum: 88), spacing: Spacing.S, alignment: .leading)],
257
+ alignment: .leading, spacing: Spacing.S) {
258
+ ForEach(options) { option in
259
+ MoMoUIKits.Button(title: option.title, action: option.onPress,
260
+ type: option.selected ? .primary : .outline, size: .small, isFull: false)
261
+ }
262
+ }
263
+ }
264
+ }
265
+ }
266
+
267
+ private struct IconOptions: View {
268
+ let title: String
269
+ let icons: [String]
270
+ let value: String
271
+ let onChange: (String) -> Void
272
+
273
+ @Environment(\.appTheme) private var theme
274
+
275
+ var body: some View {
276
+ VStack(alignment: .leading, spacing: Spacing.XS) {
277
+ MomoText(title, typography: .labelDefaultMedium)
278
+ HStack(spacing: Spacing.S) {
279
+ ForEach(icons, id: \.self) { icon in
280
+ let selected = icon == value
281
+ SwiftUI.Button { onChange(icon) } label: {
282
+ Icon(source: icon, size: 24, color: selected ? theme.colors.primary : theme.colors.text.default)
283
+ .frame(width: 40, height: 40)
284
+ .overlay(
285
+ RoundedRectangle(cornerRadius: Radius.S)
286
+ .stroke(selected ? theme.colors.primary : theme.colors.border.default, lineWidth: 1)
287
+ )
288
+ }
289
+ .buttonStyle(.plain)
290
+ }
291
+ }
292
+ }
76
293
  }
77
294
  }
78
295
 
@@ -80,10 +297,6 @@ struct BottomTabDemoContent: View {
80
297
 
81
298
  struct BottomTabDemo: View {
82
299
  var body: some View {
83
- if #available(iOS 16.0, *) {
84
- BottomTabDemoContent()
85
- } else {
86
- Text("Bottom tab demo requires iOS 16+").padding()
87
- }
300
+ BottomTabDemoContent()
88
301
  }
89
302
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.168.1-beta.31",
3
+ "version": "0.168.1-beta.32-debug",
4
4
  "private": false,
5
5
  "dependeNavigationncies": {},
6
6
  "devDependencies": {},
@@ -0,0 +1,64 @@
1
+ import org.gradle.kotlin.dsl.maven
2
+
3
+ rootProject.name = "momo-native-kits"
4
+ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
5
+
6
+ pluginManagement {
7
+ repositories {
8
+ google {
9
+ mavenContent {
10
+ includeGroupAndSubgroups("androidx")
11
+ includeGroupAndSubgroups("com.android")
12
+ includeGroupAndSubgroups("com.google")
13
+ }
14
+ }
15
+ mavenCentral()
16
+ gradlePluginPortal()
17
+ maven {
18
+ url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
19
+ credentials {username = "download_packages"; password = "gldt-bjDqLpU_sPcHDuXau2ws" }
20
+ }
21
+ maven {
22
+ url = uri("https://artifacts.mservice.com.vn/repository/maven-momo-app/")
23
+ credentials {
24
+ username = "viewer"
25
+ password = "viewer"
26
+ }
27
+ isAllowInsecureProtocol = true
28
+ }
29
+ }
30
+ }
31
+
32
+ dependencyResolutionManagement {
33
+ repositories {
34
+ google {
35
+ mavenContent {
36
+ includeGroupAndSubgroups("androidx")
37
+ includeGroupAndSubgroups("com.android")
38
+ includeGroupAndSubgroups("com.google")
39
+ }
40
+ }
41
+ mavenCentral()
42
+ maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
43
+ maven {
44
+ url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
45
+ credentials {
46
+ username = "download_packages";
47
+ password = "gldt-bjDqLpU_sPcHDuXau2ws"
48
+ }
49
+ }
50
+ maven {
51
+ url = uri("https://artifacts.mservice.com.vn/repository/maven-momo-app/")
52
+ credentials {
53
+ username = "viewer"
54
+ password = "viewer"
55
+ }
56
+ isAllowInsecureProtocol = true
57
+ }
58
+ }
59
+ }
60
+
61
+ include(":compose")
62
+
63
+ include(":sample:androidApp")
64
+ include(":sample:shared")