@momo-kits/native-kits 0.300.7 → 0.300.8-beta.1-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 (256) hide show
  1. package/CLAUDE.md +12 -8
  2. package/README.md +8 -7
  3. package/build.gradle.kts +13 -0
  4. package/compose/build.gradle.kts +195 -0
  5. package/compose/build.gradle.kts.backup +195 -0
  6. package/compose/compose.podspec +47 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -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 +154 -0
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +61 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +60 -0
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +32 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1067 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +268 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +55 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +354 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +130 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +482 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +224 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +137 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +473 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +113 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +262 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +237 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +228 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +280 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +183 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +342 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +40 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +82 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +39 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +362 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +304 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +88 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +308 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +218 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +456 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +205 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +89 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +542 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +175 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +201 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +208 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +12 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +291 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +315 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +54 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +397 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +153 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +118 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +212 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +422 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +750 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +152 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +244 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +398 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +103 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +93 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +208 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +167 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +446 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +387 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +33 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +197 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +38 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +135 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +114 -0
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +7 -0
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +21 -0
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +117 -0
  131. package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +44 -0
  132. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +39 -0
  133. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +53 -0
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +31 -0
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +65 -0
  139. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
  140. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  141. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +143 -0
  142. package/gradle/libs.versions.toml +66 -0
  143. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  144. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  145. package/gradle.properties +24 -0
  146. package/gradlew +252 -0
  147. package/gradlew.bat +94 -0
  148. package/ios/Application/ApplicationEnvironment.swift +6 -4
  149. package/ios/Application/DesignSystemKits.swift +59 -13
  150. package/ios/Application/DesignSystemKitsPayload.swift +0 -8
  151. package/ios/Application/LanguageSource.swift +2 -11
  152. package/ios/Application/Localize.swift +8 -35
  153. package/ios/Application/LocalizeModifier.swift +2 -11
  154. package/ios/Application/MaxApi.swift +3 -11
  155. package/ios/Avatar/Avatar.swift +0 -1
  156. package/ios/Badge/Badge.swift +5 -8
  157. package/ios/Badge/BadgeRibbon.swift +2 -5
  158. package/ios/Button/Button.swift +4 -8
  159. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
  160. package/ios/Carousel/Carousel.swift +4 -17
  161. package/ios/Checkbox/Checkbox.swift +0 -2
  162. package/ios/Collapse/Collapse.swift +17 -11
  163. package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
  164. package/ios/DateTimePicker/DateTimePicker.swift +4 -10
  165. package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
  166. package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
  167. package/ios/DateTimePicker/WheelPicker.swift +2 -4
  168. package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
  169. package/ios/Extensions/Color++.swift +2 -4
  170. package/ios/Extensions/SkeletonUICompat.swift +0 -8
  171. package/ios/Icon/Icon.swift +3 -6
  172. package/ios/IconButton/IconButton.swift +2 -5
  173. package/ios/Input/ErrorView.swift +0 -7
  174. package/ios/Input/Input.swift +9 -20
  175. package/ios/Input/InputPhoneNumber.swift +37 -20
  176. package/ios/Input/InputSearch.swift +23 -12
  177. package/ios/Input/InputTextArea.swift +4 -13
  178. package/ios/InputDropDown/InputDropDown.swift +1 -11
  179. package/ios/InputMoney/InputMoney.swift +9 -28
  180. package/ios/InputOTP/InputOTP.swift +2 -9
  181. package/ios/Layout/HeaderLayout.swift +72 -0
  182. package/ios/Layout/Item.swift +1 -2
  183. package/ios/Layout/ModalLayout.swift +144 -0
  184. package/ios/Layout/ScreenLayout.swift +48 -31
  185. package/ios/Layout/Section.swift +2 -3
  186. package/ios/Loader/Loader.swift +3 -12
  187. package/ios/Lottie/LottieView.swift +0 -11
  188. package/ios/Navigation/BottomSheet.swift +73 -94
  189. package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
  190. package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
  191. package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
  192. package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
  193. package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
  194. package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
  195. package/ios/Navigation/Component/FloatingButton.swift +4 -11
  196. package/ios/Navigation/Component/Header.swift +35 -54
  197. package/ios/Navigation/Component/HeaderBackground.swift +2 -8
  198. package/ios/Navigation/Component/HeaderJourney.swift +4 -8
  199. package/ios/Navigation/Component/HeaderLocation.swift +4 -8
  200. package/ios/Navigation/Component/HeaderRight.swift +20 -22
  201. package/ios/Navigation/Component/HeaderTitle.swift +1 -6
  202. package/ios/Navigation/Component/HeaderUser.swift +4 -10
  203. package/ios/Navigation/Component/SideBar.swift +6 -21
  204. package/ios/Navigation/Component/SnackBar.swift +9 -13
  205. package/ios/Navigation/HostBackGestureBridge.swift +2 -9
  206. package/ios/Navigation/ModalScreen.swift +24 -13
  207. package/ios/Navigation/Navigation.swift +35 -19
  208. package/ios/Navigation/NavigationContainer.swift +4 -15
  209. package/ios/Navigation/Navigator.swift +21 -39
  210. package/ios/Navigation/StackScreen.swift +64 -51
  211. package/ios/Navigation/StackTransition.swift +7 -14
  212. package/ios/Navigation/SwipeBackHaptic.swift +2 -7
  213. package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
  214. package/ios/Pagination/PaginationDot.swift +0 -9
  215. package/ios/Pagination/PaginationNumber.swift +1 -9
  216. package/ios/Pagination/PaginationScroll.swift +2 -14
  217. package/ios/Pagination/PaginationWhiteDot.swift +1 -10
  218. package/ios/Popup/PopupDisplay.swift +7 -5
  219. package/ios/Popup/PopupInput.swift +6 -4
  220. package/ios/Popup/PopupLayout.swift +17 -9
  221. package/ios/Popup/PopupNotify.swift +32 -25
  222. package/ios/PopupView/FullscreenPopup.swift +3 -4
  223. package/ios/PopupView/PopupView.swift +2 -2
  224. package/ios/PopupView/Utils++.swift +1 -2
  225. package/ios/ProgressInfo/ProgressInfo.swift +2 -13
  226. package/ios/Skeleton/Skeleton.swift +5 -16
  227. package/ios/Slider/Slider.swift +5 -12
  228. package/ios/StatusBarTap/StatusBarTap.h +2 -3
  229. package/ios/StatusBarTap/StatusBarTap.m +3 -16
  230. package/ios/Stepper/Stepper.swift +8 -27
  231. package/ios/Steps/Steps.swift +29 -26
  232. package/ios/Swipeable/SwipeCell.swift +2 -2
  233. package/ios/Swipeable/SwipeCellModel.swift +3 -6
  234. package/ios/TabView/TabView.swift +14 -28
  235. package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
  236. package/ios/Title/Title.swift +1 -3
  237. package/ios/Tooltip/Tooltip.swift +4 -9
  238. package/ios/Typography/FontScale.swift +79 -24
  239. package/ios/Typography/Text.swift +6 -12
  240. package/ios/Typography/Typography.swift +8 -11
  241. package/ios/Uploader/Uploader.swift +2 -17
  242. package/ios-demo/README.md +120 -0
  243. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  244. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  245. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
  246. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
  247. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
  248. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
  249. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
  250. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
  251. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
  252. package/package.json +1 -1
  253. package/publish.sh +8 -2
  254. package/scripts/ci/build-swiftui.sh +22 -0
  255. package/scripts/ci/resolve-version.mjs +144 -0
  256. package/settings.gradle.kts +63 -0
