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

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 (150) hide show
  1. package/CLAUDE.md +2 -1
  2. package/ios/Input/Input.swift +3 -1
  3. package/ios/Input/InputTextArea.swift +3 -1
  4. package/ios/Navigation/BottomTab/BottomTab.swift +33 -14
  5. package/ios/Navigation/BottomTab/BottomTabBar.swift +131 -254
  6. package/ios/Navigation/BottomTab/CurvedContainer.swift +47 -51
  7. package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +364 -0
  8. package/ios/Navigation/BottomTab/DuoTabBar.swift +292 -71
  9. package/ios/Navigation/StackScreen.swift +1 -3
  10. package/ios/native-kits.podspec +1 -1
  11. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  12. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +59 -224
  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/ReservedRegions.android.kt +0 -6
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -370
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -321
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -502
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -148
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -224
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -383
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -94
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -203
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -106
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -20
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  139. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -218
  140. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -138
  141. package/gradle/libs.versions.toml +0 -69
  142. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  143. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  144. package/gradle.properties +0 -26
  145. package/gradlew +0 -252
  146. package/gradlew.bat +0 -94
  147. package/ios/Navigation/BottomTab/TabBarMetrics.swift +0 -88
  148. package/ios-demo/README.md +0 -120
  149. package/local.properties +0 -9
  150. package/settings.gradle.kts +0 -64
@@ -2,13 +2,29 @@
2
2
  // DuoTabBar.swift
3
3
  // MoMoUIKits
4
4
  //
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.
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
7
  //
8
8
 
9
9
  import SwiftUI
10
10
 
11
- private let compactSize = DuoMetrics.controlSize
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
12
28
 
13
29
  /// Room tab screens leave for the Duo tab bar, provided by BottomTab to its tab StackScreens.
14
30
  struct DuoTabBarInsets: Equatable {
@@ -29,54 +45,70 @@ extension EnvironmentValues {
29
45
  }
30
46
  }
31
47
 
32
- /// Rail container plus the center action under it; compressed, the rail is a single button.
48
+ /// Rail plus the QR button under it; compressed, the rail is a single button.
33
49
  func duoRailHeight(itemCount: Int, hasQr: Bool, compressed: Bool = false) -> CGFloat {
34
- let rail = compressed
35
- ? compactSize
36
- : CGFloat(itemCount) * TabBarMetrics.railItemHeight + TabBarMetrics.railPaddingBottom
37
- return rail + (hasQr ? TabBarMetrics.railCtaGap + TabBarMetrics.railCtaHeight : 0)
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)
38
53
  }
39
54
 
40
55
  extension ScreenLayout {
41
- /// The horizontal bar sits above the home indicator area.
56
+ /// Overlaps the home indicator inset like the system tab bar (21pt above the bottom with a 34pt inset).
42
57
  var duoFloatingTabBarBottom: CGFloat {
43
- TabBarMetrics.bottomGap(insets.bottom)
58
+ max(insets.bottom - DuoMetrics.floatingTabBarInsetOverlap, Spacing.S)
44
59
  }
45
60
 
46
61
  func duoTabBarInsets(itemCount: Int, hasFloatingButton: Bool, tabBarCompressed: Bool = false) -> DuoTabBarInsets {
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)
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)
53
66
  }
54
67
  let rail = duoRailHeight(itemCount: itemCount, hasQr: hasFloatingButton, compressed: tabBarCompressed)
55
68
  return DuoTabBarInsets(sideBarReserve: sideBar.bottom + rail + DuoBarCompression.groupGap)
56
69
  }
57
70
  }
