@momo-kits/native-kits 0.168.1-beta.3-debug → 0.168.1-beta.30

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 (179) hide show
  1. package/CLAUDE.md +14 -10
  2. package/README.md +2 -10
  3. package/ios/Application/ApplicationEnvironment.swift +7 -6
  4. package/ios/Application/DesignSystemKits.swift +163 -0
  5. package/ios/Application/DesignSystemKitsPayload.swift +68 -0
  6. package/ios/Badge/BadgeRibbon.swift +8 -1
  7. package/ios/Extensions/Color++.swift +2 -4
  8. package/ios/Input/Input.swift +13 -3
  9. package/ios/Input/InputPhoneNumber.swift +1 -3
  10. package/ios/Input/InputSearch.swift +1 -2
  11. package/ios/Input/InputTextArea.swift +5 -3
  12. package/ios/InputMoney/InputMoney.swift +6 -7
  13. package/ios/Layout/ScreenLayout.swift +65 -10
  14. package/ios/Navigation/BottomSheet.swift +152 -21
  15. package/ios/Navigation/BottomTab/BottomTab.swift +12 -18
  16. package/ios/Navigation/BottomTab/BottomTabBar.swift +255 -114
  17. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  18. package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
  19. package/ios/Navigation/BottomTab/DuoTabBar.swift +63 -172
  20. package/ios/Navigation/BottomTab/TabBarMetrics.swift +88 -0
  21. package/ios/Navigation/Component/HeaderBackground.swift +22 -1
  22. package/ios/Navigation/Component/SnackBar.swift +4 -0
  23. package/ios/Navigation/ModalScreen.swift +7 -3
  24. package/ios/Navigation/StackScreen.swift +6 -8
  25. package/ios/Popup/PopupDisplay.swift +2 -2
  26. package/ios/Popup/PopupInput.swift +2 -2
  27. package/ios/Popup/PopupLayout.swift +15 -10
  28. package/ios/Popup/PopupNotify.swift +2 -2
  29. package/ios/Stepper/Stepper.swift +1 -2
  30. package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
  31. package/ios/Typography/FontScale.swift +29 -15
  32. package/ios/Typography/Text.swift +86 -12
  33. package/ios/Typography/Typography.swift +2 -2
  34. package/ios/native-kits.podspec +1 -1
  35. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  36. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +224 -59
  37. package/package.json +1 -1
  38. package/publish.sh +2 -7
  39. package/build.gradle.kts +0 -13
  40. package/compose/build.gradle.kts +0 -197
  41. package/compose/build.gradle.kts.backup +0 -197
  42. package/compose/compose.podspec +0 -47
  43. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  44. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  45. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  46. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  47. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
  48. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -124
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -65
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -361
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -16
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -283
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -309
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -338
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -137
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -215
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -404
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -40
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -233
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -217
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -98
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -312
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  140. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
  141. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -103
  142. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  143. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  144. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -413
  145. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  146. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  147. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +0 -37
  148. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
  149. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  150. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +0 -41
  151. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -135
  152. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  153. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  154. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  155. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
  156. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -13
  157. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  158. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  159. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  160. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  161. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +0 -44
  162. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +0 -62
  163. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -40
  164. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  165. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -36
  166. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  167. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  168. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  169. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -94
  170. package/gradle/libs.versions.toml +0 -76
  171. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  172. package/gradle/wrapper/gradle-wrapper.properties +0 -10
  173. package/gradle.properties +0 -26
  174. package/gradlew +0 -252
  175. package/gradlew.bat +0 -94
  176. package/ios/Typography/FontScaleStore.swift +0 -58
  177. package/ios/Typography/KitDesignSystem.swift +0 -17
  178. package/ios-demo/README.md +0 -120
  179. package/settings.gradle.kts +0 -64
@@ -3,8 +3,8 @@
3
3
  // MoMoUIKits
4
4
  //
5
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).
6
+ // Horizontal navigation bar (Figma "Specs Navigation", DS-984): floating container, items split
7
+ // evenly with a tonal active indicator, badges/dots, and the Special type's center action in a notch.
8
8
  //
9
9
 
10
10
  import SwiftUI
@@ -57,170 +57,311 @@ public struct BottomTabFloatingButton {
57
57
  }
58
58
  }
59
59
 
60
- let bottomTabFloatingButtonWidth: CGFloat = 75
61
- let BOTTOM_TAB_BAR_HEIGHT: CGFloat = 64
60
+ let BOTTOM_TAB_BAR_HEIGHT: CGFloat = TabBarMetrics.height
62
61
 
