@momo-kits/native-kits 0.300.7-debug → 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 (202) hide show
  1. package/CLAUDE.md +12 -8
  2. package/README.md +8 -7
  3. package/compose/build.gradle.kts +2 -4
  4. package/compose/build.gradle.kts.backup +1 -3
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +1 -2
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +1 -1
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +60 -0
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +32 -0
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +20 -24
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +5 -6
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +7 -17
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +18 -18
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +2 -2
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -18
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +13 -73
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +1 -8
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -53
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +3 -8
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -3
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +12 -15
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +17 -12
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +20 -5
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -5
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +1 -2
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -2
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +1 -2
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +83 -82
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +6 -10
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +9 -9
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -2
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +13 -35
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +5 -22
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -2
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -3
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +6 -24
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -5
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -7
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +3 -6
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +1 -1
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +22 -50
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -7
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -7
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +18 -9
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +123 -64
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +24 -8
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +11 -9
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -19
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +59 -41
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +69 -51
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +5 -10
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +43 -32
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +330 -149
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +87 -70
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +1 -5
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +92 -261
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -2
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +31 -40
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +3 -1
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +46 -72
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +8 -12
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +29 -24
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +8 -11
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +9 -9
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +26 -3
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +4 -3
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +2 -3
  84. package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +44 -0
  85. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +2 -7
  86. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +9 -18
  87. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +1 -1
  88. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +3 -6
  89. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +5 -6
  90. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -12
  91. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  92. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +11 -6
  93. package/gradle/libs.versions.toml +1 -3
  94. package/gradle.properties +1 -3
  95. package/ios/Application/ApplicationEnvironment.swift +6 -4
  96. package/ios/Application/DesignSystemKits.swift +59 -13
  97. package/ios/Application/DesignSystemKitsPayload.swift +0 -8
  98. package/ios/Application/LanguageSource.swift +2 -11
  99. package/ios/Application/Localize.swift +8 -35
  100. package/ios/Application/LocalizeModifier.swift +2 -11
  101. package/ios/Application/MaxApi.swift +3 -11
  102. package/ios/Avatar/Avatar.swift +0 -1
  103. package/ios/Badge/Badge.swift +5 -8
  104. package/ios/Badge/BadgeRibbon.swift +2 -5
  105. package/ios/Button/Button.swift +4 -8
  106. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
  107. package/ios/Carousel/Carousel.swift +4 -17
  108. package/ios/Checkbox/Checkbox.swift +0 -2
  109. package/ios/Collapse/Collapse.swift +17 -11
  110. package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
  111. package/ios/DateTimePicker/DateTimePicker.swift +4 -10
  112. package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
  113. package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
  114. package/ios/DateTimePicker/WheelPicker.swift +2 -4
  115. package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
  116. package/ios/Extensions/Color++.swift +2 -4
  117. package/ios/Extensions/SkeletonUICompat.swift +0 -8
  118. package/ios/Icon/Icon.swift +3 -6
  119. package/ios/IconButton/IconButton.swift +2 -5
  120. package/ios/Input/ErrorView.swift +0 -7
  121. package/ios/Input/Input.swift +9 -20
  122. package/ios/Input/InputPhoneNumber.swift +37 -20
  123. package/ios/Input/InputSearch.swift +23 -12
  124. package/ios/Input/InputTextArea.swift +4 -13
  125. package/ios/InputDropDown/InputDropDown.swift +1 -11
  126. package/ios/InputMoney/InputMoney.swift +9 -28
  127. package/ios/InputOTP/InputOTP.swift +2 -9
  128. package/ios/Layout/HeaderLayout.swift +72 -0
  129. package/ios/Layout/Item.swift +1 -2
  130. package/ios/Layout/ModalLayout.swift +144 -0
  131. package/ios/Layout/ScreenLayout.swift +48 -31
  132. package/ios/Layout/Section.swift +2 -3
  133. package/ios/Loader/Loader.swift +3 -12
  134. package/ios/Lottie/LottieView.swift +0 -11
  135. package/ios/Navigation/BottomSheet.swift +73 -94
  136. package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
  137. package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
  138. package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
  139. package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
  140. package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
  141. package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
  142. package/ios/Navigation/Component/FloatingButton.swift +4 -11
  143. package/ios/Navigation/Component/Header.swift +35 -54
  144. package/ios/Navigation/Component/HeaderBackground.swift +2 -8
  145. package/ios/Navigation/Component/HeaderJourney.swift +4 -8
  146. package/ios/Navigation/Component/HeaderLocation.swift +4 -8
  147. package/ios/Navigation/Component/HeaderRight.swift +20 -22
  148. package/ios/Navigation/Component/HeaderTitle.swift +1 -6
  149. package/ios/Navigation/Component/HeaderUser.swift +4 -10
  150. package/ios/Navigation/Component/SideBar.swift +6 -21
  151. package/ios/Navigation/Component/SnackBar.swift +9 -13
  152. package/ios/Navigation/HostBackGestureBridge.swift +2 -9
  153. package/ios/Navigation/ModalScreen.swift +24 -13
  154. package/ios/Navigation/Navigation.swift +35 -19
  155. package/ios/Navigation/NavigationContainer.swift +4 -15
  156. package/ios/Navigation/Navigator.swift +21 -39
  157. package/ios/Navigation/StackScreen.swift +64 -51
  158. package/ios/Navigation/StackTransition.swift +7 -14
  159. package/ios/Navigation/SwipeBackHaptic.swift +2 -7
  160. package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
  161. package/ios/Pagination/PaginationDot.swift +0 -9
  162. package/ios/Pagination/PaginationNumber.swift +1 -9
  163. package/ios/Pagination/PaginationScroll.swift +2 -14
  164. package/ios/Pagination/PaginationWhiteDot.swift +1 -10
  165. package/ios/Popup/PopupDisplay.swift +7 -5
  166. package/ios/Popup/PopupInput.swift +6 -4
  167. package/ios/Popup/PopupLayout.swift +17 -9
  168. package/ios/Popup/PopupNotify.swift +32 -25
  169. package/ios/PopupView/FullscreenPopup.swift +3 -4
  170. package/ios/PopupView/PopupView.swift +2 -2
  171. package/ios/PopupView/Utils++.swift +1 -2
  172. package/ios/ProgressInfo/ProgressInfo.swift +2 -13
  173. package/ios/Skeleton/Skeleton.swift +5 -16
  174. package/ios/Slider/Slider.swift +5 -12
  175. package/ios/StatusBarTap/StatusBarTap.h +2 -3
  176. package/ios/StatusBarTap/StatusBarTap.m +3 -16
  177. package/ios/Stepper/Stepper.swift +8 -27
  178. package/ios/Steps/Steps.swift +29 -26
  179. package/ios/Swipeable/SwipeCell.swift +2 -2
  180. package/ios/Swipeable/SwipeCellModel.swift +3 -6
  181. package/ios/TabView/TabView.swift +14 -28
  182. package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
  183. package/ios/Title/Title.swift +1 -3
  184. package/ios/Tooltip/Tooltip.swift +4 -9
  185. package/ios/Typography/FontScale.swift +79 -24
  186. package/ios/Typography/Text.swift +6 -12
  187. package/ios/Typography/Typography.swift +8 -11
  188. package/ios/Uploader/Uploader.swift +2 -17
  189. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  190. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  191. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
  192. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
  193. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
  194. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
  195. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
  196. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
  197. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
  198. package/package.json +1 -1
  199. package/publish.sh +8 -2
  200. package/scripts/ci/build-swiftui.sh +22 -0
  201. package/scripts/ci/resolve-version.mjs +144 -0
  202. package/settings.gradle.kts +0 -1
@@ -1,31 +1,9 @@
1
- //
2
- // DuoTabBar.swift
3
- // MoMoUIKits
4
- //
5
- // iPhone Duo tab bar, port of RN `BottomTab/DuoTabBar.tsx` (Figma Fold-Design-System MT1/MT2):
6
- // a rail in the side bar, or a floating bar when unfolded portrait.
7
- //
1
+ // iPhone Duo tab bar, port of RN `BottomTab/DuoTabBar.tsx` (Figma "Specs Navigation", DS-984):
2
+ // a rail in the side bar, or the horizontal bar at 65% of the short side when unfolded portrait.
8
3
 
9
4
  import SwiftUI
10
5
 
11
- private let itemSize = DuoMetrics.controlSize
12
- private let iconSize: CGFloat = 28
13
- private let qrIconSize: CGFloat = 24
14
- private let railPadding: CGFloat = 6
15
- private let railGap = Spacing.XXS
16
- // selection bubble overflows the 48 rail cell by 5 above and below (Figma MT2)
17
- private let railBubbleWidth: CGFloat = 44
18
- private let railBubbleHeight: CGFloat = 58
19
- private let floatingHeight = DuoMetrics.floatingTabBarHeight
20
- private let floatingPadding = Spacing.XS
21
- // the system bar sizes its pill to the tabs instead of stretching it across the display
22
- private let floatingItemWidth: CGFloat = 80
23
- // while pressed the selection bubble grows into a lens past the pill's edges
24
- private let lensScaleX: CGFloat = 1.2
25
- private let lensScaleY: CGFloat = 1.3
26
- // Figma Home-2026 tab bar "Selection": brand pink at 8%
27
- private let selectionTintOpacity: Double = 0x14 / 255
28
- private let tabSpring = Animation.interpolatingSpring(mass: 0.8, stiffness: 220, damping: 18)
6
+ private let compactSize = DuoMetrics.controlSize
29
7
 
