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

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 (152) hide show
  1. package/CLAUDE.md +1 -2
  2. package/ios/Input/Input.swift +1 -3
  3. package/ios/Input/InputTextArea.swift +1 -3
  4. package/ios/Navigation/BottomTab/BottomTab.swift +48 -67
  5. package/ios/Navigation/BottomTab/BottomTabBar.swift +281 -131
  6. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  7. package/ios/Navigation/BottomTab/DuoTabBar.swift +72 -292
  8. package/ios/Navigation/BottomTab/TabBarMetrics.swift +88 -0
  9. package/ios/Navigation/StackScreen.swift +3 -1
  10. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  11. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  12. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
  13. package/package.json +1 -1
  14. package/build.gradle.kts +0 -11
  15. package/compose/build.gradle.kts +0 -198
  16. package/compose/build.gradle.kts.backup +0 -198
  17. package/compose/compose.podspec +0 -47
  18. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
  19. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  20. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  21. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  22. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
  23. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  24. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -18
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -370
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -321
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -502
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -148
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -232
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -237
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoLiquidSelection.kt +0 -380
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -436
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -21
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  139. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  140. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  141. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -218
  142. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  143. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -138
  144. package/gradle/libs.versions.toml +0 -69
  145. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  146. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  147. package/gradle.properties +0 -26
  148. package/gradlew +0 -252
  149. package/gradlew.bat +0 -94
  150. package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +0 -364
  151. package/ios-demo/README.md +0 -120
  152. package/settings.gradle.kts +0 -64
@@ -2,29 +2,13 @@
2
2
  // DuoTabBar.swift
3
3
  // MoMoUIKits
4
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.
5
+ // iPhone Duo tab bar, port of RN `BottomTab/DuoTabBar.tsx` (Figma "Specs Navigation", DS-984):
6
+ // a rail in the side bar, or the horizontal bar at 65% of the short side when unfolded portrait.
7
7
  //
8
8
 
9
9
  import SwiftUI
10
10
 
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
- // the rail's badge stays inside the capsule: its end sits XXS off the cell's end edge
24
- private let railBadgeMaxWidth = itemSize - Spacing.XXS * 2
25
- private let railBadgeEndOffset = (itemSize - iconSize) / 2 - Spacing.XXS
26
- // Figma Home-2026 tab bar "Selection": brand pink at 8%
27
- private let selectionTintOpacity: Double = 0x14 / 255
11
+ private let compactSize = DuoMetrics.controlSize
28
12
 
29
13
  /// Room tab screens leave for the Duo tab bar, provided by BottomTab to its tab StackScreens.
30
14
  struct DuoTabBarInsets: Equatable {
@@ -45,70 +29,54 @@ extension EnvironmentValues {
45
29
  }
46
30
  }
47
31
 
48
- /// Rail plus the QR button under it; compressed, the rail is a single button.
32
+ /// Rail container plus the center action under it; compressed, the rail is a single button.
49
33
  func duoRailHeight(itemCount: Int, hasQr: Bool, compressed: Bool = false) -> CGFloat {
50
- let count = CGFloat(itemCount)
51
- let rail = compressed ? itemSize : railPadding * 2 + count * itemSize + max(count - 1, 0) * railGap
52
- return rail + (hasQr ? Spacing.M + itemSize : 0)
34
+ let rail = compressed
35
+ ? compactSize
36
+ : CGFloat(itemCount) * TabBarMetrics.railItemHeight + TabBarMetrics.railPaddingBottom
37
+ return rail + (hasQr ? TabBarMetrics.railCtaGap + TabBarMetrics.railCtaHeight : 0)
53
38
  }
54
39
 