63
62
  // MARK: - Tab bar
64
63
 
64
+ /// Phone tab bar: the horizontal navigation bar filling the window, above the home indicator.
65
65
  struct BottomTabBar: View {
66
66
  let items: [BottomTabItem]
67
67
  let floatingButton: BottomTabFloatingButton?
68
68
  let selectedIndex: Int
69
69
  let onTabSelected: (Int) -> Void
70
+ let bottomInset: CGFloat
70
71
 
71
72
  @Environment(\.screenLayout) private var layout
72
- @Environment(\.appTheme) private var theme
73
73
 
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 }
74
+ var body: some View {
75
+ HorizontalTabBar(
76
+ items: items,
77
+ floatingButton: floatingButton,
78
+ selectedIndex: selectedIndex,
79
+ onTabSelected: onTabSelected,
80
+ width: TabBarMetrics.horizontalBarWidth(layout)
81
+ )
82
+ .padding(.bottom, TabBarMetrics.bottomGap(bottomInset))
83
+ .frame(maxWidth: .infinity)
84
+ }
85
+ }
77
86
 
78
- private var tabWidth: CGFloat {
79
- if floatingButton != nil {
80
- return (screenWidth - bottomTabFloatingButtonWidth) / CGFloat(items.count)
81
- }
82
- return screenWidth / CGFloat(items.count)
87
+ /// Horizontal navigation bar: floating container, items split evenly; Special type puts the center
88
+ /// action in a notch in the middle, rising ctaLift above the container. One active indicator slides
89
+ /// behind the selected item.
90
+ struct HorizontalTabBar: View {
91
+ let items: [BottomTabItem]
92
+ let floatingButton: BottomTabFloatingButton?
93
+ let selectedIndex: Int
94
+ let onTabSelected: (Int) -> Void
95
+ let width: CGFloat
96
+ var fixedFontScale = false
97
+
98
+ private var cta: BottomTabFloatingButton? {
99
+ TabBarMetrics.hasCenterAction(floatingButton, tabCount: items.count) ? floatingButton : nil
100
+ }
101
+
102
+ /// Items share what the padding, gaps and center action slot leave.
103
+ private var itemWidth: CGFloat {
104
+ let slots = CGFloat(items.count + (cta == nil ? 0 : 1))
105
+ let content = width - 2 * TabBarMetrics.paddingHorizontal - (slots - 1) * TabBarMetrics.itemGap
106
+ return max((content - (cta == nil ? 0 : TabBarMetrics.ctaSlotWidth)) / CGFloat(max(items.count, 1)), 0)
83
107
  }
84
108
 
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
109
+ private func itemX(_ index: Int) -> CGFloat {
110
+ let afterCta = cta != nil && index >= items.count / 2
111
+ return TabBarMetrics.paddingHorizontal + CGFloat(index) * (itemWidth + TabBarMetrics.itemGap)
112
+ + (afterCta ? TabBarMetrics.ctaSlotWidth + TabBarMetrics.itemGap : 0)
88
113
  }
89
114
 
90
115
  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)
116
+ let shape = NotchedBarShape(radius: TabBarMetrics.height / 2, notchCenterX: cta == nil ? nil : width / 2)
117
+ ZStack(alignment: .top) {
118
+ ZStack(alignment: .topLeading) {
119
+ ActiveIndicator(radius: TabBarMetrics.indicatorRadius)
120
+ .frame(width: itemWidth, height: TabBarMetrics.indicatorHeight)
121
+ .offset(x: itemX(selectedIndex), y: TabBarMetrics.paddingVertical)
122
+ .animation(TabBarMetrics.indicatorMotion, value: selectedIndex)
123
+
124
+ HStack(spacing: TabBarMetrics.itemGap) {
125
+ ForEach(items.indices, id: \.self) { index in
126
+ if cta != nil && index == items.count / 2 {
127
+ Color.clear.frame(width: TabBarMetrics.ctaSlotWidth)
128
+ }
129
+ SwiftUI.Button { onTabSelected(index) } label: {
130
+ VStack(spacing: Spacing.XXS) {
131
+ TabItemContent(item: items[index], selected: index == selectedIndex, fixedFontScale: fixedFontScale)
132
+ }
133
+ .frame(width: itemWidth)
134
+ .contentShape(Rectangle())
135
+ }
136
+ .buttonStyle(.plain)
137
+ .accessibilityLabel(items[index].label)
138
+ .accessibilityAddTraits(index == selectedIndex ? .isSelected : [])
139
+ }
101
140
  }
141
+ .padding(.horizontal, TabBarMetrics.paddingHorizontal)
142
+ .padding(.vertical, TabBarMetrics.paddingVertical)
102
143
  }
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)
144
+ .frame(width: width, height: TabBarMetrics.height, alignment: .topLeading)
145
+ .modifier(TabBarContainer(shape: shape))
146
+ .accessibilityElement(children: .contain)
147
+ .accessibilityIdentifier("bottom_tab_bar")
148
+ .padding(.top, cta == nil ? 0 : TabBarMetrics.ctaLift)
123
149
 
124
- if let floatingButton {
125
- CenterFloatingButton(data: floatingButton)
150
+ if let cta {
151
+ CenterAction(data: cta, fixedFontScale: fixedFontScale)
126
152
  }
127
153
  }
154
+ .frame(width: width)
128
155
  }
