@momo-kits/native-kits 0.167.1-duo.2-debug → 0.167.1-duo.20-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 (194) hide show
  1. package/CLAUDE.md +36 -8
  2. package/README.md +2 -2
  3. package/compose/build.gradle.kts +15 -1
  4. package/compose/build.gradle.kts.backup +14 -0
  5. package/compose/compose.podspec +1 -1
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +2 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +168 -52
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +20 -21
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +2 -1
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +4 -2
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +1 -1
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +24 -14
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +1 -1
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -1
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +9 -6
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +11 -12
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +4 -9
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +2 -2
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +10 -9
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +6 -6
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +53 -26
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +12 -2
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +7 -9
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +1 -1
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +13 -6
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +13 -5
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +3 -2
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +14 -6
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +19 -21
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +2 -2
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +5 -2
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +3 -1
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +7 -15
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +4 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +10 -4
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +3 -17
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +173 -21
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +43 -4
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +8 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +10 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +153 -48
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +114 -71
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +8 -9
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +98 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +312 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +84 -18
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +33 -13
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +2 -1
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +51 -19
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +4 -2
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +1 -1
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +46 -23
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +2 -1
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +13 -0
  57. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +38 -0
  58. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +4 -0
  59. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +94 -0
  60. package/gradle.properties +1 -1
  61. package/ios/Application/ApplicationEnvironment.swift +17 -0
  62. package/ios/Application/MaxApi.swift +12 -3
  63. package/ios/Avatar/Avatar.swift +4 -3
  64. package/ios/Badge/Badge.swift +6 -4
  65. package/ios/Badge/BadgeDot.swift +1 -1
  66. package/ios/Badge/BadgeRibbon.swift +0 -1
  67. package/ios/Button/Button.swift +15 -12
  68. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +64 -18
  69. package/ios/Carousel/Carousel.swift +29 -12
  70. package/ios/Checkbox/Checkbox.swift +7 -3
  71. package/ios/Chip/Chip.swift +5 -4
  72. package/ios/Collapse/Collapse.swift +70 -19
  73. package/ios/Colors+Radius+Spacing/Colors.swift +10 -1
  74. package/ios/Colors+Radius+Spacing/Radius.swift +6 -0
  75. package/ios/DateTimePicker/DateTimePicker.swift +54 -20
  76. package/ios/DateTimePicker/WheelPicker.swift +103 -105
  77. package/ios/Divider/Divider.swift +37 -4
  78. package/ios/Extensions/Color++.swift +38 -9
  79. package/ios/Extensions/OptionalEnvironmentObject.swift +12 -0
  80. package/ios/Extensions/SkeletonUICompat.swift +11 -0
  81. package/ios/Icon/Icon.swift +21 -23
  82. package/ios/Icon/Icons.swift +1329 -0
  83. package/ios/IconButton/IconButton.swift +15 -7
  84. package/ios/Image/Image.swift +7 -23
  85. package/ios/Information/Information.swift +27 -9
  86. package/ios/Input/ErrorView.swift +2 -2
  87. package/ios/Input/Input.swift +160 -147
  88. package/ios/Input/InputPhoneNumber.swift +12 -9
  89. package/ios/Input/InputSearch.swift +102 -75
  90. package/ios/Input/InputTextArea.swift +128 -145
  91. package/ios/InputDropDown/InputDropDown.swift +10 -7
  92. package/ios/InputMoney/InputMoney.swift +33 -11
  93. package/ios/InputOTP/InputOTP.swift +22 -12
  94. package/ios/Layout/Card.swift +50 -0
  95. package/ios/Layout/GridContext.swift +187 -3
  96. package/ios/Layout/Item.swift +5 -4
  97. package/ios/Layout/ScreenLayout.swift +380 -0
  98. package/ios/Layout/Section.swift +4 -100
  99. package/ios/Loader/Loader.swift +5 -9
  100. package/ios/Lottie/LottieView.swift +14 -2
  101. package/ios/{Application/Navigation/Overplay → Navigation}/BottomSheet.swift +128 -9
  102. package/ios/Navigation/BottomTab/BottomTab.swift +185 -0
  103. package/ios/{Application/Navigation → Navigation}/BottomTab/BottomTabBar.swift +15 -7
  104. package/ios/Navigation/BottomTab/DuoBarCompression.swift +105 -0
  105. package/ios/Navigation/BottomTab/DuoTabBar.swift +304 -0
  106. package/ios/{Application → Navigation/Component}/FloatingButton.swift +14 -3
  107. package/ios/Navigation/Component/Header.swift +531 -0
  108. package/ios/Navigation/Component/HeaderBackground.swift +133 -0
  109. package/ios/Navigation/Component/HeaderJourney.swift +73 -0
  110. package/ios/Navigation/Component/HeaderLocation.swift +48 -0
  111. package/ios/Navigation/Component/HeaderRight.swift +377 -0
  112. package/ios/Navigation/Component/HeaderTitle.swift +36 -0
  113. package/ios/{Application/Navigation → Navigation/Component}/HeaderUser.swift +21 -24
  114. package/ios/Navigation/Component/SideBar.swift +183 -0
  115. package/ios/{Application/Navigation/Overplay → Navigation/Component}/SnackBar.swift +5 -6
  116. package/ios/Navigation/HostBackGestureBridge.swift +78 -0
  117. package/ios/{Application/Navigation/Overplay → Navigation}/ModalScreen.swift +5 -2
  118. package/ios/Navigation/Navigation.swift +204 -0
  119. package/ios/Navigation/NavigationContainer.swift +194 -0
  120. package/ios/{Application/Navigation → Navigation}/Navigator.swift +177 -91
  121. package/ios/Navigation/StackScreen.swift +820 -0
  122. package/ios/Navigation/StackTransition.swift +400 -0
  123. package/ios/Navigation/SwipeBackHaptic.swift +33 -0
  124. package/ios/{Application/Navigation → Navigation}/Tracking/ScreenTracker.swift +12 -5
  125. package/ios/OTPKeyboard/OTPKeyboard.swift +8 -11
  126. package/ios/Pagination/PaginationScroll.swift +2 -2
  127. package/ios/Popup/PopupDisplay.swift +72 -136
  128. package/ios/Popup/PopupInput.swift +10 -13
  129. package/ios/Popup/PopupLayout.swift +140 -0
  130. package/ios/Popup/PopupNotify.swift +56 -73
  131. package/ios/Popup/PopupPromotion.swift +31 -47
  132. package/ios/PopupView/FullscreenPopup.swift +13 -19
  133. package/ios/PopupView/PopupView.swift +1 -1
  134. package/ios/PopupView/Utils++.swift +0 -8
  135. package/ios/ProgressInfo/ProgressInfo.swift +4 -2
  136. package/ios/Radio/Radio.swift +2 -1
  137. package/ios/Rating/Rating.swift +9 -1
  138. package/ios/Resources/dot_loading.json +558 -0
  139. package/ios/Resources/lottie_circle_loader.json +1 -0
  140. package/ios/ScrollIndicator/ScrollIndicator.swift +11 -10
  141. package/ios/Skeleton/Skeleton.swift +22 -27
  142. package/ios/Slider/Slider.swift +16 -18
  143. package/ios/Stepper/Stepper.swift +6 -1
  144. package/ios/Steps/Steps.swift +8 -6
  145. package/ios/SuggestAction/SuggestAction.swift +5 -0
  146. package/ios/Swipeable/SwipeCell.swift +10 -6
  147. package/ios/Switch/Switch.swift +22 -20
  148. package/ios/TabView/TabView.swift +102 -21
  149. package/ios/Tag/Tag.swift +15 -4
  150. package/ios/Template/Logo/Logo.swift +2 -1
  151. package/ios/Template/TrustBanner/TrustBanner.swift +106 -54
  152. package/ios/Title/Title.swift +6 -17
  153. package/ios/Tooltip/Tooltip.swift +29 -14
  154. package/ios/Typography/Text.swift +61 -19
  155. package/ios/Uploader/Uploader.swift +3 -1
  156. package/ios/native-kits.podspec +2 -1
  157. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  158. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ContentView.swift +1 -1
  159. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DuoTabDemo.swift +80 -0
  160. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +1 -0
  161. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IPhoneDuoDemo.swift +173 -0
  162. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +77 -1
  163. package/package.json +1 -1
  164. package/scripts/gen-ios-icons.mjs +36 -0
  165. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -52
  166. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
  167. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
  168. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
  169. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  170. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  171. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  172. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -293
  173. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  174. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -110
  175. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
  176. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  177. package/ios/Application/Components.swift +0 -270
  178. package/ios/Application/ComposeApi.swift +0 -22
  179. package/ios/Application/HeaderRight.swift +0 -306
  180. package/ios/Application/Navigation/BottomTab/BottomTab.swift +0 -104
  181. package/ios/Application/Navigation/HeaderBackProps.swift +0 -66
  182. package/ios/Application/Navigation/HeaderTitle.swift +0 -57
  183. package/ios/Application/Navigation/NavigationContainer.swift +0 -213
  184. package/ios/Application/Navigation/NavigationOptions.swift +0 -109
  185. package/ios/Application/Navigation/NavigatorManager.swift +0 -22
  186. package/ios/Application/Navigation/component/Header.swift +0 -178
  187. package/ios/Application/Navigation/component/HeaderBackground.swift +0 -83
  188. package/ios/Application/Navigation/component/HeaderColor.swift +0 -65
  189. package/ios/Application/Navigation/component/HeaderRightWidthKey.swift +0 -11
  190. package/ios/Application/Navigation/component/NavigationFooter.swift +0 -90
  191. package/ios/Application/Navigation/component/NavigationHeaderRight.swift +0 -196
  192. package/ios/Application/Screen.swift +0 -250
  193. package/ios/Application/StackScreen.swift +0 -492
  194. /package/ios/{Application/Navigation → Navigation}/BottomTab/CurvedContainer.swift +0 -0
