@momo-kits/native-kits 0.169.8 → 0.169.9

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.
@@ -166,10 +166,19 @@ struct HorizontalTabBar: View {
166
166
 
167
167
  if let cta {
168
168
  CenterAction(data: cta)
169
+ .offset(y: centerActionTop)
169
170
  }
170
171
  }
171
172
  .frame(width: width)
172
173
  }
174
+
175
+ /// Offset of the center action column from the bar top: the items sit at the top of the container
176
+ /// (which starts ctaLift down), so the column is placed for its label to start on the tab labels' line.
177
+ private var centerActionTop: CGFloat {
178
+ let itemLabelTop = TabBarMetrics.ctaLift + TabBarMetrics.paddingVertical
179
+ + TabBarMetrics.indicatorHeight + TabBarMetrics.itemIconLabelGap
180
+ return itemLabelTop - TabBarMetrics.ctaLabelGap - TabBarMetrics.ctaSize
181
+ }
173
182
  }
174
183
 
175
184
  /// One active indicator per bar: Background/tonal with its inner light (white 12% from below) and
@@ -14,6 +14,9 @@ public final class Navigation: ObservableObject {
14
14
  private weak var registry: DynamicScreenRegistry?
15
15
  /// What the footer (or navigation bar) takes from the window bottom; lifts snack bars.
16
16
  var bottomObstruction: CGFloat = 0
17
+ /// A tab that pads itself asks (via `floatingTabBarEdgeToEdge()`) to run edge to edge behind the floating
18
+ /// bar and the home indicator; the kit then stops reserving that space. Compose's `bottomTabEdgeToEdge`.
19
+ @Published var bottomTabEdgeToEdge = false
17
20
 
18
21
  init(
19
22
  id: Int = -1,
@@ -189,3 +192,25 @@ struct OptionsStackScreen: View {
189
192
  )
190
193
  }
191
194
  }
195
+
196
+ // MARK: - Edge-to-edge tab content
197
+
198
+ public extension View {
199
+ /// Compose's `floatingTabBarContentPadding()`: the content of a `BottomTab` tab runs edge to edge behind
200
+ /// the floating tab bar and the home indicator, and pads its own bottom (e.g. a full-screen native view
201
+ /// with its own safe area). No effect outside a tab.
202
+ func floatingTabBarEdgeToEdge() -> some View {
203
+ modifier(FloatingTabBarEdgeToEdge())
204
+ }
205
+ }
206
+
207
+ private struct FloatingTabBarEdgeToEdge: ViewModifier {
208
+ @OptionalEnvironmentObject private var navigation: Navigation?
209
+
210
+ func body(content: Content) -> some View {
211
+ content.onAppear {
212
+ guard let navigation, navigation.bottomTabIndex != -1, !navigation.bottomTabEdgeToEdge else { return }
213
+ navigation.bottomTabEdgeToEdge = true
214
+ }
215
+ }
216
+ }
@@ -161,6 +161,16 @@ public struct StackScreen<Content: View>: View {
161
161
  && inputSearchProps == nil && !headerTransparent && !fullScreenContent
162
162
  }
163
163
 
164
+ /// Bottom room for the tab's content: clear of the floating bar, unless the tab runs edge to edge
165
+ /// (`floatingTabBarEdgeToEdge()`), when it also covers the home indicator that BottomTab keeps clear of
166
+ /// (a negative inset extends the content past the tab's frame).
167
+ private var contentBottomInset: CGFloat {
168
+ guard let navigation, navigation.bottomTabIndex != -1, navigation.bottomTabEdgeToEdge else {
169
+ return duoTabBarInsets.overlay
170
+ }
171
+ return -layout.insets.bottom
172
+ }
173
+
164
174
  /// iPhone Duo: the header leaves with the content and slides back in on a reverse scroll
165
175
  /// (RN DuoQuickReturnHeader). The side bar is drawn apart from the header, so it stays put.