55
40
  extension ScreenLayout {
56
- /// Overlaps the home indicator inset like the system tab bar (21pt above the bottom with a 34pt inset).
41
+ /// The horizontal bar sits above the home indicator area.
57
42
  var duoFloatingTabBarBottom: CGFloat {
58
- max(insets.bottom - DuoMetrics.floatingTabBarInsetOverlap, Spacing.S)
43
+ TabBarMetrics.bottomGap(insets.bottom)
59
44
  }
60
45
 
61
46
  func duoTabBarInsets(itemCount: Int, hasFloatingButton: Bool, tabBarCompressed: Bool = false) -> DuoTabBarInsets {
62
- guard isIPhoneDuo else { return DuoTabBarInsets() }
63
- guard let sideBar else {
64
- // overlay is measured from the bottom safe area, the bar reaches into it
65
- return DuoTabBarInsets(overlay: floatingHeight + duoFloatingTabBarBottom - insets.bottom)
47
+ // the horizontal bar floats over the content (phone and unfolded Duo); the overlay is measured
48
+ // from the bottom safe area, the bar reaches into it
49
+ guard isIPhoneDuo, let sideBar else {
50
+ // the center action's button rises above the bar, tab content leaves room for it too
51
+ let ctaLift = hasFloatingButton && itemCount % 2 == 0 ? TabBarMetrics.ctaLift : 0
52
+ return DuoTabBarInsets(overlay: TabBarMetrics.height + ctaLift + duoFloatingTabBarBottom - insets.bottom)
66
53
  }
67
54
  let rail = duoRailHeight(itemCount: itemCount, hasQr: hasFloatingButton, compressed: tabBarCompressed)
68
55
  return DuoTabBarInsets(sideBarReserve: sideBar.bottom + rail + DuoBarCompression.groupGap)
69
56
  }
70
57
  }
71
58
 
72
- /// RN `BarMaterial`: surface with a 1pt border.
73
- struct DuoBarMaterial<S: InsettableShape>: ViewModifier {
74
- let shape: S
75
-
76
- @Environment(\.appTheme) private var theme
77
-
78
- func body(content: Content) -> some View {
79
- content.background(
80
- shape.fill(theme.colors.background.surface)
81
- .overlay(shape.strokeBorder(theme.colors.border.default, lineWidth: 1))
82
- .allowsHitTesting(false)
83
- )
84
- }
85
- }
86
-
87
59
  struct DuoTabBar: View {
88
60
  let items: [BottomTabItem]
89
61
  let floatingButton: BottomTabFloatingButton?
90
62
  let selectedIndex: Int
91
63
  let onTabSelected: (Int) -> Void
92
64
  var compression = DuoBarCompression()
93
- var onTabLongPress: ((Int) -> Void)?
94
- /// A tick per tab the lens enters while dragged.
95
- var onTick: () -> Void = {}
96
65
 
97
66
  @Environment(\.screenLayout) private var layout
98
67
 
99
68
  var body: some View {
100
69
  if let sideBar = layout.sideBar {
101
70
  DuoRailTabBar(sideBar: sideBar, items: items, floatingButton: floatingButton,
102
- selectedIndex: selectedIndex, onTabSelected: onTabSelected, compression: compression,
103
- onTabLongPress: onTabLongPress, onTick: onTick)
71
+ selectedIndex: selectedIndex, onTabSelected: onTabSelected, compression: compression)
104
72
  } else {
105
- DuoFloatingTabBar(items: items, floatingButton: floatingButton, selectedIndex: selectedIndex,
106
- onTabSelected: onTabSelected, onTabLongPress: onTabLongPress, onTick: onTick)
73
+ DuoFloatingTabBar(items: items, floatingButton: floatingButton,
74
+ selectedIndex: selectedIndex, onTabSelected: onTabSelected)
107
75
  }
108
76
  }
109
77
  }
110
78
 
111
- /// Vertical bar anchored to the bottom of the side bar, QR button below it (Figma MT1-C/E).
79
+ /// Vertical bar anchored to the bottom of the side bar, center action below it.
112
80
  /// When the side bar is short it can shrink to one button showing the current tab
113
81
  /// (HIG "Tab bar compressed"); tapping it expands the rail and compresses the toolbar.