156
+ }
129
157
 
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) }
158
+ /// One active indicator per bar: Background/tonal with its inner light (white 12% from below) and
159
+ /// tint (primary 12% from above).
160
+ struct ActiveIndicator: View {
161
+ let radius: CGFloat
162
+
163
+ @Environment(\.appTheme) private var theme
164
+
165
+ var body: some View {
166
+ let shape = RoundedRectangle(cornerRadius: radius)
167
+ shape
168
+ .fill(theme.colors.background.tonal)
169
+ // inner shadows: primary 12% falling 1 from the top edge, white 12% rising 2 from the bottom one
170
+ .overlay(
171
+ LinearGradient(
172
+ stops: [
173
+ .init(color: theme.colors.primary.opacity(0.12), location: 0),
174
+ .init(color: theme.colors.primary.opacity(0), location: 0.1),
175
+ .init(color: Color.white.opacity(0), location: 0.85),
176
+ .init(color: Color.white.opacity(0.12), location: 1),
177
+ ],
178
+ startPoint: .top,
179
+ endPoint: .bottom
180
+ )
181
+ .clipShape(shape)
137
182
  )
138
- .frame(maxWidth: .infinity)
139
- }
183
+ .allowsHitTesting(false)
184
+ }
185
+ }
186
+
187
+ /// Like the system tab bar, text keeps its design size instead of growing with the wide Duo displays.
188
+ struct FixedFontScale: ViewModifier {
189
+ let enabled: Bool
190
+
191
+ @Environment(\.momoFontScale) private var fontScale
192
+
193
+ func body(content: Content) -> some View {
194
+ content.environment(\.momoFontScale, enabled ? FontScale(userScaleRate: 1, useOSScaleRate: false) : fontScale)
140
195
  }
141
196
  }
142
197
 
143
198
  // MARK: - Tab item
144
199
 
