@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,11 +1,5 @@
1
- //
2
- // BottomTabBar.swift
3
- // MoMoUIKits
4
- //
5
- // SwiftUI mirror of Compose's `navigation/bottomtab/BottomTabBar.kt`.
6
- // Renders the row of tab items, an animated selection indicator, a top shadow,
7
- // badges/dots, and an optional center floating button (with the curved notch).
8
- //
1
+ // SwiftUI mirror of Compose's `navigation/bottomtab/BottomTabBar.kt` (Figma "Specs Navigation", DS-984): floating
2
+ // container, evenly split items with a tonal active indicator, badges/dots, the Special center action in a notch.
9
3
 
10
4
  import SwiftUI
11
5
 
@@ -49,178 +43,349 @@ public struct BottomTabFloatingButton {
49
43
  public let icon: String
50
44
  public let label: String
51
45
  public let onPress: () -> Void
46
+ /// Replaces the icon inside the 48 button, e.g. the button part of a Lottie; centered, unclipped.
47
+ public let iconContent: AnyView?
48
+ /// Drawn over the label text, which stays, e.g. the label part of a Lottie; centered, unclipped.
49
+ public let labelContent: AnyView?
52
50
 
53
51
  public init(icon: String, label: String, onPress: @escaping () -> Void) {
54
52
  self.icon = icon
55
53
  self.label = label
56
54
  self.onPress = onPress
55
+ self.iconContent = nil
56
+ self.labelContent = nil
57
+ }
58
+
59
+ /// The button and label parts given separately, e.g. a Lottie split into both.
60
+ public init<IconContent: View, LabelContent: View>(
61
+ label: String,
62
+ onPress: @escaping () -> Void,
63
+ @ViewBuilder iconContent: () -> IconContent,
64
+ @ViewBuilder labelContent: () -> LabelContent
65
+ ) {
66
+ self.icon = ""
67
+ self.label = label
68
+ self.onPress = onPress
69
+ self.iconContent = AnyView(iconContent())
70
+ self.labelContent = AnyView(labelContent())
57
71
  }
58
- }
59
72
 
60
- let bottomTabFloatingButtonWidth: CGFloat = 75
61
- let BOTTOM_TAB_BAR_HEIGHT: CGFloat = 64
73
+ }
62
74
 
63
75
  // MARK: - Tab bar
64
76
 
77
+ /// Phone tab bar: the horizontal navigation bar filling the window, above the home indicator.
65
78
  struct BottomTabBar: View {
66
79
  let items: [BottomTabItem]
67
80
  let floatingButton: BottomTabFloatingButton?
68
81
  let selectedIndex: Int
69
82
  let onTabSelected: (Int) -> Void
83
+ let bottomInset: CGFloat
70
84
 
71
85
  @Environment(\.screenLayout) private var layout
72
- @Environment(\.appTheme) private var theme
73
86
 
74
- // the bar sits between the side safe areas
75
- private var screenWidth: CGFloat { layout.width - layout.insets.leading - layout.insets.trailing }
76
- private var mid: Int { items.count / 2 }
87
+ var body: some View {
88
+ HorizontalTabBar(
89
+ items: items,
90
+ floatingButton: floatingButton,
91
+ selectedIndex: selectedIndex,
92
+ onTabSelected: onTabSelected,
93
+ width: TabBarMetrics.horizontalBarWidth(
94
+ layout,
95
+ itemCount: items.count,
96
+ hasCta: TabBarMetrics.hasCenterAction(floatingButton, tabCount: items.count)
97
+ )
98
+ )
99
+ .padding(.bottom, TabBarMetrics.bottomGap(bottomInset))
100
+ .frame(maxWidth: .infinity)
101
+ }
102
+ }
77
103
 
