@momo-kits/native-kits 0.168.1-beta.32-debug → 0.168.1-beta.33

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 (151) hide show
  1. package/CLAUDE.md +1 -0
  2. package/ios/Input/Input.swift +3 -1
  3. package/ios/Input/InputTextArea.swift +3 -1
  4. package/ios/Navigation/BottomTab/BottomTab.swift +67 -48
  5. package/ios/Navigation/BottomTab/BottomTabBar.swift +131 -281
  6. package/ios/Navigation/BottomTab/CurvedContainer.swift +47 -51
  7. package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +364 -0
  8. package/ios/Navigation/BottomTab/DuoTabBar.swift +292 -72
  9. package/ios/Navigation/Component/HeaderRight.swift +1 -1
  10. package/ios/Navigation/StackScreen.swift +1 -3
  11. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +59 -272
  12. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +90 -0
  13. package/package.json +1 -1
  14. package/build.gradle.kts +0 -11
  15. package/compose/build.gradle.kts +0 -198
  16. package/compose/build.gradle.kts.backup +0 -198
  17. package/compose/compose.podspec +0 -47
  18. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
  19. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  20. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  21. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  22. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  23. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -370
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -321
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -502
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -148
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -240
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -389
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -94
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -203
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -106
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -92
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -20
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  139. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -219
  140. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -138
  141. package/gradle/libs.versions.toml +0 -69
  142. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  143. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  144. package/gradle.properties +0 -26
  145. package/gradlew +0 -252
  146. package/gradlew.bat +0 -94
  147. package/ios/Navigation/BottomTab/TabBarMetrics.swift +0 -88
  148. package/ios-demo/README.md +0 -120
  149. package/ios-demo/Resources/tabbar_scan_qr_button.json +0 -1
  150. package/ios-demo/Resources/tabbar_scan_qr_label.json +0 -1
  151. package/settings.gradle.kts +0 -64
package/CLAUDE.md CHANGED
@@ -77,6 +77,7 @@ Publishing is automated (`publish.sh` + GitLab CI on `[ci build]` / `main`). Do
77
77
  - iPhone Duo with a side strip ≥ 60pt: back + toolkit leave the bar for `HeaderSideBar` (`navigation/component/SideBar.kt`, 48pt glass controls); custom header-right stays in the bar. `sideBar.top` is 170pt in portrait, 120pt on the inner display in landscape (height ≥ 600), 24pt on the outer display in landscape, or below the header when the status bar is on top; UIKit's `statusBarFrame` is useless on Duo. Unlike RN the column is clamped above footer (24pt gap) / rail (12pt gap).
78
78
  - Reserved regions (iOS 27.1 `reservedRegionsOfKind:`, reached through the ObjC runtime so older SDKs still build): a probe `UIView` (`platform/ReservedRegions.ios.kt` on the Compose root view; `ReservedRegionsProbe` inside SwiftUI `momoScreenLayout()`) re-reads them in `layoutSubviews`, which UIKit re-runs when they change. They push `sideBar.top` below the status cluster as it grows for calls / Live Activities, and `sideBar.bottom` (≥ 24pt) above a camera at the bottom end of the strip.
79
79
  - Tab bar on Duo is `bottomtab/DuoTabBar.kt`: a rail in the side strip (`sideBar.bottom` above the window bottom, QR below it) or, without a side bar, a floating bar spanning 6/8 grid columns. Both overlay the content; `duoFloatingTabBarInset` pads tab content, footer and FAB.
80
+ - Duo tab selection motion (`bottomtab/DuoLiquidSelection.kt` / `ios/Navigation/BottomTab/DuoLiquidSelection.swift`, port of RN `useLiquidSelection.ts`, momo-kits !682): press lifts the lens, a drag past 10pt takes over (Compose: the bar's `pointerInput` consumes and so cancels the tab's clickable; SwiftUI: one `DragGesture` over the bar, tabs are not `Button`s), long press calls `BottomTab(onTabLongPress)` and release still selects, Reduce Motion (`platform/ReduceMotion`) falls back to a plain slide. SwiftUI integrates the lens spring on a display link because the stretch and the tabs' active tint read it every frame. Constants mirror RN — change both together.
80
81
  - Bar compression (`bottomtab/DuoBarCompression.kt`, HIG "Vertical controls"): when toolbar + rail don't fit in the strip, one is compressed — the toolkit into a `navigation_menu` button, the rail into one button showing the current tab — and tapping it swaps them; `BottomTab(compressionBehavior)` picks which starts compressed. If neither fits beside the other compressed, both rest compressed and a tap opens one for a moment. Side bar columns report their full height (0 when the screen puts nothing there) so the decision follows each screen's toolkit.