145
- private struct TabBarItem: View {
200
+ /// Icon in its indicator slot, label under it. The bar slides one shared active indicator behind the
201
+ /// slots; the icon and label tint cross-fade on focus.
202
+ struct TabItemContent: View {
146
203
  let item: BottomTabItem
147
204
  let selected: Bool
148
- let onClick: () -> Void
205
+ var vertical = false
206
+ var showLabel = true
207
+ var fixedFontScale = false
149
208
 
150
209
  @Environment(\.appTheme) private var theme
151
210
 
152
- private var tintColor: Color { selected ? theme.colors.primary : theme.colors.text.hint }
211
+ var body: some View {
212
+ TabIcon(item: item, selected: selected, vertical: vertical)
213
+ .frame(height: vertical ? TabBarMetrics.railIndicatorHeight : TabBarMetrics.indicatorHeight)
214
+ if showLabel {
215
+ let label = ZStack {
216
+ labelText(theme.colors.text.secondary).opacity(selected ? 0 : 1)
217
+ labelText(theme.colors.primary).opacity(selected ? 1 : 0)
218
+ }
219
+ .animation(TabBarMetrics.tintMotion, value: selected)
220
+ .frame(maxWidth: vertical ? nil : .infinity)
221
+ label.modifier(FixedFontScale(enabled: fixedFontScale))
222
+ }
223
+ }
224
+
225
+ private func labelText(_ color: Color) -> some View {
226
+ MomoText(
227
+ item.label,
228
+ typography: vertical ? .labelXsMedium : .labelSMedium,
229
+ color: color,
230
+ textAlign: .center,
231
+ maxLines: 1
232
+ )
233
+ .truncationMode(.tail)
234
+ }
235
+ }
153
236
 
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
237
+ /// Badge value shown on a tab: nil hides it, "" is a dot, numbers cap at 99+ ("0" hides it, RN parity).
238
+ func tabBadgeLabel(_ item: BottomTabItem) -> String? {
239
+ guard let label = item.badgeLabel else { return item.showDot ? "" : nil }
240
+ if label.isEmpty { return "" }
241
+ if label.allSatisfy({ ("0"..."9").contains($0) }) {
242
+ let value = Int(label) ?? Int.max
243
+ if value == 0 { return item.showDot ? "" : nil }
244
+ return value > 99 ? "99+" : label
159
245
  }
246
+ return label
247
+ }
160
248
 
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)
249
+ /// 24 icon, active and inactive tints cross-faded; badges hang off it: dot at 16/-2, label badge at
250
+ /// 12/-7 growing right, or centered over the icon at -10 on the rail.
251
+ struct TabIcon: View {
252
+ let item: BottomTabItem
253
+ let selected: Bool
254
+ var vertical = false
178
255
 
179
- if let badgeLabel {
180
- if badgeLabel.isEmpty {
256
+ @Environment(\.appTheme) private var theme
257
+
258
+ var body: some View {
259
+ ZStack {
260
+ Icon(source: item.icon, size: TabBarMetrics.iconSize, color: theme.colors.text.secondary)
261
+ .opacity(selected ? 0 : 1)
262
+ Icon(source: item.icon, size: TabBarMetrics.iconSize, color: theme.colors.primary)
263
+ .opacity(selected ? 1 : 0)
264
+ }
265
+ .animation(TabBarMetrics.tintMotion, value: selected)
266
+ .frame(width: TabBarMetrics.iconSize, height: TabBarMetrics.iconSize)
267
+ .overlay(alignment: vertical ? .top : .topLeading) {
268
+ if let badge = tabBadgeLabel(item) {
269
+ if badge.isEmpty {
181
270
  BadgeDot(size: .small)
182
- .offset(x: -Spacing.S, y: Spacing.XS)
271
+ .offset(x: vertical ? 16 - (TabBarMetrics.iconSize - 10) / 2 : 16, y: -Spacing.XXS)
183
272
  } else {
184
- Badge(label: badgeLabel)
185
- .offset(x: -Spacing.XS, y: 0)
273
+ TabBadge(label: badge)
274
+ .fixedSize()
275
+ .frame(width: TabBarMetrics.badgeMaxWidth, alignment: vertical ? .center : .leading)
276
+ .offset(x: vertical ? 0 : Spacing.M, y: vertical ? -10 : -7)
186
277
  }
187
- } else if item.showDot {
188
- BadgeDot(size: .small)
189
- .offset(x: -Spacing.S, y: Spacing.XS)
190
278
  }
191
279
  }
192
- .frame(maxWidth: .infinity, maxHeight: .infinity)
193
- .padding(.horizontal, Spacing.XXS)
194
- .contentShape(Rectangle())
195
- .onTapGesture { onClick() }
196
280
  }
197
281
  }
198
282
 
199
- // MARK: - Center floating button
200
-
201
- private struct CenterFloatingButton: View {
202
- let data: BottomTabFloatingButton
283
+ /// Numbers use the error color, text the warning color (Figma Badge round numeric / text); the text
284
+ /// keeps its design size so it fits the 16 height on the Duo displays too.
285
+ private struct TabBadge: View {
286
+ let label: String
203
287
 
204
288
  @Environment(\.appTheme) private var theme
205
289
 
290
+ private var isNumber: Bool {
291
+ let digits = label.hasSuffix("+") ? String(label.dropLast()) : label
292
+ return !digits.isEmpty && digits.allSatisfy { ("0"..."9").contains($0) }
293
+ }
294
+
206
295
  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))
296
+ MomoText(label, typography: .actionXxsBold, color: Colors.black01, maxLines: 1)
297
+ .truncationMode(.tail)
298
+ .environment(\.momoFontScale, FontScale(userScaleRate: 1, useOSScaleRate: false))
299
+ .padding(.horizontal, Spacing.XS)
300
+ .frame(minWidth: 16, maxWidth: TabBarMetrics.badgeMaxWidth, minHeight: 16, maxHeight: 16)
301
+ .background(Capsule().fill(isNumber ? theme.colors.error.primary : theme.colors.warning.primary))
302
+ .overlay(Capsule().strokeBorder(theme.colors.background.surface, lineWidth: 1))
303
+ }
304
+ }
305
+
306
+ // MARK: - Center action
307
+
308
+ /// Center action press: the button shrinks while held and its label turns active (label in a
309
+ /// Background/primary pill, white text).
310
+ struct CenterActionStyle: ButtonStyle {
311
+ let size: CGFloat
312
+ let vertical: Bool
313
+ let icon: String
314
+ let label: String
315
+ var fixedFontScale = false
316
+
317
+ @Environment(\.appTheme) private var theme
318
+
319
+ func makeBody(configuration: Configuration) -> some View {
320
+ let pressed = configuration.isPressed
321
+ VStack(spacing: vertical ? TabBarMetrics.railCtaLabelGap : TabBarMetrics.ctaLabelGap) {
322
+ ZStack {
323
+ // Figma Effect/Popover, one layer per shadow, spread as a shrunk circle:
324
+ // 8% y8 blur 24 spread -12, 4% y12 blur 32 spread -16
325
+ Circle().inset(by: 12).fill(theme.colors.primary)
326
+ .shadow(color: Color.black.opacity(0.08), radius: 12, x: 0, y: 8)
327
+ Circle().inset(by: 16).fill(theme.colors.primary)
328
+ .shadow(color: Color.black.opacity(0.04), radius: 16, x: 0, y: 12)
329
+ Circle().fill(theme.colors.primary)
330
+ Icon(source: icon, size: TabBarMetrics.ctaIconSize, color: Colors.black01)
331
+ }
332
+ .frame(width: size, height: size)
333
+ .scaleEffect(pressed ? TabBarMetrics.ctaPressedScale : 1)
334
+ .animation(TabBarMetrics.ctaPressMotion, value: pressed)
335
+ MomoText(
336
+ label,
337
+ typography: vertical ? .labelXsMedium : .labelSMedium,
338
+ color: pressed ? Colors.black01 : theme.colors.text.secondary,
339
+ textAlign: .center,
340
+ maxLines: 1
341
+ )
342
+ .truncationMode(.tail)
343
+ .modifier(FixedFontScale(enabled: fixedFontScale))
344
+ .padding(.horizontal, vertical ? Spacing.XS : Spacing.XXS)
345
+ .frame(minHeight: vertical ? nil : TabBarMetrics.ctaLabelHeight)
346
+ .background(Capsule().fill(pressed ? theme.colors.primary : Color.clear))
219
347
  }
220
- .frame(width: bottomTabFloatingButtonWidth)
221
- .padding(.horizontal, Spacing.XXS)
222
- .padding(.vertical, Spacing.S)
348
+ // the whole slot is the hit area, not just the button and label
349
+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
223
350
  .contentShape(Rectangle())
224
- .onTapGesture { data.onPress() }
351
+ }
352
+ }
353
+
354
+ /// Center action (.Nav/CTA): button rising out of the notch, label under it.
355
+ private struct CenterAction: View {
356
+ let data: BottomTabFloatingButton
357
+ var fixedFontScale = false
358
+
359
+ var body: some View {
360
+ SwiftUI.Button(action: data.onPress) { EmptyView() }
361
+ .buttonStyle(CenterActionStyle(size: TabBarMetrics.ctaSize, vertical: false, icon: data.icon,
362
+ label: data.label, fixedFontScale: fixedFontScale))
363
+ .frame(width: TabBarMetrics.ctaSlotWidth, height: TabBarMetrics.ctaSize + TabBarMetrics.ctaLabelGap + TabBarMetrics.ctaLabelHeight)
364
+ .accessibilityLabel(data.label)
365
+ .accessibilityIdentifier(data.label)
225
366
  }
226
367
  }