@@ -1,13 +1,5 @@
1
- //
2
- // BottomSheet.swift
3
- // MoMoUIKits
4
- //
5
- // SwiftUI mirror of Compose's `navigation/BottomSheet.kt`.
6
- // A sheet that slides up from the bottom over a dimmed scrim, with a drag
7
- // handle, a header (title or custom), a divider and the content body.
8
- // Dragging down past a threshold (or tapping the scrim) dismisses it.
9
- // Driven by `Navigator.showBottomSheet`.
10
- //
1
+ // SwiftUI mirror of Compose's `navigation/BottomSheet.kt`, driven by `Navigator.showBottomSheet`:
2
+ // drag handle, header and body over a dimmed scrim; a long drag down or a scrim tap dismisses it.
11
3
 
12
4
  import SwiftUI
13
5
 
@@ -15,16 +7,25 @@ import SwiftUI
15
7
 
16
8
  /// Mirrors Compose's `sealed class BottomHeader` (Title / Custom).
17
9
  public struct BottomSheetHeader {
10
+ struct Back {
11
+ let icon: String
12
+ let action: () -> Void
13
+ }
14
+
18
15
  enum Style {
19
- case title(String)
16
+ case title(String, back: Back?)
20
17
  case custom(() -> AnyView)
21
18
  }
22
19
 
23
20
  let style: Style
24
21
 
25
- /// Mirrors `BottomHeader.Title`.
26
- public static func title(_ text: String = "Bottom Sheet Title") -> BottomSheetHeader {
27
- BottomSheetHeader(style: .title(text))
22
+ /// Mirrors `BottomHeader.Title`. `onBack` shows a back button; the sheet closes, then it runs.
23
+ public static func title(
24
+ _ text: String = "Bottom Sheet Title",
25
+ backIcon: String = "arrow-back",
26
+ onBack: (() -> Void)? = nil
27
+ ) -> BottomSheetHeader {
28
+ BottomSheetHeader(style: .title(text, back: onBack.map { Back(icon: backIcon, action: $0) }))
28
29
  }
29
30
 
30
31
  /// Mirrors `BottomHeader.Custom`.
@@ -59,50 +60,29 @@ struct BottomSheetView<Content: View>: View {
59
60
  @State private var didAppear = false
60
61
  @State private var isClosing = false
61
62
  @State private var keyboardHeight: CGFloat = 0
62
- /// Live drag offset, isolated from `sheetOffset` so a touch-move only invalidates
63
- /// this gesture-scoped value instead of forcing the whole body (including
64
- /// `content()`) to reconstruct every frame — mirrors the pattern already used in
65
- /// `ios/PopupView/PopupView.swift` for smooth drag-to-dismiss.
63
+ /// Kept apart from `sheetOffset` so a touch-move invalidates only this value instead of
64
+ /// rebuilding `content()` every frame (as PopupView does for drag-to-dismiss).
66
65
  @GestureState private var dragTranslation: CGFloat = 0
67
66
 
68
67
  /// Mirrors Compose's `sheetCloseOffset` (100dp drag threshold to dismiss).
69
68
  private let closeThreshold: CGFloat = 100
70
69
 
71
- /// Mirrors Compose's per-term peak (0.3f). Combined with `backgroundAlpha` the
72
- /// steady-state (fully open) scrim peaks at 0.6, matching ModalScreen's peak.
73
- private let maxDynamicAlpha: CGFloat = 0.3
74
-
75
- // UIScreen stays on the outer display on iPhone Duo, even when unfolded
76
- private var screenHeight: CGFloat { isDuo ? layout.height : UIScreen.main.bounds.height }
77
-
78
- private var isDuo: Bool { layout.isDuoDevice }
79
- // iPhone Duo inner display: center the sheet instead of spanning the width
80
- private var isDuoCentered: Bool { isDuo && layout.width >= 600 }
70
+ private let indicatorHeight: CGFloat = 16
71
+ private let headerRowHeight: CGFloat = 56
81
72
 
82
- /// Keeps the portrait width in landscape, like system sheets.
83
- private var duoCenteredWidth: CGFloat {
84
- min(
85
- min(layout.width, layout.height) - Spacing.L * 2,
86
- layout.width - max(layout.insets.leading, layout.insets.trailing, Spacing.L) * 2
87
- )
88
- }
73
+ /// Half the scrim fades in first, the other half follows the sheet; together they reach
74
+ /// `scrimOpacity` (0.6 on phones, as ModalScreen; 0.2 on foldables).
75
+ private let maxDynamicAlpha: CGFloat = 0.5
89
76
 
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.
92
- private var sideInsetLeading: CGFloat {
93
- isDuo && !isDuoCentered && layout.width > layout.height ? layout.insets.leading : 0
94
- }
77
+ private var modal: ModalLayout { layout.modalLayout }
78
+ private var isFoldable: Bool { modal.isFoldable }
95
79
 
96
- private var sideInsetTrailing: CGFloat {
97
- isDuo && !isDuoCentered && layout.width > layout.height ? layout.insets.trailing : 0
98
- }
80
+ // UIScreen stays on the outer display on iPhone Duo, even when unfolded
81
+ private var screenHeight: CGFloat { isFoldable ? layout.height : UIScreen.main.bounds.height }
99
82
 
100
- private var maxHeight: CGFloat {
101
- isDuo ? layout.height - max(layout.duoTopInset, Spacing.XL) : screenHeight - 90
102
- }
83
+ private var maxHeight: CGFloat { modal.sheet.maxHeight ?? screenHeight - 90 }
103
84
  private var bottomInset: CGFloat { useBottomInset ? safeAreaBottomInset() : 0 }
104
- /// While the keyboard is up, it already covers the home-indicator area, so it
105
- /// replaces (rather than adds to) the usual bottom-inset filler.
85
+ /// The keyboard already covers the home-indicator area, so it replaces the filler, not adds to it.
106
86
  private var effectiveBottomInset: CGFloat { keyboardHeight > 0 ? keyboardHeight : bottomInset }
107
87
 
108
88
  private var backgroundColor: Color {
@@ -111,9 +91,8 @@ struct BottomSheetView<Content: View>: View {
111
91
 
112
92
  private var effectiveOffset: CGFloat { sheetOffset + dragTranslation }
113
93
 
114
- /// Mirrors Compose's `dynamicAlpha`: a plain derived value (not itself animated)
115
- /// that tracks the current offset live, shrinking toward 0 as the sheet is
116
- /// dragged down.
94
+ /// Mirrors Compose's `dynamicAlpha`: derived from the live offset (not animated), shrinking
95
+ /// toward 0 as the sheet is dragged down.
117
96
  private var dynamicAlpha: CGFloat {
118
97
  let denom = sheetHeight > 0 ? sheetHeight : screenHeight
119
98
  guard denom > 0 else { return maxDynamicAlpha }
@@ -121,15 +100,14 @@ struct BottomSheetView<Content: View>: View {
121
100
  return progress * maxDynamicAlpha
122
101
  }
123
102
 
124
- /// Mirrors Compose's `alpha = backgroundAlpha + dynamicAlpha`: additive, so the
125
- /// scrim peaks at 0.6 at rest and only fades to a 0.3 floor while dragging
126
- /// (backgroundAlpha holds steady until an explicit close()).
127
- private var totalScrimAlpha: CGFloat { backgroundAlpha + dynamicAlpha }
103
+ /// Compose's `(backgroundAlpha + dynamicAlpha) * scrimOpacity`: additive, so a drag fades the scrim only to half
104
+ /// of `scrimOpacity` (backgroundAlpha holds until an explicit close()).
105
+ private var totalScrimAlpha: CGFloat { (backgroundAlpha + dynamicAlpha) * modal.scrimOpacity }
128
106
 
129
107
  var body: some View {
130
108
  ZStack(alignment: .bottom) {
131
- // Dimmed scrim — additive backgroundAlpha + dynamicAlpha (see above).
132
- Color.black.opacity(totalScrimAlpha)
109
+ // full screen on foldables too
110
+ Colors.black20.opacity(totalScrimAlpha)
133
111
  .contentShape(Rectangle())
134
112
  .onTapGesture {
135
113
  if barrierDismissible { close() }
@@ -170,13 +148,11 @@ struct BottomSheetView<Content: View>: View {
170
148
  .frame(width: 40, height: 4)
171
149
  Spacer().frame(height: 4)
172
150
  headerView
173
- .frame(height: 56)
151
+ .frame(height: headerRowHeight)
174
152
  .padding(.horizontal, Spacing.M)
175
- .padding(.leading, sideInsetLeading)
176
- .padding(.trailing, sideInsetTrailing)
177
153
  }
178
154
  .frame(maxWidth: .infinity)
179
- .frame(height: 72)
155
+ .frame(height: indicatorHeight + headerRowHeight)
180
156
  .contentShape(Rectangle())
181
157
  .gesture(dragGesture, including: draggable ? .all : .subviews)
182
158
 
@@ -185,15 +161,16 @@ struct BottomSheetView<Content: View>: View {
185
161
  .frame(height: 1)
186
162
 
187
163
  content()
188
- .padding(.leading, sideInsetLeading)
189
- .padding(.trailing, sideInsetTrailing)
190
164
  // a tall sheet keeps its header (and footer) and gives the content what is left
191
165
  .layoutPriority(-1)
192
166
 
193
167
  if let footer {
168
+ // a sheet held at its min height keeps the footer at the bottom
169
+ Spacer(minLength: 0).layoutPriority(-2)
194
170
  BottomSheetFooter(content: footer)
195
171
  }
196
172
  }
173
+ .frame(minHeight: max(modal.sheet.minHeight - effectiveBottomInset, 0), alignment: .top)
197
174
  // The filler stays outside the cap, which shrinks by it instead: the sheet still ends at
198
175
  // `maxHeight`, and the iOS 15 fallback never measures the keyboard as content.
199
176
  .modifier(CapHeight(maxHeight: maxHeight - effectiveBottomInset))
@@ -201,7 +178,8 @@ struct BottomSheetView<Content: View>: View {
201
178
  (footer != nil ? theme.colors.background.surface : backgroundColor)
202
179
  .frame(height: effectiveBottomInset)
203
180
  }
204
- .frame(maxWidth: isDuoCentered ? duoCenteredWidth : .infinity)
181
+ .frame(width: modal.sheet.width)
182
+ .frame(maxWidth: modal.sheet.width == nil ? .infinity : nil)
205
183
  .clipped()
206
184
  .background(
207
185
  GeometryReader { geo in
@@ -209,44 +187,45 @@ struct BottomSheetView<Content: View>: View {
209
187
  }
210
188
  )
211
189
  .background(backgroundColor)
212
- .clipShape(RoundedCorner(radius: Radius.M, corners: [.topLeft, .topRight]))
190
+ .clipShape(RoundedCorner(radius: modal.sheet.radius, corners: [.topLeft, .topRight]))
191
+ // centered in the placement: off the iPhone Duo control column, the right half when half folded
192
+ .padding(.leading, isFoldable ? modal.placement.minX : 0)
193
+ .padding(.trailing, isFoldable ? layout.width - modal.placement.maxX : 0)
213
194
  }
214
195
 
215
196
  @ViewBuilder
216
197
  private var headerView: some View {
217
198
  switch header.style {
218
- case .title(let text):
219
- HStack(spacing: 0) {
220
- Color.clear.frame(width: 24, height: 24)
199
+ case .title(let text, let back):
200
+ HStack(spacing: Spacing.S) {
201
+ if let back {
202
+ ModalIconButton(icon: back.icon, accessibilityId: "btn_bottom_sheet_back") { goBack(back) }
203
+ } else {
204
+ Color.clear.frame(width: ModalMetrics.iconButtonSize, height: ModalMetrics.iconButtonSize)
205
+ }
221
206
  MomoText(text, typography: .headerDefaultBold, color: Colors.black17)
222
207
  .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() }
208
+ ModalIconButton(icon: "navigation_close", accessibilityId: "btn_bottom_sheet_close") { close() }
227
209
  }
228
210
  case .custom(let builder):
229
211
  builder()
230
212
  }
231
213
  }
232
214
 
215
+ /// RN `leftOptions.onPressIconLeft`: the sheet closes first, then the back runs.
216
+ private func goBack(_ back: BottomSheetHeader.Back) {
217
+ close(then: back.action)
218
+ }
219
+
233
220
  // MARK: - Drag handling (mirrors Compose's detectDragGestures)
234
221
 
235
222
  private var dragGesture: some Gesture {
236
- // `.global` (not the default `.local`) so the gesture tracks against the
237
- // window rather than the handle's own view, which is itself repositioned
238
- // every frame by this same gesture's output (`sheet.offset(y: effectiveOffset)`
239
- // in `body`) — the local coordinate space chasing its own moving reference
240
- // frame is a plausible source of a continuous drag-time jitter.
223
+ // `.global`: the handle moves with this gesture's own output, so the local space would
224
+ // chase a moving reference frame and jitter.
241
225
  DragGesture(coordinateSpace: .global)
242
226
  .onChanged { _ in
243
- // Touching the handle should immediately settle `sheetOffset` to its
244
- // resting value (0) with no animation, so a drag that starts while the
245
- // open animation — or the keyboard-driven resize, which shifts this
246
- // same bottom-anchored top edge — is still in flight doesn't fight a
247
- // moving target. Without this, the live drag value chases an animated
248
- // one, producing a couple of corrective jumps before it settles.
249
- // A closing sheet keeps going down.
227
+ // Settle an in-flight open (or keyboard resize) at rest without animation, or the
228
+ // drag chases an animated value and jumps. A closing sheet keeps going down.
250
229
  if sheetOffset != 0 && !isClosing {
251
230
  sheetOffset = 0
252
231
  }
@@ -257,9 +236,8 @@ struct BottomSheetView<Content: View>: View {
257
236
  .onEnded { value in
258
237
  guard !isClosing else { return }
259
238
  let finalOffset = max(value.translation.height, 0)
260
- // Capture into persisted state BEFORE @GestureState resets to 0,
261
- // avoiding a one-frame snap back to rest before close()'s own
262
- // slide-out animation starts (mirrors PopupView's `lastDragPosition`).
239
+ // Persist before @GestureState resets to 0, or the sheet snaps back for a frame
240
+ // before close() slides it out (PopupView's `lastDragPosition`).
263
241
  sheetOffset = finalOffset
264
242
  if finalOffset > closeThreshold {
265
243
  close()
@@ -282,7 +260,7 @@ struct BottomSheetView<Content: View>: View {
282
260
 
283
261
  /// Mirrors Compose's `closeEvent`: slide out over 200ms, then fade the scrim
284
262
  /// out over 100ms only after the slide finishes, then dismiss.
285
- private func close() {
263
+ private func close(then onClosed: (() -> Void)? = nil) {
286
264
  guard !isClosing else { return }
287
265
  isClosing = true
288
266
  withAnimation(.timingCurve(0.3, 0, 0.8, 0.15, duration: 0.2)) {
@@ -294,14 +272,16 @@ struct BottomSheetView<Content: View>: View {
294
272
  }
295
273
  }
296
274
  DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
275
+ // a newer overlay replaced this one: it stays, and this sheet's back is dropped
276
+ guard navigator.overplay?.id == overplayId else { return }
297
277
  navigator.finishOverplayDismiss(id: overplayId)
278
+ onClosed?()
298
279
  }
299
280
  }
300
281
  }
301
282
 
302
- /// Compose's `heightIn(max:)`. `.frame(maxHeight:)` grows to the cap whenever the proposal is
303
- /// larger, leaving a gap above the header; this sizes the sheet to its content and only caps it
304
- /// when taller.
283
+ /// Compose's `heightIn(max:)`: sizes the sheet to its content, capped only when taller. `.frame(maxHeight:)` grows
284
+ /// to the cap whenever the proposal is larger, leaving a gap above the header.
305
285
  private struct CapHeight: ViewModifier {
306
286
  let maxHeight: CGFloat
307
287
 
@@ -314,9 +294,8 @@ private struct CapHeight: ViewModifier {
314
294
  }
315
295
  }
316
296
 
317
- /// iOS 15 has no `Layout`: the sheet hugs its ideal height until that outgrows the cap, then is
318
- /// held at the cap. A capped sheet can't read its ideal height (that needs a second copy of the
319
- /// content), so it is re-measured only when the cap grows, e.g. once the keyboard goes down.
297
+ /// iOS 15 (no `Layout`): hugs the ideal height until it outgrows the cap. A capped sheet can't read its ideal height
298
+ /// without a second copy of the content, so it is re-measured only when the cap grows (e.g. the keyboard hides).
320
299
  private struct CapHeightFallback: ViewModifier {
321
300
  let maxHeight: CGFloat
322
301
  @State private var capped = false
@@ -1,11 +1,5 @@
1
- //
2
- // BottomTab.swift
3
- // MoMoUIKits
4
- //
5
- // SwiftUI mirror of Compose's `navigation/bottomtab/BottomTab.kt`: tabbed screens, each in
6
- // `StackScreen` chrome built from its own `Navigation`, over a `BottomTabBar` (or the iPhone Duo
7
- // rail / floating bar). Switching tabs cross-fades + scales the content.
8
- //
1
+ // SwiftUI mirror of Compose's `navigation/bottomtab/BottomTab.kt`: tabs in `StackScreen` chrome, each with its own
2
+ // `Navigation`, over a `BottomTabBar` (or the iPhone Duo rail / floating bar); a switch cross-fades + scales.
9
3
 
10
4
  import SwiftUI
11
5
  import UIKit
@@ -30,10 +24,8 @@ public struct BottomTab: View {
30
24
  @State private var expandedBar: DuoBar?
31
25
  @State private var openedBar: DuoBar?
32
26
 
33
- /// `compressionBehavior`: on iPhone Duo, when the side bar can't hold both bars, which one
34
- /// starts compressed; tapping the compressed one swaps them.
35
- /// `onTabPress` gets every tab press with the switch to perform, e.g. after a login gate.
36
- /// `backToInitialTab`: back off another tab returns to the initial one before leaving the screen.
27
+ /// `compressionBehavior`: iPhone Duo bar that starts compressed when the side bar can't hold both (a tap swaps).
28
+ /// `onTabPress` gets the switch to run, e.g. after a login gate. `backToInitialTab`: back goes to it first.
37
29
  public init(
38
30
  items: [BottomTabItem],
39
31
  floatingButton: BottomTabFloatingButton? = nil,
@@ -53,10 +45,9 @@ public struct BottomTab: View {
53
45
  }
54
46
 
55
47
  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
- }
48
+ // the bars float over the content (tab screens keep clear of them through duoTabBarInsets) or sit
49
+ // in the side strip, so only the home indicator is kept clear
50
+ private var reservedBottom: CGFloat { layout.insets.bottom }
60
51
 
61
52
  private var compression: DuoBarCompression {
62
53
  DuoBarCompression.resolve(
@@ -87,7 +78,6 @@ public struct BottomTab: View {
87
78
  public var body: some View {
88
79
  let compression = compression
89
80
  ZStack(alignment: .bottom) {
90
- // Tab content area, inset above the bar.
91
81
  TabHost(selectedIndex: selectedIndex, count: items.count) { index in AnyView(tabScreen(for: index)) }
92
82
  // each tab hosts itself, so it needs the window's safe area to draw its header under the status bar
93
83
  .ignoresSafeArea(.container, edges: [.top, .horizontal])
@@ -95,28 +85,26 @@ public struct BottomTab: View {
95
85
  .environment(\.duoTabBarInsets, duoInsets(compression))
96
86
  .environment(\.duoBarCompression, compression)
97
87
 
98
- if layout.isIPhoneDuo {
99
- DuoTabBar(
100
- items: items,
101
- floatingButton: floatingButton,
102
- selectedIndex: selectedIndex,
103
- onTabSelected: selectTab,
104
- compression: compression
105
- )
106
- } else {
107
- // Tab bar + home-indicator filler.
108
- VStack(spacing: 0) {
88
+ Group {
89
+ if layout.isIPhoneDuo {
90
+ DuoTabBar(
91
+ items: items,
92
+ floatingButton: floatingButton,
93
+ selectedIndex: selectedIndex,
94
+ onTabSelected: selectTab,
95
+ compression: compression
96
+ )
97
+ } else {
109
98
  BottomTabBar(
110
99
  items: items,
111
100
  floatingButton: floatingButton,
112
101
  selectedIndex: selectedIndex,
113
- onTabSelected: selectTab
102
+ onTabSelected: selectTab,
103
+ bottomInset: bottomInset
114
104
  )
115
- theme.colors.background.surface
116
- .frame(height: bottomInset + Spacing.S)
117
- .ignoresSafeArea(edges: .horizontal)
118
105
  }
119
106
  }
107
+ .scaleSizeMaxRate(TabBarMetrics.labelMaxScale)
120
108
  }
121
109
  .frame(maxWidth: .infinity, maxHeight: .infinity)
122
110
  .ignoresSafeArea(edges: .bottom)
@@ -137,6 +125,7 @@ public struct BottomTab: View {
137
125
  }
138
126
 
139
127
  private func selectTab(_ index: Int) {
128
+ navigator.maxApi?.triggerEventVibration("light")
140
129
  let switchTab = { if index != selectedIndex { selectedIndex = index } }
141
130
  if let onTabPress { onTabPress(index, switchTab) } else { switchTab() }
142
131
  }
@@ -188,10 +177,8 @@ private struct TabScreenHost: View {
188
177
 
189
178
  // MARK: - Tab host
190
179
 
191
- /// Compose's tab NavHost with `saveState` / `restoreState`. A tab gets its own UIHostingController
192
- /// on first selection and keeps it, so its state and scroll survive a switch; while hidden it is
193
- /// out of the window, so it gets onDisappear / onAppear (and re-runs screen tracking) like a NavHost
194
- /// destination or a UITabBarController tab. Same scheme as `StackController`.
180
+ /// Compose's tab NavHost with `saveState` / `restoreState`: a tab keeps its UIHostingController (state, scroll).
181
+ /// Hidden, it leaves the window and gets onDisappear / onAppear, re-running screen tracking, as in `StackController`.
195
182
  private struct TabHost: UIViewControllerRepresentable {
196
183
  let selectedIndex: Int
197
184
  let count: Int
@@ -208,11 +195,11 @@ private struct TabHost: UIViewControllerRepresentable {
208
195
 
209
196
  private final class TabController: UIViewController {
210
197
  private final class Tab {
211
- let motion = TabMotion()
212
198
  var host: UIHostingController<AnyView>!
213
199
  }
214
200
 
215
- private static let switchDuration: TimeInterval = 0.2
201
+ /// The tab switch: the screens slide in index order over 280ms, CSS `ease`.
202
+ private static let switchDuration: TimeInterval = 0.28
216
203
 
217
204
  private var tabs: [Int: Tab] = [:]
218
205
  private var selectedIndex: Int?
@@ -226,7 +213,7 @@ private final class TabController: UIViewController {
226
213
 
227
214
  override func viewDidLayoutSubviews() {
228
215
  super.viewDidLayoutSubviews()
229
- for subview in view.subviews { subview.frame = view.bounds }
216
+ for subview in view.subviews { place(subview) }
230
217
  }
231
218
 
232
219
  func update(
@@ -243,33 +230,43 @@ private final class TabController: UIViewController {
243
230
  }
244
231
  if let selectedIndex, tabs[selectedIndex] == nil { self.selectedIndex = nil }
245
232
  // hidden tabs too, so a tab coming back already shows the latest items and environment
246
- for (tabIndex, existing) in tabs { existing.host.rootView = rootView(tabIndex, existing) }
233
+ for (tabIndex, existing) in tabs { existing.host.rootView = rootView(tabIndex) }
247
234
  guard (0..<count).contains(index), index != selectedIndex else { return }
248
235
 
249
- let previous = selectedIndex.flatMap { tabs[$0] }
236
+ let previousIndex = selectedIndex
237
+ let previous = previousIndex.flatMap { tabs[$0] }
250
238
  selectedIndex = index
251
239
  let selected = tabs[index] ?? makeTab(index)
240
+ // a tab selected again while it leaves carries on from where it is
241
+ let entering = selected.host.view.superview == nil
252
242
  attach(selected)
253
243
 
254
- guard let previous, view.window != nil else {
255
- selected.motion.visible = true
244
+ guard let previous, let previousIndex, view.window != nil else {
245
+ selected.host.view.transform = .identity
256
246
  previous.map(leave)
257
247
  return
258
248
  }
259
249
  previous.host.view.isUserInteractionEnabled = false
260
- // a frame at the start values first, so a tab created just now fades in too
250
+ let offset = index > previousIndex ? view.bounds.width : -view.bounds.width
251
+ if entering { selected.host.view.transform = CGAffineTransform(translationX: offset, y: 0) }
252
+ // a frame at the start values first, so a tab created just now slides in with its content
261
253
  DispatchQueue.main.async {
262
- selected.motion.visible = true
263
- previous.motion.visible = false
264
- }
265
- DispatchQueue.main.asyncAfter(deadline: .now() + Self.switchDuration) { [weak self] in
266
- self?.leave(previous)
254
+ let animator = UIViewPropertyAnimator(
255
+ duration: Self.switchDuration,
256
+ controlPoint1: CGPoint(x: 0.25, y: 0.1),
257
+ controlPoint2: CGPoint(x: 0.25, y: 1)
258
+ ) {
259
+ selected.host.view.transform = .identity
260
+ previous.host.view.transform = CGAffineTransform(translationX: -offset, y: 0)
261
+ }
262
+ animator.addCompletion { [weak self] _ in self?.leave(previous) }
263
+ animator.startAnimation()
267
264
  }
268
265
  }
269
266
 
270
267
  private func makeTab(_ index: Int) -> Tab {
271
268
  let tab = Tab()
272
- let host = UIHostingController(rootView: rootView(index, tab))
269
+ let host = UIHostingController(rootView: rootView(index))
273
270
  host.view.backgroundColor = .clear
274
271
  addChild(host)
275
272
  host.didMove(toParent: self)
@@ -278,14 +275,20 @@ private final class TabController: UIViewController {
278
275
  return tab
279
276
  }
280
277
 
281
- private func rootView(_ index: Int, _ tab: Tab) -> AnyView {
282
- AnyView(TabCard(motion: tab.motion, content: content(index)).environment(\.self, environment))
278
+ private func rootView(_ index: Int) -> AnyView {
279
+ AnyView(content(index).environment(\.self, environment))
280
+ }
281
+
282
+ /// Bounds and center, not frame: a sliding tab carries a transform.
283
+ private func place(_ subview: UIView) {
284
+ subview.bounds = view.bounds
285
+ subview.center = CGPoint(x: view.bounds.midX, y: view.bounds.midY)
283
286
  }
284
287
 
285
288
  private func attach(_ tab: Tab) {
286
289
  let hostView: UIView = tab.host.view
287
290
  hostView.isUserInteractionEnabled = true
288
- hostView.frame = view.bounds
291
+ place(hostView)
289
292
  if hostView.superview === view {
290
293
  view.bringSubviewToFront(hostView)
291
294
  } else {
@@ -297,6 +300,7 @@ private final class TabController: UIViewController {
297
300
  private func leave(_ tab: Tab) {
298
301
  guard selectedIndex.flatMap({ tabs[$0] }) !== tab else { return }
299
302
  tab.host.view.removeFromSuperview()
303
+ tab.host.view.transform = .identity
300
304
  }
301
305
 
302
306
  private func tearDown(_ tab: Tab) {
@@ -306,27 +310,8 @@ private final class TabController: UIViewController {
306
310
  }
307
311
  }
308
312
 
309
- private final class TabMotion: ObservableObject {
310
- @Published var visible = false
311
- }
312
-
313
- /// The tab switch: 0.97 scale + fade over 200ms, both ways (Compose's tab enter / exit transitions).
314
- private struct TabCard: View {
315
- @ObservedObject var motion: TabMotion
316
- let content: AnyView
317
-
318
- var body: some View {
319
- content
320
- .opacity(motion.visible ? 1 : 0)
321
- .scaleEffect(motion.visible ? 1 : 0.97)
322
- .animation(.easeInOut(duration: 0.2), value: motion.visible)
323
- }
324
- }
325
-
326
- /// Bottom safe-area inset (home indicator).
327
313
  private func safeAreaBottomInset() -> CGFloat {
328
- let bottomInset = UIApplication.shared.connectedScenes
314
+ UIApplication.shared.connectedScenes
329
315
  .compactMap { ($0 as? UIWindowScene)?.keyWindow?.safeAreaInsets.bottom }
330
316
  .first ?? 0
331
- return min(bottomInset, 21)
332
317
  }