30
8
  /// Room tab screens leave for the Duo tab bar, provided by BottomTab to its tab StackScreens.
31
9
  struct DuoTabBarInsets: Equatable {
@@ -46,45 +24,34 @@ extension EnvironmentValues {
46
24
  }
47
25
  }
48
26
 
49
- /// Rail plus the QR button under it; compressed, the rail is a single button.
27
+ /// Rail container plus the center action under it; compressed, the rail is a single button.
50
28
  func duoRailHeight(itemCount: Int, hasQr: Bool, compressed: Bool = false) -> CGFloat {
51
- let count = CGFloat(itemCount)
52
- let rail = compressed ? itemSize : railPadding * 2 + count * itemSize + max(count - 1, 0) * railGap
53
- return rail + (hasQr ? Spacing.M + itemSize : 0)
29
+ var rail = CGFloat(itemCount) * TabBarMetrics.railItemHeight + TabBarMetrics.railPaddingBottom
30
+ if compressed {
31
+ rail = compactSize
32
+ }
33
+ return rail + (hasQr ? TabBarMetrics.railCtaGap + TabBarMetrics.railCtaHeight : 0)
54
34
  }
55
35
 
56
36
  extension ScreenLayout {
57
- /// Overlaps the home indicator inset like the system tab bar (21pt above the bottom with a 34pt inset).
37
+ /// The horizontal bar sits above the home indicator area.
58
38
  var duoFloatingTabBarBottom: CGFloat {
59
- max(insets.bottom - DuoMetrics.floatingTabBarInsetOverlap, Spacing.S)
39
+ TabBarMetrics.bottomGap(insets.bottom)
60
40
  }
61
41
 
62
42
  func duoTabBarInsets(itemCount: Int, hasFloatingButton: Bool, tabBarCompressed: Bool = false) -> DuoTabBarInsets {
63
- guard isIPhoneDuo else { return DuoTabBarInsets() }
64
- guard let sideBar else {
65
- // overlay is measured from the bottom safe area, the bar reaches into it
66
- return DuoTabBarInsets(overlay: floatingHeight + duoFloatingTabBarBottom - insets.bottom)
43
+ // the horizontal bar floats over the content (phone and unfolded Duo); the overlay is measured
44
+ // from the bottom safe area, the bar reaches into it
45
+ guard isIPhoneDuo, let sideBar else {
46
+ // the center action's button rises above the bar, tab content leaves room for it too
47
+ let ctaLift = hasFloatingButton && itemCount % 2 == 0 ? TabBarMetrics.ctaLift : 0
48
+ return DuoTabBarInsets(overlay: TabBarMetrics.height + ctaLift + duoFloatingTabBarBottom - insets.bottom)
67
49
  }
68
50
  let rail = duoRailHeight(itemCount: itemCount, hasQr: hasFloatingButton, compressed: tabBarCompressed)
69
51
  return DuoTabBarInsets(sideBarReserve: sideBar.bottom + rail + DuoBarCompression.groupGap)
70
52
  }
71
53
  }
72
54
 
73
- /// RN `BarMaterial`: surface with a 1pt border.
74
- struct DuoBarMaterial<S: InsettableShape>: ViewModifier {
75
- let shape: S
76
-
77
- @Environment(\.appTheme) private var theme
78
-
79
- func body(content: Content) -> some View {
80
- content.background(
81
- shape.fill(theme.colors.background.surface)
82
- .overlay(shape.strokeBorder(theme.colors.border.default, lineWidth: 1))
83
- .allowsHitTesting(false)
84
- )
85
- }
86
- }
87
-
88
55
  struct DuoTabBar: View {
89
56
  let items: [BottomTabItem]
90
57
  let floatingButton: BottomTabFloatingButton?
@@ -105,9 +72,8 @@ struct DuoTabBar: View {
105
72
  }
106
73
  }
107
74
 
108
- /// Vertical bar anchored to the bottom of the side bar, QR button below it (Figma MT1-C/E).
109
- /// When the side bar is short it can shrink to one button showing the current tab
110
- /// (HIG "Tab bar compressed"); tapping it expands the rail and compresses the toolbar.
75
+ /// Vertical bar at the bottom of the side bar, center action below. A short side bar shrinks it to one button showing
76
+ /// the current tab (HIG "Tab bar compressed"); a tap expands the rail and compresses the toolbar.
111
77
  private struct DuoRailTabBar: View {
112
78
  let sideBar: SideBarLayout
113
79
  let items: [BottomTabItem]
@@ -116,20 +82,20 @@ private struct DuoRailTabBar: View {
116
82
  let onTabSelected: (Int) -> Void
117
83
  let compression: DuoBarCompression
118
84
 
119
- @State private var pressedIndex: Int?
85
+ @Environment(\.appTheme) private var theme
120
86
 
121
87
  private var isRight: Bool { sideBar.edge == .right }
122
88
 
123
89
  var body: some View {
124
- VStack(spacing: Spacing.M) {
90
+ VStack(spacing: TabBarMetrics.railCtaGap) {
125
91
  if compression.tabBarCompressed, items.indices.contains(selectedIndex) {
126
92
  SwiftUI.Button(action: compression.expandTabBar) {
127
- DuoTabIcon(item: items[selectedIndex], selected: true)
128
- .frame(width: itemSize, height: itemSize)
93
+ TabIcon(item: items[selectedIndex], selected: true, vertical: true)
94
+ .frame(width: compactSize, height: compactSize)
129
95
  .contentShape(Circle())
130
96
  }
131
97
  .buttonStyle(.plain)
132
- .modifier(DuoBarMaterial(shape: Circle()))
98
+ .modifier(TabBarContainer(shape: Circle()))
133
99
  .accessibilityLabel(items[selectedIndex].label)
134
100
  .accessibilityIdentifier("bottom_tab_bar")
135
101
  } else {
@@ -137,9 +103,12 @@ private struct DuoRailTabBar: View {
137
103
  }
138
104
 
139
105
  if let floatingButton {
140
- DuoQrButton(data: floatingButton, size: itemSize)
106
+ RailCenterAction(data: floatingButton)
141
107
  }
142
108
  }
109
+ // the rail lines up with the header buttons in the side bar: centered on a 48 lane kept
110
+ // Spacing.M from the strip's inner edge; the wider rail and center action overflow it evenly
111
+ .frame(width: compactSize)
143
112
  .padding(isRight ? .leading : .trailing, Spacing.M)
144
113
  .frame(width: sideBar.width, alignment: isRight ? .leading : .trailing)
145
114
  .padding(.bottom, sideBar.bottom)
@@ -147,39 +116,42 @@ private struct DuoRailTabBar: View {
147
116
  .ignoresSafeArea()
148
117
  }
149
118
 
150
- /// Column of icon-only tab items with the sliding selection bubble.
119
+ /// Column of rail items (.Nav/Duo/Item) with the sliding active indicator.
151
120
  private var rail: some View {
152
121
  ZStack(alignment: .top) {
153
- DuoSelectionMaterial(lens: pressedIndex != nil)
154
- .frame(width: railBubbleWidth, height: railBubbleHeight)
155
- .offset(y: railPadding - (railBubbleHeight - itemSize) / 2
156
- + CGFloat(pressedIndex ?? selectedIndex) * (itemSize + railGap))
157
- .animation(tabSpring, value: selectedIndex)
158
- .animation(tabSpring, value: pressedIndex)
122
+ ActiveIndicator(radius: TabBarMetrics.railIndicatorRadius)
123
+ .frame(width: TabBarMetrics.railItemWidth, height: TabBarMetrics.railIndicatorHeight)
124
+ .offset(y: Spacing.XS + CGFloat(selectedIndex) * TabBarMetrics.railItemHeight)
125
+ .animation(TabBarMetrics.indicatorMotion, value: selectedIndex)
159
126
 
160
- VStack(spacing: railGap) {
127
+ VStack(spacing: 0) {
161
128
  ForEach(items.indices, id: \.self) { index in
162
129
  SwiftUI.Button {
163
130
  onTabSelected(index)
164
131
  compression.onTabSelected()
165
132
  } label: {
166
- DuoTabIcon(item: items[index], selected: index == selectedIndex)
167
- .frame(width: itemSize, height: itemSize)
168
- .contentShape(Rectangle())
133
+ VStack(spacing: 0) {
134
+ TabItemContent(item: items[index], selected: index == selectedIndex, vertical: true)
135
+ }
136
+ .frame(width: TabBarMetrics.railItemWidth, height: TabBarMetrics.railItemHeight)
137
+ .contentShape(Rectangle())
169
138
  }
170
- .buttonStyle(DuoLensPressStyle(index: index, pressedIndex: $pressedIndex))
139
+ .buttonStyle(.plain)
171
140
  .accessibilityLabel(items[index].label)
141
+ .accessibilityAddTraits(index == selectedIndex ? .isSelected : [])
172
142
  }
173
143
  }
174
- .padding(.vertical, railPadding)
175
144
  }
176
- .frame(width: itemSize)
177
- .modifier(DuoBarMaterial(shape: Capsule()))
145
+ .padding(.horizontal, TabBarMetrics.railPaddingHorizontal)
146
+ .padding(.bottom, TabBarMetrics.railPaddingBottom)
147
+ .frame(width: TabBarMetrics.railContainerWidth)
148
+ .modifier(TabBarContainer(shape: RoundedRectangle(cornerRadius: Radius.XL)))
149
+ .accessibilityElement(children: .contain)
178
150
  .accessibilityIdentifier("bottom_tab_bar")
179
151
  }
180
152
  }
181
153
 
182
- /// Floating labelled bar for the unfolded portrait display, QR pinned in its own platter beside it.
154
+ /// Horizontal navigation bar of the unfolded display: 65% of the short side, centered.
183
155
  private struct DuoFloatingTabBar: View {
184
156
  let items: [BottomTabItem]
185
157
  let floatingButton: BottomTabFloatingButton?
@@ -187,143 +159,36 @@ private struct DuoFloatingTabBar: View {
187
159
  let onTabSelected: (Int) -> Void
188
160
 
189
161
  @Environment(\.screenLayout) private var layout
190
- @Environment(\.appTheme) private var theme
191
- @State private var pressedIndex: Int?
192
-
193
- private var barWidth: CGFloat {
194
- let margins = layout.insets.leading + layout.insets.trailing + 2 * DuoMetrics.floatingTabBarMargin
195
- let qr = floatingButton == nil ? 0 : floatingHeight + Spacing.S
196
- let preferred = CGFloat(items.count) * floatingItemWidth + 2 * floatingPadding
197
- return max(min(preferred, layout.width - margins - qr), 0)
198
- }
199
-
200
- private var cellWidth: CGFloat { (barWidth - floatingPadding * 2) / CGFloat(max(items.count, 1)) }
201
162
 
202
163
  var body: some View {
203
- HStack(spacing: Spacing.S) {
204
- bar
205
- if let floatingButton {
206
- DuoQrButton(data: floatingButton, size: floatingHeight)
207
- .shadow(color: Color.black.opacity(0.16), radius: 16, x: 0, y: 6)
208
- }
209
- }
164
+ HorizontalTabBar(
165
+ items: items,
166
+ floatingButton: floatingButton,
167
+ selectedIndex: selectedIndex,
168
+ onTabSelected: onTabSelected,
169
+ width: TabBarMetrics.horizontalBarWidth(
170
+ layout,
171
+ itemCount: items.count,
172
+ hasCta: TabBarMetrics.hasCenterAction(floatingButton, tabCount: items.count)
173
+ )
174
+ )
210
175
  .padding(.bottom, layout.duoFloatingTabBarBottom)
211
176
  .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
212
177
  .ignoresSafeArea()
213
178
  }
214
-
215
- private var bar: some View {
216
- ZStack(alignment: .leading) {
217
- DuoSelectionMaterial(lens: pressedIndex != nil)
218
- .frame(width: cellWidth)
219
- .offset(x: CGFloat(pressedIndex ?? selectedIndex) * cellWidth)
220
- .animation(tabSpring, value: selectedIndex)
221
- .animation(tabSpring, value: pressedIndex)
222
-
223
- HStack(spacing: 0) {
224
- ForEach(items.indices, id: \.self) { index in
225
- tabCell(index)
226
- }
227
- }
228
- }
229
- .padding(floatingPadding)
230
- .frame(width: barWidth, height: floatingHeight)
231
- .modifier(DuoBarMaterial(shape: Capsule()))
232
- .accessibilityIdentifier("bottom_tab_bar")
233
- }
234
-
235
- private func tabCell(_ index: Int) -> some View {
236
- let selected = index == selectedIndex
237
- return SwiftUI.Button { onTabSelected(index) } label: {
238
- VStack(spacing: Spacing.XXS) {
239
- DuoTabIcon(item: items[index], selected: selected)
240
- MomoText(
241
- items[index].label,
242
- typography: .labelXsMedium,
243
- color: selected ? theme.colors.primary : theme.colors.text.hint,
244
- textAlign: .center,
245
- maxLines: 1
246
- )
247
- // like the system tab bar the label keeps its design size; a constant snapshot, nothing to observe
248
- .environment(\.momoFontScale, FontScale(userScaleRate: 1, useOSScaleRate: false))
249
- }
250
- .frame(width: cellWidth)
251
- .frame(maxHeight: .infinity)
252
- .contentShape(Rectangle())
253
- }
254
- .buttonStyle(DuoLensPressStyle(index: index, pressedIndex: $pressedIndex))
255
- .accessibilityLabel(items[index].label)
256
- }
257
- }
258
-
259
- /// Pink tinted capsule under the selected tab; while pressed it grows into a lens (80x54 to about 96x70).
260
- private struct DuoSelectionMaterial: View {
261
- let lens: Bool
262
-
263
- @Environment(\.appTheme) private var theme
264
-
265
- var body: some View {
266
- Capsule()
267
- .fill(theme.colors.primary.opacity(selectionTintOpacity))
268
- .scaleEffect(x: lens ? lensScaleX : 1, y: lens ? lensScaleY : 1)
269
- .allowsHitTesting(false)
270
- }
271
- }
272
-
273
- /// Tracks the finger so the selection lens jumps to the pressed tab before it is selected.
274
- private struct DuoLensPressStyle: ButtonStyle {
275
- let index: Int
276
- @Binding var pressedIndex: Int?
277
-
278
- func makeBody(configuration: Configuration) -> some View {
279
- configuration.label.onChange(of: configuration.isPressed) { pressed in
280
- if pressed {
281
- pressedIndex = index
282
- } else if pressedIndex == index {
283
- pressedIndex = nil
284
- }
285
- }
286
- }
287
179
  }
288
180
 
289
- private struct DuoTabIcon: View {
290
- let item: BottomTabItem
291
- let selected: Bool
292
-
293
- @Environment(\.appTheme) private var theme
294
-
295
- private var badgeLabel: String? {
296
- guard let label = item.badgeLabel else { return nil }
297
- if let n = Int(label), n == 0 { return nil }
298
- return label
299
- }
300
-
301
- var body: some View {
302
- Icon(source: item.icon, size: iconSize, color: selected ? theme.colors.primary : theme.colors.text.hint)
303
- .overlay(alignment: .topTrailing) {
304
- if let badgeLabel, !badgeLabel.isEmpty {
305
- Badge(label: badgeLabel).offset(x: Spacing.S, y: -Spacing.XS)
306
- } else if badgeLabel != nil || item.showDot {
307
- BadgeDot(size: .small)
308
- }
309
- }
310
- }
311
- }
312
-
313
- private struct DuoQrButton: View {
181
+ /// Center action of the rail: round button with its label, under the container.
182
+ private struct RailCenterAction: View {
314
183
  let data: BottomTabFloatingButton
315
- let size: CGFloat
316
-
317
- @Environment(\.appTheme) private var theme
318
184
 
319
185
  var body: some View {
320
- SwiftUI.Button(action: data.onPress) {
321
- Circle()
322
- .fill(theme.colors.primary)
323
- .frame(width: size, height: size)
324
- .overlay(Icon(source: data.icon, size: qrIconSize, color: Colors.black01))
325
- }
326
- .buttonStyle(.plain)
327
- .accessibilityLabel(data.label)
186
+ SwiftUI.Button(action: data.onPress) { EmptyView() }
187
+ .buttonStyle(CenterActionStyle(size: TabBarMetrics.railCtaSize, vertical: true, icon: data.icon,
188
+ iconContent: data.iconContent, labelContent: data.labelContent,
189
+ label: data.label))
190
+ .frame(width: TabBarMetrics.railCtaWidth, height: TabBarMetrics.railCtaHeight)
191
+ .accessibilityLabel(data.label)
192
+ .accessibilityIdentifier(data.label)
328
193
  }
329
194
  }
@@ -0,0 +1,97 @@
1
+ // Navigation bar measurements (Figma "Specs Navigation", DS-984), mirrored from Compose's `TabBarMetrics.kt` and RN
2
+ // `BottomTab/metrics.ts`. Horizontal: floating, center action in a notch; vertical: iPhone Duo rail, action under it.
3
+
4
+ import SwiftUI
5
+
6
+ enum TabBarMetrics {
7
+ static let height: CGFloat = 60
8
+ static let margin = Spacing.S
9
+ static let paddingVertical = Spacing.XS
10
+ static let paddingHorizontal = Spacing.M
11
+ static let itemGap: CGFloat = 1
12
+ // gap between the icon slot and the label inside a tab (Figma: none)
13
+ static let itemIconLabelGap: CGFloat = 0
14
+ // .Nav/Background: no backdrop blur, so use the Figma Blur=Off spec (opacity 95%, no blur) plus the 1px
15
+ // border below — nearly solid, matching the frosted sample; surface keeps dark-mode support
16
+ static let backgroundOpacity: CGFloat = 0.95
17
+ // white 60% hairline around the center action button (Figma Icon Button border)
18
+ static let ctaBorderOpacity: CGFloat = 0.6
19
+ static let iconSize: CGFloat = 24
20
+ static let indicatorHeight: CGFloat = 32
21
+ // label_s_medium / label_xs_medium line heights: the label slot keeps this height so a scaled
22
+ // label overflows downward instead of pushing the icon up
23
+ static let labelHeight: CGFloat = 18
24
+ static let railLabelHeight: CGFloat = 14
25
+ // font scale cap for the whole bar (RN ScaleSizeProvider around renderTabBar): its text follows the
26
+ // OS/host scale up to 1.2× so the fixed-height container and the notch stay aligned
27
+ static let labelMaxScale: CGFloat = 1.2
28
+ static let indicatorRadius = Radius.XL
29
+ // home indicator / gesture bar area under the container
30
+ static let systemIndicatorHeight: CGFloat = 24
31
+ // unfolded foldables (short side from 600, the smallest in the spec) use 65% of the short side,
32
+ // centered; phones and folded outer displays fill the window
33
+ static let foldableMinShortSide: CGFloat = 600
34
+ static let foldableWidthRatio: CGFloat = 0.65
35
+ // a 2-tab bar doesn't stretch to the full width: each item is this fixed width and the bar is sized
36
+ // to its content, centered (Figma Navigation · 2 Tab: item 100, bar ~225)
37
+ static let twoTabItemWidth: CGFloat = 100
38
+ static let ctaSlotWidth: CGFloat = 92
39
+ static let ctaSize: CGFloat = 48
40
+ // the icon sits 10 inside the 48 button (prototype .cta: 28 icon), 12 inside the 52 rail one
41
+ static let ctaIconSize: CGFloat = 28
42
+ // the button rises 22 above the container top edge
43
+ static let ctaLift: CGFloat = 22
44
+ static let ctaLabelGap = Spacing.M
45
+ static let ctaLabelHeight: CGFloat = 18
46
+ // container-top notch under the center action (Figma "Backgroud" path): from notchHalfWidth left of the center,
47
+ // cubic segments [control1, control2, end], each point (dx from the center, dy below the top edge)
48
+ static let notchHalfWidth: CGFloat = 50.758
49
+ static let notchCurves: [[CGPoint]] = [
50
+ [CGPoint(x: -39.749, y: 0), CGPoint(x: -31.231, y: 9.765), CGPoint(x: -24.563, y: 18.526)],
51
+ [CGPoint(x: -18.928, y: 25.93), CGPoint(x: -10.022, y: 30.709), CGPoint(x: 0, y: 30.709)],
52
+ [CGPoint(x: 10.022, y: 30.709), CGPoint(x: 18.928, y: 25.93), CGPoint(x: 24.563, y: 18.526)],
53
+ [CGPoint(x: 31.231, y: 9.765), CGPoint(x: 39.749, y: 0), CGPoint(x: notchHalfWidth, y: 0)],
54
+ ]
55
+ static let railContainerWidth: CGFloat = 56
56
+ static let railPaddingHorizontal = Spacing.XS
57
+ static let railPaddingBottom = Spacing.S
58
+ static let railItemWidth: CGFloat = 48
59
+ static let railItemHeight: CGFloat = 62
60
+ static let railIndicatorHeight: CGFloat = 40
61
+ static let railIndicatorRadius: CGFloat = 20
62
+ static let railCtaGap = Spacing.L
63
+ static let railCtaSize: CGFloat = 52
64
+ static let railCtaLabelGap = Spacing.XS
65
+ static let railCtaWidth: CGFloat = 68
66
+ static let railCtaHeight: CGFloat = 70
67
+ static let badgeMaxWidth: CGFloat = 58
68
+
69
+ // motion (MoMo Navigation Prototype): one active indicator slides to the selected item overshooting
70
+ // a little, icon and label tint cross-fade, the center action shrinks while held
71
+ static let indicatorMotion = Animation.timingCurve(0.34, 1.4, 0.5, 1, duration: 0.55)
72
+ static let tintMotion = Animation.easeInOut(duration: 0.25)
73
+ static let ctaPressMotion = Animation.easeOut(duration: 0.15)
74
+ static let ctaPressedScale: CGFloat = 0.92
75
+
76
+ /// Width of the horizontal bar: 65% of the short side on an unfolded foldable, otherwise the window
77
+ /// minus the side safe areas and margins.
78
+ static func horizontalBarWidth(_ layout: ScreenLayout, itemCount: Int, hasCta: Bool) -> CGFloat {
79
+ // 2 tabs (no center action) stay content-sized and centered instead of filling the window
80
+ if itemCount == 2 && !hasCta {
81
+ return twoTabItemWidth * 2 + paddingHorizontal * 2 + itemGap
82
+ }
83
+ let shortSide = min(layout.width, layout.height)
84
+ if shortSide >= foldableMinShortSide { return shortSide * foldableWidthRatio }
85
+ return layout.width - layout.insets.leading - layout.insets.trailing - 2 * margin
86
+ }
87
+
88
+ /// Gap under the container: the home indicator area.
89
+ static func bottomGap(_ bottomInset: CGFloat) -> CGFloat {
90
+ max(min(bottomInset, systemIndicatorHeight), Spacing.S)
91
+ }
92
+
93
+ /// The center action needs a tab on each side: Special type takes 2 or 4 tabs.
94
+ static func hasCenterAction(_ floatingButton: BottomTabFloatingButton?, tabCount: Int) -> Bool {
95
+ floatingButton != nil && tabCount % 2 == 0
96
+ }
97
+ }
@@ -1,25 +1,18 @@
1
- //
2
- // FloatingButton.swift
3
- // MoMoUIKits
4
- //
5
- // SwiftUI mirror of Compose's `navigation/component/FloatingButton.kt`: the screen FAB, whose
6
- // label collapses while the content scrolls down.
7
- //
1
+ // SwiftUI mirror of Compose's `navigation/component/FloatingButton.kt`: the screen FAB, whose
2
+ // label collapses while the content scrolls down.
8
3
 
9
4
  import SwiftUI
10
5
 
11
6
  public enum FABSize {
12
7
  case small
13
8
  case `default`
14
- /// Backward-compatible alias for older iOS call sites. Compose names this
15
- /// size `DEFAULT`.
9
+ /// Older iOS name for `default` (Compose `DEFAULT`), kept for existing call sites.
16
10
  case large
17
11
  }
18
12
 
19
13
  public enum FABPosition {
20
14
  case end
21
- /// Backward-compatible alias for older iOS call sites. Compose names this
22
- /// position `END`.
15
+ /// Older iOS name for `end` (Compose `END`), kept for existing call sites.
23
16
  case right
24
17
  case center
25
18
  }