58
71
 
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
+
59
87
  struct DuoTabBar: View {
60
88
  let items: [BottomTabItem]
61
89
  let floatingButton: BottomTabFloatingButton?
62
90
  let selectedIndex: Int
63
91
  let onTabSelected: (Int) -> Void
64
92
  var compression = DuoBarCompression()
93
+ var onTabLongPress: ((Int) -> Void)?
94
+ /// A tick per tab the lens enters while dragged.
95
+ var onTick: () -> Void = {}
65
96
 
66
97
  @Environment(\.screenLayout) private var layout
67
98
 
68
99
  var body: some View {
69
100
  if let sideBar = layout.sideBar {
70
101
  DuoRailTabBar(sideBar: sideBar, items: items, floatingButton: floatingButton,
71
- selectedIndex: selectedIndex, onTabSelected: onTabSelected, compression: compression)
102
+ selectedIndex: selectedIndex, onTabSelected: onTabSelected, compression: compression,
103
+ onTabLongPress: onTabLongPress, onTick: onTick)
72
104
  } else {
73
- DuoFloatingTabBar(items: items, floatingButton: floatingButton,
74
- selectedIndex: selectedIndex, onTabSelected: onTabSelected)
105
+ DuoFloatingTabBar(items: items, floatingButton: floatingButton, selectedIndex: selectedIndex,
106
+ onTabSelected: onTabSelected, onTabLongPress: onTabLongPress, onTick: onTick)
75
107
  }
76
108
  }
77
109
  }
78
110
 
79
- /// Vertical bar anchored to the bottom of the side bar, center action below it.
111
+ /// Vertical bar anchored to the bottom of the side bar, QR button below it (Figma MT1-C/E).
80
112
  /// When the side bar is short it can shrink to one button showing the current tab
81
113
  /// (HIG "Tab bar compressed"); tapping it expands the rail and compresses the toolbar.
82
114
  private struct DuoRailTabBar: View {
@@ -86,21 +118,24 @@ private struct DuoRailTabBar: View {
86
118
  let selectedIndex: Int
87
119
  let onTabSelected: (Int) -> Void
88
120
  let compression: DuoBarCompression
121
+ let onTabLongPress: ((Int) -> Void)?
122
+ let onTick: () -> Void
89
123
 
90
- @Environment(\.appTheme) private var theme
124
+ @Environment(\.accessibilityReduceMotion) private var reduceMotion
125
+ @StateObject private var selection = DuoLiquidSelection()
91
126
 
92
127
  private var isRight: Bool { sideBar.edge == .right }
93
128
 
94
129
  var body: some View {
95
- VStack(spacing: TabBarMetrics.railCtaGap) {
130
+ VStack(spacing: Spacing.M) {
96
131
  if compression.tabBarCompressed, items.indices.contains(selectedIndex) {
97
132
  SwiftUI.Button(action: compression.expandTabBar) {
98
- TabIcon(item: items[selectedIndex], selected: true, vertical: true)
99
- .frame(width: compactSize, height: compactSize)
133
+ DuoTabIcon(item: items[selectedIndex], selected: true, badgeMaxWidth: railBadgeMaxWidth, inRail: true)
134
+ .frame(width: itemSize, height: itemSize)
100
135
  .contentShape(Circle())
101
136
  }
102
- .buttonStyle(.plain)
103
- .modifier(TabBarContainer(shape: Circle()))
137
+ .buttonStyle(DuoPressLiftStyle())
138
+ .modifier(DuoBarMaterial(shape: Circle()))
104
139
  .accessibilityLabel(items[selectedIndex].label)
105
140
  .accessibilityIdentifier("bottom_tab_bar")
106
141
  } else {
@@ -108,12 +143,9 @@ private struct DuoRailTabBar: View {
108
143
  }
109
144
 
110
145
  if let floatingButton {
111
- RailCenterAction(data: floatingButton)
146
+ DuoQrButton(data: floatingButton, size: itemSize)
112
147
  }
113
148
  }
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)
117
149
  .padding(isRight ? .leading : .trailing, Spacing.M)
118
150
  .frame(width: sideBar.width, alignment: isRight ? .leading : .trailing)
119
151
  .padding(.bottom, sideBar.bottom)
@@ -121,75 +153,264 @@ private struct DuoRailTabBar: View {
121
153
  .ignoresSafeArea()
122
154
  }
123
155
 
124
- /// Column of rail items (.Nav/Duo/Item) with the sliding active indicator.
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.
125
162
  private var rail: some View {
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)
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)
131
170
 
132
- VStack(spacing: 0) {
171
+ VStack(spacing: railGap) {
133
172
  ForEach(items.indices, id: \.self) { index in
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())
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)
143
177
  }
144
- .buttonStyle(.plain)
145
- .accessibilityLabel(items[index].label)
146
- .accessibilityAddTraits(index == selectedIndex ? .isSelected : [])
147
178
  }
148
179
  }
180
+ .padding(.vertical, railPadding)
149
181
  }
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)
182
+ .frame(width: itemSize)
183
+ .modifier(DuoLiquidInput(selection: selection, space: "DuoRail"))
184
+ .modifier(DuoBarMaterial(shape: Capsule()))
185
+ .scaleEffect(selection.barScale)
155
186
  .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