78
- private var tabWidth: CGFloat {
79
- if floatingButton != nil {
80
- return (screenWidth - bottomTabFloatingButtonWidth) / CGFloat(items.count)
81
- }
82
- return screenWidth / CGFloat(items.count)
104
+ /// One active indicator slides behind the selected item; the Special type's center action rises ctaLift above
105
+ /// the container's notch.
106
+ struct HorizontalTabBar: View {
107
+ let items: [BottomTabItem]
108
+ let floatingButton: BottomTabFloatingButton?
109
+ let selectedIndex: Int
110
+ let onTabSelected: (Int) -> Void
111
+ let width: CGFloat
112
+
113
+ private var cta: BottomTabFloatingButton? {
114
+ TabBarMetrics.hasCenterAction(floatingButton, tabCount: items.count) ? floatingButton : nil
83
115
  }
84
116
 
85
- private var indicatorOffset: CGFloat {
86
- let adjust: CGFloat = (floatingButton != nil && selectedIndex >= mid) ? bottomTabFloatingButtonWidth : 0
87
- return tabWidth * CGFloat(selectedIndex) + tabWidth / 2 - screenWidth / 2 + adjust
117
+ /// Items share what the padding, gaps and center action slot leave.
118
+ private var itemWidth: CGFloat {
119
+ let slots = CGFloat(items.count + (cta == nil ? 0 : 1))
120
+ let content = width - 2 * TabBarMetrics.paddingHorizontal - (slots - 1) * TabBarMetrics.itemGap
121
+ return max((content - (cta == nil ? 0 : TabBarMetrics.ctaSlotWidth)) / CGFloat(max(items.count, 1)), 0)
122
+ }
123
+
124
+ private func itemX(_ index: Int) -> CGFloat {
125
+ let afterCta = cta != nil && index >= items.count / 2
126
+ return TabBarMetrics.paddingHorizontal + CGFloat(index) * (itemWidth + TabBarMetrics.itemGap)
127
+ + (afterCta ? TabBarMetrics.ctaSlotWidth + TabBarMetrics.itemGap : 0)
88
128
  }
89
129
 
90
130
  var body: some View {
91
- ZStack(alignment: .bottom) {
92
- HStack(spacing: 0) {
93
- if floatingButton == nil {
94
- tabItems(from: 0, to: items.count)
95
- } else {
96
- tabItems(from: 0, to: mid)
97
- Spacer()
98
- .frame(width: bottomTabFloatingButtonWidth)
99
- .padding(.horizontal, Spacing.XXS)
100
- tabItems(from: mid, to: items.count)
131
+ let shape = NotchedBarShape(radius: TabBarMetrics.height / 2, notchCenterX: cta == nil ? nil : width / 2)
132
+ ZStack(alignment: .top) {
133
+ ZStack(alignment: .topLeading) {
134
+ ActiveIndicator(radius: TabBarMetrics.indicatorRadius)
135
+ .frame(width: itemWidth, height: TabBarMetrics.indicatorHeight)
136
+ .offset(x: itemX(selectedIndex), y: TabBarMetrics.paddingVertical)
137
+ .animation(TabBarMetrics.indicatorMotion, value: selectedIndex)
138
+
139
+ HStack(spacing: TabBarMetrics.itemGap) {
140
+ ForEach(items.indices, id: \.self) { index in
141
+ if cta != nil && index == items.count / 2 {
142
+ Color.clear.frame(width: TabBarMetrics.ctaSlotWidth)
143
+ }
144
+ SwiftUI.Button { onTabSelected(index) } label: {
145
+ VStack(spacing: TabBarMetrics.itemIconLabelGap) {
146
+ TabItemContent(item: items[index], selected: index == selectedIndex)
147
+ }
148
+ .frame(width: itemWidth)
149
+ .contentShape(Rectangle())
150
+ }
151
+ .buttonStyle(.plain)
152
+ .accessibilityLabel(items[index].label)
153
+ .accessibilityAddTraits(index == selectedIndex ? .isSelected : [])
154
+ }
101
155
  }
156
+ .padding(.horizontal, TabBarMetrics.paddingHorizontal)
157
+ .padding(.vertical, TabBarMetrics.paddingVertical)
102
158
  }
103
- .frame(maxWidth: .infinity)
104
- .frame(height: BOTTOM_TAB_BAR_HEIGHT)
105
- .background(theme.colors.background.surface.ignoresSafeArea(edges: .horizontal))
106
-
107
- // Animated selection indicator.
108
- RoundedRectangle(cornerRadius: 2)
109
- .fill(theme.colors.primary)
110
- .frame(width: 44, height: 2)
111
- .offset(x: indicatorOffset, y: -BOTTOM_TAB_BAR_HEIGHT + 2)
112
- .animation(.easeInOut(duration: 0.25), value: selectedIndex)
113
-
114
- // Top shadow.
115
- LinearGradient(
116
- colors: [Color.black.opacity(0.05), .clear],
117
- startPoint: .bottom,
118
- endPoint: .top
119
- )
120
- .frame(height: 6)
121
- .frame(maxWidth: .infinity)
122
- .offset(y: -BOTTOM_TAB_BAR_HEIGHT)
159
+ .frame(width: width, height: TabBarMetrics.height, alignment: .topLeading)
160
+ .modifier(TabBarContainer(shape: shape))
161
+ .accessibilityElement(children: .contain)
162
+ .accessibilityIdentifier("bottom_tab_bar")
163
+ .padding(.top, cta == nil ? 0 : TabBarMetrics.ctaLift)
123
164
 
124
- if let floatingButton {
125
- CenterFloatingButton(data: floatingButton)
165
+ if let cta {
166
+ CenterAction(data: cta)
167
+ .offset(y: centerActionTop)
126
168
  }
127
169
  }
170
+ .frame(width: width)
128
171
  }
129
172
 
130
- @ViewBuilder
131
- private func tabItems(from: Int, to: Int) -> some View {
132
- ForEach(from..<to, id: \.self) { index in
133
- TabBarItem(
134
- item: items[index],
135
- selected: index == selectedIndex,
136
- onClick: { onTabSelected(index) }
173
+ /// Offset of the center action column from the bar top: the items sit at the top of the container
174
+ /// (which starts ctaLift down), so the column is placed for its label to start on the tab labels' line.
175
+ private var centerActionTop: CGFloat {
176
+ let itemLabelTop = TabBarMetrics.ctaLift + TabBarMetrics.paddingVertical
177
+ + TabBarMetrics.indicatorHeight + TabBarMetrics.itemIconLabelGap
178
+ return itemLabelTop - TabBarMetrics.ctaLabelGap - TabBarMetrics.ctaSize
179
+ }
180
+ }
181
+
182
+ /// One active indicator per bar: Background/tonal with its inner light (white 12% from below) and
183
+ /// tint (primary 12% from above).
184
+ struct ActiveIndicator: View {
185
+ let radius: CGFloat
186
+
187
+ @Environment(\.appTheme) private var theme
188
+
189
+ var body: some View {
190
+ let shape = RoundedRectangle(cornerRadius: radius)
191
+ shape
192
+ .fill(theme.colors.background.tonal)
193
+ // inner shadows: primary 12% falling 1 from the top edge, white 12% rising 2 from the bottom one
194
+ .overlay(
195
+ LinearGradient(
196
+ stops: [
197
+ .init(color: theme.colors.primary.opacity(0.12), location: 0),
198
+ .init(color: theme.colors.primary.opacity(0), location: 0.1),
199
+ .init(color: Color.white.opacity(0), location: 0.85),
200
+ .init(color: Color.white.opacity(0.12), location: 1),
201
+ ],
202
+ startPoint: .top,
203
+ endPoint: .bottom
204
+ )
205
+ .clipShape(shape)
137
206
  )
138
- .frame(maxWidth: .infinity)
139
- }
207
+ .allowsHitTesting(false)
140
208
  }
141
209
  }
142
210
 
143
211
  // MARK: - Tab item
144
212
 
145
- private struct TabBarItem: View {
213
+ /// Icon in its indicator slot, label under it. The bar slides one shared active indicator behind the
214
+ /// slots; the icon and label tint cross-fade on focus.
215
+ struct TabItemContent: View {
146
216
  let item: BottomTabItem
147
217
  let selected: Bool
148
- let onClick: () -> Void
218
+ var vertical = false
219
+ var showLabel = true
149
220
 
150
221
  @Environment(\.appTheme) private var theme
151
222
 
152
- private var tintColor: Color { selected ? theme.colors.primary : theme.colors.text.hint }
223
+ var body: some View {
224
+ TabIcon(item: item, selected: selected, vertical: vertical)
225
+ .frame(height: vertical ? TabBarMetrics.railIndicatorHeight : TabBarMetrics.indicatorHeight)
226
+ if showLabel {
227
+ ZStack {
228
+ labelText(theme.colors.text.secondary).opacity(selected ? 0 : 1)
229
+ labelText(theme.colors.primary).opacity(selected ? 1 : 0)
230
+ }
231
+ .animation(TabBarMetrics.tintMotion, value: selected)
232
+ .frame(maxWidth: vertical ? nil : .infinity)
233
+ // fixed slot so a capped-scale label overflows downward and the icon above it stays put
234
+ .frame(
235
+ height: vertical ? TabBarMetrics.railLabelHeight : TabBarMetrics.labelHeight,
236
+ alignment: .top
237
+ )
238
+ }
239
+ }
153
240
 
154
- /// Mirrors Compose's `formatLabel`: hide a badge that is the number "0".
155
- private var badgeLabel: String? {
156
- guard let label = item.badgeLabel else { return nil }
157
- if let n = Int(label), n == 0 { return nil }
158
- return label
241
+ private func labelText(_ color: Color) -> some View {
242
+ MomoText(
243
+ item.label,
244
+ typography: vertical ? .labelXsMedium : .labelSMedium,
245
+ color: color,
246
+ textAlign: .center,
247
+ maxLines: 1
248
+ )
249
+ .truncationMode(.tail)
159
250
  }
251
+ }
160
252
 
161
- var body: some View {
162
- ZStack(alignment: .topTrailing) {
163
- VStack(spacing: 0) {
164
- Icon(source: item.icon, size: 28, color: tintColor)
165
- .padding(Spacing.XS)
166
- MomoText(
167
- item.label,
168
- typography: selected ? .labelXsMedium : .descriptionXsRegular,
169
- color: tintColor,
170
- textAlign: .center,
171
- maxLines: 1
172
- )
173
- .truncationMode(.tail)
174
- }
175
- .frame(maxWidth: .infinity, maxHeight: .infinity)
176
- .padding(.horizontal, Spacing.S)
177
- .padding(.vertical, Spacing.S)
253
+ /// Badge value shown on a tab: nil hides it, "" is a dot, numbers cap at 99+ ("0" hides it, RN parity).
254
+ func tabBadgeLabel(_ item: BottomTabItem) -> String? {
255
+ guard let label = item.badgeLabel else { return item.showDot ? "" : nil }
256
+ if label.isEmpty { return "" }
257
+ if label.allSatisfy({ ("0"..."9").contains($0) }) {
258
+ let value = Int(label) ?? Int.max
259
+ if value == 0 { return item.showDot ? "" : nil }
260
+ return value > 99 ? "99+" : label
261
+ }
262
+ return label
263
+ }
264
+
265
+ /// 24 icon, active and inactive tints cross-faded; badges hang off it: dot at 16/-2, label badge at
266
+ /// 12/-7 growing right, or centered over the icon at -10 on the rail.
267
+ struct TabIcon: View {
268
+ let item: BottomTabItem
269
+ let selected: Bool
270
+ var vertical = false
271
+
272
+ @Environment(\.appTheme) private var theme
178
273
 
179
- if let badgeLabel {
180
- if badgeLabel.isEmpty {
274
+ var body: some View {
275
+ ZStack {
276
+ Icon(source: item.icon, size: TabBarMetrics.iconSize, color: theme.colors.text.secondary)
277
+ .opacity(selected ? 0 : 1)
278
+ Icon(source: item.icon, size: TabBarMetrics.iconSize, color: theme.colors.primary)
279
+ .opacity(selected ? 1 : 0)
280
+ }
281
+ .animation(TabBarMetrics.tintMotion, value: selected)
282
+ .frame(width: TabBarMetrics.iconSize, height: TabBarMetrics.iconSize)
283
+ .overlay(alignment: vertical ? .top : .topLeading) {
284
+ if let badge = tabBadgeLabel(item) {
285
+ if badge.isEmpty {
181
286
  BadgeDot(size: .small)
182
- .offset(x: -Spacing.S, y: Spacing.XS)
287
+ .offset(x: vertical ? 16 - (TabBarMetrics.iconSize - 10) / 2 : 16, y: -Spacing.XXS)
183
288
  } else {
184
- Badge(label: badgeLabel)
185
- .offset(x: -Spacing.XS, y: 0)
289
+ TabBadge(label: badge)
290
+ .fixedSize()
291
+ .frame(width: TabBarMetrics.badgeMaxWidth, alignment: vertical ? .center : .leading)
292
+ .offset(x: vertical ? 0 : Spacing.M, y: vertical ? -10 : -7)
186
293
  }
187
- } else if item.showDot {
188
- BadgeDot(size: .small)
189
- .offset(x: -Spacing.S, y: Spacing.XS)
190
294
  }
191
295
  }
192
- .frame(maxWidth: .infinity, maxHeight: .infinity)
193
- .padding(.horizontal, Spacing.XXS)
194
- .contentShape(Rectangle())
195
- .onTapGesture { onClick() }
196
296
  }
197
297
  }
198
298
 
199
- // MARK: - Center floating button
200
-
201
- private struct CenterFloatingButton: View {
202
- let data: BottomTabFloatingButton
299
+ /// Numbers use the error color, text the warning color (Figma Badge round numeric / text); the text
300
+ /// keeps its design size so it fits the 16 height on the Duo displays too.
301
+ private struct TabBadge: View {
302
+ let label: String
203
303
 
204
304
  @Environment(\.appTheme) private var theme
205
305
 
306
+ private var isNumber: Bool {
307
+ let digits = label.hasSuffix("+") ? String(label.dropLast()) : label
308
+ return !digits.isEmpty && digits.allSatisfy { ("0"..."9").contains($0) }
309
+ }
310
+
206
311
  var body: some View {
207
- VStack(spacing: 0) {
208
- CurvedContainer()
209
- Circle()
210
- .fill(theme.colors.primary)
211
- .frame(width: 48, height: 48)
212
- .overlay(Icon(source: data.icon, size: 28, color: .white))
213
- Spacer().frame(height: 4)
214
- MomoText(data.label, typography: .labelXsMedium, color: Colors.black01, textAlign: .center, maxLines: 1)
215
- .frame(maxWidth: .infinity)
216
- .frame(height: 14)
217
- .background(theme.colors.primary)
218
- .clipShape(RoundedRectangle(cornerRadius: Radius.XL))
312
+ MomoText(label, typography: .actionXxsBold, color: Colors.black01, maxLines: 1)
313
+ .truncationMode(.tail)
314
+ .scaleSizeMaxRate(1)
315
+ .padding(.horizontal, Spacing.XS)
316
+ .frame(minWidth: 16, maxWidth: TabBarMetrics.badgeMaxWidth, minHeight: 16, maxHeight: 16)
317
+ .background(Capsule().fill(isNumber ? theme.colors.error.primary : theme.colors.warning.primary))
318
+ .overlay(Capsule().strokeBorder(theme.colors.background.surface, lineWidth: 1))
319
+ }
320
+ }
321
+
322
+ // MARK: - Center action
323
+
324
+ /// Center action press: the button shrinks while held; the label stays plain text.
325
+ struct CenterActionStyle: ButtonStyle {
326
+ let size: CGFloat
327
+ let vertical: Bool
328
+ let icon: String
329
+ var iconContent: AnyView? = nil
330
+ var labelContent: AnyView? = nil
331
+ let label: String
332
+
333
+ @Environment(\.appTheme) private var theme
334
+
335
+ func makeBody(configuration: Configuration) -> some View {
336
+ let pressed = configuration.isPressed
337
+ VStack(spacing: vertical ? TabBarMetrics.railCtaLabelGap : TabBarMetrics.ctaLabelGap) {
338
+ ZStack {
339
+ // Figma Effect/Popover, one layer per shadow, spread as a shrunk circle:
340
+ // 8% y8 blur 24 spread -12, 4% y12 blur 32 spread -16
341
+ Circle().inset(by: 12).fill(theme.colors.primary)
342
+ .shadow(color: Color.black.opacity(0.08), radius: 12, x: 0, y: 8)
343
+ Circle().inset(by: 16).fill(theme.colors.primary)
344
+ .shadow(color: Color.black.opacity(0.04), radius: 16, x: 0, y: 12)
345
+ Circle().fill(theme.colors.primary)
346
+ // Figma Icon Button border: white 60% hairline
347
+ .overlay(Circle().stroke(Color.white.opacity(TabBarMetrics.ctaBorderOpacity), lineWidth: 1))
348
+ if let iconContent {
349
+ // custom content (e.g. an oversized Lottie) is clipped to the round button
350
+ iconContent
351
+ .frame(width: size, height: size)
352
+ .clipShape(Circle())
353
+ } else {
354
+ Icon(source: icon, size: TabBarMetrics.ctaIconSize, color: Colors.black01)
355
+ }
356
+ }
357
+ .frame(width: size, height: size)
358
+ .scaleEffect(pressed ? TabBarMetrics.ctaPressedScale : 1)
359
+ .animation(TabBarMetrics.ctaPressMotion, value: pressed)
360
+ MomoText(
361
+ label,
362
+ typography: vertical ? .labelXsMedium : .labelSMedium,
363
+ color: theme.colors.text.secondary,
364
+ textAlign: .center,
365
+ maxLines: 1
366
+ )
367
+ .truncationMode(.tail)
368
+ .padding(.horizontal, vertical ? Spacing.XS : Spacing.XXS)
369
+ .frame(minHeight: vertical ? nil : TabBarMetrics.ctaLabelHeight)
370
+ .overlay(labelContent?.allowsHitTesting(false))
219
371
  }
220
- .frame(width: bottomTabFloatingButtonWidth)
221
- .padding(.horizontal, Spacing.XXS)
222
- .padding(.vertical, Spacing.S)
372
+ // the whole slot is the hit area, not just the button and label
373
+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
223
374
  .contentShape(Rectangle())
224
- .onTapGesture { data.onPress() }
375
+ }
376
+ }
377
+
378
+ /// Center action (.Nav/CTA): button rising out of the notch, label under it.
379
+ private struct CenterAction: View {
380
+ let data: BottomTabFloatingButton
381
+
382
+ var body: some View {
383
+ SwiftUI.Button(action: data.onPress) { EmptyView() }
384
+ .buttonStyle(CenterActionStyle(size: TabBarMetrics.ctaSize, vertical: false, icon: data.icon,
385
+ iconContent: data.iconContent, labelContent: data.labelContent,
386
+ label: data.label))
387
+ .frame(width: TabBarMetrics.ctaSlotWidth, height: TabBarMetrics.ctaSize + TabBarMetrics.ctaLabelGap + TabBarMetrics.ctaLabelHeight)
388
+ .accessibilityLabel(data.label)
389
+ .accessibilityIdentifier(data.label)
225
390
  }
226
391
  }
@@ -1,65 +1,63 @@
1
- //
2
- // CurvedContainer.swift
3
- // MoMoUIKits
4
- //
5
- // SwiftUI mirror of Compose's `CurvedContainer` (navigation/bottomtab/CurvedContainer.kt).
6
- // Draws the surface-colored notch that sits behind the center floating button,
7
- // carving a circular cut-out into the tab bar's top edge.
8
- //
1
+ // SwiftUI mirror of Compose's `CurvedContainer.kt`: the navigation bar container shape, a rounded
2
+ // rectangle with a notch cut into the top edge around the center action, and its floating shadow.
9
3
 
10
4
  import SwiftUI
11
5
 
12
- struct CurvedContainer: View {
13
- var circleSize: CGFloat = 48
14
- var tabBarItemIconSize: CGFloat = 28
15
- var circleOverSize: CGFloat = 2
16
- var width: CGFloat = 71
17
- var height: CGFloat = 16
18
- var color: Color = Colors.black01
6
+ /// Rounded container, with the notch dipped into the top edge around `notchCenterX` (from the
7
+ /// leading edge).
8
+ struct NotchedBarShape: Shape {
9
+ var radius: CGFloat
10
+ var notchCenterX: CGFloat?
19
11
 
20
- var body: some View {
21
- let circlePositionTop = circleSize - tabBarItemIconSize - 10
22
- let circleOverTop = circlePositionTop + circleOverSize
23
- let circleR = circleSize / 2
24
- let circleOverR = circleR + circleOverSize
25
- let centerX = width / 2
12
+ func path(in rect: CGRect) -> Path {
13
+ let r = min(radius, rect.height / 2, rect.width / 2)
14
+ guard let cx = notchCenterX else {
15
+ return Path(roundedRect: rect, cornerRadius: r)
16
+ }
17
+ let w = rect.width
18
+ let h = rect.height
26
19
 
27
- CurvedShape(circleOverTop: circleOverTop, centerX: centerX, circleOverR: circleOverR, width: width)
28
- .fill(color)
29
- .frame(width: width, height: height)
30
- .offset(y: 24)
31
- .zIndex(-1)
20
+ var path = Path()
21
+ path.move(to: CGPoint(x: r, y: 0))
22
+ path.addLine(to: CGPoint(x: cx - TabBarMetrics.notchHalfWidth, y: 0))
23
+ for curve in TabBarMetrics.notchCurves {
24
+ path.addCurve(
25
+ to: CGPoint(x: cx + curve[2].x, y: curve[2].y),
26
+ control1: CGPoint(x: cx + curve[0].x, y: curve[0].y),
27
+ control2: CGPoint(x: cx + curve[1].x, y: curve[1].y)
28
+ )
29
+ }
30
+ path.addLine(to: CGPoint(x: w - r, y: 0))
31
+ path.addRelativeArc(center: CGPoint(x: w - r, y: r), radius: r, startAngle: .degrees(-90), delta: .degrees(90))
32
+ path.addLine(to: CGPoint(x: w, y: h - r))
33
+ path.addRelativeArc(center: CGPoint(x: w - r, y: h - r), radius: r, startAngle: .degrees(0), delta: .degrees(90))
34
+ path.addLine(to: CGPoint(x: r, y: h))
35
+ path.addRelativeArc(center: CGPoint(x: r, y: h - r), radius: r, startAngle: .degrees(90), delta: .degrees(90))
36
+ path.addLine(to: CGPoint(x: 0, y: r))
37
+ path.addRelativeArc(center: CGPoint(x: r, y: r), radius: r, startAngle: .degrees(180), delta: .degrees(90))
38
+ path.closeSubpath()
39
+ return path.offsetBy(dx: rect.minX, dy: rect.minY)
32
40
  }
33
41
  }
34
42
 
35
- /// Mirrors Compose's `getPath`: a flat bar with a smooth circular dip in the
36
- /// middle, sized to cradle the floating button.
37
- private struct CurvedShape: Shape {
38
- let circleOverTop: CGFloat
39
- let centerX: CGFloat
40
- let circleOverR: CGFloat
41
- let width: CGFloat
42
-
43
- func path(in rect: CGRect) -> Path {
44
- var path = Path()
45
- path.move(to: CGPoint(x: 0, y: circleOverTop))
46
- path.addLine(to: CGPoint(x: centerX - circleOverR - 40, y: circleOverTop))
47
-
48
- path.addCurve(
49
- to: CGPoint(x: centerX, y: 0),
50
- control1: CGPoint(x: centerX - circleOverR, y: circleOverTop),
51
- control2: CGPoint(x: centerX - circleOverR, y: 0)
52
- )
53
- path.addCurve(
54
- to: CGPoint(x: centerX + circleOverR + 40, y: circleOverTop),
55
- control1: CGPoint(x: centerX + circleOverR, y: 0),
56
- control2: CGPoint(x: centerX + circleOverR, y: circleOverTop)
43
+ /// Translucent fill (Figma .Nav/Background) with the shadow following the shape. Shadows go over the fill, as opaque
44
+ /// layers under it would make the glass solid (compositingGroup keeps the first from being re-cast).
45
+ struct TabBarContainer<S: Shape>: ViewModifier {
46
+ let shape: S
47
+
48
+ @Environment(\.appTheme) private var theme
49
+
50
+ func body(content: Content) -> some View {
51
+ content.background(
52
+ shape
53
+ .fill(theme.colors.background.surface.opacity(TabBarMetrics.backgroundOpacity))
54
+ // Figma .Nav/Background: 1px light-gray hairline defining the pill edge
55
+ .overlay(shape.stroke(theme.colors.border.default, lineWidth: 1))
56
+ .compositingGroup()
57
+ // Figma Shadow/floating: 12% blur 24, then 4% blur 32 spread -16 offset y12
58
+ .shadow(color: Color.black.opacity(0.12), radius: 12)
59
+ .shadow(color: Color.black.opacity(0.04), radius: 16, x: 0, y: 12)
60
+ .allowsHitTesting(false)
57
61
  )
58
-
59
- path.addLine(to: CGPoint(x: width, y: circleOverTop))
60
- path.addLine(to: CGPoint(x: width, y: 60))
61
- path.addLine(to: CGPoint(x: 0, y: 60))
62
- path.closeSubpath()
63
- return path
64
62
  }
65
63
  }
@@ -1,14 +1,9 @@
1
- //
2
- // DuoBarCompression.swift
3
- // MoMoUIKits
4
- //
5
- // Port of RN `BottomTab/DuoBarCompression.tsx` (HIG, Designing for iPhone Duo: Vertical controls):
6
- // keeps the side bar's toolbar and tab bar clear of each other.
7
- //
1
+ // Port of RN `BottomTab/DuoBarCompression.tsx` (HIG, Designing for iPhone Duo: Vertical controls):
2
+ // keeps the side bar's toolbar and tab bar clear of each other.
8
3
 
9
4
  import SwiftUI
10
5
 
11
- /// iPhone Duo: which side bar bar starts compressed when the strip cannot hold both whole.
6
+ /// iPhone Duo: which of the side bar's bars starts compressed when the strip cannot hold both whole.
12
7
  public enum DuoBarCompressionBehavior {
13
8
  case toolbar, tabBar
14
9
  }
@@ -36,10 +31,8 @@ struct DuoBarCompression {
36
31
  /// Back, then the single button the toolbar folds into.
37
32
  private static let compressedToolbarHeight = 2 * DuoMetrics.controlSize + Spacing.M
38
33
 
39
- /// - both fit: both stay whole
40
- /// - one fits whole beside the other compressed: one is compressed, tapping it swaps them
41
- /// - otherwise both rest compressed; tapping one opens it for a moment (the rail closes
42
- /// again once a tab is picked)
34
+ /// Both fit: both whole. One fits beside the other compressed: it is compressed and a tap swaps them. Otherwise
35
+ /// both rest compressed and a tap opens one for a moment (the rail closes again once a tab is picked).
43
36
  static func resolve(
44
37
  layout: ScreenLayout,
45
38
  tabCount: Int,