@momo-kits/native-kits 0.168.1-beta.32-debug → 0.168.1-beta.33
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/CLAUDE.md +1 -0
- package/ios/Input/Input.swift +3 -1
- package/ios/Input/InputTextArea.swift +3 -1
- package/ios/Navigation/BottomTab/BottomTab.swift +67 -48
- package/ios/Navigation/BottomTab/BottomTabBar.swift +131 -281
- package/ios/Navigation/BottomTab/CurvedContainer.swift +47 -51
- package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +364 -0
- package/ios/Navigation/BottomTab/DuoTabBar.swift +292 -72
- package/ios/Navigation/Component/HeaderRight.swift +1 -1
- package/ios/Navigation/StackScreen.swift +1 -3
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +59 -272
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +90 -0
- package/package.json +1 -1
- package/build.gradle.kts +0 -11
- package/compose/build.gradle.kts +0 -198
- package/compose/build.gradle.kts.backup +0 -198
- package/compose/compose.podspec +0 -47
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -370
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -321
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -502
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -148
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -240
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -389
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -94
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -203
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -106
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -92
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -20
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -219
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -138
- package/gradle/libs.versions.toml +0 -69
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +0 -8
- package/gradle.properties +0 -26
- package/gradlew +0 -252
- package/gradlew.bat +0 -94
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +0 -88
- package/ios-demo/README.md +0 -120
- package/ios-demo/Resources/tabbar_scan_qr_button.json +0 -1
- package/ios-demo/Resources/tabbar_scan_qr_label.json +0 -1
- package/settings.gradle.kts +0 -64
package/CLAUDE.md
CHANGED
|
@@ -77,6 +77,7 @@ Publishing is automated (`publish.sh` + GitLab CI on `[ci build]` / `main`). Do
|
|
|
77
77
|
- iPhone Duo with a side strip ≥ 60pt: back + toolkit leave the bar for `HeaderSideBar` (`navigation/component/SideBar.kt`, 48pt glass controls); custom header-right stays in the bar. `sideBar.top` is 170pt in portrait, 120pt on the inner display in landscape (height ≥ 600), 24pt on the outer display in landscape, or below the header when the status bar is on top; UIKit's `statusBarFrame` is useless on Duo. Unlike RN the column is clamped above footer (24pt gap) / rail (12pt gap).
|
|
78
78
|
- Reserved regions (iOS 27.1 `reservedRegionsOfKind:`, reached through the ObjC runtime so older SDKs still build): a probe `UIView` (`platform/ReservedRegions.ios.kt` on the Compose root view; `ReservedRegionsProbe` inside SwiftUI `momoScreenLayout()`) re-reads them in `layoutSubviews`, which UIKit re-runs when they change. They push `sideBar.top` below the status cluster as it grows for calls / Live Activities, and `sideBar.bottom` (≥ 24pt) above a camera at the bottom end of the strip.
|
|
79
79
|
- Tab bar on Duo is `bottomtab/DuoTabBar.kt`: a rail in the side strip (`sideBar.bottom` above the window bottom, QR below it) or, without a side bar, a floating bar spanning 6/8 grid columns. Both overlay the content; `duoFloatingTabBarInset` pads tab content, footer and FAB.
|
|
80
|
+
- Duo tab selection motion (`bottomtab/DuoLiquidSelection.kt` / `ios/Navigation/BottomTab/DuoLiquidSelection.swift`, port of RN `useLiquidSelection.ts`, momo-kits !682): press lifts the lens, a drag past 10pt takes over (Compose: the bar's `pointerInput` consumes and so cancels the tab's clickable; SwiftUI: one `DragGesture` over the bar, tabs are not `Button`s), long press calls `BottomTab(onTabLongPress)` and release still selects, Reduce Motion (`platform/ReduceMotion`) falls back to a plain slide. SwiftUI integrates the lens spring on a display link because the stretch and the tabs' active tint read it every frame. Constants mirror RN — change both together.
|
|
80
81
|
- Bar compression (`bottomtab/DuoBarCompression.kt`, HIG "Vertical controls"): when toolbar + rail don't fit in the strip, one is compressed — the toolkit into a `navigation_menu` button, the rail into one button showing the current tab — and tapping it swaps them; `BottomTab(compressionBehavior)` picks which starts compressed. If neither fits beside the other compressed, both rest compressed and a tap opens one for a moment. Side bar columns report their full height (0 when the screen puts nothing there) so the decision follows each screen's toolkit.
|
|
81
82
|
- Glass header: on Duo with a side bar, Default/Extended headers without search and with a `ScrollState` let content scroll under the bar (`usesDuoGlassHeader`); the bar fades in a translucent surface + hairline over 16pt (Compose has no backdrop blur — RN's fallback look), the gradient leaves with the content.
|
|
82
83
|
- Quick return header: glass headers and Animated headers (with a `ScrollState`) on the Duo side bar layout slide out with the content and back in on a reverse scroll; a half-shown header settles in or out once the scroll stops. The side bar is drawn apart from the header, so it stays put.
|
package/ios/Input/Input.swift
CHANGED
|
@@ -252,7 +252,9 @@ public struct Input: View {
|
|
|
252
252
|
}
|
|
253
253
|
.padding(.horizontal, Spacing.S)
|
|
254
254
|
.background(theme.colors.background.surface)
|
|
255
|
-
|
|
255
|
+
// A zero-height frame on the top edge centers the label on the border, re-laid out with font scale.
|
|
256
|
+
.fixedSize(horizontal: false, vertical: true)
|
|
257
|
+
.frame(height: 0)
|
|
256
258
|
.offset(x: Spacing.S)
|
|
257
259
|
}
|
|
258
260
|
}
|
|
@@ -279,7 +279,9 @@ public struct InputTextArea: View {
|
|
|
279
279
|
}
|
|
280
280
|
.padding(.horizontal, Spacing.S)
|
|
281
281
|
.background(theme.colors.background.surface)
|
|
282
|
-
|
|
282
|
+
// A zero-height frame on the top edge centers the label on the border, re-laid out with font scale.
|
|
283
|
+
.fixedSize(horizontal: false, vertical: true)
|
|
284
|
+
.frame(height: 0)
|
|
283
285
|
.offset(x: Spacing.S)
|
|
284
286
|
}
|
|
285
287
|
}
|
|
@@ -16,6 +16,7 @@ public struct BottomTab: View {
|
|
|
16
16
|
private let compressionBehavior: DuoBarCompressionBehavior
|
|
17
17
|
private let onTabPress: ((_ index: Int, _ switchTab: @escaping () -> Void) -> Void)?
|
|
18
18
|
private let backToInitialTab: Bool
|
|
19
|
+
private let onTabLongPress: ((_ index: Int) -> Void)?
|
|
19
20
|
|
|
20
21
|
@EnvironmentObject private var navigator: Navigator
|
|
21
22
|
/// The screen hosting the tabs (Compose's `LocalNavigation` in BottomTab).
|
|
@@ -34,28 +35,32 @@ public struct BottomTab: View {
|
|
|
34
35
|
/// starts compressed; tapping the compressed one swaps them.
|
|
35
36
|
/// `onTabPress` gets every tab press with the switch to perform, e.g. after a login gate.
|
|
36
37
|
/// `backToInitialTab`: back off another tab returns to the initial one before leaving the screen.
|
|
38
|
+
/// `onTabLongPress`: RN `tabLongPress`; on iPhone Duo the held tab is still selected on release.
|
|
37
39
|
public init(
|
|
38
40
|
items: [BottomTabItem],
|
|
39
41
|
floatingButton: BottomTabFloatingButton? = nil,
|
|
40
42
|
compressionBehavior: DuoBarCompressionBehavior = .toolbar,
|
|
41
43
|
initialRouteName: String? = nil,
|
|
42
44
|
onTabPress: ((_ index: Int, _ switchTab: @escaping () -> Void) -> Void)? = nil,
|
|
43
|
-
backToInitialTab: Bool = true
|
|
45
|
+
backToInitialTab: Bool = true,
|
|
46
|
+
onTabLongPress: ((_ index: Int) -> Void)? = nil
|
|
44
47
|
) {
|
|
45
48
|
self.items = items
|
|
46
49
|
self.floatingButton = floatingButton
|
|
47
50
|
self.compressionBehavior = compressionBehavior
|
|
48
51
|
self.onTabPress = onTabPress
|
|
49
52
|
self.backToInitialTab = backToInitialTab
|
|
53
|
+
self.onTabLongPress = onTabLongPress
|
|
50
54
|
let start = items.firstIndex { $0.name == initialRouteName } ?? 0
|
|
51
55
|
_startIndex = State(initialValue: start)
|
|
52
56
|
_selectedIndex = State(initialValue: start)
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
private var bottomInset: CGFloat { safeAreaBottomInset() }
|
|
56
|
-
// the bars
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
// the Duo bars overlay the content or sit in the side strip, so only the home indicator is kept clear
|
|
61
|
+
private var reservedBottom: CGFloat {
|
|
62
|
+
layout.isIPhoneDuo ? layout.insets.bottom : BOTTOM_TAB_BAR_HEIGHT + bottomInset + Spacing.S
|
|
63
|
+
}
|
|
59
64
|
|
|
60
65
|
private var compression: DuoBarCompression {
|
|
61
66
|
DuoBarCompression.resolve(
|
|
@@ -100,16 +105,30 @@ public struct BottomTab: View {
|
|
|
100
105
|
floatingButton: floatingButton,
|
|
101
106
|
selectedIndex: selectedIndex,
|
|
102
107
|
onTabSelected: selectTab,
|
|
103
|
-
compression: compression
|
|
108
|
+
compression: compression,
|
|
109
|
+
onTabLongPress: onTabLongPress,
|
|
110
|
+
onTick: { [maxApi = navigator.maxApi] in
|
|
111
|
+
if let maxApi {
|
|
112
|
+
maxApi.triggerEventVibration("light")
|
|
113
|
+
} else {
|
|
114
|
+
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
|
115
|
+
}
|
|
116
|
+
}
|
|
104
117
|
)
|
|
105
118
|
} else {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
119
|
+
// Tab bar + home-indicator filler.
|
|
120
|
+
VStack(spacing: 0) {
|
|
121
|
+
BottomTabBar(
|
|
122
|
+
items: items,
|
|
123
|
+
floatingButton: floatingButton,
|
|
124
|
+
selectedIndex: selectedIndex,
|
|
125
|
+
onTabSelected: selectTab,
|
|
126
|
+
onTabLongPress: onTabLongPress
|
|
127
|
+
)
|
|
128
|
+
theme.colors.background.surface
|
|
129
|
+
.frame(height: bottomInset + Spacing.S)
|
|
130
|
+
.ignoresSafeArea(edges: .horizontal)
|
|
131
|
+
}
|
|
113
132
|
}
|
|
114
133
|
}
|
|
115
134
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
@@ -131,7 +150,6 @@ public struct BottomTab: View {
|
|
|
131
150
|
}
|
|
132
151
|
|
|
133
152
|
private func selectTab(_ index: Int) {
|
|
134
|
-
navigator.maxApi?.triggerEventVibration("light")
|
|
135
153
|
let switchTab = { if index != selectedIndex { selectedIndex = index } }
|
|
136
154
|
if let onTabPress { onTabPress(index, switchTab) } else { switchTab() }
|
|
137
155
|
}
|
|
@@ -203,11 +221,11 @@ private struct TabHost: UIViewControllerRepresentable {
|
|
|
203
221
|
|
|
204
222
|
private final class TabController: UIViewController {
|
|
205
223
|
private final class Tab {
|
|
224
|
+
let motion = TabMotion()
|
|
206
225
|
var host: UIHostingController<AnyView>!
|
|
207
226
|
}
|
|
208
227
|
|
|
209
|
-
|
|
210
|
-
private static let switchDuration: TimeInterval = 0.28
|
|
228
|
+
private static let switchDuration: TimeInterval = 0.2
|
|
211
229
|
|
|
212
230
|
private var tabs: [Int: Tab] = [:]
|
|
213
231
|
private var selectedIndex: Int?
|
|
@@ -221,7 +239,7 @@ private final class TabController: UIViewController {
|
|
|
221
239
|
|
|
222
240
|
override func viewDidLayoutSubviews() {
|
|
223
241
|
super.viewDidLayoutSubviews()
|
|
224
|
-
for subview in view.subviews {
|
|
242
|
+
for subview in view.subviews { subview.frame = view.bounds }
|
|
225
243
|
}
|
|
226
244
|
|
|
227
245
|
func update(
|
|
@@ -238,43 +256,33 @@ private final class TabController: UIViewController {
|
|
|
238
256
|
}
|
|
239
257
|
if let selectedIndex, tabs[selectedIndex] == nil { self.selectedIndex = nil }
|
|
240
258
|
// hidden tabs too, so a tab coming back already shows the latest items and environment
|
|
241
|
-
for (tabIndex, existing) in tabs { existing.host.rootView = rootView(tabIndex) }
|
|
259
|
+
for (tabIndex, existing) in tabs { existing.host.rootView = rootView(tabIndex, existing) }
|
|
242
260
|
guard (0..<count).contains(index), index != selectedIndex else { return }
|
|
243
261
|
|
|
244
|
-
let
|
|
245
|
-
let previous = previousIndex.flatMap { tabs[$0] }
|
|
262
|
+
let previous = selectedIndex.flatMap { tabs[$0] }
|
|
246
263
|
selectedIndex = index
|
|
247
264
|
let selected = tabs[index] ?? makeTab(index)
|
|
248
|
-
// a tab selected again while it leaves carries on from where it is
|
|
249
|
-
let entering = selected.host.view.superview == nil
|
|
250
265
|
attach(selected)
|
|
251
266
|
|
|
252
|
-
guard let previous,
|
|
253
|
-
selected.
|
|
267
|
+
guard let previous, view.window != nil else {
|
|
268
|
+
selected.motion.visible = true
|
|
254
269
|
previous.map(leave)
|
|
255
270
|
return
|
|
256
271
|
}
|
|
257
272
|
previous.host.view.isUserInteractionEnabled = false
|
|
258
|
-
|
|
259
|
-
if entering { selected.host.view.transform = CGAffineTransform(translationX: offset, y: 0) }
|
|
260
|
-
// a frame at the start values first, so a tab created just now slides in with its content
|
|
273
|
+
// a frame at the start values first, so a tab created just now fades in too
|
|
261
274
|
DispatchQueue.main.async {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
)
|
|
267
|
-
selected.host.view.transform = .identity
|
|
268
|
-
previous.host.view.transform = CGAffineTransform(translationX: -offset, y: 0)
|
|
269
|
-
}
|
|
270
|
-
animator.addCompletion { [weak self] _ in self?.leave(previous) }
|
|
271
|
-
animator.startAnimation()
|
|
275
|
+
selected.motion.visible = true
|
|
276
|
+
previous.motion.visible = false
|
|
277
|
+
}
|
|
278
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + Self.switchDuration) { [weak self] in
|
|
279
|
+
self?.leave(previous)
|
|
272
280
|
}
|
|
273
281
|
}
|
|
274
282
|
|
|
275
283
|
private func makeTab(_ index: Int) -> Tab {
|
|
276
284
|
let tab = Tab()
|
|
277
|
-
let host = UIHostingController(rootView: rootView(index))
|
|
285
|
+
let host = UIHostingController(rootView: rootView(index, tab))
|
|
278
286
|
host.view.backgroundColor = .clear
|
|
279
287
|
addChild(host)
|
|
280
288
|
host.didMove(toParent: self)
|
|
@@ -283,20 +291,14 @@ private final class TabController: UIViewController {
|
|
|
283
291
|
return tab
|
|
284
292
|
}
|
|
285
293
|
|
|
286
|
-
private func rootView(_ index: Int) -> AnyView {
|
|
287
|
-
AnyView(content(index).environment(\.self, environment))
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/// Bounds and center, a sliding tab carries a transform that frame doesn't work with.
|
|
291
|
-
private func place(_ subview: UIView) {
|
|
292
|
-
subview.bounds = view.bounds
|
|
293
|
-
subview.center = CGPoint(x: view.bounds.midX, y: view.bounds.midY)
|
|
294
|
+
private func rootView(_ index: Int, _ tab: Tab) -> AnyView {
|
|
295
|
+
AnyView(TabCard(motion: tab.motion, content: content(index)).environment(\.self, environment))
|
|
294
296
|
}
|
|
295
297
|
|
|
296
298
|
private func attach(_ tab: Tab) {
|
|
297
299
|
let hostView: UIView = tab.host.view
|
|
298
300
|
hostView.isUserInteractionEnabled = true
|
|
299
|
-
|
|
301
|
+
hostView.frame = view.bounds
|
|
300
302
|
if hostView.superview === view {
|
|
301
303
|
view.bringSubviewToFront(hostView)
|
|
302
304
|
} else {
|
|
@@ -308,7 +310,6 @@ private final class TabController: UIViewController {
|
|
|
308
310
|
private func leave(_ tab: Tab) {
|
|
309
311
|
guard selectedIndex.flatMap({ tabs[$0] }) !== tab else { return }
|
|
310
312
|
tab.host.view.removeFromSuperview()
|
|
311
|
-
tab.host.view.transform = .identity
|
|
312
313
|
}
|
|
313
314
|
|
|
314
315
|
private func tearDown(_ tab: Tab) {
|
|
@@ -318,9 +319,27 @@ private final class TabController: UIViewController {
|
|
|
318
319
|
}
|
|
319
320
|
}
|
|
320
321
|
|
|
322
|
+
private final class TabMotion: ObservableObject {
|
|
323
|
+
@Published var visible = false
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/// The tab switch: 0.97 scale + fade over 200ms, both ways (Compose's tab enter / exit transitions).
|
|
327
|
+
private struct TabCard: View {
|
|
328
|
+
@ObservedObject var motion: TabMotion
|
|
329
|
+
let content: AnyView
|
|
330
|
+
|
|
331
|
+
var body: some View {
|
|
332
|
+
content
|
|
333
|
+
.opacity(motion.visible ? 1 : 0)
|
|
334
|
+
.scaleEffect(motion.visible ? 1 : 0.97)
|
|
335
|
+
.animation(.easeInOut(duration: 0.2), value: motion.visible)
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
321
339
|
/// Bottom safe-area inset (home indicator).
|
|
322
340
|
private func safeAreaBottomInset() -> CGFloat {
|
|
323
|
-
UIApplication.shared.connectedScenes
|
|
341
|
+
let bottomInset = UIApplication.shared.connectedScenes
|
|
324
342
|
.compactMap { ($0 as? UIWindowScene)?.keyWindow?.safeAreaInsets.bottom }
|
|
325
343
|
.first ?? 0
|
|
344
|
+
return min(bottomInset, 21)
|
|
326
345
|
}
|