@momo-kits/native-kits 0.168.1-beta.37 → 0.168.1-beta.38-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 (159) hide show
  1. package/CLAUDE.md +2 -3
  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 +113 -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 +739 -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 +239 -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 +104 -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/Layout/ScreenLayout.swift +24 -28
  138. package/ios/Navigation/BottomSheet.swift +157 -29
  139. package/ios/Navigation/BottomTab/BottomTab.swift +48 -67
  140. package/ios/Navigation/BottomTab/BottomTabBar.swift +280 -132
  141. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  142. package/ios/Navigation/BottomTab/DuoTabBar.swift +72 -292
  143. package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
  144. package/ios/Navigation/Component/HeaderRight.swift +1 -1
  145. package/ios/Navigation/ModalScreen.swift +7 -18
  146. package/ios/Navigation/StackScreen.swift +3 -1
  147. package/ios/Popup/PopupDisplay.swift +2 -4
  148. package/ios/Popup/PopupInput.swift +2 -4
  149. package/ios/Popup/PopupLayout.swift +9 -10
  150. package/ios/Popup/PopupNotify.swift +23 -26
  151. package/ios-demo/README.md +120 -0
  152. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  153. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  154. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
  155. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -103
  156. package/package.json +1 -1
  157. package/settings.gradle.kts +64 -0
  158. package/ios/Layout/ModalLayout.swift +0 -152
  159. package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +0 -364
@@ -46,8 +46,6 @@ public struct ScreenLayout: Equatable {
46
46
  public let sideBar: SideBarLayout?
47
47
  /// iPhone Duo inner display in portrait: the header row shares the status bar band, between its clusters.
48
48
  public let statusBarClearance: StatusBarClearance?
49
- /// Half-folded iPhone Duo: the hinge in window coordinates, running top to bottom; nil while flat.
50
- public let hinge: CGRect?
51
49
 
52
50
  public var headerBarHeight: CGFloat { headerHeight - headerStatusBarHeight }
53
51
  }
@@ -78,6 +76,11 @@ enum DuoMetrics {
78
76
  static let floatingTabBarHeight: CGFloat = 62
79
77
  static let floatingTabBarMargin: CGFloat = 20
80
78
  static let floatingTabBarInsetOverlap: CGFloat = 13
79
+ // Width of a system alert on the inner display, in both orientations.
80
+ static let modalMaxWidth: CGFloat = 440
81
+ // Fits a PopupNotify with image, scrolled description and actions at the max width (RN
82
+ // Application/device.ts); taller content scrolls instead of filling the inner display.
83
+ static let modalMaxHeight: CGFloat = 640
81
84
  }
82
85
 
83
86
  enum HeaderMetrics {
@@ -113,14 +116,11 @@ extension ScreenLayout {
113
116
  insets: EdgeInsets,
114
117
  reservedRegions: [CGRect] = ReservedRegions.current,
115
118
  isPhone: Bool = isPhoneIdiom,
116
- isFoldable: Bool = FoldableDevice.isFoldable(measuredIn: keyWindow),
117
- division: CGRect? = FoldableDevice.halfFoldedHinge
119
+ isFoldable: Bool = FoldableDevice.isFoldable(measuredIn: keyWindow)
118
120
  ) -> ScreenLayout {
119
121
  let width = size.width
120
122
  let height = size.height
121
123
  let isDuoDevice = isPhone && isFoldable
122
- // only a hinge splitting the window into left and right halves moves overlays
123
- let hinge = division.flatMap { isPhone && $0.height > $0.width ? $0 : nil }
124
124
  var (headerHeight, headerStatusBarHeight) = headerGeometry(topInset: insets.top, isPhone: isPhone)
125
125
  let isDuo = isPhone && isIPhoneDuoWindow(width: width, height: height, insets: insets)
126
126
  guard isDuo else {
@@ -128,7 +128,7 @@ extension ScreenLayout {
128
128
  width: width, height: height, isIPhoneDuo: false, isDuoDevice: isDuoDevice, insets: insets,
129
129
  insetLeft: 0, insetRight: 0, contentWidth: width,
130
130
  headerHeight: headerHeight, headerStatusBarHeight: headerStatusBarHeight, sideBar: nil,
131
- statusBarClearance: nil, hinge: hinge
131
+ statusBarClearance: nil
132
132
  )
133
133
  }
134
134
 
@@ -191,7 +191,7 @@ extension ScreenLayout {
191
191
  insetLeft: insets.leading, insetRight: insets.trailing,
192
192
  contentWidth: width - insets.leading - insets.trailing,
193
193
  headerHeight: headerHeight, headerStatusBarHeight: headerStatusBarHeight, sideBar: sideBar,
194
- statusBarClearance: statusBarClearance, hinge: hinge
194
+ statusBarClearance: statusBarClearance
195
195
  )
196
196
  }
197
197
 
@@ -265,6 +265,15 @@ extension ScreenLayout {
265
265
  max(insets.top, height > width ? max(insets.leading, insets.trailing) * 2 : 0)
266
266
  }
267
267
 
268
+ /// Room for a dialog on iPhone Duo: inside the safe area, so clear of the side toolbar strip, and
269
+ /// capped so it stays a dialog on the inner display.
270
+ var duoModalMaxWidth: CGFloat {
271
+ min(width - insets.leading - insets.trailing - Spacing.XL * 2, DuoMetrics.modalMaxWidth)
272
+ }
273
+
274
+ var duoModalMaxHeight: CGFloat {
275
+ min(height - insets.top - insets.bottom - Spacing.XL * 2, DuoMetrics.modalMaxHeight)
276
+ }
268
277
  }
269
278
 
270
279
  /// Snapshot for call sites without `\.screenLayout`; not reactive. `windowSize` is ignored,