@@ -2,64 +2,68 @@
2
2
  // CurvedContainer.swift
3
3
  // MoMoUIKits
4
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.
5
+ // SwiftUI mirror of Compose's `CurvedContainer.kt`: the navigation bar container shape, a rounded
6
+ // rectangle with a notch cut into the top edge around the center action, and its floating shadow.
8
7
  //
9
8
 
10
9
  import SwiftUI
11
10
 
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
11
+ /// Rounded container, with the notch dipped into the top edge around `notchCenterX` (from the
12
+ /// leading edge).
13
+ struct NotchedBarShape: Shape {
14
+ var radius: CGFloat
15
+ var notchCenterX: CGFloat?
19
16
 
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
17
+ func path(in rect: CGRect) -> Path {
18
+ let r = min(radius, rect.height / 2, rect.width / 2)
19
+ guard let cx = notchCenterX else {
20
+ return Path(roundedRect: rect, cornerRadius: r)
21
+ }
22
+ let w = rect.width
23
+ let h = rect.height
26
24
 
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)
25
+ var path = Path()
26
+ path.move(to: CGPoint(x: r, y: 0))
27
+ path.addLine(to: CGPoint(x: cx - TabBarMetrics.notchHalfWidth, y: 0))
28
+ for curve in TabBarMetrics.notchCurves {
29
+ path.addCurve(
30
+ to: CGPoint(x: cx + curve[2].x, y: curve[2].y),
31
+ control1: CGPoint(x: cx + curve[0].x, y: curve[0].y),
32
+ control2: CGPoint(x: cx + curve[1].x, y: curve[1].y)
33
+ )
34
+ }
35
+ path.addLine(to: CGPoint(x: w - r, y: 0))
36
+ path.addRelativeArc(center: CGPoint(x: w - r, y: r), radius: r, startAngle: .degrees(-90), delta: .degrees(90))
37
+ path.addLine(to: CGPoint(x: w, y: h - r))
38
+ path.addRelativeArc(center: CGPoint(x: w - r, y: h - r), radius: r, startAngle: .degrees(0), delta: .degrees(90))
39
+ path.addLine(to: CGPoint(x: r, y: h))
40
+ path.addRelativeArc(center: CGPoint(x: r, y: h - r), radius: r, startAngle: .degrees(90), delta: .degrees(90))
41
+ path.addLine(to: CGPoint(x: 0, y: r))
42
+ path.addRelativeArc(center: CGPoint(x: r, y: r), radius: r, startAngle: .degrees(180), delta: .degrees(90))
43
+ path.closeSubpath()
44
+ return path.offsetBy(dx: rect.minX, dy: rect.minY)
32
45
  }
