@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.
- package/CLAUDE.md +2 -1
- package/ios/Input/Input.swift +3 -1
- package/ios/Input/InputTextArea.swift +3 -1
- package/ios/Navigation/BottomTab/BottomTab.swift +33 -14
- package/ios/Navigation/BottomTab/BottomTabBar.swift +131 -254
- package/ios/Navigation/BottomTab/CurvedContainer.swift +47 -51
- package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +364 -0
- package/ios/Navigation/BottomTab/DuoTabBar.swift +292 -71
- package/ios/Navigation/StackScreen.swift +1 -3
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +59 -224
- 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 -153
- 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 -224
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -383
- 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 -91
- 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 -74
- 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 -218
- 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/local.properties +0 -9
- package/settings.gradle.kts +0 -64
package/CLAUDE.md
CHANGED
|
@@ -71,12 +71,13 @@ Publishing is automated (`publish.sh` + GitLab CI on `[ci build]` / `main`). Do
|
|
|
71
71
|
## Screen layout / iPhone Duo (port of RN `useScreenLayout`, momo-kits !664)
|
|
72
72
|
|
|
73
73
|
- `layout/ScreenLayout.kt`: `getScreenLayout()` returns window size, raw top/bottom + side insets, `contentWidth`, header geometry, the iPhone Duo `sideBar` and `duoTopInset`. `NavigationContainer` computes it once and provides `LocalScreenLayout`; reactive to fold/unfold and rotation (window size + `WindowInsets`). Metrics (`DuoMetrics`, 72pt iPhone header floor, 20pt status-bar threshold) mirror RN `Layout/utils.ts` — change both together.
|
|
74
|
-
- iPhone-only: everything gates on `isPhoneIdiom()` (`platform/`), never on "iOS", so iPad windows keep the regular layout. Two detectors, as in RN: `isIPhoneDuo` (window aspect < 1.6 or asymmetric side insets) drives layout; `isIPhoneDuoDevice` (Apple's foldable check: a `.division` reserved region, queried with include-inactive; Swift also latches on `UIHingeInteraction`; or asymmetric side insets, since the outer display reports no hinge) drives popups, modal and bottom sheet.
|
|
74
|
+
- iPhone-only: everything gates on `isPhoneIdiom()` (`platform/`), never on "iOS", so iPad windows keep the regular layout. Two detectors, as in RN: `isIPhoneDuo` (window aspect < 1.6 or asymmetric side insets) drives layout; `isIPhoneDuoDevice` (Apple's foldable check: a `.division` reserved region, queried with include-inactive; Swift also latches on `UIHingeInteraction`; or asymmetric side insets, since the outer display reports no hinge; on Android the hinge angle sensor feature, so foldables get the sizes but no side strip or side column) drives popups, modal and bottom sheet.
|
|
75
75
|
- Header height is `headerHeight` (not `AppStatusBar + HEADER_HEIGHT`); the bar row is `headerBarHeight` and starts `headerStatusBarHeight` below the window top. When the status bar is off the top edge (iPhone landscape, iPhone Duo) `headerStatusBarHeight` is 0 so the title stays centered — except on the Duo outer display: in portrait the header is 76pt and the row starts at 14pt so the title centers on the camera punchout; in landscape the row centers on the camera when it sits at the top end of the strip (else on the back button) and the header reaches 8pt below the back button.
|
|
76
76
|
- iPhone Duo inner display in portrait (status bar on top): the header row shares the status bar band — `headerHeight` 94pt (2 × the clock digits' y 47), `headerStatusBarHeight` 0 — and `ScreenLayout.statusBarClearance` keeps it between the clock / battery clusters (from reserved regions, else 128pt on the right). Back and toolkit use the 48pt side bar controls laid out horizontally (`ToolkitLayout.SideBarRow`); the collapsed search and a centered title stay clear of the clusters. Port of momo-kits `90af33ba2`.
|
|
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
|
}
|
|
@@ -320,7 +338,8 @@ private struct TabCard: View {
|
|
|
320
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
|
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// MoMoUIKits
|
|
4
4
|
//
|
|
5
5
|
// SwiftUI mirror of Compose's `navigation/bottomtab/BottomTabBar.kt`.
|
|
6
|
-
//
|
|
7
|
-
//
|
|
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).
|
|
8
8
|
//
|
|
9
9
|
|
|
10
10
|
import SwiftUI
|
|
@@ -57,311 +57,188 @@ public struct BottomTabFloatingButton {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
let
|
|
60
|
+
let bottomTabFloatingButtonWidth: CGFloat = 75
|
|
61
|
+
let BOTTOM_TAB_BAR_HEIGHT: CGFloat = 64
|
|
61
62
|
|
|
62
63
|
// MARK: - Tab bar
|
|
63
64
|
|
|
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
|
-
|
|
70
|
+
var onTabLongPress: ((Int) -> Void)?
|
|
71
71
|
|
|
72
72
|
@Environment(\.screenLayout) private var layout
|
|
73
|
+
@Environment(\.appTheme) private var theme
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
}
|
|
86
|
-
|
|
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
|
|
75
|
+
// the bar sits between the side safe areas
|
|
76
|
+
private var screenWidth: CGFloat { layout.width - layout.insets.leading - layout.insets.trailing }
|
|
77
|
+
private var mid: Int { items.count / 2 }
|
|
97
78
|
|
|
98
|
-
private var
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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)
|
|
79
|
+
private var tabWidth: CGFloat {
|
|
80
|
+
if floatingButton != nil {
|
|
81
|
+
return (screenWidth - bottomTabFloatingButtonWidth) / CGFloat(items.count)
|
|
82
|
+
}
|
|
83
|
+
return screenWidth / CGFloat(items.count)
|
|
107
84
|
}
|
|
108
85
|
|
|
109
|
-
private
|
|
110
|
-
let
|
|
111
|
-
return
|
|
112
|
-
+ (afterCta ? TabBarMetrics.ctaSlotWidth + TabBarMetrics.itemGap : 0)
|
|
86
|
+
private var indicatorOffset: CGFloat {
|
|
87
|
+
let adjust: CGFloat = (floatingButton != nil && selectedIndex >= mid) ? bottomTabFloatingButtonWidth : 0
|
|
88
|
+
return tabWidth * CGFloat(selectedIndex) + tabWidth / 2 - screenWidth / 2 + adjust
|
|
113
89
|
}
|
|
114
90
|
|
|
115
91
|
var body: some View {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
}
|
|
92
|
+
ZStack(alignment: .bottom) {
|
|
93
|
+
HStack(spacing: 0) {
|
|
94
|
+
if floatingButton == nil {
|
|
95
|
+
tabItems(from: 0, to: items.count)
|
|
96
|
+
} else {
|
|
97
|
+
tabItems(from: 0, to: mid)
|
|
98
|
+
Spacer()
|
|
99
|
+
.frame(width: bottomTabFloatingButtonWidth)
|
|
100
|
+
.padding(.horizontal, Spacing.XXS)
|
|
101
|
+
tabItems(from: mid, to: items.count)
|
|
140
102
|
}
|
|
141
|
-
.padding(.horizontal, TabBarMetrics.paddingHorizontal)
|
|
142
|
-
.padding(.vertical, TabBarMetrics.paddingVertical)
|
|
143
103
|
}
|
|
144
|
-
.frame(
|
|
145
|
-
.
|
|
146
|
-
.
|
|
147
|
-
|
|
148
|
-
|
|
104
|
+
.frame(maxWidth: .infinity)
|
|
105
|
+
.frame(height: BOTTOM_TAB_BAR_HEIGHT)
|
|
106
|
+
.background(theme.colors.background.surface.ignoresSafeArea(edges: .horizontal))
|
|
107
|
+
|
|
108
|
+
// Animated selection indicator.
|
|
109
|
+
RoundedRectangle(cornerRadius: 2)
|
|
110
|
+
.fill(theme.colors.primary)
|
|
111
|
+
.frame(width: 44, height: 2)
|
|
112
|
+
.offset(x: indicatorOffset, y: -BOTTOM_TAB_BAR_HEIGHT + 2)
|
|
113
|
+
.animation(.easeInOut(duration: 0.25), value: selectedIndex)
|
|
114
|
+
|
|
115
|
+
// Top shadow.
|
|
116
|
+
LinearGradient(
|
|
117
|
+
colors: [Color.black.opacity(0.05), .clear],
|
|
118
|
+
startPoint: .bottom,
|
|
119
|
+
endPoint: .top
|
|
120
|
+
)
|
|
121
|
+
.frame(height: 6)
|
|
122
|
+
.frame(maxWidth: .infinity)
|
|
123
|
+
.offset(y: -BOTTOM_TAB_BAR_HEIGHT)
|
|
149
124
|
|
|
150
|
-
if let
|
|
151
|
-
|
|
125
|
+
if let floatingButton {
|
|
126
|
+
CenterFloatingButton(data: floatingButton)
|
|
152
127
|
}
|
|
153
128
|
}
|
|
154
|
-
.frame(width: width)
|
|
155
129
|
}
|
|
156
|
-
}
|
|
157
|
-
|
|
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
130
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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)
|
|
131
|
+
@ViewBuilder
|
|
132
|
+
private func tabItems(from: Int, to: Int) -> some View {
|
|
133
|
+
ForEach(from..<to, id: \.self) { index in
|
|
134
|
+
TabBarItem(
|
|
135
|
+
item: items[index],
|
|
136
|
+
selected: index == selectedIndex,
|
|
137
|
+
// from the icon's center to the cell's end edge, inside both XXS paddings
|
|
138
|
+
badgeMaxWidth: tabWidth / 2 - Spacing.XXS * 2,
|
|
139
|
+
onClick: { onTabSelected(index) },
|
|
140
|
+
onLongClick: onTabLongPress.map { callback in { callback(index) } }
|
|
182
141
|
)
|
|
183
|
-
.
|
|
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)
|
|
142
|
+
.frame(maxWidth: .infinity)
|
|
143
|
+
}
|
|
195
144
|
}
|
|
196
145
|
}
|
|
197
146
|
|
|
198
147
|
// MARK: - Tab item
|
|
199
148
|
|
|
200
|
-
|
|
201
|
-
/// slots; the icon and label tint cross-fade on focus.
|
|
202
|
-
struct TabItemContent: View {
|
|
149
|
+
private struct TabBarItem: View {
|
|
203
150
|
let item: BottomTabItem
|
|
204
151
|
let selected: Bool
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
152
|
+
let badgeMaxWidth: CGFloat
|
|
153
|
+
let onClick: () -> Void
|
|
154
|
+
let onLongClick: (() -> Void)?
|
|
208
155
|
|
|
209
156
|
@Environment(\.appTheme) private var theme
|
|
210
157
|
|
|
211
|
-
var
|
|
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
|
-
}
|
|
158
|
+
private var tintColor: Color { selected ? theme.colors.primary : theme.colors.text.hint }
|
|
224
159
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
textAlign: .center,
|
|
231
|
-
maxLines: 1
|
|
232
|
-
)
|
|
233
|
-
.truncationMode(.tail)
|
|
160
|
+
/// Mirrors Compose's `formatLabel`: hide a badge that is the number "0".
|
|
161
|
+
private var badgeLabel: String? {
|
|
162
|
+
guard let label = item.badgeLabel else { return nil }
|
|
163
|
+
if let n = Int(label), n == 0 { return nil }
|
|
164
|
+
return label
|
|
234
165
|
}
|
|
235
|
-
}
|
|
236
|
-
|
|
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
|
|
245
|
-
}
|
|
246
|
-
return label
|
|
247
|
-
}
|
|
248
|
-
|
|
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
|
|
255
|
-
|
|
256
|
-
@Environment(\.appTheme) private var theme
|
|
257
166
|
|
|
258
167
|
var body: some View {
|
|
259
|
-
|
|
260
|
-
Icon(source: item.icon, size:
|
|
261
|
-
.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if let badge = tabBadgeLabel(item) {
|
|
269
|
-
if badge.isEmpty {
|
|
270
|
-
BadgeDot(size: .small)
|
|
271
|
-
.offset(x: vertical ? 16 - (TabBarMetrics.iconSize - 10) / 2 : 16, y: -Spacing.XXS)
|
|
272
|
-
} else {
|
|
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)
|
|
168
|
+
VStack(spacing: 0) {
|
|
169
|
+
Icon(source: item.icon, size: 28, color: tintColor)
|
|
170
|
+
.overlay(alignment: .topLeading) {
|
|
171
|
+
// starts at the icon's center and grows toward the cell's end edge, ellipsized past it
|
|
172
|
+
if let badgeLabel, !badgeLabel.isEmpty {
|
|
173
|
+
Badge(label: badgeLabel)
|
|
174
|
+
.frame(width: max(badgeMaxWidth, 0), alignment: .leading)
|
|
175
|
+
.offset(x: 14, y: -Spacing.S)
|
|
176
|
+
}
|
|
277
177
|
}
|
|
278
|
-
|
|
178
|
+
.overlay(alignment: .topTrailing) {
|
|
179
|
+
if badgeLabel?.isEmpty == true || (badgeLabel == nil && item.showDot) {
|
|
180
|
+
BadgeDot(size: .small).offset(x: 4, y: -4)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
.padding(Spacing.XS)
|
|
184
|
+
MomoText(
|
|
185
|
+
item.label,
|
|
186
|
+
typography: selected ? .labelXsMedium : .descriptionXsRegular,
|
|
187
|
+
color: tintColor,
|
|
188
|
+
textAlign: .center,
|
|
189
|
+
maxLines: 1
|
|
190
|
+
)
|
|
191
|
+
.truncationMode(.tail)
|
|
279
192
|
}
|
|
193
|
+
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
194
|
+
.padding(.horizontal, Spacing.S)
|
|
195
|
+
.padding(.vertical, Spacing.S)
|
|
196
|
+
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
197
|
+
.padding(.horizontal, Spacing.XXS)
|
|
198
|
+
.contentShape(Rectangle())
|
|
199
|
+
.onTapGesture { onClick() }
|
|
200
|
+
.modifier(TabLongPress(action: onLongClick))
|
|
280
201
|
}
|
|
281
202
|
}
|
|
282
203
|
|
|
283
|
-
///
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
let label: String
|
|
287
|
-
|
|
288
|
-
@Environment(\.appTheme) private var theme
|
|
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
|
-
}
|
|
204
|
+
/// Only attached with a callback, so a held tab without one still selects on release.
|
|
205
|
+
private struct TabLongPress: ViewModifier {
|
|
206
|
+
let action: (() -> Void)?
|
|
294
207
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
.
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
.background(Capsule().fill(isNumber ? theme.colors.error.primary : theme.colors.warning.primary))
|
|
302
|
-
.overlay(Capsule().strokeBorder(theme.colors.background.surface, lineWidth: 1))
|
|
208
|
+
func body(content: Content) -> some View {
|
|
209
|
+
if let action {
|
|
210
|
+
content.onLongPressGesture(minimumDuration: 0.5, perform: action)
|
|
211
|
+
} else {
|
|
212
|
+
content
|
|
213
|
+
}
|
|
303
214
|
}
|
|
304
215
|
}
|
|
305
216
|
|
|
306
|
-
// MARK: - Center
|
|
217
|
+
// MARK: - Center floating button
|
|
307
218
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
struct CenterActionStyle: ButtonStyle {
|
|
311
|
-
let size: CGFloat
|
|
312
|
-
let vertical: Bool
|
|
313
|
-
let icon: String
|
|
314
|
-
let label: String
|
|
315
|
-
var fixedFontScale = false
|
|
219
|
+
private struct CenterFloatingButton: View {
|
|
220
|
+
let data: BottomTabFloatingButton
|
|
316
221
|
|
|
317
222
|
@Environment(\.appTheme) private var theme
|
|
318
223
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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))
|
|
224
|
+
var body: some View {
|
|
225
|
+
VStack(spacing: 0) {
|
|
226
|
+
CurvedContainer()
|
|
227
|
+
Circle()
|
|
228
|
+
.fill(theme.colors.primary)
|
|
229
|
+
.frame(width: 48, height: 48)
|
|
230
|
+
.overlay(Icon(source: data.icon, size: 28, color: .white))
|
|
231
|
+
Spacer().frame(height: 4)
|
|
232
|
+
MomoText(data.label, typography: .labelXsMedium, color: Colors.black01, textAlign: .center, maxLines: 1)
|
|
233
|
+
.frame(maxWidth: .infinity)
|
|
234
|
+
.frame(height: 14)
|
|
235
|
+
.background(theme.colors.primary)
|
|
236
|
+
.clipShape(RoundedRectangle(cornerRadius: Radius.XL))
|
|
347
237
|
}
|
|
348
|
-
|
|
349
|
-
.
|
|
238
|
+
.frame(width: bottomTabFloatingButtonWidth)
|
|
239
|
+
.padding(.horizontal, Spacing.XXS)
|
|
240
|
+
.padding(.vertical, Spacing.S)
|
|
350
241
|
.contentShape(Rectangle())
|
|
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)
|
|
242
|
+
.onTapGesture { data.onPress() }
|
|
366
243
|
}
|
|
367
244
|
}
|