@@ -281,12 +290,6 @@ public func isIPhoneDuoDevice(windowSize: CGSize? = nil) -> Bool {
281
290
  enum FoldableDevice {
282
291
  // a hinge never goes away, so a positive answer is kept
283
292
  private static var isKnownFoldable = false
284
- private static var isPartiallyOpen = false
285
-
286
- /// The active division region while the hinge reports partially open; nil while flat.
287
- static var halfFoldedHinge: CGRect? {
288
- isPartiallyOpen ? ReservedRegions.division : nil
289
- }
290
293
 
291
294
  static func isFoldable(measuredIn view: UIView?) -> Bool {
292
295
  if isKnownFoldable { return true }
@@ -303,11 +306,8 @@ enum FoldableDevice {
303
306
  #if canImport(UIKit, _version: 9127.0.85.28)
304
307
  guard #available(iOS 27.1, *) else { return }
305
308
  view.addInteraction(UIHingeInteraction { _, update in
306
- guard let hinge = update.hinge else { return }
307
- let partiallyOpen = hinge.status == .partiallyOpen
308
- guard !isKnownFoldable || partiallyOpen != isPartiallyOpen else { return }
309
+ guard update.hinge != nil, !isKnownFoldable else { return }
309
310
  isKnownFoldable = true
310
- isPartiallyOpen = partiallyOpen
311
311
  NotificationCenter.default.post(name: ReservedRegions.didChange, object: nil)
312
312
  })
313
313
  #endif
@@ -318,17 +318,14 @@ enum FoldableDevice {
318
318
 
319
319
  /// System occlusion regions (iOS 27.1+) in window coordinates: the iPhone Duo camera, and the
320
320
  /// status bar cluster as it grows for a call or a Live Activity. Empty before iOS 27.1.
321
- /// `division` is the active hinge region, there only while the device is half folded.
322
321
  enum ReservedRegions {
323
322
  // last report of a probe, so `ScreenLayout.current` includes it
324
323
  private(set) static var current: [CGRect] = []
325
- private(set) static var division: CGRect?
326
324
  static let didChange = Notification.Name("MoMoUIKitsReservedRegionsDidChange")
327
325
 
328
- fileprivate static func publish(_ regions: [CGRect], division: CGRect?) {
329
- guard regions != current || division != self.division else { return }
326
+ fileprivate static func publish(_ regions: [CGRect]) {
327
+ guard regions != current else { return }
330
328
  current = regions
331
- self.division = division
332
329
  NotificationCenter.default.post(name: didChange, object: nil)
333
330
  }
334
331
  }
@@ -347,13 +344,12 @@ private final class ReservedRegionsProbe: UIView {
347
344
  override func layoutSubviews() {
348
345
  super.layoutSubviews()
349
346
  // read even when not publishing, so UIKit keeps re-running this when they change
350
- let regions = activeRegions(kind: "occlusionRegionKind")
351
- let division = activeRegions(kind: "divisionRegionKind").first
347
+ let regions = occlusionRegions()
352
348
  // every screen has a probe but the regions are window-wide: one sliding in on a push or
353
349
  // a present, or off the window, would overwrite them with a partial read
354
350
  guard spansWindow else { return }
355
351
  // layout pass: publish on the next turn instead of mutating SwiftUI state mid-update
356
- DispatchQueue.main.async { ReservedRegions.publish(regions, division: division) }
352
+ DispatchQueue.main.async { ReservedRegions.publish(regions) }
357
353
  }
358
354
 
359
355
  private var spansWindow: Bool {
@@ -368,11 +364,11 @@ private final class ReservedRegionsProbe: UIView {
368
364
  }
369
365
 
370
366
  // The API is newer than the SDKs hosts may build with, so it is reached through the runtime.
371
- private func activeRegions(kind kindName: String) -> [CGRect] {
367
+ private func occlusionRegions() -> [CGRect] {
372
368
  let regionsOfKind = NSSelectorFromString("reservedRegionsOfKind:")
373
369
  guard window != nil, responds(to: regionsOfKind),
374
370
  let kindType = NSClassFromString("UIViewReservedRegionKind") as? NSObject.Type,
375
- let kind = (kindType as AnyObject).perform(NSSelectorFromString(kindName))?.takeUnretainedValue(),
371
+ let kind = (kindType as AnyObject).perform(NSSelectorFromString("occlusionRegionKind"))?.takeUnretainedValue(),
376
372
  let regions = perform(regionsOfKind, with: kind)?.takeUnretainedValue() as? [NSObject]
377
373
  else { return [] }
378
374
  return regions.compactMap { ($0.value(forKey: "frame") as? NSValue)?.cgRectValue }
@@ -80,17 +80,56 @@ struct BottomSheetView<Content: View>: View {
80
80
  private let indicatorHeight: CGFloat = 16
81
81
  private let headerRowHeight: CGFloat = 56
82
82
 
83
- /// Half the scrim fades in first, the other half follows the sheet; together they reach
84
- /// `scrimOpacity` (0.6 on phones, as ModalScreen; 0.2 on foldables).
85
- private let maxDynamicAlpha: CGFloat = 0.5
86
-
87
- private var modal: ModalLayout { layout.modalLayout }
88
- private var isFoldable: Bool { modal.isFoldable }
83
+ /// Mirrors Compose's per-term peak (0.3f). Combined with `backgroundAlpha` the
84
+ /// steady-state (fully open) scrim peaks at 0.6, matching ModalScreen's peak.
85
+ private let maxDynamicAlpha: CGFloat = 0.3
89
86
 
90
87
  // UIScreen stays on the outer display on iPhone Duo, even when unfolded
91
- private var screenHeight: CGFloat { isFoldable ? layout.height : UIScreen.main.bounds.height }
88
+ private var screenHeight: CGFloat { isDuo ? layout.height : UIScreen.main.bounds.height }
89
+
90
+ private var isDuo: Bool { layout.isDuoDevice }
91
+ // iPhone Duo inner display: center the sheet instead of spanning the width
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
+ }
109
+
110
+ /// Keeps the portrait width in landscape, like system sheets.
111
+ private var duoCenteredWidth: CGFloat {
112
+ min(
113
+ min(layout.width, layout.height) - Spacing.L * 2,
114
+ layout.width - max(layout.insets.leading, layout.insets.trailing, Spacing.L) * 2
115
+ )
116
+ }
117
+
118
+ /// The floating sheet spans the side safe area, its content stays clear of it.
119
+ private var sideInsetLeading: CGFloat {
120
+ isDuoFloating ? max(layout.insets.leading - Spacing.M, 0) : 0
121
+ }
92
122
 
93
- private var maxHeight: CGFloat { modal.sheet.maxHeight ?? screenHeight - 90 }
123
+ private var sideInsetTrailing: CGFloat {
124
+ isDuoFloating ? max(layout.insets.trailing - Spacing.M, 0) : 0
125
+ }
126
+
127
+ private var maxHeight: CGFloat {
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)
132
+ }
94
133
  private var bottomInset: CGFloat { useBottomInset ? safeAreaBottomInset() : 0 }
95
134
  /// While the keyboard is up, it already covers the home-indicator area, so it
96
135
  /// replaces (rather than adds to) the usual bottom-inset filler.
@@ -112,15 +151,15 @@ struct BottomSheetView<Content: View>: View {
112
151
  return progress * maxDynamicAlpha
113
152
  }
114
153
 
115
- /// Mirrors Compose's `alpha = (backgroundAlpha + dynamicAlpha) * scrimOpacity`: additive, so the
116
- /// scrim peaks at `scrimOpacity` at rest and only fades to half of it while dragging
154
+ /// Mirrors Compose's `alpha = backgroundAlpha + dynamicAlpha`: additive, so the
155
+ /// scrim peaks at 0.6 at rest and only fades to a 0.3 floor while dragging
117
156
  /// (backgroundAlpha holds steady until an explicit close()).
118
- private var totalScrimAlpha: CGFloat { (backgroundAlpha + dynamicAlpha) * modal.scrimOpacity }
157
+ private var totalScrimAlpha: CGFloat { backgroundAlpha + dynamicAlpha }
119
158
 
120
159
  var body: some View {
121
160
  ZStack(alignment: .bottom) {
122
- // Dimmed scrim — additive backgroundAlpha + dynamicAlpha (see above); full screen on foldables too.
123
- Colors.black20.opacity(totalScrimAlpha)
161
+ // Dimmed scrim — additive backgroundAlpha + dynamicAlpha (see above).
162
+ Color.black.opacity(totalScrimAlpha)
124
163
  .contentShape(Rectangle())
125
164
  .onTapGesture {
126
165
  if barrierDismissible { close() }
@@ -160,9 +199,12 @@ struct BottomSheetView<Content: View>: View {
160
199
  .fill(Colors.black06)
161
200
  .frame(width: 40, height: 4)
162
201
  Spacer().frame(height: 4)
202
+ // the handle centers on the whole sheet, only the header row keeps clear of the strip
163
203
  headerView
164
204
  .frame(height: headerRowHeight)
165
205
  .padding(.horizontal, Spacing.M)
206
+ .padding(.leading, sideInsetLeading)
207
+ .padding(.trailing, sideInsetTrailing)
166
208
  }
167
209
  .frame(maxWidth: .infinity)
168
210
  .frame(height: indicatorHeight + headerRowHeight)
@@ -172,18 +214,19 @@ struct BottomSheetView<Content: View>: View {
172
214
  Rectangle()
173
215
  .fill(theme.colors.border.default)
174
216
  .frame(height: 1)
217
+ .padding(.leading, sideInsetLeading)
218
+ .padding(.trailing, sideInsetTrailing)
175
219
 
176
220
  content()
221
+ .padding(.leading, sideInsetLeading)
222
+ .padding(.trailing, sideInsetTrailing)
177
223
  // a tall sheet keeps its header (and footer) and gives the content what is left
178
224
  .layoutPriority(-1)
179
225
 
180
226
  if let footer {
181
- // a sheet held at its min height keeps the footer at the bottom
182
- Spacer(minLength: 0).layoutPriority(-2)
183
- BottomSheetFooter(content: footer)
227
+ BottomSheetFooter(content: footer, leadingInset: sideInsetLeading, trailingInset: sideInsetTrailing)
184
228
  }
185
229
  }
186
- .frame(minHeight: max(modal.sheet.minHeight - effectiveBottomInset, 0), alignment: .top)
187
230
  // The filler stays outside the cap, which shrinks by it instead: the sheet still ends at
188
231
  // `maxHeight`, and the iOS 15 fallback never measures the keyboard as content.
189
232
  .modifier(CapHeight(maxHeight: maxHeight - effectiveBottomInset))
@@ -191,8 +234,7 @@ struct BottomSheetView<Content: View>: View {
191
234
  (footer != nil ? theme.colors.background.surface : backgroundColor)
192
235
  .frame(height: effectiveBottomInset)
193
236
  }
194
- .frame(width: modal.sheet.width)
195
- .frame(maxWidth: modal.sheet.width == nil ? .infinity : nil)
237
+ .frame(maxWidth: isDuoCentered ? duoCenteredWidth : .infinity)
196
238
  .clipped()
197
239
  .background(
198
240
  GeometryReader { geo in
@@ -200,31 +242,56 @@ struct BottomSheetView<Content: View>: View {
200
242
  }
201
243
  )
202
244
  .background(backgroundColor)
203
- .clipShape(RoundedCorner(radius: modal.sheet.radius, corners: [.topLeft, .topRight]))
204
- // centered in the placement: off the iPhone Duo control column, the right half when half folded
205
- .padding(.leading, isFoldable ? modal.placement.minX : 0)
206
- .padding(.trailing, isFoldable ? layout.width - modal.placement.maxX : 0)
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)
207
259
  }
208
260
 
209
261
  @ViewBuilder
210
262
  private var headerView: some View {
211
263
  switch header.style {
212
264
  case .title(let text, let back):
213
- HStack(spacing: Spacing.S) {
214
- if let back {
215
- ModalIconButton(icon: back.icon, accessibilityId: "btn_bottom_sheet_back") { goBack(back) }
216
- } else {
217
- Color.clear.frame(width: ModalMetrics.iconButtonSize, height: ModalMetrics.iconButtonSize)
265
+ // the side column holds back and close, the row keeps only the title
266
+ let showsButtons = sideColumn == nil
267
+ HStack(spacing: 0) {
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
+ }
218
274
  }
219
275
  MomoText(text, typography: .headerDefaultBold, color: Colors.black17)
220
276
  .frame(maxWidth: .infinity, alignment: .center)
221
- ModalIconButton(icon: "navigation_close", accessibilityId: "btn_bottom_sheet_close") { close() }
277
+ .padding(.horizontal, showsButtons ? 0 : Spacing.M)
278
+ if showsButtons {
279
+ headerButton(icon: "navigation_close", accessibilityId: "btn_bottom_sheet_close") { close() }
280
+ }
222
281
  }
223
282
  case .custom(let builder):
224
283
  builder()
225
284
  }
226
285
  }
227
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
+
228
295
  /// RN `leftOptions.onPressIconLeft`: the sheet closes first, then the back runs.
229
296
  private func goBack(_ back: BottomSheetHeader.Back) {
230
297
  close(then: back.action)
@@ -302,6 +369,63 @@ struct BottomSheetView<Content: View>: View {
302
369
  }
303
370
  }
304
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)
425
+ }
426
+ }
427
+ }
428
+
305
429
  /// Compose's `heightIn(max:)`. `.frame(maxHeight:)` grows to the cap whenever the proposal is
306
430
  /// larger, leaving a gap above the header; this sizes the sheet to its content and only caps it
307
431
  /// when taller.
@@ -374,12 +498,16 @@ private struct CapHeightLayout: Layout {
374
498
  /// Mirrors Compose's `BottomSheetFooter`: a surface band with a soft shadow cast on the content.
375
499
  private struct BottomSheetFooter: View {
376
500
  let content: () -> AnyView
501
+ var leadingInset: CGFloat = 0
502
+ var trailingInset: CGFloat = 0
377
503
 
378
504
  @Environment(\.appTheme) private var theme
379
505
 
380
506
  var body: some View {
381
507
  content()
382
508
  .frame(maxWidth: .infinity)
509
+ .padding(.leading, leadingInset)
510
+ .padding(.trailing, trailingInset)
383
511
  .padding(.vertical, Spacing.S)
384
512
  .background(theme.colors.background.surface)
385
513
  .overlay(alignment: .top) {
@@ -16,7 +16,6 @@ public struct BottomTab: View {
16
16
  private let compressionBehavior: DuoBarCompressionBehavior
17
17
  private let onTabPress: ((_ index: Int, _ switchTab: @escaping () -> Void) -> Void)?
18
18
  private let backToInitialTab: Bool
19
- private let onTabLongPress: ((_ index: Int) -> Void)?
20
19
 
21
20
  @EnvironmentObject private var navigator: Navigator
22
21
  /// The screen hosting the tabs (Compose's `LocalNavigation` in BottomTab).
@@ -35,32 +34,28 @@ public struct BottomTab: View {
35
34
  /// starts compressed; tapping the compressed one swaps them.
36
35
  /// `onTabPress` gets every tab press with the switch to perform, e.g. after a login gate.
37
36
  /// `backToInitialTab`: back off another tab returns to the initial one before leaving the screen.
38
- /// `onTabLongPress`: RN `tabLongPress`; on iPhone Duo the held tab is still selected on release.
39
37
  public init(
40
38
  items: [BottomTabItem],
41
39
  floatingButton: BottomTabFloatingButton? = nil,
42
40
  compressionBehavior: DuoBarCompressionBehavior = .toolbar,
43
41
  initialRouteName: String? = nil,
44
42
  onTabPress: ((_ index: Int, _ switchTab: @escaping () -> Void) -> Void)? = nil,
45
- backToInitialTab: Bool = true,
46
- onTabLongPress: ((_ index: Int) -> Void)? = nil
43
+ backToInitialTab: Bool = true
47
44
  ) {
48
45
  self.items = items
49
46
  self.floatingButton = floatingButton
50
47
  self.compressionBehavior = compressionBehavior
51
48
  self.onTabPress = onTabPress
52
49
  self.backToInitialTab = backToInitialTab
53
- self.onTabLongPress = onTabLongPress
54
50
  let start = items.firstIndex { $0.name == initialRouteName } ?? 0
55
51
  _startIndex = State(initialValue: start)
56
52
  _selectedIndex = State(initialValue: start)
57
53
  }
58
54
 
59
55
  private var bottomInset: CGFloat { safeAreaBottomInset() }
60
- // the Duo bars overlay the content or sit in the side strip, so only the home indicator is kept clear
61
- private var reservedBottom: CGFloat {
62
- layout.isIPhoneDuo ? layout.insets.bottom : BOTTOM_TAB_BAR_HEIGHT + bottomInset + Spacing.S
63
- }
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 }
64
59
 
65
60
  private var compression: DuoBarCompression {
66
61
  DuoBarCompression.resolve(
@@ -105,30 +100,16 @@ public struct BottomTab: View {
105
100
  floatingButton: floatingButton,
106
101
  selectedIndex: selectedIndex,
107
102
  onTabSelected: selectTab,
108
- compression: compression,
109
- onTabLongPress: onTabLongPress,
110
- onTick: { [maxApi = navigator.maxApi] in
111
- if let maxApi {
112
- maxApi.triggerEventVibration("light")
113
- } else {
114
- UIImpactFeedbackGenerator(style: .light).impactOccurred()
115
- }
116
- }
103
+ compression: compression
117
104
  )
118
105
  } else {
119
- // Tab bar + home-indicator filler.
120
- VStack(spacing: 0) {
121
- BottomTabBar(
122
- items: items,
123
- floatingButton: floatingButton,
124
- selectedIndex: selectedIndex,
125
- onTabSelected: selectTab,
126
- onTabLongPress: onTabLongPress
127
- )
128
- theme.colors.background.surface
129
- .frame(height: bottomInset + Spacing.S)
130
- .ignoresSafeArea(edges: .horizontal)
131
- }
106
+ BottomTabBar(
107
+ items: items,
108
+ floatingButton: floatingButton,
109
+ selectedIndex: selectedIndex,
110
+ onTabSelected: selectTab,
111
+ bottomInset: bottomInset
112
+ )
132
113
  }
133
114
  }
134
115
  .frame(maxWidth: .infinity, maxHeight: .infinity)
@@ -150,6 +131,7 @@ public struct BottomTab: View {
150
131
  }
151
132
 
152
133
  private func selectTab(_ index: Int) {
134
+ navigator.maxApi?.triggerEventVibration("light")
153
135
  let switchTab = { if index != selectedIndex { selectedIndex = index } }
154
136
  if let onTabPress { onTabPress(index, switchTab) } else { switchTab() }
155
137
  }
@@ -221,11 +203,11 @@ private struct TabHost: UIViewControllerRepresentable {
221
203
 
222
204
  private final class TabController: UIViewController {
223
205
  private final class Tab {
224
- let motion = TabMotion()
225
206
  var host: UIHostingController<AnyView>!
226
207
  }
227
208
 
228
- private static let switchDuration: TimeInterval = 0.2
209
+ /// The tab switch: the screens slide in index order over 280ms, CSS `ease`.
210
+ private static let switchDuration: TimeInterval = 0.28
229
211
 
230
212
  private var tabs: [Int: Tab] = [:]
231
213
  private var selectedIndex: Int?
@@ -239,7 +221,7 @@ private final class TabController: UIViewController {
239
221
 
240
222
  override func viewDidLayoutSubviews() {
241
223
  super.viewDidLayoutSubviews()
242
- for subview in view.subviews { subview.frame = view.bounds }
224
+ for subview in view.subviews { place(subview) }
243
225
  }
244
226
 
245
227
  func update(
@@ -256,33 +238,43 @@ private final class TabController: UIViewController {
256
238
  }
257
239
  if let selectedIndex, tabs[selectedIndex] == nil { self.selectedIndex = nil }
258
240
  // hidden tabs too, so a tab coming back already shows the latest items and environment
259
- for (tabIndex, existing) in tabs { existing.host.rootView = rootView(tabIndex, existing) }
241
+ for (tabIndex, existing) in tabs { existing.host.rootView = rootView(tabIndex) }
260
242
  guard (0..<count).contains(index), index != selectedIndex else { return }
261
243
 
262
- let previous = selectedIndex.flatMap { tabs[$0] }
244
+ let previousIndex = selectedIndex
245
+ let previous = previousIndex.flatMap { tabs[$0] }
263
246
  selectedIndex = index
264
247
  let selected = tabs[index] ?? makeTab(index)
248
+ // a tab selected again while it leaves carries on from where it is
249
+ let entering = selected.host.view.superview == nil
265
250
  attach(selected)
266
251
 
267
- guard let previous, view.window != nil else {
268
- selected.motion.visible = true
252
+ guard let previous, let previousIndex, view.window != nil else {
253
+ selected.host.view.transform = .identity
269
254
  previous.map(leave)
270
255
  return
271
256
  }
272
257
  previous.host.view.isUserInteractionEnabled = false
273
- // a frame at the start values first, so a tab created just now fades in too
258
+ let offset = index > previousIndex ? view.bounds.width : -view.bounds.width
259
+ if entering { selected.host.view.transform = CGAffineTransform(translationX: offset, y: 0) }
260
+ // a frame at the start values first, so a tab created just now slides in with its content
274
261
  DispatchQueue.main.async {
275
- selected.motion.visible = true
276
- previous.motion.visible = false
277
- }
278
- DispatchQueue.main.asyncAfter(deadline: .now() + Self.switchDuration) { [weak self] in
279
- self?.leave(previous)
262
+ let animator = UIViewPropertyAnimator(
263
+ duration: Self.switchDuration,
264
+ controlPoint1: CGPoint(x: 0.25, y: 0.1),
265
+ controlPoint2: CGPoint(x: 0.25, y: 1)
266
+ ) {
267
+ selected.host.view.transform = .identity
268
+ previous.host.view.transform = CGAffineTransform(translationX: -offset, y: 0)
269
+ }
270
+ animator.addCompletion { [weak self] _ in self?.leave(previous) }
271
+ animator.startAnimation()
280
272
  }
281
273
  }
282
274
 
283
275
  private func makeTab(_ index: Int) -> Tab {
284
276
  let tab = Tab()
285
- let host = UIHostingController(rootView: rootView(index, tab))
277
+ let host = UIHostingController(rootView: rootView(index))
286
278
  host.view.backgroundColor = .clear
287
279
  addChild(host)
288
280
  host.didMove(toParent: self)
@@ -291,14 +283,20 @@ private final class TabController: UIViewController {
291
283
  return tab
292
284
  }
293
285
 
294
- private func rootView(_ index: Int, _ tab: Tab) -> AnyView {
295
- AnyView(TabCard(motion: tab.motion, content: content(index)).environment(\.self, environment))
286
+ private func rootView(_ index: Int) -> AnyView {
287
+ AnyView(content(index).environment(\.self, environment))
288
+ }
289
+
290
+ /// Bounds and center, a sliding tab carries a transform that frame doesn't work with.
291
+ private func place(_ subview: UIView) {
292
+ subview.bounds = view.bounds
293
+ subview.center = CGPoint(x: view.bounds.midX, y: view.bounds.midY)
296
294
  }
297
295
 
298
296
  private func attach(_ tab: Tab) {
299
297
  let hostView: UIView = tab.host.view
300
298
  hostView.isUserInteractionEnabled = true
301
- hostView.frame = view.bounds
299
+ place(hostView)
302
300
  if hostView.superview === view {
303
301
  view.bringSubviewToFront(hostView)
304
302
  } else {
@@ -310,6 +308,7 @@ private final class TabController: UIViewController {
310
308
  private func leave(_ tab: Tab) {
311
309
  guard selectedIndex.flatMap({ tabs[$0] }) !== tab else { return }
312
310
  tab.host.view.removeFromSuperview()
311
+ tab.host.view.transform = .identity
313
312
  }
314
313
 
315
314
  private func tearDown(_ tab: Tab) {
@@ -319,27 +318,9 @@ private final class TabController: UIViewController {
319
318
  }
320
319
  }
321
320
 
322
- private final class TabMotion: ObservableObject {
323
- @Published var visible = false
324
- }
325
-
326
- /// The tab switch: 0.97 scale + fade over 200ms, both ways (Compose's tab enter / exit transitions).
327
- private struct TabCard: View {
328
- @ObservedObject var motion: TabMotion
329
- let content: AnyView
330
-
331
- var body: some View {
332
- content
333
- .opacity(motion.visible ? 1 : 0)
334
- .scaleEffect(motion.visible ? 1 : 0.97)
335
- .animation(.easeInOut(duration: 0.2), value: motion.visible)
336
- }
337
- }
338
-
339
321
  /// Bottom safe-area inset (home indicator).
340
322
  private func safeAreaBottomInset() -> CGFloat {
341
- let bottomInset = UIApplication.shared.connectedScenes
323
+ UIApplication.shared.connectedScenes
342
324
  .compactMap { ($0 as? UIWindowScene)?.keyWindow?.safeAreaInsets.bottom }
343
325
  .first ?? 0
344
- return min(bottomInset, 21)
345
326
  }