156
201
  }
157
202
  }
158
203
 
159
- /// Horizontal navigation bar of the unfolded display: 65% of the short side, centered.
204
+ /// Floating labelled bar for the unfolded portrait display, QR pinned in its own platter beside it.
160
205
  private struct DuoFloatingTabBar: View {
161
206
  let items: [BottomTabItem]
162
207
  let floatingButton: BottomTabFloatingButton?
163
208
  let selectedIndex: Int
164
209
  let onTabSelected: (Int) -> Void
210
+ let onTabLongPress: ((Int) -> Void)?
211
+ let onTick: () -> Void
165
212
 
166
213
  @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)) }
167
226
 
168
227
  var body: some View {
169
- HorizontalTabBar(
170
- items: items,
171
- floatingButton: floatingButton,
172
- selectedIndex: selectedIndex,
173
- onTabSelected: onTabSelected,
174
- width: TabBarMetrics.horizontalBarWidth(layout),
175
- fixedFontScale: true
176
- )
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
+ }
177
235
  .padding(.bottom, layout.duoFloatingTabBarBottom)
178
236
  .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
179
237
  .ignoresSafeArea()
180
238
  }
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
+ }
181
297
  }
182
298
 
183
- /// Center action of the rail: round button with its label, under the container.
184
- private struct RailCenterAction: View {
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 {
185
401
  let data: BottomTabFloatingButton
402
+ let size: CGFloat
403
+
404
+ @Environment(\.appTheme) private var theme
186
405
 
187
406
  var body: some View {
188
- SwiftUI.Button(action: data.onPress) { EmptyView() }
189
- .buttonStyle(CenterActionStyle(size: TabBarMetrics.railCtaSize, vertical: true, icon: data.icon,
190
- label: data.label, fixedFontScale: true))
191
- .frame(width: TabBarMetrics.railCtaWidth, height: TabBarMetrics.railCtaHeight)
192
- .accessibilityLabel(data.label)
193
- .accessibilityIdentifier(data.label)
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)
194
415
  }
195
416
  }
@@ -573,8 +573,7 @@ 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 the floating tab bar that overlays the content: scrolling content runs under it and
577
- /// ends clear of it, static content stays above it.
576
+ /// Room for a bar that overlays the content (iPhone Duo floating tab bar).
578
577
  var bottomInset: CGFloat = 0
579
578
  /// Compose's animated-search snap: a scroll that comes to rest part way through this distance
580
579
  /// finishes the move, up or back down.
@@ -645,7 +644,6 @@ private struct StackScreenContent<Content: View>: View {
645
644
  }
646
645
  }
647
646
  } else {
648
- // static tab content stays above the floating tab bar
649
647
  content()
650
648
  .padding(.top, topInset)
651
649
  .padding(.bottom, bottomInset)
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKits'
3
- s.version = '0.168.1-beta.30'
3
+ s.version = '0.168.1-beta.24'
4
4
  s.summary = 'MoMoUIKits for iOS'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKitsDemo'
3
- s.version = '0.168.1-beta.30'
3
+ s.version = '0.168.1-beta.24'
4
4
  s.summary = 'Demo browser for MoMoUIKits SwiftUI components'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }