@momo-kits/native-kits 0.169.8-beta.6 → 0.169.8-beta.7
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.
- package/ios/Navigation/BottomTab/BottomTabBar.swift +9 -0
- package/ios/Navigation/Navigation.swift +25 -0
- package/ios/Navigation/StackScreen.swift +18 -5
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +13 -1
- package/package.json +1 -1
|
@@ -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,
|
|
@@ -194,3 +197,25 @@ struct OptionsStackScreen: View {
|
|
|
194
197
|
)
|
|
195
198
|
}
|
|
196
199
|
}
|
|
200
|
+
|
|
201
|
+
// MARK: - Edge-to-edge tab content
|
|
202
|
+
|
|
203
|
+
public extension View {
|
|
204
|
+
/// Compose's `floatingTabBarContentPadding()`: the content of a `BottomTab` tab runs edge to edge behind
|
|
205
|
+
/// the floating tab bar and the home indicator, and pads its own bottom (e.g. a full-screen native view
|
|
206
|
+
/// with its own safe area). No effect outside a tab.
|
|
207
|
+
func floatingTabBarEdgeToEdge() -> some View {
|
|
208
|
+
modifier(FloatingTabBarEdgeToEdge())
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
private struct FloatingTabBarEdgeToEdge: ViewModifier {
|
|
213
|
+
@OptionalEnvironmentObject private var navigation: Navigation?
|
|
214
|
+
|
|
215
|
+
func body(content: Content) -> some View {
|
|
216
|
+
content.onAppear {
|
|
217
|
+
guard let navigation, navigation.bottomTabIndex != -1, !navigation.bottomTabEdgeToEdge else { return }
|
|
218
|
+
navigation.bottomTabEdgeToEdge = true
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -164,6 +164,16 @@ public struct StackScreen<Content: View>: View {
|
|
|
164
164
|
&& inputSearchProps == nil && !headerTransparent && !fullScreenContent
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
/// Bottom room for the tab's content: clear of the floating bar, unless the tab runs edge to edge
|
|
168
|
+
/// (`floatingTabBarEdgeToEdge()`), when it also covers the home indicator that BottomTab keeps clear of
|
|
169
|
+
/// (a negative inset extends the content past the tab's frame).
|
|
170
|
+
private var contentBottomInset: CGFloat {
|
|
171
|
+
guard let navigation, navigation.bottomTabIndex != -1, navigation.bottomTabEdgeToEdge else {
|
|
172
|
+
return duoTabBarInsets.overlay
|
|
173
|
+
}
|
|
174
|
+
return -layout.insets.bottom
|
|
175
|
+
}
|
|
176
|
+
|
|
167
177
|
/// iPhone Duo: the header leaves with the content and slides back in on a reverse scroll
|
|
168
178
|
/// (RN DuoQuickReturnHeader). The side bar is drawn apart from the header, so it stays put.
|
|
169
179
|
private var useQuickReturn: Bool {
|
|
@@ -383,7 +393,7 @@ public struct StackScreen<Content: View>: View {
|
|
|
383
393
|
scrollOffset: $scrollOffset,
|
|
384
394
|
scrollToTopCallback: scrollToTopCallback,
|
|
385
395
|
animatedSearchInset: animatedSearchInset,
|
|
386
|
-
bottomInset:
|
|
396
|
+
bottomInset: contentBottomInset,
|
|
387
397
|
snapDistance: searchSnapDistance,
|
|
388
398
|
onScrollIdle: settleHeader,
|
|
389
399
|
content: { animatedHeroBody(animatedHeader) }
|
|
@@ -416,7 +426,7 @@ public struct StackScreen<Content: View>: View {
|
|
|
416
426
|
scrollOffset: $scrollOffset,
|
|
417
427
|
scrollToTopCallback: scrollToTopCallback,
|
|
418
428
|
animatedSearchInset: animatedSearchInset,
|
|
419
|
-
bottomInset:
|
|
429
|
+
bottomInset: contentBottomInset,
|
|
420
430
|
snapDistance: searchSnapDistance,
|
|
421
431
|
onScrollIdle: settleHeader,
|
|
422
432
|
content: { duoInsetContent }
|
|
@@ -437,7 +447,7 @@ public struct StackScreen<Content: View>: View {
|
|
|
437
447
|
scrollOffset: $scrollOffset,
|
|
438
448
|
scrollToTopCallback: scrollToTopCallback,
|
|
439
449
|
topInset: layout.headerHeight - layout.insets.top,
|
|
440
|
-
bottomInset:
|
|
450
|
+
bottomInset: contentBottomInset,
|
|
441
451
|
snapDistance: searchSnapDistance,
|
|
442
452
|
onScrollIdle: settleHeader,
|
|
443
453
|
content: content
|
|
@@ -483,7 +493,7 @@ public struct StackScreen<Content: View>: View {
|
|
|
483
493
|
scrollOffset: $scrollOffset,
|
|
484
494
|
scrollToTopCallback: scrollToTopCallback,
|
|
485
495
|
animatedSearchInset: animatedSearchInset,
|
|
486
|
-
bottomInset:
|
|
496
|
+
bottomInset: contentBottomInset,
|
|
487
497
|
snapDistance: searchSnapDistance,
|
|
488
498
|
onScrollIdle: settleHeader,
|
|
489
499
|
content: content
|
|
@@ -575,7 +585,8 @@ private struct StackScreenContent<Content: View>: View {
|
|
|
575
585
|
/// Room for a header the content scrolls under (iPhone Duo glass header).
|
|
576
586
|
var topInset: CGFloat = 0
|
|
577
587
|
/// Room for the floating tab bar that overlays the content: scrolling content runs under it and
|
|
578
|
-
/// ends clear of it, static content stays above it.
|
|
588
|
+
/// ends clear of it, static content stays above it. Negative for an edge-to-edge tab: the content
|
|
589
|
+
/// reaches that far past its frame.
|
|
579
590
|
var bottomInset: CGFloat = 0
|
|
580
591
|
/// Compose's animated-search snap: a scroll that comes to rest part way through this distance
|
|
581
592
|
/// finishes the move, up or back down.
|
|
@@ -636,6 +647,8 @@ private struct StackScreenContent<Content: View>: View {
|
|
|
636
647
|
}
|
|
637
648
|
}
|
|
638
649
|
.coordinateSpace(name: scrollSpace)
|
|
650
|
+
// an edge-to-edge tab's scroll reaches past its frame, under the home indicator
|
|
651
|
+
.padding(.bottom, min(bottomInset, 0))
|
|
639
652
|
.modifier(ScrollRest(offset: scrollOffset, onRest: scrollDidRest))
|
|
640
653
|
// Status-bar tap (MoMoStatusBarTap swizzle) scrolls to top and notifies the consumer.
|
|
641
654
|
.onReceive(NotificationCenter.default.publisher(for: MoMoStatusBarTap.notificationName)) { _ in
|
package/ios/native-kits.podspec
CHANGED
|
@@ -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(
|
|
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)") {
|