@@ -0,0 +1,173 @@
1
+ //
2
+ // IPhoneDuoDemo.swift
3
+ // Example
4
+ //
5
+ // Mirrors RN `app/screens/IPhoneDuo`: the live screen layout, an extended header + search
6
+ // + footer screen, the Duo tab bars, the popup / bottom sheet behaviour and a grid to scroll.
7
+ //
8
+
9
+ import MoMoUIKits
10
+ import SwiftUI
11
+
12
+ private let gridRows: [[Int]] = [[12], [6, 6], [4, 4, 4], [3, 3, 3, 3]]
13
+
14
+ // enough rows to scroll, so the header glass and side bar can be checked
15
+ private let scrollRows: [[Int]] = Array(repeating: gridRows, count: 4).flatMap { $0 }
16
+
17
+ struct IPhoneDuoDemo: View {
18
+ var body: some View {
19
+ if #available(iOS 16.0, *) {
20
+ IPhoneDuoDemoContent()
21
+ } else {
22
+ Text("Requires iOS 16+").padding()
23
+ }
24
+ }
25
+ }
26
+
27
+ @available(iOS 16.0, *)
28
+ private struct IPhoneDuoDemoContent: View {
29
+ @EnvironmentObject private var navigator: Navigator
30
+ @Environment(\.screenLayout) private var layout
31
+
32
+ var body: some View {
33
+ VStack(alignment: .leading, spacing: Spacing.M) {
34
+ VStack(spacing: 0) {
35
+ ForEach(info, id: \.0) { label, value in
36
+ HStack {
37
+ MomoText(label, typography: .bodyDefaultRegular)
38
+ Spacer()
39
+ MomoText(value, typography: .headerSSemibold)
40
+ }
41
+ .padding(.vertical, Spacing.XS)
42
+ }
43
+ }
44
+ .padding(.horizontal, Spacing.M)
45
+
46
+ VStack(spacing: Spacing.S) {
47
+ demoButton("Extended header + footer") {
48
+ navigator.push({ DuoGridScreen() }, options: extendedOptions)
49
+ }
50
+ demoButton("Glass tab bar") {
51
+ navigator.push({ DuoTabDemo(useShortcut: false) }, options: tabOptions)
52
+ }
53
+ demoButton("Glass tab bar + useShortcut") {
54
+ navigator.push({ DuoTabDemo(useShortcut: true) }, options: tabOptions)
55
+ }
56
+ demoButton("Glass tab bar + compress tab bar") {
57
+ navigator.push({ DuoTabDemo(useShortcut: true, compressTabBar: true) }, options: tabOptions)
58
+ }
59
+ demoButton("Bottom sheet: iPhone Duo safe area") {
60
+ navigator.showBottomSheet({ BottomSheetSafeArea() }, isSurface: true, header: .title("Safe area"))
61
+ }
62
+ demoButton("PopupNotify") {
63
+ navigator.showModal {
64
+ PopupNotify(props: PopupNotifyProps(
65
+ image: "https://static.momocdn.net/app/img/popup_permission/img_permission_popup_camera.png",
66
+ title: "Title",
67
+ description: String(repeating: "Check lại một nhịp auto chuyển sang dạng CTA. ", count: 8),
68
+ primary: PopupAction(title: "Đồng ý", onPress: { navigator.hideOverplay() }),
69
+ secondary: PopupAction(title: "Đóng", onPress: { navigator.hideOverplay() }),
70
+ onIconClose: { navigator.hideOverplay() }
71
+ ))
72
+ }
73
+ }
74
+ }
75
+ .padding(.horizontal, Spacing.M)
76
+
77
+ DuoGrid()
78
+ }
79
+ .padding(.vertical, Spacing.M)
80
+ }
81
+
82
+ private var info: [(String, String)] {
83
+ let insets = layout.insets
84
+ return [
85
+ ("iPhone Duo", layout.isIPhoneDuo ? "yes" : "no"),
86
+ ("Window", "\(Int(layout.width)) x \(Int(layout.height))"),
87
+ ("Safe area (T R B L)", "\(Int(insets.top)) \(Int(insets.trailing)) \(Int(insets.bottom)) \(Int(insets.leading))"),
88
+ ("Content inset (L R)", "\(Int(layout.insetLeft)) \(Int(layout.insetRight))"),
89
+ ("Content width", "\(Int(layout.contentWidth))"),
90
+ ("Header height", "\(Int(layout.headerHeight))"),
91
+ ("Side bar", layout.sideBar.map { "\($0.edge == .left ? "left" : "right"), \(Int($0.width))pt, top \(Int($0.top))" } ?? "none"),
92
+ ]
93
+ }
94
+
95
+ private var extendedOptions: NavigationOptions {
96
+ NavigationOptions(
97
+ title: "Extended",
98
+ headerType: .extended,
99
+ headerRightData: HeaderRightData(useShortcut: true),
100
+ footer: { AnyView(MoMoUIKits.Button(title: "Footer action", action: {}, size: .large)) }
101
+ )
102
+ }
103
+
104
+ private var tabOptions: NavigationOptions {
105
+ NavigationOptions(title: "Duo tabs", headerType: .none, scrollable: false)
106
+ }
107
+
108
+ private func demoButton(_ title: String, action: @escaping () -> Void) -> some View {
109
+ MoMoUIKits.Button(title: title, action: action, type: .secondary, size: .small)
110
+ }
111
+ }
112
+
113
+ private struct DuoGridScreen: View {
114
+ var body: some View {
115
+ DuoGrid().padding(.vertical, Spacing.M)
116
+ }
117
+ }
118
+
119
+ private struct DuoGrid: View {
120
+ var body: some View {
121
+ VStack(spacing: Spacing.M) {
122
+ ForEach(scrollRows.indices, id: \.self) { row in
123
+ SectionView {
124
+ ForEach(scrollRows[row].indices, id: \.self) { index in
125
+ let span = scrollRows[row][index]
126
+ ItemView(widthSpan: span) {
127
+ MomoText("span \(span)", typography: .descriptionDefaultRegular)
128
+ .frame(maxWidth: .infinity)
129
+ .frame(height: 48)
130
+ .background(Colors.black04)
131
+ .clipShape(RoundedRectangle(cornerRadius: Radius.S))
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
139
+
140
+ /// Markers on the content edges show the side safe area inside the sheet.
141
+ private struct BottomSheetSafeArea: View {
142
+ @Environment(\.screenLayout) private var layout
143
+
144
+ var body: some View {
145
+ VStack(alignment: .leading, spacing: Spacing.XS) {
146
+ HStack {
147
+ marker("← content edge")
148
+ Spacer()
149
+ marker("content edge →")
150
+ }
151
+ .padding(.bottom, Spacing.S)
152
+ MomoText("Window: \(Int(layout.width)) × \(Int(layout.height))", typography: .bodyDefaultRegular)
153
+ MomoText(
154
+ "Insets: top \(Int(layout.insets.top)) · right \(Int(layout.insets.trailing)) · bottom \(Int(layout.insets.bottom)) · left \(Int(layout.insets.leading))",
155
+ typography: .bodyDefaultRegular
156
+ )
157
+ MomoText(
158
+ "On iPhone Duo: the outer display keeps a full-width sheet with content inside the side safe area; the inner display centers the sheet, still attached to the bottom edge. Other devices are unchanged.",
159
+ typography: .descriptionDefaultRegular,
160
+ color: Colors.black12
161
+ )
162
+ }
163
+ .padding(.vertical, Spacing.M)
164
+ }
165
+
166
+ private func marker(_ text: String) -> some View {
167
+ MomoText(text, typography: .labelSMedium, color: Colors.pink03)
168
+ .padding(.vertical, Spacing.XS)
169
+ .padding(.horizontal, Spacing.S)
170
+ .background(Colors.black04)
171
+ .clipShape(RoundedRectangle(cornerRadius: Radius.XS))
172
+ }
173
+ }
@@ -4,7 +4,7 @@
4
4
  //
5
5
  // Usage demo for the navigation flow. Mirrors Compose's `NavigationUsage`:
6
6
  // exercises push / present / replace / reset, the modal & bottom-sheet
7
- // overplays, the snack bar, the user header title and the bottom-tab layout.
7
+ // overplays, the snack bar, the header titles, runtime options and the bottom-tab layout.
8
8
  //
9
9
 
10
10
  import MoMoUIKits
@@ -149,6 +149,52 @@ private struct NavigationDemoContent: View {
149
149
  )
150
150
  }
151
151
 
152
+ row("Header Location Title") {
153
+ navigator.push(
154
+ { DemoLeafScreen(title: "Location title", color: Colors.blue09) },
155
+ options: NavigationOptions(
156
+ headerTitle: .location(
157
+ HeaderLocationData(description: "Deliver to", location: "123 Nguyen Hue, District 1", onPress: { print("location") })
158
+ )
159
+ )
160
+ )
161
+ }
162
+
163
+ row("Header Journey Title") {
164
+ navigator.push(
165
+ { DemoLeafScreen(title: "Journey title", color: Colors.pink09) },
166
+ options: NavigationOptions(
167
+ headerTitle: .journey(
168
+ HeaderJourneyData(start: "Ho Chi Minh", end: "Ha Noi", description: "Mon, 12/10 · 1 adult", icon: "16_arrow_chevron_right", onPress: { print("journey") })
169
+ )
170
+ )
171
+ )
172
+ }
173
+
174
+ row("Update Options At Runtime") {
175
+ navigator.push(
176
+ { UpdateOptionsScreen() },
177
+ options: NavigationOptions(title: "Before update")
178
+ )
179
+ }
180
+
181
+ row("Bottom Sheet With Footer") {
182
+ navigator.showBottomSheet({
183
+ VStack(spacing: 12) {
184
+ ForEach(0..<6, id: \.self) { i in
185
+ MomoText("Bottom sheet row \(i + 1)")
186
+ .frame(maxWidth: .infinity, alignment: .leading)
187
+ }
188
+ }
189
+ .padding(Spacing.L)
190
+ }, header: .title("Footer"), draggable: false, footer: {
191
+ AnyView(
192
+ MoMoUIKits.Button(title: "Confirm", action: { navigator.hideOverplay() }, type: .primary, size: .large)
193
+ .padding(.horizontal, Spacing.M)
194
+ )
195
+ })
196
+ }
197
+
152
198
  row("Header Animated") {
153
199
  navigator.push(
154
200
  { AnimatedHeaderDemoContent() },
@@ -177,6 +223,36 @@ private struct NavigationDemoContent: View {
177
223
 
178
224
  // MARK: - Leaf / presented screens
179
225
 
226
+ /// A screen changing its own header and footer after it is shown (Compose `LocalNavigation`).
227
+ @available(iOS 16.0, *)
228
+ private struct UpdateOptionsScreen: View {
229
+ @EnvironmentObject private var navigation: Navigation
230
+ @EnvironmentObject private var navigator: Navigator
231
+
232
+ var body: some View {
233
+ VStack(spacing: 16) {
234
+ MoMoUIKits.Button(title: "Change title", action: {
235
+ navigation.setOptions { $0.title = "Updated at \(Date().formatted(date: .omitted, time: .standard))" }
236
+ }, type: .primary, size: .large)
237
+ MoMoUIKits.Button(title: "Add footer", action: {
238
+ navigation.setOptions {
239
+ $0.footer = { AnyView(MoMoUIKits.Button(title: "Footer action", action: {}, type: .primary, size: .large)) }
240
+ }
241
+ }, type: .secondary, size: .large)
242
+ MoMoUIKits.Button(title: "Show snack bar above the footer", action: {
243
+ navigator.showSnackBar(.custom(duration: 2.0) {
244
+ MomoText("Snack bar", color: Colors.black01)
245
+ .frame(maxWidth: .infinity, minHeight: 48)
246
+ .background(Colors.black17)
247
+ .clipShape(RoundedRectangle(cornerRadius: Radius.M))
248
+ .padding(.horizontal, Spacing.M)
249
+ })
250
+ }, type: .secondary, size: .large)
251
+ }
252
+ .padding(16)
253
+ }
254
+ }
255
+
180
256
  @available(iOS 16.0, *)
181
257
  private struct DemoLeafScreen: View {
182
258
  @EnvironmentObject private var navigator: Navigator
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.167.1-duo.2-debug",
3
+ "version": "0.167.1-duo.20-debug",
4
4
  "private": false,
5
5
  "dependeNavigationncies": {},
6
6
  "devDependencies": {},
@@ -0,0 +1,36 @@
1
+ // Generates ios/Icon/Icons.swift from the Compose icon map so both kits ship the same
2
+ // compiled-in icons. Run from anywhere: `node scripts/gen-ios-icons.mjs`.
3
+ import { readFileSync, writeFileSync } from "fs";
4
+ import { dirname, join } from "path";
5
+ import { fileURLToPath } from "url";
6
+
7
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
8
+ const source = join(root, "compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt");
9
+ const target = join(root, "ios/Icon/Icons.swift");
10
+
11
+ const kotlin = readFileSync(source, "utf8");
12
+ const kotlinString = String.raw`"((?:[^"\\]|\\.)*)"`;
13
+ const unescapeKotlin = (s) => s.replace(/\\(["\\$])/g, "$1");
14
+ const swiftString = (s) => `"${s.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
15
+
16
+ const icons = [...kotlin.matchAll(new RegExp(`^\\s*${kotlinString} to ${kotlinString}`, "gm"))]
17
+ .map(([, key, url]) => [unescapeKotlin(key), unescapeKotlin(url)]);
18
+ const noThemeBlock = kotlin.match(/val noThemeIcons = listOf\(([^)]*)\)/);
19
+ const noTheme = noThemeBlock
20
+ ? [...noThemeBlock[1].matchAll(new RegExp(kotlinString, "g"))].map(([, s]) => unescapeKotlin(s))
21
+ : [];
22
+
23
+ if (icons.length === 0) throw new Error(`No icons parsed from ${source}`);
24
+ if (new Set(icons.map(([key]) => key)).size !== icons.length) throw new Error("Duplicate icon keys");
25
+
26
+ const swift = `// Generated by scripts/gen-ios-icons.mjs from compose/.../utils/Icons.kt. Do not edit by hand.
27
+
28
+ let kitIcons: [String: String] = [
29
+ ${icons.map(([key, url]) => ` ${swiftString(key)}: ${swiftString(url)},`).join("\n")}
30
+ ]
31
+
32
+ let noThemeIcons: [String] = [${noTheme.map(swiftString).join(", ")}]
33
+ `;
34
+
35
+ writeFileSync(target, swift);
36
+ console.log(`Wrote ${icons.length} icons (${noTheme.length} untinted) to ${target}`);
@@ -1,52 +0,0 @@
1
- package vn.momo.kits.application
2
-
3
- import androidx.compose.foundation.background
4
- import androidx.compose.foundation.layout.*
5
- import androidx.compose.foundation.shape.RoundedCornerShape
6
- import androidx.compose.runtime.Composable
7
- import androidx.compose.ui.Modifier
8
- import androidx.compose.ui.graphics.Color
9
- import androidx.compose.ui.unit.dp
10
- import androidx.compose.ui.zIndex
11
- import vn.momo.kits.components.InputSearch
12
- import vn.momo.kits.components.InputSearchProps
13
- import vn.momo.kits.const.Radius
14
- import vn.momo.kits.const.Spacing
15
-
16
- @Composable
17
- internal fun AnimationSearchInput(
18
- animations: HeaderAnimations,
19
- inputSearchProps: InputSearchProps
20
- ) {
21
- Box(
22
- modifier = Modifier
23
- .fillMaxWidth()
24
- .offset(
25
- x = animations.translateX.dp,
26
- y = animations.translateY.dp
27
- )
28
- ) {
29
- Box(
30
- modifier = Modifier
31
- .height(HEADER_HEIGHT.dp)
32
- .padding(vertical = Spacing.S)
33
- .zIndex(1f)
34
- ) {
35
- Box(
36
- modifier = Modifier
37
- .width(animations.width.dp)
38
- .background(
39
- color = animations.backgroundSearch,
40
- shape = RoundedCornerShape(Radius.XL)
41
- )
42
- ) {
43
- InputSearch(
44
- inputSearchProps = inputSearchProps.copy(
45
- showButtonText = false,
46
- backgroundColor = Color.Transparent
47
- )
48
- )
49
- }
50
- }
51
- }
52
- }
@@ -1,183 +0,0 @@
1
- package vn.momo.kits.application
2
-
3
- import androidx.compose.animation.*
4
- import androidx.compose.animation.core.CubicBezierEasing
5
- import androidx.compose.animation.core.animateDpAsState
6
- import androidx.compose.animation.core.tween
7
- import androidx.compose.foundation.ScrollState
8
- import androidx.compose.foundation.background
9
- import androidx.compose.foundation.interaction.MutableInteractionSource
10
- import androidx.compose.foundation.layout.*
11
- import androidx.compose.material3.AlertDialogDefaults.shape
12
- import androidx.compose.material3.FloatingActionButton
13
- import androidx.compose.material3.FloatingActionButtonDefaults
14
- import androidx.compose.runtime.*
15
- import androidx.compose.runtime.saveable.rememberSaveable
16
- import androidx.compose.ui.Alignment
17
- import androidx.compose.ui.Modifier
18
- import androidx.compose.ui.graphics.Color
19
- import androidx.compose.ui.unit.Dp
20
- import androidx.compose.ui.unit.dp
21
- import androidx.compose.ui.zIndex
22
- import kotlinx.coroutines.delay
23
- import kotlinx.coroutines.flow.MutableStateFlow
24
- import kotlinx.coroutines.flow.collectLatest
25
- import kotlinx.coroutines.launch
26
- import vn.momo.kits.components.Icon
27
- import vn.momo.kits.components.Text
28
- import vn.momo.kits.const.Typography
29
- import kotlin.time.Duration.Companion.milliseconds
30
-
31
- enum class FABSize {
32
- SMALL,
33
- DEFAULT,
34
- }
35
-
36
- enum class FABPosition {
37
- END,
38
- CENTER,
39
- }
40
-
41
- data class FabProps(
42
- val icon: String,
43
- val iconColor: Color? = null,
44
- val label: String? = null,
45
- val onClick: () -> Unit,
46
- val size: FABSize = FABSize.DEFAULT,
47
- val bottom: Dp? = null,
48
- val scrollState: ScrollState? = null,
49
- val position: FABPosition? = FABPosition.END,
50
- )
51
-
52
- @Deprecated("Use vn.momo.kits.navigation.FloatingButton instead", ReplaceWith("vn.momo.kits.navigation.FloatingButton"))
53
- @Composable
54
- internal fun FloatingButton(
55
- scrollPosition: Int,
56
- bottom: Dp,
57
- onClick: () -> Unit,
58
- containerColor: Color,
59
- contentColor: Color = containerColor,
60
- icon: String,
61
- iconColor: Color? = null,
62
- text: String? = null,
63
- elevation: androidx.compose.material3.FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation(
64
- 4.dp,
65
- 4.dp,
66
- 4.dp,
67
- 4.dp
68
- ),
69
- size: FABSize = FABSize.DEFAULT,
70
- position: FABPosition = FABPosition.END,
71
- keyboardSize: Dp = 0.dp,
72
- ) {
73
- val scrollPositionStateFlow = remember { MutableStateFlow(scrollPosition) }
74
- var lastScrollPosition by rememberSaveable { mutableStateOf(0) }
75
- val coroutineScope = rememberCoroutineScope()
76
- var isExpanded by rememberSaveable { mutableStateOf(false) }
77
-
78
- val startPadding = if (isExpanded) 12.dp else 0.dp
79
- val endPadding = if (isExpanded) 12.dp else 0.dp
80
- val widthIn = if ((size === FABSize.SMALL)) 36.dp else 48.dp
81
-
82
-
83
- val width = animateDpAsState(
84
- targetValue = if (isExpanded && text != null) 80.dp else widthIn,
85
- animationSpec = tween(
86
- durationMillis = 200,
87
- easing = CubicBezierEasing(0.2f, 0.2f, 0.2f, 0.2f),
88
- )
89
- )
90
-
91
- LaunchedEffect(text) {
92
- if (text != null) {
93
- coroutineScope.launch {
94
- scrollPositionStateFlow
95
- .collectLatest { debouncedScrollPosition ->
96
- isExpanded = debouncedScrollPosition > lastScrollPosition
97
- delay(300.milliseconds)
98
- lastScrollPosition = debouncedScrollPosition
99
-
100
- }
101
- }
102
- }
103
- }
104
-
105
- LaunchedEffect(scrollPosition) {
106
- scrollPositionStateFlow.value = scrollPosition
107
- }
108
-
109
- Box(
110
- Modifier
111
- .fillMaxSize()
112
- .padding(end = 12.dp, bottom = bottom)
113
- .offset(y = -keyboardSize)
114
- .background(Color.Transparent)
115
- .zIndex(10f),
116
- contentAlignment = if (position == FABPosition.END) Alignment.BottomEnd else Alignment.BottomCenter,
117
- ) {
118
- FloatingActionButton(
119
- onClick = onClick,
120
- shape = shape,
121
- containerColor = containerColor,
122
- contentColor = contentColor,
123
- elevation = elevation,
124
- interactionSource = remember { MutableInteractionSource() },
125
- modifier = Modifier
126
- .sizeIn(minWidth = width.value)
127
- .height(widthIn)
128
- ) {
129
- Row(
130
- modifier = Modifier.padding(start = startPadding, end = endPadding),
131
- verticalAlignment = Alignment.CenterVertically,
132
- horizontalArrangement = if (isExpanded) Arrangement.Start else Arrangement.Center
133
- ) {
134
- Icon(
135
- icon,
136
- size = if (size === FABSize.SMALL) 12.dp else 24.dp,
137
- color = iconColor ?: Color.White
138
- )
139
- AnimatedVisibility(
140
- visible = isExpanded,
141
- enter = ExtendedFabExpandAnimation,
142
- exit = ExtendedFabCollapseAnimation,
143
- ) {
144
- Row {
145
- Spacer(Modifier.width(12.dp))
146
- Text(
147
- text ?: "",
148
- color = Color.White,
149
- style = Typography.actionDefaultBold
150
- )
151
- }
152
- }
153
- }
154
- }
155
- }
156
- }
157
-
158
- private val ExtendedFabCollapseAnimation = fadeOut(
159
- animationSpec = tween(
160
- durationMillis = 800,
161
- easing = CubicBezierEasing(0.0f, 0.0f, 1.0f, 1.0f),
162
- )
163
- ) + shrinkHorizontally(
164
- animationSpec = tween(
165
- durationMillis = 500,
166
- easing = CubicBezierEasing(0.2f, 0.0f, 0.0f, 1.0f),
167
- ),
168
- shrinkTowards = Alignment.Start,
169
- )
170
-
171
- private val ExtendedFabExpandAnimation = fadeIn(
172
- animationSpec = tween(
173
- durationMillis = 200,
174
- delayMillis = 100,
175
- easing = CubicBezierEasing(0.0f, 0.0f, 1.0f, 1.0f),
176
- ),
177
- ) + expandHorizontally(
178
- animationSpec = tween(
179
- durationMillis = 500,
180
- easing = CubicBezierEasing(0.2f, 0.0f, 0.0f, 1.0f),
181
- ),
182
- expandFrom = Alignment.Start,
183
- )