114
82
  private struct DuoRailTabBar: View {
@@ -118,24 +86,21 @@ private struct DuoRailTabBar: View {
118
86
  let selectedIndex: Int
119
87
  let onTabSelected: (Int) -> Void
120
88
  let compression: DuoBarCompression
121
- let onTabLongPress: ((Int) -> Void)?
122
- let onTick: () -> Void
123
89
 
124
- @Environment(\.accessibilityReduceMotion) private var reduceMotion
125
- @StateObject private var selection = DuoLiquidSelection()
90
+ @Environment(\.appTheme) private var theme
126
91
 
127
92
  private var isRight: Bool { sideBar.edge == .right }
128
93
 
129
94
  var body: some View {
130
- VStack(spacing: Spacing.M) {
95
+ VStack(spacing: TabBarMetrics.railCtaGap) {
131
96
  if compression.tabBarCompressed, items.indices.contains(selectedIndex) {
132
97
  SwiftUI.Button(action: compression.expandTabBar) {
133
- DuoTabIcon(item: items[selectedIndex], selected: true, badgeMaxWidth: railBadgeMaxWidth, inRail: true)
134
- .frame(width: itemSize, height: itemSize)
98
+ TabIcon(item: items[selectedIndex], selected: true, vertical: true)
99
+ .frame(width: compactSize, height: compactSize)
135
100
  .contentShape(Circle())
136
101
  }
137
- .buttonStyle(DuoPressLiftStyle())
138
- .modifier(DuoBarMaterial(shape: Circle()))
102
+ .buttonStyle(.plain)
103
+ .modifier(TabBarContainer(shape: Circle()))
139
104
  .accessibilityLabel(items[selectedIndex].label)
140
105
  .accessibilityIdentifier("bottom_tab_bar")
141
106
  } else {
@@ -143,9 +108,12 @@ private struct DuoRailTabBar: View {
143
108
  }
144
109
 
145
110
  if let floatingButton {
146
- DuoQrButton(data: floatingButton, size: itemSize)
111
+ RailCenterAction(data: floatingButton)
147
112
  }
148
113
  }
114
+ // the rail lines up with the header buttons in the side bar: centered on a 48 lane kept
115
+ // Spacing.M from the strip's inner edge; the wider rail and center action overflow it evenly
116
+ .frame(width: compactSize)
149
117
  .padding(isRight ? .leading : .trailing, Spacing.M)
150
118
  .frame(width: sideBar.width, alignment: isRight ? .leading : .trailing)
151
119
  .padding(.bottom, sideBar.bottom)
@@ -153,264 +121,76 @@ private struct DuoRailTabBar: View {
153
121
  .ignoresSafeArea()
154
122
  }
155
123
 
156
- private func select(_ index: Int) {
157
- onTabSelected(index)
158
- compression.onTabSelected()
159
- }
160
-
161
- /// Column of icon-only tab items with the sliding selection lens.
124
+ /// Column of rail items (.Nav/Duo/Item) with the sliding active indicator.
162
125
  private var rail: some View {
163
- let selection = configured()
164
- let lens = selection.lensScale
165
- return ZStack(alignment: .top) {
166
- DuoSelectionMaterial()
167
- .frame(width: railBubbleWidth, height: railBubbleHeight)
168
- .scaleEffect(x: lens.x * lens.across, y: lens.y * lens.along)
169
- .offset(y: railPadding - (railBubbleHeight - itemSize) / 2 + selection.offset)
126
+ ZStack(alignment: .top) {
127
+ ActiveIndicator(radius: TabBarMetrics.railIndicatorRadius)
128
+ .frame(width: TabBarMetrics.railItemWidth, height: TabBarMetrics.railIndicatorHeight)
129
+ .offset(y: Spacing.XS + CGFloat(selectedIndex) * TabBarMetrics.railItemHeight)
130
+ .animation(TabBarMetrics.indicatorMotion, value: selectedIndex)
170
131
 
171
- VStack(spacing: railGap) {
132
+ VStack(spacing: 0) {
172
133
  ForEach(items.indices, id: \.self) { index in
173
- DuoLiquidTab(selection: selection, index: index, label: items[index].label,
174
- selected: index == selectedIndex, onSelect: { select(index) }) { active in
175
- DuoTabIcon(item: items[index], selected: active, badgeMaxWidth: railBadgeMaxWidth, inRail: true)
176
- .frame(width: itemSize, height: itemSize)
134
+ SwiftUI.Button {
135
+ onTabSelected(index)
136
+ compression.onTabSelected()
137
+ } label: {
138
+ VStack(spacing: 0) {
139
+ TabItemContent(item: items[index], selected: index == selectedIndex, vertical: true, fixedFontScale: true)
140
+ }
141
+ .frame(width: TabBarMetrics.railItemWidth, height: TabBarMetrics.railItemHeight)
142
+ .contentShape(Rectangle())
177
143
  }
144
+ .buttonStyle(.plain)
145
+ .accessibilityLabel(items[index].label)
146
+ .accessibilityAddTraits(index == selectedIndex ? .isSelected : [])
178
147
  }
179
148
  }
180
- .padding(.vertical, railPadding)
181
149
  }
182
- .frame(width: itemSize)
183
- .modifier(DuoLiquidInput(selection: selection, space: "DuoRail"))
184
- .modifier(DuoBarMaterial(shape: Capsule()))
185
- .scaleEffect(selection.barScale)
150
+ .padding(.horizontal, TabBarMetrics.railPaddingHorizontal)
151
+ .padding(.bottom, TabBarMetrics.railPaddingBottom)
152
+ .frame(width: TabBarMetrics.railContainerWidth)
153
+ .modifier(TabBarContainer(shape: RoundedRectangle(cornerRadius: Radius.XL)))
154
+ .accessibilityElement(children: .contain)
186
155
  .accessibilityIdentifier("bottom_tab_bar")
187
- .onAppear { selection.sync(index: selectedIndex) }
188
- .onChange(of: selectedIndex) { selection.sync(index: $0) }
189
- }
190
-
191
- private func configured() -> DuoLiquidSelection {
192
- selection.axis = .y
193
- selection.count = items.count
194
- selection.pitch = itemSize + railGap
195
- selection.firstCenter = railPadding + itemSize / 2
196
- selection.reduceMotion = reduceMotion
197
- selection.onSelect = select
198
- selection.onLongPress = onTabLongPress
199
- selection.onTick = onTick
200
- return selection
201
156
  }
202
157
  }
203
158
 
204
- /// Floating labelled bar for the unfolded portrait display, QR pinned in its own platter beside it.
159
+ /// Horizontal navigation bar of the unfolded display: 65% of the short side, centered.
205
160
  private struct DuoFloatingTabBar: View {
206
161
  let items: [BottomTabItem]
207
162
  let floatingButton: BottomTabFloatingButton?
208
163
  let selectedIndex: Int
209
164
  let onTabSelected: (Int) -> Void
210
- let onTabLongPress: ((Int) -> Void)?
211
- let onTick: () -> Void
212
165
 
213
166
  @Environment(\.screenLayout) private var layout
214
- @Environment(\.appTheme) private var theme
215
- @Environment(\.accessibilityReduceMotion) private var reduceMotion
216
- @StateObject private var selection = DuoLiquidSelection()
217
-
218
- private var barWidth: CGFloat {
219
- let margins = layout.insets.leading + layout.insets.trailing + 2 * DuoMetrics.floatingTabBarMargin
220
- let qr = floatingButton == nil ? 0 : floatingHeight + Spacing.S
221
- let preferred = CGFloat(items.count) * floatingItemWidth + 2 * floatingPadding
222
- return max(min(preferred, layout.width - margins - qr), 0)
223
- }
224
-
225
- private var cellWidth: CGFloat { (barWidth - floatingPadding * 2) / CGFloat(max(items.count, 1)) }
226
167
 
227
168
  var body: some View {
228
- HStack(spacing: Spacing.S) {
229
- bar
230
- if let floatingButton {
231
- DuoQrButton(data: floatingButton, size: floatingHeight)
232
- .shadow(color: Color.black.opacity(0.16), radius: 16, x: 0, y: 6)
233
- }
234
- }
169
+ HorizontalTabBar(
170
+ items: items,
171
+ floatingButton: floatingButton,
172
+ selectedIndex: selectedIndex,
173
+ onTabSelected: onTabSelected,
174
+ width: TabBarMetrics.horizontalBarWidth(layout),
175
+ fixedFontScale: true
176
+ )
235
177
  .padding(.bottom, layout.duoFloatingTabBarBottom)
236
178
  .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
237
179
  .ignoresSafeArea()
238
180
  }
239
-
240
- private var bar: some View {
241
- let selection = configured()
242
- let lens = selection.lensScale
243
- return ZStack(alignment: .leading) {
244
- DuoSelectionMaterial()
245
- .frame(width: cellWidth)
246
- .scaleEffect(x: lens.x * lens.along, y: lens.y * lens.across)
247
- .offset(x: selection.offset)
248
-
249
- HStack(spacing: 0) {
250
- ForEach(items.indices, id: \.self) { index in
251
- DuoLiquidTab(selection: selection, index: index, label: items[index].label,
252
- selected: index == selectedIndex, onSelect: { onTabSelected(index) }) { active in
253
- tabCell(index, active: active)
254
- }
255
- }
256
- }
257
- }
258
- .modifier(DuoLiquidInput(selection: selection, space: "DuoFloatingBar"))
259
- .padding(floatingPadding)
260
- .frame(width: barWidth, height: floatingHeight)
261
- .modifier(DuoBarMaterial(shape: Capsule()))
262
- .scaleEffect(selection.barScale)
263
- .accessibilityIdentifier("bottom_tab_bar")
264
- .onAppear { selection.sync(index: selectedIndex) }
265
- .onChange(of: selectedIndex) { selection.sync(index: $0) }
266
- .onChange(of: cellWidth) { _ in selection.sync(index: selectedIndex) }
267
- }
268
-
269
- private func configured() -> DuoLiquidSelection {
270
- selection.axis = .x
271
- selection.count = items.count
272
- selection.pitch = cellWidth
273
- selection.firstCenter = cellWidth / 2
274
- selection.reduceMotion = reduceMotion
275
- selection.onSelect = onTabSelected
276
- selection.onLongPress = onTabLongPress
277
- selection.onTick = onTick
278
- return selection
279
- }
280
-
281
- private func tabCell(_ index: Int, active: Bool) -> some View {
282
- VStack(spacing: Spacing.XXS) {
283
- DuoTabIcon(item: items[index], selected: active, badgeMaxWidth: cellWidth / 2 - Spacing.XXS)
284
- MomoText(
285
- items[index].label,
286
- typography: .labelXsMedium,
287
- color: active ? theme.colors.primary : theme.colors.text.hint,
288
- textAlign: .center,
289
- maxLines: 1
290
- )
291
- // like the system tab bar the label keeps its design size; a constant snapshot, nothing to observe
292
- .environment(\.momoFontScale, FontScale(userScaleRate: 1, useOSScaleRate: false))
293
- }
294
- .frame(width: cellWidth)
295
- .frame(maxHeight: .infinity)
296
- }
297
181
  }
298
182
 
299
- /// One gesture over the whole bar drives the selection; SwiftUI drops `onEnded` when the system
300
- /// cancels a touch, so the reset of the gesture state ends it instead.
301
- private struct DuoLiquidInput: ViewModifier {
302
- let selection: DuoLiquidSelection
303
- let space: String
304
-
305
- @GestureState private var touching = false
306
-
307
- func body(content: Content) -> some View {
308
- content
309
- .coordinateSpace(name: space)
310
- .contentShape(Rectangle())
311
- .gesture(
312
- DragGesture(minimumDistance: 0, coordinateSpace: .named(space))
313
- .updating($touching) { _, state, _ in state = true }
314
- .onChanged { selection.touchChanged(location: $0.location, translation: $0.translation, time: $0.time) }
315
- .onEnded { selection.touchEnded(location: $0.location) }
316
- )
317
- .onChange(of: touching) { if !$0 { selection.touchCancelled() } }
318
- }
319
- }
320
-
321
- /// A tab drawn twice, inactive with the active layer over it fading in as the lens passes;
322
- /// the tab the lens lands on pops.
323
- private struct DuoLiquidTab<Content: View>: View {
324
- @ObservedObject var selection: DuoLiquidSelection
325
- let index: Int
326
- let label: String
327
- let selected: Bool
328
- let onSelect: () -> Void
329
- @ViewBuilder let content: (_ active: Bool) -> Content
330
-
331
- var body: some View {
332
- ZStack {
333
- content(false)
334
- content(true).opacity(selection.activeOpacity(index))
335
- }
336
- .scaleEffect(selection.popIndex == index ? selection.pop : 1)
337
- .accessibilityElement(children: .ignore)
338
- .accessibilityLabel(label)
339
- .accessibilityAddTraits(selected ? [.isButton, .isSelected] : .isButton)
340
- .accessibilityAction { onSelect() }
341
- }
342
- }
343
-
344
- /// Pink tinted capsule under the selected tab.
345
- private struct DuoSelectionMaterial: View {
346
- @Environment(\.appTheme) private var theme
347
-
348
- var body: some View {
349
- Capsule()
350
- .fill(theme.colors.primary.opacity(selectionTintOpacity))
351
- .allowsHitTesting(false)
352
- }
353
- }
354
-
355
- /// Lift of a single button, e.g. the compressed rail (RN `usePressLift`).
356
- private struct DuoPressLiftStyle: ButtonStyle {
357
- @Environment(\.accessibilityReduceMotion) private var reduceMotion
358
-
359
- func makeBody(configuration: Configuration) -> some View {
360
- configuration.label
361
- .scaleEffect(configuration.isPressed && !reduceMotion ? 1 + (liquidLensScaleX - 1) * 0.5 : 1)
362
- .animation(liquidSpring, value: configuration.isPressed)
363
- }
364
- }
365
-
366
- /// Floating bar: the badge starts at the icon's center and grows toward the cell's end edge.
367
- /// Rail: it ends just inside the capsule and grows back over the icon (RN TabBarIcon `end: -3`).
368
- /// Capped at `badgeMaxWidth` (an overlay alone would only offer it the icon's 28pt).
369
- private struct DuoTabIcon: View {
370
- let item: BottomTabItem
371
- let selected: Bool
372
- let badgeMaxWidth: CGFloat
373
- var inRail = false
374
-
375
- @Environment(\.appTheme) private var theme
376
-
377
- private var badgeLabel: String? {
378
- guard let label = item.badgeLabel else { return nil }
379
- if let n = Int(label), n == 0 { return nil }
380
- return label
381
- }
382
-
383
- var body: some View {
384
- Icon(source: item.icon, size: iconSize, color: selected ? theme.colors.primary : theme.colors.text.hint)
385
- .overlay(alignment: inRail ? .topTrailing : .topLeading) {
386
- if let badgeLabel, !badgeLabel.isEmpty {
387
- Badge(label: badgeLabel)
388
- .frame(width: max(badgeMaxWidth, 0), alignment: inRail ? .trailing : .leading)
389
- .offset(x: inRail ? railBadgeEndOffset : iconSize / 2, y: -Spacing.XS)
390
- }
391
- }
392
- .overlay(alignment: .topTrailing) {
393
- if badgeLabel?.isEmpty == true || (badgeLabel == nil && item.showDot) {
394
- BadgeDot(size: .small)
395
- }
396
- }
397
- }
398
- }
399
-
400
- private struct DuoQrButton: View {
183
+ /// Center action of the rail: round button with its label, under the container.
184
+ private struct RailCenterAction: View {
401
185
  let data: BottomTabFloatingButton
402
- let size: CGFloat
403
-
404
- @Environment(\.appTheme) private var theme
405
186
 
406
187
  var body: some View {
407
- SwiftUI.Button(action: data.onPress) {
408
- Circle()
409
- .fill(theme.colors.primary)
410
- .frame(width: size, height: size)
411
- .overlay(Icon(source: data.icon, size: qrIconSize, color: Colors.black01))
412
- }
413
- .buttonStyle(.plain)
414
- .accessibilityLabel(data.label)
188
+ SwiftUI.Button(action: data.onPress) { EmptyView() }
189
+ .buttonStyle(CenterActionStyle(size: TabBarMetrics.railCtaSize, vertical: true, icon: data.icon,
190
+ iconContent: data.iconContent, labelContent: data.labelContent,
191
+ label: data.label, fixedFontScale: true))
192
+ .frame(width: TabBarMetrics.railCtaWidth, height: TabBarMetrics.railCtaHeight)
193
+ .accessibilityLabel(data.label)
194
+ .accessibilityIdentifier(data.label)
415
195
  }
416
196
  }
@@ -0,0 +1,88 @@
1
+ //
2
+ // TabBarMetrics.swift
3
+ // MoMoUIKits
4
+ //
5
+ // Navigation bar measurements (Figma "Specs Navigation", DS-984), mirrored from Compose's
6
+ // `navigation/bottomtab/TabBarMetrics.kt` and RN `BottomTab/metrics.ts`.
7
+ // Horizontal: floating container with items split evenly, center action in a notch.
8
+ // Vertical: iPhone Duo rail, center action under the container.
9
+ //
10
+
11
+ import SwiftUI
12
+
13
+ enum TabBarMetrics {
14
+ static let height: CGFloat = 68
15
+ static let margin = Spacing.S
16
+ static let paddingVertical = Spacing.S
17
+ static let paddingHorizontal = Spacing.M
18
+ static let itemGap = Spacing.XS
19
+ static let iconSize: CGFloat = 24
20
+ static let indicatorHeight: CGFloat = 32
21
+ // active indicator behind the icon: 24 icon + XS·M padding
22
+ static let indicatorPaddingVertical = Spacing.XS
23
+ static let indicatorPaddingHorizontal = Spacing.M
24
+ static let indicatorRadius = Radius.XL
25
+ // home indicator / gesture bar area under the container
26
+ static let systemIndicatorHeight: CGFloat = 24
27
+ // unfolded foldables (short side from 600, the smallest in the spec) use 65% of the short side,
28
+ // centered; phones and folded outer displays fill the window
29
+ static let foldableMinShortSide: CGFloat = 600
30
+ static let foldableWidthRatio: CGFloat = 0.65
31
+ static let ctaSlotWidth: CGFloat = 92
32
+ static let ctaSize: CGFloat = 48
33
+ // the icon sits 10 inside the 48 button (prototype .cta: 28 icon), 12 inside the 52 rail one
34
+ static let ctaIconSize: CGFloat = 28
35
+ // the button rises 22 above the container top edge
36
+ static let ctaLift: CGFloat = 22
37
+ static let ctaLabelGap = Spacing.M
38
+ static let ctaLabelHeight: CGFloat = 18
39
+ // notch dipped into the container top edge under the center action (Figma "Backgroud" path):
40
+ // starts notchHalfWidth left of the center, then cubic segments of control1, control2, end,
41
+ // each point as (dx from the center, dy below the top edge)
42
+ static let notchHalfWidth: CGFloat = 50.758
43
+ static let notchCurves: [[CGPoint]] = [
44
+ [CGPoint(x: -39.749, y: 0), CGPoint(x: -31.231, y: 9.765), CGPoint(x: -24.563, y: 18.526)],
45
+ [CGPoint(x: -18.928, y: 25.93), CGPoint(x: -10.022, y: 30.709), CGPoint(x: 0, y: 30.709)],
46
+ [CGPoint(x: 10.022, y: 30.709), CGPoint(x: 18.928, y: 25.93), CGPoint(x: 24.563, y: 18.526)],
47
+ [CGPoint(x: 31.231, y: 9.765), CGPoint(x: 39.749, y: 0), CGPoint(x: notchHalfWidth, y: 0)],
48
+ ]
49
+ static let railContainerWidth: CGFloat = 56
50
+ static let railPaddingHorizontal = Spacing.XS
51
+ static let railPaddingBottom = Spacing.S
52
+ static let railItemWidth: CGFloat = 48
53
+ static let railItemHeight: CGFloat = 62
54
+ static let railIndicatorHeight: CGFloat = 40
55
+ static let railIndicatorPaddingVertical = Spacing.S
56
+ static let railIndicatorRadius: CGFloat = 20
57
+ static let railCtaGap = Spacing.L
58
+ static let railCtaSize: CGFloat = 52
59
+ static let railCtaLabelGap = Spacing.XS
60
+ static let railCtaWidth: CGFloat = 68
61
+ static let railCtaHeight: CGFloat = 70
62
+ static let badgeMaxWidth: CGFloat = 58
63
+
64
+ // motion (MoMo Navigation Prototype): one active indicator slides to the selected item overshooting
65
+ // a little, icon and label tint cross-fade, the center action shrinks while held
66
+ static let indicatorMotion = Animation.timingCurve(0.34, 1.4, 0.5, 1, duration: 0.55)
67
+ static let tintMotion = Animation.easeInOut(duration: 0.25)
68
+ static let ctaPressMotion = Animation.easeOut(duration: 0.15)
69
+ static let ctaPressedScale: CGFloat = 0.92
70
+
71
+ /// Width of the horizontal bar: 65% of the short side on an unfolded foldable, otherwise the window
72
+ /// minus the side safe areas and margins.
73
+ static func horizontalBarWidth(_ layout: ScreenLayout) -> CGFloat {
74
+ let shortSide = min(layout.width, layout.height)
75
+ if shortSide >= foldableMinShortSide { return shortSide * foldableWidthRatio }
76
+ return layout.width - layout.insets.leading - layout.insets.trailing - 2 * margin
77
+ }
78
+
79
+ /// Gap under the container: the home indicator area.
80
+ static func bottomGap(_ bottomInset: CGFloat) -> CGFloat {
81
+ max(min(bottomInset, systemIndicatorHeight), Spacing.S)
82
+ }
83
+
84
+ /// The center action needs a tab on each side: Special type takes 2 or 4 tabs.
85
+ static func hasCenterAction(_ floatingButton: BottomTabFloatingButton?, tabCount: Int) -> Bool {
86
+ floatingButton != nil && tabCount % 2 == 0
87
+ }
88
+ }
@@ -573,7 +573,8 @@ private struct StackScreenContent<Content: View>: View {
573
573
  var animatedSearchInset: CGFloat = 0
574
574
  /// Room for a header the content scrolls under (iPhone Duo glass header).
575
575
  var topInset: CGFloat = 0
576
- /// Room for a bar that overlays the content (iPhone Duo floating tab bar).
576
+ /// Room for the floating tab bar that overlays the content: scrolling content runs under it and
577
+ /// ends clear of it, static content stays above it.
577
578
  var bottomInset: CGFloat = 0
578
579
  /// Compose's animated-search snap: a scroll that comes to rest part way through this distance
579
580
  /// finishes the move, up or back down.
@@ -644,6 +645,7 @@ private struct StackScreenContent<Content: View>: View {
644
645
  }
645
646
  }
646
647
  } else {
648
+ // static tab content stays above the floating tab bar
647
649
  content()
648
650
  .padding(.top, topInset)
649
651
  .padding(.bottom, bottomInset)