81
82
  - Glass header: on Duo with a side bar, Default/Extended headers without search and with a `ScrollState` let content scroll under the bar (`usesDuoGlassHeader`); the bar fades in a translucent surface + hairline over 16pt (Compose has no backdrop blur — RN's fallback look), the gradient leaves with the content.
82
83
  - Quick return header: glass headers and Animated headers (with a `ScrollState`) on the Duo side bar layout slide out with the content and back in on a reverse scroll; a half-shown header settles in or out once the scroll stops. The side bar is drawn apart from the header, so it stays put.
@@ -252,7 +252,9 @@ public struct Input: View {
252
252
  }
253
253
  .padding(.horizontal, Spacing.S)
254
254
  .background(theme.colors.background.surface)
255
- .alignmentGuide(.top) { $0[VerticalAlignment.center] }
255
+ // A zero-height frame on the top edge centers the label on the border, re-laid out with font scale.
256
+ .fixedSize(horizontal: false, vertical: true)
257
+ .frame(height: 0)
256
258
  .offset(x: Spacing.S)
257
259
  }
258
260
  }
@@ -279,7 +279,9 @@ public struct InputTextArea: View {
279
279
  }
280
280
  .padding(.horizontal, Spacing.S)
281
281
  .background(theme.colors.background.surface)
282
- .alignmentGuide(.top) { $0[VerticalAlignment.center] }
282
+ // A zero-height frame on the top edge centers the label on the border, re-laid out with font scale.
283
+ .fixedSize(horizontal: false, vertical: true)
284
+ .frame(height: 0)
283
285
  .offset(x: Spacing.S)
284
286
  }
285
287
  }
@@ -16,6 +16,7 @@ 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)?
19
20
 
20
21
  @EnvironmentObject private var navigator: Navigator
21
22
  /// The screen hosting the tabs (Compose's `LocalNavigation` in BottomTab).
@@ -34,28 +35,32 @@ public struct BottomTab: View {
34
35
  /// starts compressed; tapping the compressed one swaps them.
35
36
  /// `onTabPress` gets every tab press with the switch to perform, e.g. after a login gate.
36
37
  /// `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.
37
39
  public init(
38
40
  items: [BottomTabItem],
39
41
  floatingButton: BottomTabFloatingButton? = nil,
40
42
  compressionBehavior: DuoBarCompressionBehavior = .toolbar,
41
43
  initialRouteName: String? = nil,
42
44
  onTabPress: ((_ index: Int, _ switchTab: @escaping () -> Void) -> Void)? = nil,
43
- backToInitialTab: Bool = true
45
+ backToInitialTab: Bool = true,
46
+ onTabLongPress: ((_ index: Int) -> Void)? = nil
44
47
  ) {
45
48
  self.items = items
46
49
  self.floatingButton = floatingButton
47
50
  self.compressionBehavior = compressionBehavior
48
51
  self.onTabPress = onTabPress
49
52
  self.backToInitialTab = backToInitialTab
53
+ self.onTabLongPress = onTabLongPress
50
54
  let start = items.firstIndex { $0.name == initialRouteName } ?? 0
51
55
  _startIndex = State(initialValue: start)
52
56
  _selectedIndex = State(initialValue: start)
53
57
  }
54
58
 
55
59
  private var bottomInset: CGFloat { safeAreaBottomInset() }
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
+ // 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
+ }
59
64
 
60
65
  private var compression: DuoBarCompression {
61
66
  DuoBarCompression.resolve(
@@ -100,16 +105,30 @@ public struct BottomTab: View {
100
105
  floatingButton: floatingButton,
101
106
  selectedIndex: selectedIndex,
102
107
  onTabSelected: selectTab,
103
- compression: compression
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
+ }
104
117
  )
105
118
  } else {
106
- BottomTabBar(
107
- items: items,
108
- floatingButton: floatingButton,
109
- selectedIndex: selectedIndex,
110
- onTabSelected: selectTab,
111
- bottomInset: bottomInset
112
- )
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
+ }
113
132
  }
114
133
  }
115
134
  .frame(maxWidth: .infinity, maxHeight: .infinity)
@@ -131,7 +150,6 @@ public struct BottomTab: View {
131
150
  }
132
151
 
133
152
  private func selectTab(_ index: Int) {
134
- navigator.maxApi?.triggerEventVibration("light")
135
153
  let switchTab = { if index != selectedIndex { selectedIndex = index } }
136
154
  if let onTabPress { onTabPress(index, switchTab) } else { switchTab() }
137
155
  }