166
176
  private var useQuickReturn: Bool {
@@ -379,7 +389,7 @@ public struct StackScreen<Content: View>: View {
379
389
  scrollOffset: $scrollOffset,
380
390
  scrollToTopCallback: scrollToTopCallback,
381
391
  animatedSearchInset: animatedSearchInset,
382
- bottomInset: duoTabBarInsets.overlay,
392
+ bottomInset: contentBottomInset,
383
393
  snapDistance: searchSnapDistance,
384
394
  onScrollIdle: settleHeader,
385
395
  content: { animatedHeroBody(animatedHeader) }
@@ -412,7 +422,7 @@ public struct StackScreen<Content: View>: View {
412
422
  scrollOffset: $scrollOffset,
413
423
  scrollToTopCallback: scrollToTopCallback,
414
424
  animatedSearchInset: animatedSearchInset,
415
- bottomInset: duoTabBarInsets.overlay,
425
+ bottomInset: contentBottomInset,
416
426
  snapDistance: searchSnapDistance,
417
427
  onScrollIdle: settleHeader,
418
428
  content: { duoInsetContent }
@@ -433,7 +443,7 @@ public struct StackScreen<Content: View>: View {
433
443
  scrollOffset: $scrollOffset,
434
444
  scrollToTopCallback: scrollToTopCallback,
435
445
  topInset: layout.headerHeight - layout.insets.top,
436
- bottomInset: duoTabBarInsets.overlay,
446
+ bottomInset: contentBottomInset,
437
447
  snapDistance: searchSnapDistance,
438
448
  onScrollIdle: settleHeader,
439
449
  content: content
@@ -479,7 +489,7 @@ public struct StackScreen<Content: View>: View {
479
489
  scrollOffset: $scrollOffset,
480
490
  scrollToTopCallback: scrollToTopCallback,
481
491
  animatedSearchInset: animatedSearchInset,
482
- bottomInset: duoTabBarInsets.overlay,
492
+ bottomInset: contentBottomInset,
483
493
  snapDistance: searchSnapDistance,
484
494
  onScrollIdle: settleHeader,
485
495
  content: content
@@ -561,7 +571,8 @@ private struct StackScreenContent<Content: View>: View {
561
571
  /// Room for a header the content scrolls under (iPhone Duo glass header).
562
572
  var topInset: CGFloat = 0
563
573
  /// Room for the floating tab bar that overlays the content: scrolling content runs under it and
564
- /// ends clear of it, static content stays above it.
574
+ /// ends clear of it, static content stays above it. Negative for an edge-to-edge tab: the content
575
+ /// reaches that far past its frame.
565
576
  var bottomInset: CGFloat = 0
566
577
  /// Compose's animated-search snap: a scroll that comes to rest part way through this distance
567
578
  /// finishes the move, up or back down.
@@ -622,6 +633,8 @@ private struct StackScreenContent<Content: View>: View {
622
633
  }
623
634
  }
624
635
  .coordinateSpace(name: scrollSpace)
636
+ // an edge-to-edge tab's scroll reaches past its frame, under the home indicator
637
+ .padding(.bottom, min(bottomInset, 0))
625
638
  .modifier(ScrollRest(offset: scrollOffset, onRest: scrollDidRest))
626
639
  // Status-bar tap (MoMoStatusBarTap swizzle) scrolls to top and notifies the consumer.
627
640
  .onReceive(NotificationCenter.default.publisher(for: MoMoStatusBarTap.notificationName)) { _ in
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKits'
3
- s.version = '0.169.8'
3
+ s.version = '0.169.9'
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.169.8'
3
+ s.version = '0.169.9'
4
4
  s.summary = 'Demo browser for MoMoUIKits SwiftUI components'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
@@ -39,6 +39,8 @@ private struct DemoConfig: Hashable {
39
39
  var initialRouteName = "Momo"
40
40
  var compressionBehavior: DuoBarCompressionBehavior = .toolbar
41
41
  var backToInitialTab = true
42
+ // a sticky footer in the tab's content body, to check it clears the floating bar
43
+ var footer = false
42
44
 
43
45
  var visibleTabs: [TabConfig] { Array(tabs.prefix(tabCount)) }
44
46
  }
@@ -107,7 +109,10 @@ struct BottomTabDemoContent: View {
107
109
  icon: tab.icon,
108
110
  showDot: tab.showDot,
109
111
  badgeLabel: tab.badgeLabel,
110
- options: NavigationOptions(headerTitle: .default(tab.label)),
112
+ options: NavigationOptions(
113
+ headerTitle: .default(tab.label),
114
+ footer: config.footer ? { AnyView(demoFooter) } : nil
115
+ ),
111
116
  screen: { TabContent(name: tab.name, config: $config, focused: $focused) }
112
117
  )
113
118
  },
@@ -124,6 +129,10 @@ struct BottomTabDemoContent: View {
124
129
  .onAppear { ctaLottieLoader.load() }
125
130
  }
126
131
 
132
+ private var demoFooter: some View {
133
+ MoMoUIKits.Button(title: "Footer trong content", action: {}, isFull: true)
134
+ }
135
+
127
136
  private var floatingButton: BottomTabFloatingButton? {
128
137
  guard config.special else { return nil }
129
138
  guard config.ctaLottie else {
@@ -202,6 +211,9 @@ private struct TabContent: View {
202
211
  ])
203
212
  Options(title: "backToInitialTab", hint: "Back ở tab khác quay về tab đầu trước khi rời màn",
204
213
  options: yesNo(config.backToInitialTab) { config.backToInitialTab = $0 })
214
+ Options(title: "footer",
215
+ hint: "Footer dính trong content body, kiểm tra nó nằm trên thanh tab nổi",
216
+ options: yesNo(config.footer) { config.footer = $0 })
205
217
  }
206
218
 
207
219
  Section(title: "Nút giữa (floatingButton)") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.169.8",
3
+ "version": "0.169.9",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "publish:local": "bash publish.sh local"