@momo-kits/native-kits 0.168.1-beta.3 → 0.168.1-beta.30-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 (176) hide show
  1. package/CLAUDE.md +14 -10
  2. package/README.md +2 -10
  3. package/build.gradle.kts +11 -0
  4. package/compose/build.gradle.kts +198 -0
  5. package/compose/build.gradle.kts.backup +198 -0
  6. package/compose/compose.podspec +47 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +20 -0
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +153 -0
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +62 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1071 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +542 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +231 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +189 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +478 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +265 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +235 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +223 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +265 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +185 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +84 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +370 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +308 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +90 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +330 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +220 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +473 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +207 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +92 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +560 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +125 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +501 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +236 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +17 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +287 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +321 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +502 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +148 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +116 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +205 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +422 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +732 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +224 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +383 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +94 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +97 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +203 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +106 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +455 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +399 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +192 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +91 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +74 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +20 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +118 -0
  123. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
  124. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  125. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +218 -0
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +138 -0
  130. package/gradle/libs.versions.toml +69 -0
  131. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  132. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  133. package/gradle.properties +26 -0
  134. package/gradlew +252 -0
  135. package/gradlew.bat +94 -0
  136. package/ios/Application/ApplicationEnvironment.swift +7 -6
  137. package/ios/Application/DesignSystemKits.swift +163 -0
  138. package/ios/Application/DesignSystemKitsPayload.swift +68 -0
  139. package/ios/Badge/BadgeRibbon.swift +8 -1
  140. package/ios/Extensions/Color++.swift +2 -4
  141. package/ios/Input/Input.swift +13 -3
  142. package/ios/Input/InputPhoneNumber.swift +1 -3
  143. package/ios/Input/InputSearch.swift +1 -2
  144. package/ios/Input/InputTextArea.swift +5 -3
  145. package/ios/InputMoney/InputMoney.swift +6 -7
  146. package/ios/Layout/ScreenLayout.swift +65 -10
  147. package/ios/Navigation/BottomSheet.swift +152 -21
  148. package/ios/Navigation/BottomTab/BottomTab.swift +12 -18
  149. package/ios/Navigation/BottomTab/BottomTabBar.swift +255 -114
  150. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  151. package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
  152. package/ios/Navigation/BottomTab/DuoTabBar.swift +63 -172
  153. package/ios/Navigation/BottomTab/TabBarMetrics.swift +88 -0
  154. package/ios/Navigation/Component/HeaderBackground.swift +22 -1
  155. package/ios/Navigation/Component/SnackBar.swift +4 -0
  156. package/ios/Navigation/ModalScreen.swift +7 -3
  157. package/ios/Navigation/StackScreen.swift +6 -8
  158. package/ios/Popup/PopupDisplay.swift +2 -2
  159. package/ios/Popup/PopupInput.swift +2 -2
  160. package/ios/Popup/PopupLayout.swift +15 -10
  161. package/ios/Popup/PopupNotify.swift +2 -2
  162. package/ios/Stepper/Stepper.swift +1 -2
  163. package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
  164. package/ios/Typography/FontScale.swift +29 -15
  165. package/ios/Typography/Text.swift +86 -12
  166. package/ios/Typography/Typography.swift +2 -2
  167. package/ios/native-kits.podspec +1 -1
  168. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  169. package/ios-demo/README.md +120 -0
  170. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +224 -59
  171. package/local.properties +9 -0
  172. package/package.json +1 -1
  173. package/publish.sh +2 -7
  174. package/settings.gradle.kts +64 -0
  175. package/ios/Typography/FontScaleStore.swift +0 -58
  176. package/ios/Typography/KitDesignSystem.swift +0 -17
@@ -15,16 +15,25 @@ import SwiftUI
15
15
 
16
16
  /// Mirrors Compose's `sealed class BottomHeader` (Title / Custom).
17
17
  public struct BottomSheetHeader {
18
+ struct Back {
19
+ let icon: String
20
+ let action: () -> Void
21
+ }
22
+
18
23
  enum Style {
19
- case title(String)
24
+ case title(String, back: Back?)
20
25
  case custom(() -> AnyView)
21
26
  }
22
27
 
23
28
  let style: Style
24
29
 
25
- /// Mirrors `BottomHeader.Title`.
26
- public static func title(_ text: String = "Bottom Sheet Title") -> BottomSheetHeader {
27
- BottomSheetHeader(style: .title(text))
30
+ /// Mirrors `BottomHeader.Title`. `onBack` shows a back button; the sheet closes, then it runs.
31
+ public static func title(
32
+ _ text: String = "Bottom Sheet Title",
33
+ backIcon: String = "arrow-back",
34
+ onBack: (() -> Void)? = nil
35
+ ) -> BottomSheetHeader {
36
+ BottomSheetHeader(style: .title(text, back: onBack.map { Back(icon: backIcon, action: $0) }))
28
37
  }
29
38
 
30
39
  /// Mirrors `BottomHeader.Custom`.
@@ -68,6 +77,9 @@ struct BottomSheetView<Content: View>: View {
68
77
  /// Mirrors Compose's `sheetCloseOffset` (100dp drag threshold to dismiss).
69
78
  private let closeThreshold: CGFloat = 100
70
79
 
80
+ private let indicatorHeight: CGFloat = 16
81
+ private let headerRowHeight: CGFloat = 56
82
+
71
83
  /// Mirrors Compose's per-term peak (0.3f). Combined with `backgroundAlpha` the
72
84
  /// steady-state (fully open) scrim peaks at 0.6, matching ModalScreen's peak.
73
85
  private let maxDynamicAlpha: CGFloat = 0.3
@@ -77,7 +89,23 @@ struct BottomSheetView<Content: View>: View {
77
89
 
78
90
  private var isDuo: Bool { layout.isDuoDevice }
79
91
  // iPhone Duo inner display: center the sheet instead of spanning the width
80
- private var isDuoCentered: Bool { isDuo && layout.width >= 600 }
92
+ // short side, as RN: the outer display stays floating in landscape (678pt wide) too
93
+ private var isDuoCentered: Bool { isDuo && min(layout.width, layout.height) >= 600 }
94
+ /// Outer display: the sheet floats Spacing.M off the side edges like system sheets, its content
95
+ /// stays in the safe area and its buttons move to the side bar column (HIG).
96
+ private var isDuoFloating: Bool { isDuo && !isDuoCentered }
97
+
98
+ private var titleBack: BottomSheetHeader.Back? {
99
+ if case .title(_, let back) = header.style { return back }
100
+ return nil
101
+ }
102
+
103
+ private var sideColumn: SideBarLayout? {
104
+ guard isDuoFloating, case .title = header.style, let sideBar = layout.sideBar,
105
+ sideBar.width - Spacing.M >= DuoMetrics.controlSize + Spacing.M
106
+ else { return nil }
107
+ return sideBar
108
+ }
81
109
 
82
110
  /// Keeps the portrait width in landscape, like system sheets.
83
111
  private var duoCenteredWidth: CGFloat {
@@ -87,18 +115,20 @@ struct BottomSheetView<Content: View>: View {
87
115
  )
88
116
  }
89
117
 
90
- /// Landscape side buttons span the full height, so the content is inset; in portrait the
91
- /// side status bar only covers the top corner.
118
+ /// The floating sheet spans the side safe area, its content stays clear of it.
92
119
  private var sideInsetLeading: CGFloat {
93
- isDuo && !isDuoCentered && layout.width > layout.height ? layout.insets.leading : 0
120
+ isDuoFloating ? max(layout.insets.leading - Spacing.M, 0) : 0
94
121
  }
95
122
 
96
123
  private var sideInsetTrailing: CGFloat {
97
- isDuo && !isDuoCentered && layout.width > layout.height ? layout.insets.trailing : 0
124
+ isDuoFloating ? max(layout.insets.trailing - Spacing.M, 0) : 0
98
125
  }
99
126
 
100
127
  private var maxHeight: CGFloat {
101
- isDuo ? layout.height - max(layout.duoTopInset, Spacing.XL) : screenHeight - 90
128
+ guard isDuo else { return screenHeight - 90 }
129
+ // stays below the side status bar: unlike RN (StatusBar.pushStackEntry) nothing restyles it, so a light
130
+ // clock over the sheet would vanish
131
+ return layout.height - max(layout.duoTopInset, Spacing.XL)
102
132
  }
103
133
  private var bottomInset: CGFloat { useBottomInset ? safeAreaBottomInset() : 0 }
104
134
  /// While the keyboard is up, it already covers the home-indicator area, so it
@@ -169,20 +199,23 @@ struct BottomSheetView<Content: View>: View {
169
199
  .fill(Colors.black06)
170
200
  .frame(width: 40, height: 4)
171
201
  Spacer().frame(height: 4)
202
+ // the handle centers on the whole sheet, only the header row keeps clear of the strip
172
203
  headerView
173
- .frame(height: 56)
204
+ .frame(height: headerRowHeight)
174
205
  .padding(.horizontal, Spacing.M)
175
206
  .padding(.leading, sideInsetLeading)
176
207
  .padding(.trailing, sideInsetTrailing)
177
208
  }
178
209
  .frame(maxWidth: .infinity)
179
- .frame(height: 72)
210
+ .frame(height: indicatorHeight + headerRowHeight)
180
211
  .contentShape(Rectangle())
181
212
  .gesture(dragGesture, including: draggable ? .all : .subviews)
182
213
 
183
214
  Rectangle()
184
215
  .fill(theme.colors.border.default)
185
216
  .frame(height: 1)
217
+ .padding(.leading, sideInsetLeading)
218
+ .padding(.trailing, sideInsetTrailing)
186
219
 
187
220
  content()
188
221
  .padding(.leading, sideInsetLeading)
@@ -191,7 +224,7 @@ struct BottomSheetView<Content: View>: View {
191
224
  .layoutPriority(-1)
192
225
 
193
226
  if let footer {
194
- BottomSheetFooter(content: footer)
227
+ BottomSheetFooter(content: footer, leadingInset: sideInsetLeading, trailingInset: sideInsetTrailing)
195
228
  }
196
229
  }
197
230
  // The filler stays outside the cap, which shrinks by it instead: the sheet still ends at
@@ -209,27 +242,61 @@ struct BottomSheetView<Content: View>: View {
209
242
  }
210
243
  )
211
244
  .background(backgroundColor)
212
- .clipShape(RoundedCorner(radius: Radius.M, corners: [.topLeft, .topRight]))
245
+ .overlay {
246
+ if let sideColumn {
247
+ BottomSheetSideColumn(
248
+ sideBar: sideColumn,
249
+ windowHeight: layout.height,
250
+ topOffset: indicatorHeight + (headerRowHeight - DuoMetrics.controlSize) / 2,
251
+ back: titleBack,
252
+ onBack: goBack,
253
+ onClose: { close() }
254
+ )
255
+ }
256
+ }
257
+ .clipShape(RoundedCorner(radius: isDuo ? Radius.XL : Radius.M, corners: [.topLeft, .topRight]))
258
+ .padding(.horizontal, isDuoFloating ? Spacing.M : 0)
213
259
  }
214
260
 
215
261
  @ViewBuilder
216
262
  private var headerView: some View {
217
263
  switch header.style {
218
- case .title(let text):
264
+ case .title(let text, let back):
265
+ // the side column holds back and close, the row keeps only the title
266
+ let showsButtons = sideColumn == nil
219
267
  HStack(spacing: 0) {
220
- Color.clear.frame(width: 24, height: 24)
268
+ if showsButtons {
269
+ if let back {
270
+ headerButton(icon: back.icon, accessibilityId: "btn_bottom_sheet_back") { goBack(back) }
271
+ } else {
272
+ Color.clear.frame(width: 24, height: 24)
273
+ }
274
+ }
221
275
  MomoText(text, typography: .headerDefaultBold, color: Colors.black17)
222
276
  .frame(maxWidth: .infinity, alignment: .center)
223
- Icon(source: "navigation_close", size: 24, color: Colors.black17)
224
- .frame(width: 24, height: 24)
225
- .contentShape(Rectangle())
226
- .onTapGesture { close() }
277
+ .padding(.horizontal, showsButtons ? 0 : Spacing.M)
278
+ if showsButtons {
279
+ headerButton(icon: "navigation_close", accessibilityId: "btn_bottom_sheet_close") { close() }
280
+ }
227
281
  }
228
282
  case .custom(let builder):
229
283
  builder()
230
284
  }
231
285
  }
232
286
 
287
+ private func headerButton(icon: String, accessibilityId: String, action: @escaping () -> Void) -> some View {
288
+ Icon(source: icon, size: 24, color: Colors.black17)
289
+ .frame(width: 24, height: 24)
290
+ .contentShape(Rectangle())
291
+ .onTapGesture(perform: action)
292
+ .accessibilityIdentifier(accessibilityId)
293
+ }
294
+
295
+ /// RN `leftOptions.onPressIconLeft`: the sheet closes first, then the back runs.
296
+ private func goBack(_ back: BottomSheetHeader.Back) {
297
+ close(then: back.action)
298
+ }
299
+
233
300
  // MARK: - Drag handling (mirrors Compose's detectDragGestures)
234
301
 
235
302
  private var dragGesture: some Gesture {
@@ -282,7 +349,7 @@ struct BottomSheetView<Content: View>: View {
282
349
 
283
350
  /// Mirrors Compose's `closeEvent`: slide out over 200ms, then fade the scrim
284
351
  /// out over 100ms only after the slide finishes, then dismiss.
285
- private func close() {
352
+ private func close(then onClosed: (() -> Void)? = nil) {
286
353
  guard !isClosing else { return }
287
354
  isClosing = true
288
355
  withAnimation(.timingCurve(0.3, 0, 0.8, 0.15, duration: 0.2)) {
@@ -294,7 +361,67 @@ struct BottomSheetView<Content: View>: View {
294
361
  }
295
362
  }
296
363
  DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
364
+ // a newer overlay replaced this one: it stays, and this sheet's back is dropped
365
+ guard navigator.overplay?.id == overplayId else { return }
297
366
  navigator.finishOverplayDismiss(id: overplayId)
367
+ onClosed?()
368
+ }
369
+ }
370
+ }
371
+
372
+ /// iPhone Duo outer display: back and close sit on the part of the sheet under the side safe area,
373
+ /// 12pt from the strip's inner edge like the screen side bar. They follow the header row while the
374
+ /// sheet is short and stay below the status bar cluster while it is tall.
375
+ private struct BottomSheetSideColumn: View {
376
+ let sideBar: SideBarLayout
377
+ let windowHeight: CGFloat
378
+ /// Lines the controls up with the header row.
379
+ let topOffset: CGFloat
380
+ let back: BottomSheetHeader.Back?
381
+ let onBack: (BottomSheetHeader.Back) -> Void
382
+ let onClose: () -> Void
383
+
384
+ @Environment(\.appTheme) private var theme
385
+
386
+ private var isRight: Bool { sideBar.edge == .right }
387
+
388
+ private var columnHeight: CGFloat {
389
+ let count: CGFloat = back != nil ? 2 : 1
390
+ return count * DuoMetrics.controlSize + (count - 1) * Spacing.M
391
+ }
392
+
393
+ private var headerColor: HeaderColor {
394
+ getHeaderColor(isAnimated: false, isSurface: true, opacity: 1, tintColor: nil, defaultColor: theme.colors.text.default)
395
+ }
396
+
397
+ var body: some View {
398
+ GeometryReader { proxy in
399
+ let sheetHeight = proxy.size.height
400
+ // the sheet rests on the window bottom; its slide is an offset outside this layout
401
+ let sheetTop = windowHeight - sheetHeight
402
+ // clear of a camera at the bottom end of the strip when it can
403
+ let lowest = sheetHeight - sideBar.bottom - columnHeight
404
+ let top = max(min(max(sideBar.top - sheetTop, topOffset), lowest), 0)
405
+ VStack(alignment: isRight ? .leading : .trailing, spacing: Spacing.M) {
406
+ if let back {
407
+ SideBarButton(
408
+ icon: back.icon,
409
+ headerColor: headerColor,
410
+ accessibilityId: "btn_bottom_sheet_back",
411
+ action: { onBack(back) }
412
+ )
413
+ }
414
+ SideBarButton(
415
+ icon: "navigation_close",
416
+ headerColor: headerColor,
417
+ accessibilityId: "btn_bottom_sheet_close",
418
+ action: onClose
419
+ )
420
+ }
421
+ .padding(isRight ? .leading : .trailing, Spacing.M)
422
+ .frame(width: sideBar.width - Spacing.M, alignment: isRight ? .leading : .trailing)
423
+ .padding(.top, top)
424
+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: isRight ? .topTrailing : .topLeading)
298
425
  }
299
426
  }
300
427
  }
@@ -371,12 +498,16 @@ private struct CapHeightLayout: Layout {
371
498
  /// Mirrors Compose's `BottomSheetFooter`: a surface band with a soft shadow cast on the content.
372
499
  private struct BottomSheetFooter: View {
373
500
  let content: () -> AnyView
501
+ var leadingInset: CGFloat = 0
502
+ var trailingInset: CGFloat = 0
374
503
 
375
504
  @Environment(\.appTheme) private var theme
376
505
 
377
506
  var body: some View {
378
507
  content()
379
508
  .frame(maxWidth: .infinity)
509
+ .padding(.leading, leadingInset)
510
+ .padding(.trailing, trailingInset)
380
511
  .padding(.vertical, Spacing.S)
381
512
  .background(theme.colors.background.surface)
382
513
  .overlay(alignment: .top) {
@@ -53,10 +53,9 @@ public struct BottomTab: View {
53
53
  }
54
54
 
55
55
  private var bottomInset: CGFloat { safeAreaBottomInset() }
56
- // the Duo bars overlay the content or sit in the side strip, so only the home indicator is kept clear
57
- private var reservedBottom: CGFloat {
58
- layout.isIPhoneDuo ? layout.insets.bottom : BOTTOM_TAB_BAR_HEIGHT + bottomInset + Spacing.S
59
- }
56
+ // the bars float over the content (tab screens keep clear of them through duoTabBarInsets) or sit
57
+ // in the side strip, so only the home indicator is kept clear
58
+ private var reservedBottom: CGFloat { layout.insets.bottom }
60
59
 
61
60
  private var compression: DuoBarCompression {
62
61
  DuoBarCompression.resolve(
@@ -104,18 +103,13 @@ public struct BottomTab: View {
104
103
  compression: compression
105
104
  )
106
105
  } else {
107
- // Tab bar + home-indicator filler.
108
- VStack(spacing: 0) {
109
- BottomTabBar(
110
- items: items,
111
- floatingButton: floatingButton,
112
- selectedIndex: selectedIndex,
113
- onTabSelected: selectTab
114
- )
115
- theme.colors.background.surface
116
- .frame(height: bottomInset + Spacing.S)
117
- .ignoresSafeArea(edges: .horizontal)
118
- }
106
+ BottomTabBar(
107
+ items: items,
108
+ floatingButton: floatingButton,
109
+ selectedIndex: selectedIndex,
110
+ onTabSelected: selectTab,
111
+ bottomInset: bottomInset
112
+ )
119
113
  }
120
114
  }
121
115
  .frame(maxWidth: .infinity, maxHeight: .infinity)
@@ -137,6 +131,7 @@ public struct BottomTab: View {
137
131
  }
138
132
 
139
133
  private func selectTab(_ index: Int) {
134
+ navigator.maxApi?.triggerEventVibration("light")
140
135
  let switchTab = { if index != selectedIndex { selectedIndex = index } }
141
136
  if let onTabPress { onTabPress(index, switchTab) } else { switchTab() }
142
137
  }
@@ -325,8 +320,7 @@ private struct TabCard: View {
325
320
 
326
321
  /// Bottom safe-area inset (home indicator).
327
322
  private func safeAreaBottomInset() -> CGFloat {
328
- let bottomInset = UIApplication.shared.connectedScenes
323
+ UIApplication.shared.connectedScenes
329
324
  .compactMap { ($0 as? UIWindowScene)?.keyWindow?.safeAreaInsets.bottom }
330
325
  .first ?? 0
331
- return min(bottomInset, 21)
332
326
  }