@momo-kits/native-kits 0.169.10-beta.1-debug → 0.169.10-debug
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/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +19 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +5 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -59
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +11 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +5 -20
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +5 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +7 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +3 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +18 -20
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +6 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +27 -44
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +13 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +7 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +14 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +39 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +35 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +16 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +3 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +1 -2
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +5 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +1 -2
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +2 -3
- package/gradle.properties +1 -1
- package/ios/Application/DesignSystemKits.swift +2 -3
- package/ios/Application/LanguageSource.swift +2 -3
- package/ios/Application/Localize.swift +4 -7
- package/ios/Application/LocalizeModifier.swift +2 -3
- package/ios/Badge/Badge.swift +5 -7
- package/ios/Button/Button.swift +2 -3
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +3 -5
- package/ios/Carousel/Carousel.swift +2 -3
- package/ios/Collapse/Collapse.swift +17 -11
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
- package/ios/Icon/Icon.swift +2 -3
- package/ios/IconButton/IconButton.swift +2 -3
- package/ios/Input/InputSearch.swift +6 -23
- package/ios/Layout/ModalLayout.swift +2 -3
- package/ios/Layout/ScreenLayout.swift +10 -12
- package/ios/Layout/Section.swift +2 -3
- package/ios/Navigation/BottomSheet.swift +6 -9
- package/ios/Navigation/BottomTab/BottomTab.swift +6 -9
- package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -6
- package/ios/Navigation/BottomTab/CurvedContainer.swift +2 -3
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
- package/ios/Navigation/BottomTab/DuoTabBar.swift +6 -6
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +4 -6
- package/ios/Navigation/Component/Header.swift +46 -31
- package/ios/Navigation/Component/HeaderJourney.swift +1 -2
- package/ios/Navigation/Component/HeaderLocation.swift +1 -2
- package/ios/Navigation/Component/HeaderRight.swift +15 -18
- package/ios/Navigation/Component/HeaderUser.swift +1 -2
- package/ios/Navigation/Component/SideBar.swift +15 -7
- package/ios/Navigation/HostBackGestureBridge.swift +2 -3
- package/ios/Navigation/ModalScreen.swift +13 -11
- package/ios/Navigation/Navigation.swift +3 -9
- package/ios/Navigation/NavigationContainer.swift +4 -6
- package/ios/Navigation/Navigator.swift +12 -18
- package/ios/Navigation/StackScreen.swift +25 -40
- package/ios/Navigation/StackTransition.swift +7 -6
- package/ios/Skeleton/Skeleton.swift +3 -6
- package/ios/Steps/Steps.swift +20 -15
- package/ios/TabView/TabView.swift +2 -3
- package/ios/Title/Title.swift +1 -3
- package/ios/Typography/FontScale.swift +6 -9
- package/ios/Typography/Text.swift +2 -3
- package/ios/Typography/Typography.swift +3 -4
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +2 -11
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -11
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +1 -1
- package/package.json +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -67
- package/ios/Layout/HeaderLayout.swift +0 -67
package/ios/Icon/Icon.swift
CHANGED
|
@@ -16,9 +16,8 @@ let iconSources: [String: String] = {
|
|
|
16
16
|
return kitIcons.merging(hostIcons.mapValues(\.uri)) { kit, _ in kit }
|
|
17
17
|
}()
|
|
18
18
|
|
|
19
|
-
// Compose defaults `color` to the theme text color
|
|
20
|
-
//
|
|
21
|
-
// unrepresentable sentinel: omitted -> theme text color, `nil` -> untinted.
|
|
19
|
+
// Compose defaults `color` to the theme text color, `null` meaning no tint. Swift can't tell an omitted argument
|
|
20
|
+
// from `nil`, so the default is this unrepresentable sentinel: omitted -> theme text color, `nil` -> untinted.
|
|
22
21
|
public let iconThemeColor = Color(.sRGB, red: -1, green: -1, blue: -1, opacity: -1)
|
|
23
22
|
|
|
24
23
|
public struct Icon: View {
|
|
@@ -118,9 +118,8 @@ public struct IconButton: View {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
///
|
|
122
|
-
///
|
|
123
|
-
/// erasure at the deployment target's iOS 15 floor.
|
|
121
|
+
/// Compose's `IconShape.toShape()` (`Circle` or a `Radius.S` rounded rect), type-erased by hand: `AnyShape` needs
|
|
122
|
+
/// iOS 17+ and the pod supports iOS 15.
|
|
124
123
|
private struct IconButtonShape: InsettableShape {
|
|
125
124
|
let shape: IconShape
|
|
126
125
|
var insetAmount: CGFloat = 0
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
/// Body searches keep 36 / 24; the header search matches the 32pt header buttons.
|
|
4
|
-
enum InputSearchSize {
|
|
5
|
-
case `default`, header
|
|
6
|
-
|
|
7
|
-
var height: CGFloat { self == .header ? HeaderLayoutMetrics.searchHeight : 36 }
|
|
8
|
-
var iconSize: CGFloat { self == .header ? HeaderLayoutMetrics.iconSize : 24 }
|
|
9
|
-
}
|
|
10
|
-
|
|
11
3
|
// MARK: - RenderRightIconSearch
|
|
12
4
|
|
|
13
5
|
struct RenderRightIconSearch: View {
|
|
@@ -15,7 +7,6 @@ struct RenderRightIconSearch: View {
|
|
|
15
7
|
let loading: Bool
|
|
16
8
|
let icon: String
|
|
17
9
|
let color: Color
|
|
18
|
-
var size: InputSearchSize = .default
|
|
19
10
|
let onClick: () -> Void
|
|
20
11
|
|
|
21
12
|
var body: some View {
|
|
@@ -26,13 +17,13 @@ struct RenderRightIconSearch: View {
|
|
|
26
17
|
.padding(.horizontal, Spacing.S)
|
|
27
18
|
}
|
|
28
19
|
if !icon.isEmpty {
|
|
29
|
-
// Compose: a 1pt rule inset S from the top and bottom of the bar.
|
|
20
|
+
// Compose: a 1pt rule inset S from the top and bottom of the 36pt bar.
|
|
30
21
|
Rectangle()
|
|
31
22
|
.fill(theme.colors.primary)
|
|
32
|
-
.frame(width: 1, height:
|
|
23
|
+
.frame(width: 1, height: 36 - Spacing.S * 2)
|
|
33
24
|
.padding(.leading, Spacing.S)
|
|
34
25
|
|
|
35
|
-
Icon(source: icon, size:
|
|
26
|
+
Icon(source: icon, size: 24, color: color)
|
|
36
27
|
.padding(.leading, Spacing.S)
|
|
37
28
|
.onTapGesture(perform: onClick)
|
|
38
29
|
}
|
|
@@ -146,7 +137,6 @@ public struct InputSearch: View {
|
|
|
146
137
|
var clearCondition: (() -> Bool)? = nil
|
|
147
138
|
var onClearPress: () -> Void = {}
|
|
148
139
|
var onSubmit: () -> Void = {}
|
|
149
|
-
var size: InputSearchSize = .default
|
|
150
140
|
|
|
151
141
|
@State private var isFocused = false
|
|
152
142
|
@State private var isBlurred = false
|
|
@@ -236,7 +226,7 @@ public struct InputSearch: View {
|
|
|
236
226
|
if let searchIcon = searchIcon {
|
|
237
227
|
searchIcon()
|
|
238
228
|
} else {
|
|
239
|
-
Icon(source: "navigation_search", size:
|
|
229
|
+
Icon(source: "navigation_search", size: 24, color: theme.colors.text.hint)
|
|
240
230
|
.padding(.trailing, Spacing.XS)
|
|
241
231
|
}
|
|
242
232
|
|
|
@@ -285,11 +275,11 @@ public struct InputSearch: View {
|
|
|
285
275
|
.padding(.leading, Spacing.XS)
|
|
286
276
|
}
|
|
287
277
|
|
|
288
|
-
RenderRightIconSearch(loading: loading, icon: icon, color: iconColor,
|
|
278
|
+
RenderRightIconSearch(loading: loading, icon: icon, color: iconColor, onClick: onRightIconPressed)
|
|
289
279
|
}
|
|
290
280
|
.padding(.horizontal, Spacing.M)
|
|
291
281
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
292
|
-
.frame(height:
|
|
282
|
+
.frame(height: 36)
|
|
293
283
|
.background(
|
|
294
284
|
RoundedRectangle(cornerRadius: Radius.XL)
|
|
295
285
|
.fill(backgroundColor ?? theme.colors.background.surface)
|
|
@@ -308,13 +298,6 @@ public struct InputSearch: View {
|
|
|
308
298
|
}
|
|
309
299
|
}
|
|
310
300
|
|
|
311
|
-
/// The header search: 32pt tall with a 20pt icon, level with the header buttons.
|
|
312
|
-
func headerSize() -> InputSearch {
|
|
313
|
-
var copy = self
|
|
314
|
-
copy.size = .header
|
|
315
|
-
return copy
|
|
316
|
-
}
|
|
317
|
-
|
|
318
301
|
// MARK: - Helper Functions
|
|
319
302
|
|
|
320
303
|
func getBorderColor(isFocused: Bool, error: String, disabled: Bool) -> Color {
|
|
@@ -56,9 +56,8 @@ public extension ScreenLayout {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
public extension ModalLayout {
|
|
59
|
-
///
|
|
60
|
-
///
|
|
61
|
-
/// Duo `safeInsets` also carries the control column and `hinge` is the half-fold hinge (nil while flat).
|
|
59
|
+
/// For hosts without a kits screen (`ScreenLayout.current.modalLayout` covers the key window); window points.
|
|
60
|
+
/// On iPhone Duo `safeInsets` includes the control column and `hinge` is the half-fold hinge (nil while flat).
|
|
62
61
|
static func resolve(
|
|
63
62
|
width: CGFloat,
|
|
64
63
|
height: CGFloat,
|
|
@@ -147,9 +147,10 @@ extension ScreenLayout {
|
|
|
147
147
|
// Activities; region frames already include the system's margin
|
|
148
148
|
let occlusion = stripOcclusion(reservedRegions, stripLeft: stripLeft, stripRight: stripLeft + sideInset, windowHeight: height)
|
|
149
149
|
|
|
150
|
-
var top =
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
var top = insets.top + HeaderMetrics.barHeight + Spacing.M
|
|
151
|
+
if statusBarClearance != nil {
|
|
152
|
+
top = headerHeight + Spacing.M
|
|
153
|
+
}
|
|
153
154
|
if insets.top < HeaderMetrics.statusBarMinInset {
|
|
154
155
|
// status bar lives in the strip: start under its cluster, as the native bar does
|
|
155
156
|
if width <= height {
|
|
@@ -206,9 +207,8 @@ extension ScreenLayout {
|
|
|
206
207
|
return (height, max(0, centerY * 2 - height))
|
|
207
208
|
}
|
|
208
209
|
|
|
209
|
-
/// How far system regions reach into a side strip from its top and
|
|
210
|
-
///
|
|
211
|
-
/// of the region reaching furthest from the top.
|
|
210
|
+
/// How far system regions (e.g. the camera, at either end by rotation) reach into a side strip from its top and
|
|
211
|
+
/// bottom ends, and the center y of the one reaching furthest from the top.
|
|
212
212
|
private static func stripOcclusion(
|
|
213
213
|
_ regions: [CGRect],
|
|
214
214
|
stripLeft: CGFloat,
|
|
@@ -270,9 +270,8 @@ public func isIPhoneDuoDevice(windowSize: CGSize? = nil) -> Bool {
|
|
|
270
270
|
return FoldableDevice.isFoldable(measuredIn: keyWindow) || insets.map { $0.left != $0.right } == true
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
/// Apple's foldable check (
|
|
274
|
-
///
|
|
275
|
-
/// it apart from a large iPhone in landscape or a narrowed window.
|
|
273
|
+
/// Apple's foldable check (host `SideTabRailView.isFoldableDevice`): only a hinged device reports a `.division`
|
|
274
|
+
/// region, even inactive while flat. Screen size can't tell it from a landscape iPhone or a narrowed window.
|
|
276
275
|
enum FoldableDevice {
|
|
277
276
|
// a hinge never goes away, so a positive answer is kept
|
|
278
277
|
private static var isKnownFoldable = false
|
|
@@ -311,9 +310,8 @@ enum FoldableDevice {
|
|
|
311
310
|
|
|
312
311
|
// MARK: - Reserved regions
|
|
313
312
|
|
|
314
|
-
/// System occlusion regions (iOS 27.1
|
|
315
|
-
///
|
|
316
|
-
/// `division` is the active hinge region, there only while the device is half folded.
|
|
313
|
+
/// System occlusion regions (iOS 27.1+, else empty) in window coordinates: the iPhone Duo camera and the status bar
|
|
314
|
+
/// cluster, which grows for a call or a Live Activity. `division` is the hinge, there only while half folded.
|
|
317
315
|
enum ReservedRegions {
|
|
318
316
|
// last report of a probe, so `ScreenLayout.current` includes it
|
|
319
317
|
private(set) static var current: [CGRect] = []
|
package/ios/Layout/Section.swift
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
///
|
|
4
|
-
///
|
|
5
|
-
/// size from `\.gridContext`. Mirrors `vn.momo.kits.layout.Section`.
|
|
3
|
+
/// Compose `layout.Section`: a 12-column grid (24 when wider than 600pt) with margin, optional background image
|
|
4
|
+
/// and a wrapping row of children that read their span from `\.gridContext`.
|
|
6
5
|
public struct SectionView<Content: View>: View {
|
|
7
6
|
// MARK: Lifecycle
|
|
8
7
|
|
|
@@ -100,9 +100,8 @@ struct BottomSheetView<Content: View>: View {
|
|
|
100
100
|
return progress * maxDynamicAlpha
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
///
|
|
104
|
-
///
|
|
105
|
-
/// (backgroundAlpha holds steady until an explicit close()).
|
|
103
|
+
/// Compose's `(backgroundAlpha + dynamicAlpha) * scrimOpacity`: additive, so a drag fades the scrim only to half
|
|
104
|
+
/// of `scrimOpacity` (backgroundAlpha holds until an explicit close()).
|
|
106
105
|
private var totalScrimAlpha: CGFloat { (backgroundAlpha + dynamicAlpha) * modal.scrimOpacity }
|
|
107
106
|
|
|
108
107
|
var body: some View {
|
|
@@ -281,9 +280,8 @@ struct BottomSheetView<Content: View>: View {
|
|
|
281
280
|
}
|
|
282
281
|
}
|
|
283
282
|
|
|
284
|
-
/// Compose's `heightIn(max:)
|
|
285
|
-
/// larger, leaving a gap above the header
|
|
286
|
-
/// when taller.
|
|
283
|
+
/// Compose's `heightIn(max:)`: sizes the sheet to its content, capped only when taller. `.frame(maxHeight:)` grows
|
|
284
|
+
/// to the cap whenever the proposal is larger, leaving a gap above the header.
|
|
287
285
|
private struct CapHeight: ViewModifier {
|
|
288
286
|
let maxHeight: CGFloat
|
|
289
287
|
|
|
@@ -296,9 +294,8 @@ private struct CapHeight: ViewModifier {
|
|
|
296
294
|
}
|
|
297
295
|
}
|
|
298
296
|
|
|
299
|
-
/// iOS 15
|
|
300
|
-
///
|
|
301
|
-
/// content), so it is re-measured only when the cap grows, e.g. once the keyboard goes down.
|
|
297
|
+
/// iOS 15 (no `Layout`): hugs the ideal height until it outgrows the cap. A capped sheet can't read its ideal height
|
|
298
|
+
/// without a second copy of the content, so it is re-measured only when the cap grows (e.g. the keyboard hides).
|
|
302
299
|
private struct CapHeightFallback: ViewModifier {
|
|
303
300
|
let maxHeight: CGFloat
|
|
304
301
|
@State private var capped = false
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// SwiftUI mirror of Compose's `navigation/bottomtab/BottomTab.kt`:
|
|
2
|
-
// `
|
|
3
|
-
// rail / floating bar). Switching tabs cross-fades + scales the content.
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/bottomtab/BottomTab.kt`: tabs in `StackScreen` chrome, each with its own
|
|
2
|
+
// `Navigation`, over a `BottomTabBar` (or the iPhone Duo rail / floating bar); a switch cross-fades + scales.
|
|
4
3
|
|
|
5
4
|
import SwiftUI
|
|
6
5
|
import UIKit
|
|
@@ -25,9 +24,8 @@ public struct BottomTab: View {
|
|
|
25
24
|
@State private var expandedBar: DuoBar?
|
|
26
25
|
@State private var openedBar: DuoBar?
|
|
27
26
|
|
|
28
|
-
/// `compressionBehavior`:
|
|
29
|
-
///
|
|
30
|
-
/// login gate. `backToInitialTab`: back off another tab returns to the initial one first.
|
|
27
|
+
/// `compressionBehavior`: iPhone Duo bar that starts compressed when the side bar can't hold both (a tap swaps).
|
|
28
|
+
/// `onTabPress` gets the switch to run, e.g. after a login gate. `backToInitialTab`: back goes to it first.
|
|
31
29
|
public init(
|
|
32
30
|
items: [BottomTabItem],
|
|
33
31
|
floatingButton: BottomTabFloatingButton? = nil,
|
|
@@ -179,9 +177,8 @@ private struct TabScreenHost: View {
|
|
|
179
177
|
|
|
180
178
|
// MARK: - Tab host
|
|
181
179
|
|
|
182
|
-
/// Compose's tab NavHost with `saveState` / `restoreState`: a tab keeps its UIHostingController
|
|
183
|
-
///
|
|
184
|
-
/// gets onDisappear / onAppear (re-running screen tracking). Same scheme as `StackController`.
|
|
180
|
+
/// Compose's tab NavHost with `saveState` / `restoreState`: a tab keeps its UIHostingController (state, scroll).
|
|
181
|
+
/// Hidden, it leaves the window and gets onDisappear / onAppear, re-running screen tracking, as in `StackController`.
|
|
185
182
|
private struct TabHost: UIViewControllerRepresentable {
|
|
186
183
|
let selectedIndex: Int
|
|
187
184
|
let count: Int
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// SwiftUI mirror of Compose's `navigation/bottomtab/BottomTabBar.kt
|
|
2
|
-
//
|
|
3
|
-
// evenly with a tonal active indicator, badges/dots, and the Special type's center action in a notch.
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/bottomtab/BottomTabBar.kt` (Figma "Specs Navigation", DS-984): floating
|
|
2
|
+
// container, evenly split items with a tonal active indicator, badges/dots, the Special center action in a notch.
|
|
4
3
|
|
|
5
4
|
import SwiftUI
|
|
6
5
|
|
|
@@ -102,9 +101,8 @@ struct BottomTabBar: View {
|
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
|
|
105
|
-
///
|
|
106
|
-
///
|
|
107
|
-
/// behind the selected item.
|
|
104
|
+
/// One active indicator slides behind the selected item; the Special type's center action rises ctaLift above
|
|
105
|
+
/// the container's notch.
|
|
108
106
|
struct HorizontalTabBar: View {
|
|
109
107
|
let items: [BottomTabItem]
|
|
110
108
|
let floatingButton: BottomTabFloatingButton?
|
|
@@ -40,9 +40,8 @@ struct NotchedBarShape: Shape {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
///
|
|
44
|
-
///
|
|
45
|
-
/// shadows go over the fill (compositingGroup keeps the first from being re-cast).
|
|
43
|
+
/// Translucent fill (Figma .Nav/Background) with the shadow following the shape. Shadows go over the fill, as opaque
|
|
44
|
+
/// layers under it would make the glass solid (compositingGroup keeps the first from being re-cast).
|
|
46
45
|
struct TabBarContainer<S: Shape>: ViewModifier {
|
|
47
46
|
let shape: S
|
|
48
47
|
|
|
@@ -31,9 +31,8 @@ struct DuoBarCompression {
|
|
|
31
31
|
/// Back, then the single button the toolbar folds into.
|
|
32
32
|
private static let compressedToolbarHeight = 2 * DuoMetrics.controlSize + Spacing.M
|
|
33
33
|
|
|
34
|
-
/// Both fit: both
|
|
35
|
-
///
|
|
36
|
-
/// again once a tab is picked).
|
|
34
|
+
/// Both fit: both whole. One fits beside the other compressed: it is compressed and a tap swaps them. Otherwise
|
|
35
|
+
/// both rest compressed and a tap opens one for a moment (the rail closes again once a tab is picked).
|
|
37
36
|
static func resolve(
|
|
38
37
|
layout: ScreenLayout,
|
|
39
38
|
tabCount: Int,
|
|
@@ -26,9 +26,10 @@ extension EnvironmentValues {
|
|
|
26
26
|
|
|
27
27
|
/// Rail container plus the center action under it; compressed, the rail is a single button.
|
|
28
28
|
func duoRailHeight(itemCount: Int, hasQr: Bool, compressed: Bool = false) -> CGFloat {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
var rail = CGFloat(itemCount) * TabBarMetrics.railItemHeight + TabBarMetrics.railPaddingBottom
|
|
30
|
+
if compressed {
|
|
31
|
+
rail = compactSize
|
|
32
|
+
}
|
|
32
33
|
return rail + (hasQr ? TabBarMetrics.railCtaGap + TabBarMetrics.railCtaHeight : 0)
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -71,9 +72,8 @@ struct DuoTabBar: View {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
/// Vertical bar
|
|
75
|
-
///
|
|
76
|
-
/// (HIG "Tab bar compressed"); tapping it expands the rail and compresses the toolbar.
|
|
75
|
+
/// Vertical bar at the bottom of the side bar, center action below. A short side bar shrinks it to one button showing
|
|
76
|
+
/// the current tab (HIG "Tab bar compressed"); a tap expands the rail and compresses the toolbar.
|
|
77
77
|
private struct DuoRailTabBar: View {
|
|
78
78
|
let sideBar: SideBarLayout
|
|
79
79
|
let items: [BottomTabItem]
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// Navigation bar measurements (Figma "Specs Navigation", DS-984), mirrored from Compose's
|
|
2
|
-
// `
|
|
3
|
-
// container, center action in a notch; vertical: iPhone Duo rail, center action under it.
|
|
1
|
+
// Navigation bar measurements (Figma "Specs Navigation", DS-984), mirrored from Compose's `TabBarMetrics.kt` and RN
|
|
2
|
+
// `BottomTab/metrics.ts`. Horizontal: floating, center action in a notch; vertical: iPhone Duo rail, action under it.
|
|
4
3
|
|
|
5
4
|
import SwiftUI
|
|
6
5
|
|
|
@@ -44,9 +43,8 @@ enum TabBarMetrics {
|
|
|
44
43
|
static let ctaLift: CGFloat = 22
|
|
45
44
|
static let ctaLabelGap = Spacing.M
|
|
46
45
|
static let ctaLabelHeight: CGFloat = 18
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
// each point as (dx from the center, dy below the top edge)
|
|
46
|
+
// container-top notch under the center action (Figma "Backgroud" path): from notchHalfWidth left of the center,
|
|
47
|
+
// cubic segments [control1, control2, end], each point (dx from the center, dy below the top edge)
|
|
50
48
|
static let notchHalfWidth: CGFloat = 50.758
|
|
51
49
|
static let notchCurves: [[CGPoint]] = [
|
|
52
50
|
[CGPoint(x: -39.749, y: 0), CGPoint(x: -31.231, y: 9.765), CGPoint(x: -24.563, y: 18.526)],
|
|
@@ -6,9 +6,10 @@ import SwiftUI
|
|
|
6
6
|
/// Header bar height, mirrors Compose's `HEADER_HEIGHT`.
|
|
7
7
|
public let HEADER_HEIGHT: CGFloat = 52
|
|
8
8
|
|
|
9
|
-
/// Room the back button
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/// Room the back button and toolkit take from the bar (Compose `HEADER_ACTIONS_WIDTH`).
|
|
10
|
+
let headerActionsWidth: CGFloat = 172
|
|
11
|
+
// Extra width the 48pt back and toolkit take on the iPhone Duo status bar row.
|
|
12
|
+
private let statusBarRowActionsExtra: CGFloat = 55
|
|
12
13
|
|
|
13
14
|
public enum TitlePosition {
|
|
14
15
|
case left, center
|
|
@@ -23,19 +24,15 @@ public struct AnimatedHeader {
|
|
|
23
24
|
public var aspectRatio: AnimatedHeaderRatio = .ratio16_9
|
|
24
25
|
public var isSurface: Bool = true
|
|
25
26
|
public var composable: (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) }
|
|
26
|
-
/// Wide windows: fills the sides of the phone-sized banner, fading out downward.
|
|
27
|
-
public var bannerBackgroundColor: Color?
|
|
28
27
|
|
|
29
28
|
public init(
|
|
30
29
|
aspectRatio: AnimatedHeaderRatio = .ratio16_9,
|
|
31
30
|
isSurface: Bool = true,
|
|
32
|
-
composable: @escaping (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) }
|
|
33
|
-
bannerBackgroundColor: Color? = nil
|
|
31
|
+
composable: @escaping (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) }
|
|
34
32
|
) {
|
|
35
33
|
self.aspectRatio = aspectRatio
|
|
36
34
|
self.isSurface = isSurface
|
|
37
35
|
self.composable = composable
|
|
38
|
-
self.bannerBackgroundColor = bannerBackgroundColor
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
38
|
|
|
@@ -289,10 +286,10 @@ func headerSearchProps(
|
|
|
289
286
|
}
|
|
290
287
|
|
|
291
288
|
/// Max title width: back button and toolkit share the bar unless the iPhone Duo side bar holds them.
|
|
292
|
-
func headerTitleMaxWidth(_ layout: ScreenLayout
|
|
289
|
+
func headerTitleMaxWidth(_ layout: ScreenLayout) -> CGFloat {
|
|
293
290
|
let clearance = layout.statusBarClearance.map { $0.left + $0.right } ?? 0
|
|
294
291
|
if layout.sideBar != nil { return layout.contentWidth - Spacing.M * 2 - clearance }
|
|
295
|
-
return layout.
|
|
292
|
+
return layout.width - headerActionsWidth - (layout.statusBarClearance != nil ? statusBarRowActionsExtra : 0) - clearance
|
|
296
293
|
}
|
|
297
294
|
|
|
298
295
|
// MARK: - Header
|
|
@@ -342,21 +339,21 @@ public struct NavigationHeader: View {
|
|
|
342
339
|
}
|
|
343
340
|
|
|
344
341
|
@Environment(\.screenLayout) private var layout
|
|
345
|
-
@Environment(\.contentLayout) private var contentLayout
|
|
346
342
|
@Environment(\.appTheme) private var theme
|
|
347
343
|
@OptionalEnvironmentObject private var navigator: Navigator?
|
|
348
344
|
@State private var headerRightWidth: CGFloat = 0
|
|
349
345
|
|
|
350
|
-
private var headerLayout: HeaderLayout { layout.headerLayout(contentLayout) }
|
|
351
|
-
|
|
352
346
|
/// iPhone Duo side bar holds back and the toolkit; a custom header right stays in the bar.
|
|
353
347
|
private var useSideBar: Bool { layout.sideBar != nil }
|
|
354
348
|
|
|
349
|
+
/// iPhone Duo inner portrait: the row sits on the status bar, between its clusters, with 48pt controls.
|
|
350
|
+
private var statusBarRow: Bool { layout.statusBarClearance != nil && !useSideBar }
|
|
351
|
+
|
|
355
352
|
/// Max centered title width; on the status bar row the clusters are lopsided, so both sides
|
|
356
353
|
/// keep the wider one's room.
|
|
357
354
|
private var centerTitleMaxWidth: CGFloat {
|
|
358
|
-
guard let clearance = layout.statusBarClearance else { return
|
|
359
|
-
let back = goBack == nil || useSideBar ? 0 :
|
|
355
|
+
guard let clearance = layout.statusBarClearance else { return (layout.contentWidth - Spacing.M * 2) / 2 }
|
|
356
|
+
let back = goBack == nil || useSideBar ? 0 : DuoMetrics.controlSize + Spacing.S
|
|
360
357
|
let inset = max(clearance.left + back, clearance.right + headerRightWidth) + Spacing.S
|
|
361
358
|
return max(layout.contentWidth - (Spacing.M + inset) * 2, 0)
|
|
362
359
|
}
|
|
@@ -381,8 +378,17 @@ public struct NavigationHeader: View {
|
|
|
381
378
|
ZStack {
|
|
382
379
|
HStack(spacing: 0) {
|
|
383
380
|
if let goBack, !useSideBar {
|
|
384
|
-
|
|
385
|
-
|
|
381
|
+
if statusBarRow {
|
|
382
|
+
SideBarButton(
|
|
383
|
+
icon: "arrow-back",
|
|
384
|
+
headerColor: headerColor,
|
|
385
|
+
accessibilityId: "btn_navigation_back",
|
|
386
|
+
action: goBack
|
|
387
|
+
)
|
|
388
|
+
} else {
|
|
389
|
+
BackButton(color: headerColor, onBack: goBack)
|
|
390
|
+
}
|
|
391
|
+
Spacer().frame(width: Spacing.S)
|
|
386
392
|
}
|
|
387
393
|
|
|
388
394
|
if centerTitle {
|
|
@@ -393,23 +399,33 @@ public struct NavigationHeader: View {
|
|
|
393
399
|
}
|
|
394
400
|
|
|
395
401
|
if let headerRight, !(useSideBar && toolkitHeaderRight(headerRight) != nil) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
402
|
+
Group {
|
|
403
|
+
if statusBarRow, let toolkit = toolkitHeaderRight(headerRight) {
|
|
404
|
+
Toolkit(
|
|
405
|
+
headerRight: toolkit.data ?? HeaderRightData(),
|
|
406
|
+
tintColor: toolkit.tintColor,
|
|
407
|
+
layout: .sideBarRow
|
|
408
|
+
)
|
|
409
|
+
} else {
|
|
410
|
+
AnyView(headerRight())
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
.environment(\.headerColor, headerColor)
|
|
414
|
+
.background(
|
|
415
|
+
GeometryReader { geo in
|
|
416
|
+
Color.clear.preference(key: HeaderRightWidthKey.self, value: geo.size.width)
|
|
417
|
+
}
|
|
418
|
+
)
|
|
403
419
|
}
|
|
404
420
|
}
|
|
405
|
-
.padding(.leading,
|
|
406
|
-
.padding(.trailing,
|
|
421
|
+
.padding(.leading, Spacing.M + (layout.statusBarClearance?.left ?? 0))
|
|
422
|
+
.padding(.trailing, Spacing.M + (layout.statusBarClearance?.right ?? 0))
|
|
407
423
|
|
|
408
424
|
if centerTitle {
|
|
409
425
|
titleArea(centered: true)
|
|
410
426
|
// Compose caps a centered title at half the bar
|
|
411
427
|
.frame(maxWidth: centerTitleMaxWidth)
|
|
412
|
-
.padding(.horizontal,
|
|
428
|
+
.padding(.horizontal, Spacing.M)
|
|
413
429
|
}
|
|
414
430
|
}
|
|
415
431
|
.onPreferenceChange(HeaderRightWidthKey.self) { headerRightWidth = $0 }
|
|
@@ -432,7 +448,6 @@ public struct NavigationHeader: View {
|
|
|
432
448
|
theme: theme,
|
|
433
449
|
pop: navigator.map { navigator in { navigator.pop() } }
|
|
434
450
|
))
|
|
435
|
-
.headerSize()
|
|
436
451
|
} else {
|
|
437
452
|
switch headerTitle {
|
|
438
453
|
case let .user(data)?:
|
|
@@ -486,7 +501,7 @@ struct HeaderBarBackground: View {
|
|
|
486
501
|
|
|
487
502
|
// MARK: - Back button
|
|
488
503
|
|
|
489
|
-
/// Mirrors Compose's `BackButton`: a
|
|
504
|
+
/// Mirrors Compose's `BackButton`: a 28pt circle with the back arrow.
|
|
490
505
|
private struct BackButton: View {
|
|
491
506
|
let color: HeaderColor
|
|
492
507
|
let onBack: () -> Void
|
|
@@ -496,8 +511,8 @@ private struct BackButton: View {
|
|
|
496
511
|
Circle()
|
|
497
512
|
.fill(color.backgroundButton)
|
|
498
513
|
.overlay(Circle().stroke(color.borderColor, lineWidth: 0.2))
|
|
499
|
-
.frame(width:
|
|
500
|
-
.overlay(Icon(source: "arrow-back", size:
|
|
514
|
+
.frame(width: 28, height: 28)
|
|
515
|
+
.overlay(Icon(source: "arrow-back", size: 20, color: color.tintIconColor))
|
|
501
516
|
}
|
|
502
517
|
.buttonStyle(ActiveOpacityButtonStyle())
|
|
503
518
|
.accessibilityIdentifier("btn_navigation_back")
|
|
@@ -13,7 +13,6 @@ public struct HeaderJourneyView: View {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
@Environment(\.screenLayout) private var layout
|
|
16
|
-
@Environment(\.contentLayout) private var contentLayout
|
|
17
16
|
|
|
18
17
|
public var body: some View {
|
|
19
18
|
if data.isLoading {
|
|
@@ -46,7 +45,7 @@ public struct HeaderJourneyView: View {
|
|
|
46
45
|
MomoText(description, typography: .descriptionXsRegular, color: tint, maxLines: 1)
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
|
-
.frame(maxWidth: headerTitleMaxWidth(layout
|
|
48
|
+
.frame(maxWidth: headerTitleMaxWidth(layout), alignment: .leading)
|
|
50
49
|
}
|
|
51
50
|
.buttonStyle(ActiveOpacityButtonStyle())
|
|
52
51
|
.disabled(data.onPress == nil)
|
|
@@ -13,7 +13,6 @@ public struct HeaderLocationView: View {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
@Environment(\.screenLayout) private var layout
|
|
16
|
-
@Environment(\.contentLayout) private var contentLayout
|
|
17
16
|
|
|
18
17
|
public var body: some View {
|
|
19
18
|
if data.isLoading {
|
|
@@ -35,7 +34,7 @@ public struct HeaderLocationView: View {
|
|
|
35
34
|
Icon(source: "16_arrow_chevron_down_small", size: 16, color: tint)
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
|
-
.frame(maxWidth: headerTitleMaxWidth(layout
|
|
37
|
+
.frame(maxWidth: headerTitleMaxWidth(layout), alignment: .leading)
|
|
39
38
|
}
|
|
40
39
|
.buttonStyle(ActiveOpacityButtonStyle())
|
|
41
40
|
.disabled(data.onPress == nil)
|