33
46
  }
34
47
 
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
48
+ /// Navigation bar container: surface fill with the floating shadow following the shape.
49
+ struct TabBarContainer<S: Shape>: ViewModifier {
50
+ let shape: S
42
51
 
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))
52
+ @Environment(\.appTheme) private var theme
47
53
 
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)
54
+ func body(content: Content) -> some View {
55
+ content.background(
56
+ // Figma Shadow/floating, one layer per shadow so they don't shadow each other:
57
+ // 12% blur 24, then 4% blur 32 spread -16 cast from the shape shrunk by 16
58
+ ZStack {
59
+ shape.fill(theme.colors.background.surface)
60
+ .padding(16)
61
+ .shadow(color: Color.black.opacity(0.04), radius: 16, x: 0, y: 12)
62
+ shape.fill(theme.colors.background.surface)
63
+ .shadow(color: Color.black.opacity(0.12), radius: 12)
64
+ shape.fill(theme.colors.background.surface)
65
+ }
66
+ .allowsHitTesting(false)
57
67
  )
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
68
  }
65
69
  }
@@ -35,8 +35,6 @@ struct DuoBarCompression {
35
35
  static let defaultToolbarHeight = DuoMetrics.controlSize + Spacing.M + 2 * DuoMetrics.itemPitch
36
36
  /// Back, then the single button the toolbar folds into.
37
37
  private static let compressedToolbarHeight = 2 * DuoMetrics.controlSize + Spacing.M
38
- /// Back alone, while a rail opened from the compressed state takes the toolbar slot.
39
- private static let backOnlyHeight = DuoMetrics.controlSize
40
38
 
41
39
  /// - both fit: both stay whole
42
40
  /// - one fits whole beside the other compressed: one is compressed, tapping it swaps them
@@ -72,7 +70,8 @@ struct DuoBarCompression {
72
70
 
73
71
  let expandToolbar = { opened.wrappedValue = .toolbar }
74
72
  let expandTabBar = { opened.wrappedValue = .tabBar }
75
- if opened.wrappedValue == .tabBar && fits(backOnlyHeight, tabBar) {
73
+ // an opened rail always shows, even when only the group gap is short: it closes once a tab is picked
74
+ if opened.wrappedValue == .tabBar {
76
75
  return DuoBarCompression(
77
76
  toolbarCompressed: true,
78
77
  tabBarCompressed: false,