@@ -203,11 +221,11 @@ private struct TabHost: UIViewControllerRepresentable {
203
221
 
204
222
  private final class TabController: UIViewController {
205
223
  private final class Tab {
224
+ let motion = TabMotion()
206
225
  var host: UIHostingController<AnyView>!
207
226
  }
208
227
 
209
- /// The tab switch: the screens slide in index order over 280ms, CSS `ease`.
210
- private static let switchDuration: TimeInterval = 0.28
228
+ private static let switchDuration: TimeInterval = 0.2
211
229
 
212
230
  private var tabs: [Int: Tab] = [:]
213
231
  private var selectedIndex: Int?
@@ -221,7 +239,7 @@ private final class TabController: UIViewController {
221
239
 
222
240
  override func viewDidLayoutSubviews() {
223
241
  super.viewDidLayoutSubviews()
224
- for subview in view.subviews { place(subview) }
242
+ for subview in view.subviews { subview.frame = view.bounds }
225
243
  }
226
244
 
227
245
  func update(
@@ -238,43 +256,33 @@ private final class TabController: UIViewController {
238
256
  }
239
257
  if let selectedIndex, tabs[selectedIndex] == nil { self.selectedIndex = nil }
240
258
  // hidden tabs too, so a tab coming back already shows the latest items and environment
241
- for (tabIndex, existing) in tabs { existing.host.rootView = rootView(tabIndex) }
259
+ for (tabIndex, existing) in tabs { existing.host.rootView = rootView(tabIndex, existing) }
242
260
  guard (0..<count).contains(index), index != selectedIndex else { return }
243
261
 
244
- let previousIndex = selectedIndex
245
- let previous = previousIndex.flatMap { tabs[$0] }
262
+ let previous = selectedIndex.flatMap { tabs[$0] }
246
263
  selectedIndex = index
247
264
  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
250
265
  attach(selected)
251
266
 
252
- guard let previous, let previousIndex, view.window != nil else {
253
- selected.host.view.transform = .identity
267
+ guard let previous, view.window != nil else {
268
+ selected.motion.visible = true
254
269
  previous.map(leave)
255
270
  return
256
271
  }
257
272
  previous.host.view.isUserInteractionEnabled = false
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
273
+ // a frame at the start values first, so a tab created just now fades in too
261
274
  DispatchQueue.main.async {
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()
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)
272
280
  }
273
281
  }
274
282
 
275
283
  private func makeTab(_ index: Int) -> Tab {
276
284
  let tab = Tab()
277
- let host = UIHostingController(rootView: rootView(index))
285
+ let host = UIHostingController(rootView: rootView(index, tab))
278
286
  host.view.backgroundColor = .clear
279
287
  addChild(host)
280
288
  host.didMove(toParent: self)
@@ -283,20 +291,14 @@ private final class TabController: UIViewController {
283
291
  return tab
284
292
  }
285
293
 
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)
294
+ private func rootView(_ index: Int, _ tab: Tab) -> AnyView {
295
+ AnyView(TabCard(motion: tab.motion, content: content(index)).environment(\.self, environment))
294
296
  }
295
297
 
296
298
  private func attach(_ tab: Tab) {
297
299
  let hostView: UIView = tab.host.view
298
300
  hostView.isUserInteractionEnabled = true
299
- place(hostView)
301
+ hostView.frame = view.bounds
300
302
  if hostView.superview === view {
301
303
  view.bringSubviewToFront(hostView)
302
304
  } else {
@@ -308,7 +310,6 @@ private final class TabController: UIViewController {
308
310
  private func leave(_ tab: Tab) {
309
311
  guard selectedIndex.flatMap({ tabs[$0] }) !== tab else { return }
310
312
  tab.host.view.removeFromSuperview()
311
- tab.host.view.transform = .identity
312
313
  }
313
314
 
314
315
  private func tearDown(_ tab: Tab) {
@@ -318,9 +319,27 @@ private final class TabController: UIViewController {
318
319
  }
319
320
  }
320
321
 
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
+
321
339
  /// Bottom safe-area inset (home indicator).
322
340
  private func safeAreaBottomInset() -> CGFloat {
323
- UIApplication.shared.connectedScenes
341
+ let bottomInset = UIApplication.shared.connectedScenes
324
342
  .compactMap { ($0 as? UIWindowScene)?.keyWindow?.safeAreaInsets.bottom }
325
343
  .first ?? 0
344
+ return min(bottomInset, 21)
326
345
  }