@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
|
@@ -138,9 +138,9 @@ private struct NavigationButtonConfig {
|
|
|
138
138
|
let onPress: () -> Void
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
/// `sideBarColumn`: the iPhone Duo side bar
|
|
141
|
+
/// `sideBarColumn`: the iPhone Duo side bar; `sideBarRow`: the Duo header row on the status bar, same 48pt controls.
|
|
142
142
|
enum ToolkitLayout {
|
|
143
|
-
case bar, sideBarColumn
|
|
143
|
+
case bar, sideBarColumn, sideBarRow
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
struct Toolkit: View {
|
|
@@ -293,14 +293,16 @@ struct Toolkit: View {
|
|
|
293
293
|
case .bar:
|
|
294
294
|
horizontalBody
|
|
295
295
|
case .sideBarColumn:
|
|
296
|
-
VStack(spacing: Spacing.M) { sideBarControls }
|
|
296
|
+
VStack(spacing: Spacing.M) { sideBarControls(horizontal: false) }
|
|
297
|
+
case .sideBarRow:
|
|
298
|
+
HStack(spacing: Spacing.M) { sideBarControls(horizontal: true) }
|
|
297
299
|
}
|
|
298
300
|
}
|
|
299
301
|
.onAppear(perform: loadFavoriteState)
|
|
300
302
|
}
|
|
301
303
|
|
|
302
304
|
@ViewBuilder
|
|
303
|
-
private
|
|
305
|
+
private func sideBarControls(horizontal: Bool) -> some View {
|
|
304
306
|
let config = navigationButtonConfig
|
|
305
307
|
let useHelpCenter = usesHelpCenter(context)
|
|
306
308
|
if showsShortcut(headerRight, context) {
|
|
@@ -312,7 +314,7 @@ struct Toolkit: View {
|
|
|
312
314
|
action: config.onPress
|
|
313
315
|
)
|
|
314
316
|
}
|
|
315
|
-
SideBarGroup(headerColor: headerColor, itemCount: useHelpCenter ? 2 : 1) {
|
|
317
|
+
SideBarGroup(headerColor: headerColor, itemCount: useHelpCenter ? 2 : 1, horizontal: horizontal) {
|
|
316
318
|
if useHelpCenter {
|
|
317
319
|
SideBarGroupItem(
|
|
318
320
|
icon: "help_center",
|
|
@@ -352,30 +354,25 @@ struct Toolkit: View {
|
|
|
352
354
|
}
|
|
353
355
|
toolButton(icon: headerRight.closeIcon, accessibilityId: "btn_navigation_close", action: onPressClose)
|
|
354
356
|
}
|
|
355
|
-
.frame(
|
|
356
|
-
width: usesHelpCenter(context) ? HeaderLayoutMetrics.pillWidth : HeaderLayoutMetrics.buttonSize,
|
|
357
|
-
height: HeaderLayoutMetrics.buttonSize
|
|
358
|
-
)
|
|
357
|
+
.frame(width: usesHelpCenter(context) ? 65 : 28, height: 28)
|
|
359
358
|
.background(headerColor.backgroundButton)
|
|
360
|
-
.
|
|
361
|
-
.overlay(
|
|
359
|
+
.cornerRadius(14)
|
|
360
|
+
.overlay(RoundedRectangle(cornerRadius: 14).stroke(headerColor.borderColor, lineWidth: 0.2))
|
|
362
361
|
.padding(.leading, Spacing.S)
|
|
363
362
|
}
|
|
364
363
|
}
|
|
365
364
|
|
|
366
|
-
/// One half of the help / home pill; each half takes an equal share of the pill width.
|
|
367
365
|
private func toolButton(icon: String, accessibilityId: String, action: @escaping () -> Void) -> some View {
|
|
368
366
|
SwiftUI.Button(action: action) {
|
|
369
|
-
Icon(source: icon, size:
|
|
370
|
-
.
|
|
371
|
-
.contentShape(Rectangle())
|
|
367
|
+
Icon(source: icon, size: 20, color: headerColor.tintIconColor)
|
|
368
|
+
.padding(4)
|
|
372
369
|
}
|
|
373
370
|
.buttonStyle(ActiveOpacityButtonStyle())
|
|
374
371
|
.accessibilityIdentifier(accessibilityId)
|
|
375
372
|
}
|
|
376
373
|
}
|
|
377
374
|
|
|
378
|
-
/// Mirrors Compose's `NavigationButton`: the
|
|
375
|
+
/// Mirrors Compose's `NavigationButton`: the 28pt circular shortcut / more button.
|
|
379
376
|
public struct NavigationButton: View {
|
|
380
377
|
var disabled: Bool
|
|
381
378
|
var icon: String
|
|
@@ -408,9 +405,9 @@ public struct NavigationButton: View {
|
|
|
408
405
|
Circle()
|
|
409
406
|
.fill(colors.backgroundButton)
|
|
410
407
|
.overlay(Circle().stroke(colors.borderColor, lineWidth: 0.2))
|
|
411
|
-
Icon(source: icon, size:
|
|
408
|
+
Icon(source: icon, size: 20, color: colors.tintIconColor)
|
|
412
409
|
}
|
|
413
|
-
.frame(width:
|
|
410
|
+
.frame(width: 28, height: 28)
|
|
414
411
|
.overlay(alignment: .topTrailing) {
|
|
415
412
|
if showBadge {
|
|
416
413
|
BadgeDot(size: .small).offset(x: -Spacing.XXS, y: -Spacing.XXS)
|
|
@@ -13,7 +13,6 @@ public struct HeaderUserView: View {
|
|
|
13
13
|
private let avatarSize: CGFloat = Spacing.XXL // 32
|
|
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 {
|
|
@@ -68,7 +67,7 @@ public struct HeaderUserView: View {
|
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
|
-
.frame(maxWidth: headerTitleMaxWidth(layout
|
|
70
|
+
.frame(maxWidth: headerTitleMaxWidth(layout), alignment: .leading)
|
|
72
71
|
|
|
73
72
|
Spacer(minLength: 0)
|
|
74
73
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// SwiftUI mirror of Compose's `navigation/component/SideBar.kt
|
|
2
|
-
// leave the header
|
|
3
|
-
// Port of RN `SideBarButton.tsx` + `useSideBarItemStyle`.
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/component/SideBar.kt` (RN `SideBarButton.tsx` + `useSideBarItemStyle`):
|
|
2
|
+
// on iPhone Duo, back and toolkit leave the header for a column in the side safe area, as the system bars do.
|
|
4
3
|
|
|
5
4
|
import SwiftUI
|
|
6
5
|
|
|
@@ -137,17 +136,26 @@ struct SideBarButton: View {
|
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
138
|
|
|
140
|
-
/// 48pt
|
|
139
|
+
/// 48pt glass capsule grouping related controls, one item per 50pt: vertical in the side bar,
|
|
140
|
+
/// horizontal on a header row.
|
|
141
141
|
struct SideBarGroup<Content: View>: View {
|
|
142
142
|
let headerColor: HeaderColor
|
|
143
143
|
let itemCount: Int
|
|
144
|
+
var horizontal: Bool = false
|
|
144
145
|
@ViewBuilder let content: () -> Content
|
|
145
146
|
|
|
146
147
|
var body: some View {
|
|
147
148
|
let length = itemCount > 1 ? DuoMetrics.itemPitch * CGFloat(itemCount) : DuoMetrics.controlSize
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
Group {
|
|
150
|
+
if horizontal {
|
|
151
|
+
HStack(spacing: 0) { content() }
|
|
152
|
+
.frame(width: length, height: DuoMetrics.controlSize)
|
|
153
|
+
} else {
|
|
154
|
+
VStack(spacing: 0) { content() }
|
|
155
|
+
.frame(width: DuoMetrics.controlSize, height: length)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
.modifier(SideBarGlass(headerColor: headerColor, shape: RoundedRectangle(cornerRadius: Radius.XL)))
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
161
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// SwiftUI mirror of Compose's `navigation/HostBackGestureBridge.kt`: the host
|
|
2
|
-
//
|
|
3
|
-
// `started` ... `cancelled` scrub the pop with the finger; a plain `pop` plays the regular back.
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/HostBackGestureBridge.kt`: routes the host's edge pan into the topmost
|
|
2
|
+
// kit stack (NavigationContainer attaches itself); `started` ... `cancelled` scrub the pop, `pop` plays a plain back.
|
|
4
3
|
|
|
5
4
|
import UIKit
|
|
6
5
|
|
|
@@ -37,17 +37,7 @@ struct ModalScreen<Content: View>: View {
|
|
|
37
37
|
)
|
|
38
38
|
.scaleEffect(contentScale)
|
|
39
39
|
.opacity(contentOpacity)
|
|
40
|
-
|
|
41
|
-
.padding(
|
|
42
|
-
modal.isFoldable
|
|
43
|
-
? EdgeInsets(
|
|
44
|
-
top: placement.minY,
|
|
45
|
-
leading: placement.minX,
|
|
46
|
-
bottom: layout.height - placement.maxY,
|
|
47
|
-
trailing: layout.width - placement.maxX
|
|
48
|
-
)
|
|
49
|
-
: EdgeInsets()
|
|
50
|
-
)
|
|
40
|
+
.padding(contentPadding(modal))
|
|
51
41
|
}
|
|
52
42
|
// Full screen like RN's Modal, so asymmetric landscape insets don't shift the content sideways.
|
|
53
43
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
@@ -65,6 +55,18 @@ struct ModalScreen<Content: View>: View {
|
|
|
65
55
|
}
|
|
66
56
|
}
|
|
67
57
|
|
|
58
|
+
// Centers the content in the placement: the safe area, or the right half of a half-folded iPhone Duo.
|
|
59
|
+
private func contentPadding(_ modal: ModalLayout) -> EdgeInsets {
|
|
60
|
+
guard modal.isFoldable else { return EdgeInsets() }
|
|
61
|
+
let placement = modal.placement
|
|
62
|
+
return EdgeInsets(
|
|
63
|
+
top: placement.minY,
|
|
64
|
+
leading: placement.minX,
|
|
65
|
+
bottom: layout.height - placement.maxY,
|
|
66
|
+
trailing: layout.width - placement.maxX
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
68
70
|
// Mirrors Compose's `openEvent`: 250ms fade + scale to 1.
|
|
69
71
|
private func open() {
|
|
70
72
|
DispatchQueue.main.async {
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
import SwiftUI
|
|
5
5
|
|
|
6
|
-
/// Per-screen handle (Compose `LocalNavigation`)
|
|
7
|
-
///
|
|
8
|
-
/// footer or back handling after the screen is shown.
|
|
6
|
+
/// Per-screen handle (Compose `LocalNavigation`): a screen reads `@EnvironmentObject var navigation: Navigation`
|
|
7
|
+
/// and calls `setOptions` to change the header, footer or back handling after it is shown.
|
|
9
8
|
public final class Navigation: ObservableObject {
|
|
10
9
|
public let id: Int
|
|
11
10
|
public let bottomTabIndex: Int
|
|
@@ -87,8 +86,6 @@ public struct NavigationOptions {
|
|
|
87
86
|
public var inputSearchProps: InputSearchProps?
|
|
88
87
|
public var fabProps: FabProps?
|
|
89
88
|
public var onBackHandler: (() -> Void)?
|
|
90
|
-
/// Wide windows: `.stretch` puts the header row in the centered 600pt content frame.
|
|
91
|
-
public var contentLayout: ContentLayout
|
|
92
89
|
|
|
93
90
|
public init(
|
|
94
91
|
screenName: String? = nil,
|
|
@@ -117,8 +114,7 @@ public struct NavigationOptions {
|
|
|
117
114
|
layoutOffset: CGFloat = 56,
|
|
118
115
|
inputSearchProps: InputSearchProps? = nil,
|
|
119
116
|
fabProps: FabProps? = nil,
|
|
120
|
-
onBackHandler: (() -> Void)? = nil
|
|
121
|
-
contentLayout: ContentLayout = .grid
|
|
117
|
+
onBackHandler: (() -> Void)? = nil
|
|
122
118
|
) {
|
|
123
119
|
self.screenName = screenName
|
|
124
120
|
self.title = title
|
|
@@ -147,7 +143,6 @@ public struct NavigationOptions {
|
|
|
147
143
|
self.inputSearchProps = inputSearchProps
|
|
148
144
|
self.fabProps = fabProps
|
|
149
145
|
self.onBackHandler = onBackHandler
|
|
150
|
-
self.contentLayout = contentLayout
|
|
151
146
|
}
|
|
152
147
|
}
|
|
153
148
|
|
|
@@ -191,7 +186,6 @@ struct OptionsStackScreen: View {
|
|
|
191
186
|
layoutOffset: options.layoutOffset,
|
|
192
187
|
inputSearchProps: options.inputSearchProps,
|
|
193
188
|
fabProps: options.fabProps,
|
|
194
|
-
contentLayout: options.contentLayout,
|
|
195
189
|
screenName: screenName,
|
|
196
190
|
content: content
|
|
197
191
|
)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// SwiftUI mirror of Compose's `navigation/NavigationContainer.kt`: hosts the kit stack
|
|
2
|
-
//
|
|
3
|
-
// renders every registered screen inside `StackScreen` chrome built from its options.
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/NavigationContainer.kt`: hosts the kit stack (`StackHost`, the NavHost
|
|
2
|
+
// counterpart), injects Navigator, theme, localize and font scale, and wraps each screen in `StackScreen` chrome.
|
|
4
3
|
|
|
5
4
|
import SwiftUI
|
|
6
5
|
|
|
@@ -84,9 +83,8 @@ public struct NavigationContainer<Initial: View>: View {
|
|
|
84
83
|
setNavigator?(navigator)
|
|
85
84
|
// Idempotent, so a re-appear won't double-count.
|
|
86
85
|
HostBackGestureBridge.shared.attach(navigator)
|
|
87
|
-
// Only a seed: a Localize with a language source already tracks the host
|
|
88
|
-
//
|
|
89
|
-
// raw response and hops to main itself.
|
|
86
|
+
// Only a seed: a Localize with a language source already tracks the host, so asking maxApi would race
|
|
87
|
+
// it. `changeLanguage` normalizes the raw response and hops to main itself.
|
|
90
88
|
guard !localize.observesAppLanguage else { return }
|
|
91
89
|
maxApi?.getLanguage { data in
|
|
92
90
|
localize.changeLanguage(data?["response"] as? String)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// SwiftUI mirror of Compose's `navigation/Navigator.kt`: Navigator, DynamicScreenRegistry and
|
|
2
|
-
//
|
|
3
|
-
// content is looked up from the registry on render.
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/Navigator.kt`: Navigator, DynamicScreenRegistry and the overplay model.
|
|
2
|
+
// The stack holds screen ids; content is looked up from the registry on render.
|
|
4
3
|
|
|
5
4
|
import SwiftUI
|
|
6
5
|
import Combine
|
|
@@ -101,9 +100,8 @@ public struct OverplayItem: Identifiable {
|
|
|
101
100
|
|
|
102
101
|
// MARK: - Stack
|
|
103
102
|
|
|
104
|
-
/// One back-stack entry, root first. A presented screen is
|
|
105
|
-
///
|
|
106
|
-
/// stack on top of it.
|
|
103
|
+
/// One back-stack entry, root first. A presented screen is one too (Compose's `DynamicDialogRoute` in the same
|
|
104
|
+
/// NavHost): it rises instead of sliding in, and later pushes stack on top of it.
|
|
107
105
|
struct StackEntry: Hashable, Identifiable {
|
|
108
106
|
let id: Int
|
|
109
107
|
let isDialog: Bool
|
|
@@ -132,9 +130,8 @@ public final class Navigator: ObservableObject {
|
|
|
132
130
|
/// Host dismiss fallback when there is no `composeApi` (Compose's `maxApi.dismiss`).
|
|
133
131
|
public var maxApi: MaxApi?
|
|
134
132
|
|
|
135
|
-
/// Set by a bottom tab off its first tab
|
|
136
|
-
///
|
|
137
|
-
/// over the tabs still pops normally.
|
|
133
|
+
/// Set by a bottom tab off its first tab so back returns there (Compose `tabBackHandler`). Keyed by the
|
|
134
|
+
/// hosting screen, so a screen pushed or presented over the tabs still pops normally.
|
|
138
135
|
var tabBackHandler: (screenId: Int, handler: () -> Void)?
|
|
139
136
|
|
|
140
137
|
/// The container's stack view, which plays (and lets the host gesture scrub) the transitions.
|
|
@@ -216,9 +213,8 @@ public final class Navigator: ObservableObject {
|
|
|
216
213
|
popStep(remaining: count, callback: callback)
|
|
217
214
|
}
|
|
218
215
|
|
|
219
|
-
///
|
|
220
|
-
///
|
|
221
|
-
/// steps on the closing overplay and never pop the screen.
|
|
216
|
+
/// Waits out the overplay's exit animation like Compose's coroutine loop, or a `pop(2)` (prevent-back: close
|
|
217
|
+
/// the popup, then leave) would spend both steps on the closing overplay and never pop the screen.
|
|
222
218
|
private func popStep(remaining: Int, callback: (() -> Void)?) {
|
|
223
219
|
guard remaining > 0 else {
|
|
224
220
|
callback?()
|
|
@@ -367,9 +363,8 @@ public final class Navigator: ObservableObject {
|
|
|
367
363
|
|
|
368
364
|
// MARK: Host back gesture (Compose's HostBackTarget)
|
|
369
365
|
|
|
370
|
-
/// Only a plain pop is scrubbed.
|
|
371
|
-
///
|
|
372
|
-
/// waits for the release and goes through `onBackSafe`, as RN turns the gesture off there.
|
|
366
|
+
/// Only a plain pop is scrubbed. Tab back, a custom handler, prevent-back, an open overplay or a presented
|
|
367
|
+
/// top wait for the release and go through `onBackSafe`, as RN turns the gesture off there.
|
|
373
368
|
private var canSeekBack: Bool {
|
|
374
369
|
guard canPop(), overplay == nil, let top = entries.last, !top.isDialog else { return false }
|
|
375
370
|
if let tabBackHandler, tabBackHandler.screenId == -1 || tabBackHandler.screenId == top.id {
|
|
@@ -525,9 +520,8 @@ public final class Navigator: ObservableObject {
|
|
|
525
520
|
disposeScreens(previous.map(\.id).filter { !kept.contains($0) })
|
|
526
521
|
}
|
|
527
522
|
|
|
528
|
-
///
|
|
529
|
-
///
|
|
530
|
-
/// fires, so an entry back on the stack by then keeps its screen.
|
|
523
|
+
/// Released only after the pop transition, as the outgoing view animates until then. Liveness is re-checked
|
|
524
|
+
/// when the timer fires, so an entry back on the stack by then keeps its screen.
|
|
531
525
|
private func disposeScreens(_ ids: [Int]) {
|
|
532
526
|
guard !ids.isEmpty else { return }
|
|
533
527
|
DispatchQueue.main.asyncAfter(deadline: .now() + Self.screenDisposeDelay) { [weak self] in
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// SwiftUI mirror of Compose's `navigation/StackScreen.kt`: header layer, scrollable content
|
|
2
|
-
//
|
|
3
|
-
// iPhone Duo side bar.
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/StackScreen.kt`: header layer, scrollable content (`StackScreenContent`),
|
|
2
|
+
// animated search, floating button, footer (`NavigationFooter`) and the iPhone Duo side bar.
|
|
4
3
|
|
|
5
4
|
import SwiftUI
|
|
6
5
|
|
|
@@ -34,7 +33,6 @@ public struct StackScreen<Content: View>: View {
|
|
|
34
33
|
var layoutOffset: CGFloat
|
|
35
34
|
var inputSearchProps: InputSearchProps?
|
|
36
35
|
var fabProps: FabProps?
|
|
37
|
-
var contentLayout: ContentLayout = .grid
|
|
38
36
|
var screenName: String = ""
|
|
39
37
|
var content: () -> Content
|
|
40
38
|
|
|
@@ -66,7 +64,6 @@ public struct StackScreen<Content: View>: View {
|
|
|
66
64
|
layoutOffset: CGFloat = 56,
|
|
67
65
|
inputSearchProps: InputSearchProps? = nil,
|
|
68
66
|
fabProps: FabProps? = nil,
|
|
69
|
-
contentLayout: ContentLayout = .grid,
|
|
70
67
|
screenName: String = "",
|
|
71
68
|
@ViewBuilder content: @escaping () -> Content
|
|
72
69
|
) {
|
|
@@ -97,7 +94,6 @@ public struct StackScreen<Content: View>: View {
|
|
|
97
94
|
self.layoutOffset = layoutOffset
|
|
98
95
|
self.inputSearchProps = inputSearchProps
|
|
99
96
|
self.fabProps = fabProps
|
|
100
|
-
self.contentLayout = contentLayout
|
|
101
97
|
self.screenName = screenName
|
|
102
98
|
self.content = content
|
|
103
99
|
}
|
|
@@ -160,8 +156,8 @@ public struct StackScreen<Content: View>: View {
|
|
|
160
156
|
|
|
161
157
|
/// iPhone Duo: content scrolls under a glass header instead of starting below it.
|
|
162
158
|
private var useDuoGlass: Bool {
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
let hasPlainHeader = headerType != .none && animatedHeader == nil && inputSearchProps == nil
|
|
160
|
+
return layout.sideBar != nil && hasPlainHeader && !headerTransparent && !fullScreenContent
|
|
165
161
|
}
|
|
166
162
|
|
|
167
163
|
/// Bottom room for the tab's content: clear of the floating bar, unless the tab runs edge to edge
|
|
@@ -310,7 +306,6 @@ public struct StackScreen<Content: View>: View {
|
|
|
310
306
|
}
|
|
311
307
|
}
|
|
312
308
|
.ignoresSafeArea(.keyboard, edges: .bottom)
|
|
313
|
-
.environment(\.contentLayout, contentLayout)
|
|
314
309
|
.onChange(of: scrollOffset) { updateHeaderHide($0) }
|
|
315
310
|
.onAppear { reportEmptySideBar() }
|
|
316
311
|
.onChange(of: showsSideBar) { _ in reportEmptySideBar() }
|
|
@@ -337,9 +332,8 @@ public struct StackScreen<Content: View>: View {
|
|
|
337
332
|
.onDisappear { tracking?.cancel() }
|
|
338
333
|
}
|
|
339
334
|
|
|
340
|
-
/// Compose tracks from a `LaunchedEffect
|
|
341
|
-
///
|
|
342
|
-
/// `@State` and doesn't re-run `.task`, so the run hangs off appear / disappear instead.
|
|
335
|
+
/// Compose tracks from a `LaunchedEffect`, fresh on every visit (first show, pop back, tab switch). A covered
|
|
336
|
+
/// hosting controller keeps its `@State` and doesn't re-run `.task`, so tracking hangs off appear / disappear.
|
|
343
337
|
private func startTracking() {
|
|
344
338
|
tracking?.cancel()
|
|
345
339
|
let state = ScreenTrackingState()
|
|
@@ -510,28 +504,18 @@ public struct StackScreen<Content: View>: View {
|
|
|
510
504
|
}
|
|
511
505
|
|
|
512
506
|
private func heroGlassStart(_ animatedHeader: AnimatedHeader) -> CGFloat {
|
|
513
|
-
max(
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/// Wide windows and the iPhone Duo inner display keep the phone banner size, centered; phones fill the width.
|
|
517
|
-
private var bannerWidth: CGFloat {
|
|
518
|
-
layout.headerLayout(contentLayout).isBannerCentered ? HeaderLayoutMetrics.bannerWidth : layout.width
|
|
507
|
+
max(layout.width / animatedHeader.aspectRatio.value - layout.headerHeight, 0)
|
|
519
508
|
}
|
|
520
509
|
|
|
521
510
|
/// The banner fills the width at its aspect ratio; the body starts `layoutOffset` below the
|
|
522
|
-
/// header band so it overlaps the banner's lower part.
|
|
523
|
-
/// `bannerBackgroundColor` fills the sides, fading out downward.
|
|
511
|
+
/// header band so it overlaps the banner's lower part.
|
|
524
512
|
@ViewBuilder
|
|
525
513
|
private func animatedHeroBody(_ animatedHeader: AnimatedHeader) -> some View {
|
|
526
|
-
let width =
|
|
514
|
+
let width = layout.width
|
|
527
515
|
let imageHeight = width / animatedHeader.aspectRatio.value
|
|
528
516
|
let contentTopInset = layout.headerHeight + layoutOffset
|
|
529
517
|
|
|
530
518
|
ZStack(alignment: .top) {
|
|
531
|
-
if width < layout.width, let fill = animatedHeader.bannerBackgroundColor {
|
|
532
|
-
LinearGradient(colors: [fill, fill.opacity(0)], startPoint: .top, endPoint: .bottom)
|
|
533
|
-
.frame(width: layout.width, height: imageHeight)
|
|
534
|
-
}
|
|
535
519
|
animatedHeader.composable(scrollOffset)
|
|
536
520
|
.frame(width: width, height: imageHeight)
|
|
537
521
|
.clipped()
|
|
@@ -749,10 +733,16 @@ private struct SearchAnimatedHeader: View {
|
|
|
749
733
|
var hasToolkit: Bool = false
|
|
750
734
|
|
|
751
735
|
@Environment(\.screenLayout) private var layout
|
|
752
|
-
@Environment(\.contentLayout) private var contentLayout
|
|
753
736
|
@Environment(\.appTheme) private var theme
|
|
754
737
|
@OptionalEnvironmentObject private var navigator: Navigator?
|
|
755
738
|
|
|
739
|
+
private var maxEndInset: CGFloat {
|
|
740
|
+
if useSideBar && hasToolkit {
|
|
741
|
+
return Spacing.M
|
|
742
|
+
}
|
|
743
|
+
return headerRightWidth + (hasHeaderRight ? Spacing.M * 2 : Spacing.M)
|
|
744
|
+
}
|
|
745
|
+
|
|
756
746
|
var body: some View {
|
|
757
747
|
let scroll = max(scrollOffset, 0)
|
|
758
748
|
|
|
@@ -760,14 +750,12 @@ private struct SearchAnimatedHeader: View {
|
|
|
760
750
|
let rowTop = layout.headerStatusBarHeight - layout.insets.top
|
|
761
751
|
let minTop = rowTop + (layout.headerBarHeight - HEADER_HEIGHT) / 2
|
|
762
752
|
let maxTop = layout.headerHeight - layout.insets.top
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
// collapsed on the iPhone Duo status bar row, the search stays between its clusters
|
|
753
|
+
let minSide = Spacing.M
|
|
754
|
+
// collapsed on the iPhone Duo status bar row, the search stays between its clusters (48pt back there)
|
|
766
755
|
let clearance = layout.statusBarClearance
|
|
767
|
-
let
|
|
768
|
-
let
|
|
769
|
-
|
|
770
|
-
: headerRightWidth + (hasHeaderRight ? minSide + Spacing.M : minSide))
|
|
756
|
+
let backWidth: CGFloat = clearance != nil && !useSideBar ? DuoMetrics.controlSize : 28
|
|
757
|
+
let maxStart = (clearance?.left ?? 0) + (hiddenBack || useSideBar ? Spacing.M : backWidth + Spacing.M + Spacing.S)
|
|
758
|
+
let maxEnd = (clearance?.right ?? 0) + maxEndInset
|
|
771
759
|
|
|
772
760
|
// one progress for all three, so the field docks with its final insets and never covers the toolkit
|
|
773
761
|
let progress = min(scroll / HEADER_HEIGHT, 1)
|
|
@@ -783,7 +771,6 @@ private struct SearchAnimatedHeader: View {
|
|
|
783
771
|
theme: theme,
|
|
784
772
|
pop: navigator.map { navigator in { navigator.pop() } }
|
|
785
773
|
))
|
|
786
|
-
.headerSize()
|
|
787
774
|
.frame(height: HEADER_HEIGHT)
|
|
788
775
|
.padding(.leading, start)
|
|
789
776
|
.padding(.trailing, end)
|
|
@@ -803,9 +790,8 @@ private struct FloatingContent: View {
|
|
|
803
790
|
let hasFooter: Bool
|
|
804
791
|
let scrollOffset: CGFloat
|
|
805
792
|
|
|
806
|
-
/// Compose keeps the FAB `Spacing.M + AppNavigationBar`
|
|
807
|
-
///
|
|
808
|
-
/// nothing lifts it, so the difference is applied as an offset (see NavigationFooter).
|
|
793
|
+
/// Compose keeps the FAB `Spacing.M + AppNavigationBar` up and lifts it with `imePadding()`; here it sits
|
|
794
|
+
/// `Spacing.M` above the safe area with nothing lifting it, so the difference is an offset (see NavigationFooter).
|
|
809
795
|
private var verticalOffset: CGFloat {
|
|
810
796
|
if hasFooter { return NavigationFooter.verticalOffset(keyboardSize: keyboardSize) }
|
|
811
797
|
return NavigationFooter.safeAreaBottom - NavigationFooter.navigationBarInset - keyboardSize
|
|
@@ -869,9 +855,8 @@ public struct NavigationFooter: View {
|
|
|
869
855
|
max(navigationBarInset + Spacing.S - safeAreaBottom, 0)
|
|
870
856
|
}
|
|
871
857
|
|
|
872
|
-
/// An offset, not padding: growing the footer feeds back into
|
|
873
|
-
///
|
|
874
|
-
/// `FloatingContent` rides the same amount so the FAB keeps its distance above the band.
|
|
858
|
+
/// An offset, not padding: growing the footer feeds back into keyboard avoidance and never settles. Lands at
|
|
859
|
+
/// Compose's `max(navigationBar, keyboard) + Spacing.S`; `FloatingContent` rides it so the FAB keeps its gap.
|
|
875
860
|
static func verticalOffset(keyboardSize: CGFloat) -> CGFloat {
|
|
876
861
|
(safeAreaBottom + bottomPadding) - (max(navigationBarInset, keyboardSize) + Spacing.S)
|
|
877
862
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// SwiftUI mirror of Compose's `navigation/StackTransition.kt` (RN `forStackTransitionWithOverlay`)
|
|
2
|
-
//
|
|
3
|
-
// with UINavigationController; motion is a SwiftUI `offset`, which unlike a transform keeps the safe area.
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/StackTransition.kt` (RN `forStackTransitionWithOverlay`) and its NavHost.
|
|
2
|
+
// One UIHostingController per entry, out of the window while covered; motion is an `offset` to keep the safe area.
|
|
4
3
|
|
|
5
4
|
import SwiftUI
|
|
6
5
|
import UIKit
|
|
@@ -219,9 +218,11 @@ final class StackController: UIViewController {
|
|
|
219
218
|
let fraction = min(max((link.targetTimestamp - start) / transition.duration, 0), 1)
|
|
220
219
|
// linear for the stack: the gesture maps the finger straight onto this timeline
|
|
221
220
|
let eased = transition.kind == .rise ? fastOutSlowIn(CGFloat(fraction)) : CGFloat(fraction)
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
if fraction >= 1 {
|
|
222
|
+
transition.coverage = transition.target
|
|
223
|
+
} else {
|
|
224
|
+
transition.coverage = transition.from + (transition.target - transition.from) * eased
|
|
225
|
+
}
|
|
225
226
|
apply(transition)
|
|
226
227
|
if fraction >= 1 { finish(transition) }
|
|
227
228
|
}
|
|
@@ -29,9 +29,7 @@ public struct Skeleton: View {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
///
|
|
33
|
-
/// a linear gradient band (60% of the container width) translated across the
|
|
34
|
-
/// surface on an infinite, restarting, linearly-eased loop.
|
|
32
|
+
/// Compose's `Modifier.shimmerLoadingAnimation`: a gradient band 60% of the width sweeps across on a linear loop.
|
|
35
33
|
private struct ShimmerLoading: View {
|
|
36
34
|
let size: CGSize
|
|
37
35
|
let durationMillis: Int
|
|
@@ -50,9 +48,8 @@ private struct ShimmerLoading: View {
|
|
|
50
48
|
(size.width * Self.shadowBrushPercentage).rounded(.towardZero)
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
// Compose animates
|
|
54
|
-
//
|
|
55
|
-
// from off-screen-left to off-screen-right: -widthOfShadowBrush ... maxWidth.
|
|
51
|
+
// Compose animates to `durationMillis + widthOfShadowBrush`; the band is anchored at the value, so the travel
|
|
52
|
+
// that shows runs from fully off-screen left to fully off-screen right: -widthOfShadowBrush ... maxWidth.
|
|
56
53
|
private var animationTarget: CGFloat {
|
|
57
54
|
size.width + widthOfShadowBrush
|
|
58
55
|
}
|
package/ios/Steps/Steps.swift
CHANGED
|
@@ -180,10 +180,8 @@ private struct StepsHorizontal: View {
|
|
|
180
180
|
disabled: disabled
|
|
181
181
|
)
|
|
182
182
|
let isActiveOrError = status == .current || status == .error
|
|
183
|
-
let titleStyle: TypographyStyle = isActiveOrError
|
|
184
|
-
|
|
185
|
-
let descStyle: TypographyStyle = size == .small
|
|
186
|
-
? .descriptionXsRegular : .descriptionDefaultRegular
|
|
183
|
+
let titleStyle: TypographyStyle = isActiveOrError ? .headerXsSemibold : .descriptionDefaultRegular
|
|
184
|
+
let descStyle: TypographyStyle = size == .small ? .descriptionXsRegular : .descriptionDefaultRegular
|
|
187
185
|
let titleColor = resolveTitleColor(status, theme: theme)
|
|
188
186
|
let subColor = disabled ? theme.colors.text.disable : theme.colors.text.hint
|
|
189
187
|
|
|
@@ -193,12 +191,8 @@ private struct StepsHorizontal: View {
|
|
|
193
191
|
let hideLineLeft = align == .left || (align == .stretch && index == 0)
|
|
194
192
|
let hideLineRight = align == .right || (align == .stretch && index == steps.count - 1)
|
|
195
193
|
|
|
196
|
-
let lineLeft
|
|
197
|
-
|
|
198
|
-
: (activeIndex >= index ? completedLine : defaultLine)
|
|
199
|
-
let lineRight: Color = index == steps.count - 1
|
|
200
|
-
? Color.clear
|
|
201
|
-
: (activeIndex > index ? completedLine : defaultLine)
|
|
194
|
+
let lineLeft = lineColor(isOuterEnd: index == 0, isCompleted: activeIndex >= index)
|
|
195
|
+
let lineRight = lineColor(isOuterEnd: index == steps.count - 1, isCompleted: activeIndex > index)
|
|
202
196
|
|
|
203
197
|
let clickable = status == .completed && onPress != nil && !disabled
|
|
204
198
|
|
|
@@ -264,6 +258,13 @@ private struct StepsHorizontal: View {
|
|
|
264
258
|
}
|
|
265
259
|
}
|
|
266
260
|
|
|
261
|
+
private func lineColor(isOuterEnd: Bool, isCompleted: Bool) -> Color {
|
|
262
|
+
if isOuterEnd {
|
|
263
|
+
return .clear
|
|
264
|
+
}
|
|
265
|
+
return isCompleted ? completedLine : defaultLine
|
|
266
|
+
}
|
|
267
|
+
|
|
267
268
|
private func horizontalAlignment(for index: Int) -> HorizontalAlignment {
|
|
268
269
|
switch align {
|
|
269
270
|
case .left: return .leading
|
|
@@ -335,11 +336,8 @@ private struct StepsVertical: View {
|
|
|
335
336
|
let isActiveOrError = status == .current || status == .error
|
|
336
337
|
let isLast = index == steps.count - 1
|
|
337
338
|
|
|
338
|
-
let titleStyle
|
|
339
|
-
|
|
340
|
-
: (useSmall ? .descriptionDefaultRegular : .bodyDefaultRegular)
|
|
341
|
-
let descStyle: TypographyStyle = useSmall
|
|
342
|
-
? .descriptionXsRegular : .descriptionDefaultRegular
|
|
339
|
+
let titleStyle = resolveTitleStyle(isActiveOrError: isActiveOrError)
|
|
340
|
+
let descStyle: TypographyStyle = useSmall ? .descriptionXsRegular : .descriptionDefaultRegular
|
|
343
341
|
|
|
344
342
|
let titleColor = resolveTitleColor(status, theme: theme)
|
|
345
343
|
let subColor = disabled ? theme.colors.text.disable : theme.colors.text.hint
|
|
@@ -402,6 +400,13 @@ private struct StepsVertical: View {
|
|
|
402
400
|
rowBody
|
|
403
401
|
}
|
|
404
402
|
}
|
|
403
|
+
|
|
404
|
+
private func resolveTitleStyle(isActiveOrError: Bool) -> TypographyStyle {
|
|
405
|
+
if isActiveOrError {
|
|
406
|
+
return useSmall ? .headerXsSemibold : .headerSSemibold
|
|
407
|
+
}
|
|
408
|
+
return useSmall ? .descriptionDefaultRegular : .bodyDefaultRegular
|
|
409
|
+
}
|
|
405
410
|
}
|
|
406
411
|
|
|
407
412
|
// MARK: - Public API
|
|
@@ -465,9 +465,8 @@ private struct CardTabEarShape: Shape {
|
|
|
465
465
|
)
|
|
466
466
|
path.addLine(to: CGPoint(x: 0, y: 44))
|
|
467
467
|
path.closeSubpath()
|
|
468
|
-
return
|
|
469
|
-
|
|
470
|
-
: path
|
|
468
|
+
guard mirrored else { return path }
|
|
469
|
+
return path.applying(CGAffineTransform(a: -1, b: 0, c: 0, d: 1, tx: rect.width, ty: 0))
|
|
471
470
|
}
|
|
472
471
|
}
|
|
473
472
|
|
package/ios/Title/Title.swift
CHANGED
|
@@ -129,9 +129,7 @@ public struct Title: View {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
private var trailingBackground: Color {
|
|
132
|
-
type == .section
|
|
133
|
-
? Colors.black06.opacity(0.6)
|
|
134
|
-
: Colors.black06.opacity(0.3)
|
|
132
|
+
Colors.black06.opacity(type == .section ? 0.6 : 0.3)
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
// MARK: - Body
|