@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
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
/// Immutable snapshot of the
|
|
4
|
-
///
|
|
5
|
-
/// computed independently and the larger one wins.
|
|
3
|
+
/// Immutable snapshot of the font-scale inputs; formula 1:1 with Compose's `scaleSize()` (`const/Typography.kt`):
|
|
4
|
+
/// the device-width and OS Dynamic Type scales are computed independently and the larger wins.
|
|
6
5
|
public struct FontScale: Equatable {
|
|
7
6
|
private static let defaultScreenSize: CGFloat = 375
|
|
8
7
|
private static let maxFontScale: CGFloat = 1.5
|
|
@@ -14,9 +13,8 @@ public struct FontScale: Equatable {
|
|
|
14
13
|
public let osFontScale: CGFloat
|
|
15
14
|
/// From the app window, not UIScreen.main (which stays on one display on iPhone Duo).
|
|
16
15
|
public let windowShortSide: CGFloat
|
|
17
|
-
///
|
|
18
|
-
///
|
|
19
|
-
/// `MiniAppContext.scaleSizeMaxRate`.
|
|
16
|
+
/// Caps the result at size × maxScaleRate on both the userScaleRate and OS paths, nil = no cap. Set it with
|
|
17
|
+
/// `ScaleSizeScope` or `MiniAppContext.scaleSizeMaxRate` (Compose parity).
|
|
20
18
|
public let maxScaleRate: CGFloat?
|
|
21
19
|
|
|
22
20
|
public init(
|
|
@@ -101,9 +99,8 @@ public extension EnvironmentValues {
|
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
public extension View {
|
|
104
|
-
/// Injects a
|
|
105
|
-
///
|
|
106
|
-
/// Use at every `UIHostingController` root that is not inside a `NavigationContainer`.
|
|
102
|
+
/// Injects a live font scale plus `\.designSystemKitsConfigs` (whitelist, remote config). Needed at every
|
|
103
|
+
/// `UIHostingController` root outside a `NavigationContainer`.
|
|
107
104
|
func momoFontScale(_ store: DesignSystemKits = .shared, context: MiniAppContext? = nil) -> some View {
|
|
108
105
|
modifier(MomoFontScaleModifier(store: store, context: context))
|
|
109
106
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
/// Non-reactive
|
|
4
|
-
///
|
|
5
|
-
/// re-renders when Dynamic Type or the host preference changes.
|
|
3
|
+
/// Non-reactive, for call sites that can't read the environment (UIKit bridges, free functions). In a view use
|
|
4
|
+
/// `@Environment(\.momoFontScale)` so it re-renders when Dynamic Type or the host preference changes.
|
|
6
5
|
public func scaleSize(_ size: CGFloat) -> CGFloat {
|
|
7
6
|
DesignSystemKits.shared.fontScale(size)
|
|
8
7
|
}
|
|
@@ -9,14 +9,13 @@ public extension View {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
public extension Font {
|
|
12
|
-
/// Non-reactive: reads the
|
|
13
|
-
///
|
|
14
|
-
/// `fontScale.font(size:weight:)` also re-renders on change.
|
|
12
|
+
/// Non-reactive: reads the scale on each access, so the styles below are computed (a `static let` would freeze
|
|
13
|
+
/// it). In a view, `@Environment(\.momoFontScale)` + `fontScale.font(size:weight:)` also re-renders on change.
|
|
15
14
|
static func appFont(size: CGFloat) -> Font {
|
|
16
15
|
DesignSystemKits.shared.fontScale.font(size: size)
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
//
|
|
18
|
+
// Supported styles
|
|
20
19
|
static var headline_default_bold: Font { appFont(size: 24).weight(.bold) }
|
|
21
20
|
static var header_m_bold: Font { appFont(size: 18).weight(.bold) }
|
|
22
21
|
static var header_default_bold: Font { appFont(size: 16).weight(.bold) }
|
package/ios/native-kits.podspec
CHANGED
|
@@ -30,7 +30,6 @@ struct AnimatedHeaderDemoContent: View {
|
|
|
30
30
|
|
|
31
31
|
@State private var ratio: AnimatedHeaderRatio = .ratio16_9
|
|
32
32
|
@State private var isSurface = true
|
|
33
|
-
@State private var isStretch = true
|
|
34
33
|
|
|
35
34
|
private let imageUrl = "https://static.momocdn.net/app/img/booking/holiday/mid_atumn_dldl.jpeg"
|
|
36
35
|
|
|
@@ -48,11 +47,6 @@ struct AnimatedHeaderDemoContent: View {
|
|
|
48
47
|
MomoText("Surface")
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
// wide windows (short side >= 600): phone-sized banner, sides filled with the banner color
|
|
52
|
-
Toggle(isOn: $isStretch) {
|
|
53
|
-
MomoText("Stretch content layout")
|
|
54
|
-
}
|
|
55
|
-
|
|
56
50
|
MoMoUIKits.Button(
|
|
57
51
|
title: "Show Animated Header",
|
|
58
52
|
action: show,
|
|
@@ -69,7 +63,6 @@ struct AnimatedHeaderDemoContent: View {
|
|
|
69
63
|
private func show() {
|
|
70
64
|
let ratio = ratio
|
|
71
65
|
let isSurface = isSurface
|
|
72
|
-
let contentLayout: ContentLayout = isStretch ? .stretch : .grid
|
|
73
66
|
let url = imageUrl
|
|
74
67
|
navigator.push(
|
|
75
68
|
{ AnimatedHeaderTargetScreen(ratio: ratio) },
|
|
@@ -84,10 +77,8 @@ struct AnimatedHeaderDemoContent: View {
|
|
|
84
77
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
85
78
|
.clipped()
|
|
86
79
|
)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
),
|
|
90
|
-
contentLayout: contentLayout
|
|
80
|
+
}
|
|
81
|
+
)
|
|
91
82
|
)
|
|
92
83
|
)
|
|
93
84
|
}
|
|
@@ -273,9 +273,7 @@ private struct HeaderTypesScreen: View {
|
|
|
273
273
|
|
|
274
274
|
@EnvironmentObject private var navigation: Navigation
|
|
275
275
|
@Environment(\.applicationEnvironment) private var applicationEnvironment
|
|
276
|
-
@Environment(\.screenLayout) private var layout
|
|
277
276
|
@State private var kind: AnyHashable = Kind.default
|
|
278
|
-
@State private var contentLayout: AnyHashable = ContentLayout.grid
|
|
279
277
|
@State private var titlePosition: AnyHashable = TitlePosition.left
|
|
280
278
|
@State private var showBack = true
|
|
281
279
|
@State private var headerRight: AnyHashable = HeaderRightOption.toolkit
|
|
@@ -297,15 +295,6 @@ private struct HeaderTypesScreen: View {
|
|
|
297
295
|
}, label: position == .left ? "LEFT" : "CENTER")
|
|
298
296
|
}
|
|
299
297
|
Divider()
|
|
300
|
-
// stretch only differs on wide windows (short side >= 600, iPhone Duo excluded)
|
|
301
|
-
let headerLayout = layout.headerLayout(contentLayout.base as? ContentLayout ?? .grid)
|
|
302
|
-
MomoText("Content Layout · wide: \(headerLayout.isWide), frame inset: \(Int(headerLayout.frameInset))")
|
|
303
|
-
ForEach([ContentLayout.grid, ContentLayout.stretch], id: \.self) { item in
|
|
304
|
-
Radio(value: item, groupValue: $contentLayout, onChange: {
|
|
305
|
-
navigation.setOptions { $0.contentLayout = item }
|
|
306
|
-
}, label: item == .grid ? "Grid" : "Stretch")
|
|
307
|
-
}
|
|
308
|
-
Divider()
|
|
309
298
|
Checkbox($showBack, onChange: { checked in
|
|
310
299
|
navigation.setOptions { $0.hiddenBack = !checked }
|
|
311
300
|
}, title: "Show Back")
|
|
@@ -14,7 +14,7 @@ struct PopupNotifyDemo: View {
|
|
|
14
14
|
// MARK: - Preview
|
|
15
15
|
|
|
16
16
|
// Figma Risk - eKYC (node 51445-177824)
|
|
17
|
-
private let popupHighlightTitle = "Tạm khoá giao dịch để
|
|
17
|
+
private let popupHighlightTitle = "Tạm khoá giao dịch để bảo vệ bạn"
|
|
18
18
|
private let popupHighlightSentence =
|
|
19
19
|
"Mỗi ngày có ít nhất 20 người bị lừa đảo hơn 100 triệu đồng trong các giao dịch có dấu hiệu tương tự"
|
|
20
20
|
private let popupHighlightDescription =
|
package/package.json
CHANGED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
package vn.momo.kits.layout
|
|
2
|
-
|
|
3
|
-
import androidx.compose.runtime.Composable
|
|
4
|
-
import androidx.compose.runtime.Immutable
|
|
5
|
-
import androidx.compose.runtime.remember
|
|
6
|
-
import androidx.compose.ui.unit.Dp
|
|
7
|
-
import androidx.compose.ui.unit.dp
|
|
8
|
-
import vn.momo.kits.const.DEFAULT_SCREEN_SIZE
|
|
9
|
-
import vn.momo.kits.const.Spacing
|
|
10
|
-
|
|
11
|
-
// Top navigation spec (Figma "Top Navigation · Màn hình gập"); mirrors RN and SwiftUI, keep in sync.
|
|
12
|
-
val HEADER_BUTTON_SIZE = 32.dp
|
|
13
|
-
val HEADER_ICON_SIZE = 20.dp
|
|
14
|
-
val HEADER_PILL_WIDTH = 72.dp
|
|
15
|
-
val HEADER_SEARCH_HEIGHT = 32.dp
|
|
16
|
-
val HEADER_FRAME_MAX_WIDTH = 600.dp
|
|
17
|
-
// Banner image width on every device: wide windows keep the phone size, centered.
|
|
18
|
-
val HEADER_BANNER_WIDTH = DEFAULT_SCREEN_SIZE.dp
|
|
19
|
-
internal val HEADER_TITLE_GAP = Spacing.S
|
|
20
|
-
internal val HEADER_SIDE_PADDING = Spacing.M
|
|
21
|
-
// shortcut + gap + help/home pill
|
|
22
|
-
val HEADER_CLUSTER_WIDTH = HEADER_BUTTON_SIZE + HEADER_TITLE_GAP + HEADER_PILL_WIDTH
|
|
23
|
-
|
|
24
|
-
/** How a screen lays out its content on wide windows; the header row follows it. */
|
|
25
|
-
enum class ContentLayout {
|
|
26
|
-
// 12 column grid: the header keeps the 12pt side padding.
|
|
27
|
-
Grid,
|
|
28
|
-
// One column of at most HEADER_FRAME_MAX_WIDTH, centered: the header row sits in the same frame.
|
|
29
|
-
Stretch,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Header geometry for the current window; see [headerLayoutOf]. */
|
|
33
|
-
@Immutable
|
|
34
|
-
data class HeaderLayout(
|
|
35
|
-
// short side >= FOLDABLE_MIN_WIDTH, iPhone Duo excluded (it has its own layout)
|
|
36
|
-
val isWide: Boolean,
|
|
37
|
-
// banner kept at HEADER_BANNER_WIDTH, centered: wide windows plus the iPhone Duo inner display
|
|
38
|
-
val isBannerCentered: Boolean,
|
|
39
|
-
// padding from each side of the safe area to the header row (back, title / search, right cluster)
|
|
40
|
-
val frameInset: Dp,
|
|
41
|
-
// width of the header row, so tabs and other header extensions can line up with it
|
|
42
|
-
val frameWidth: Dp,
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
// Pass the screen's NavigationOptions.contentLayout so tabs and extensions line up with its header.
|
|
46
|
-
@Composable
|
|
47
|
-
fun rememberHeaderLayout(contentLayout: ContentLayout = ContentLayout.Grid): HeaderLayout {
|
|
48
|
-
val layout = getScreenLayout()
|
|
49
|
-
return remember(layout, contentLayout) { headerLayoutOf(layout, contentLayout) }
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
fun headerLayoutOf(layout: ScreenLayout, contentLayout: ContentLayout): HeaderLayout {
|
|
53
|
-
val isDuo = layout.isIPhoneDuo || layout.isIPhoneDuoDevice
|
|
54
|
-
val isLargeWindow = minOf(layout.width, layout.height) >= FOLDABLE_MIN_WIDTH
|
|
55
|
-
val isWide = !isDuo && isLargeWindow
|
|
56
|
-
val frameInset = if (isWide && contentLayout == ContentLayout.Stretch) {
|
|
57
|
-
maxOf(HEADER_SIDE_PADDING, (layout.contentWidth - HEADER_FRAME_MAX_WIDTH) / 2)
|
|
58
|
-
} else {
|
|
59
|
-
HEADER_SIDE_PADDING
|
|
60
|
-
}
|
|
61
|
-
return HeaderLayout(
|
|
62
|
-
isWide = isWide,
|
|
63
|
-
isBannerCentered = isLargeWindow,
|
|
64
|
-
frameInset = frameInset,
|
|
65
|
-
frameWidth = layout.contentWidth - frameInset * 2,
|
|
66
|
-
)
|
|
67
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// Top navigation spec (Figma "Top Navigation · Màn hình gập"). Mirrors Compose `layout/HeaderLayout.kt`
|
|
2
|
-
// and RN; keep the three in sync.
|
|
3
|
-
|
|
4
|
-
import SwiftUI
|
|
5
|
-
|
|
6
|
-
/// Header spec values, in points. Public so custom header rights and extensions can match them.
|
|
7
|
-
public enum HeaderLayoutMetrics {
|
|
8
|
-
public static let buttonSize: CGFloat = 32
|
|
9
|
-
public static let iconSize: CGFloat = 20
|
|
10
|
-
public static let pillWidth: CGFloat = 72
|
|
11
|
-
public static let searchHeight: CGFloat = 32
|
|
12
|
-
public static let titleGap: CGFloat = Spacing.S
|
|
13
|
-
public static let sidePadding: CGFloat = Spacing.M
|
|
14
|
-
/// shortcut + gap + help/home pill
|
|
15
|
-
public static let clusterWidth: CGFloat = buttonSize + titleGap + pillWidth
|
|
16
|
-
public static let frameMaxWidth: CGFloat = 600
|
|
17
|
-
/// Banner image width on every device: wide windows keep the phone size, centered.
|
|
18
|
-
public static let bannerWidth: CGFloat = 375
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/// How a screen lays out its content on wide windows; the header row follows it.
|
|
22
|
-
public enum ContentLayout: Equatable {
|
|
23
|
-
/// 12 column grid: the header keeps the 12pt side padding.
|
|
24
|
-
case grid
|
|
25
|
-
/// One column of at most `HeaderLayoutMetrics.frameMaxWidth`, centered: the header row sits in the same frame.
|
|
26
|
-
case stretch
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/// Header geometry for a window; see `ScreenLayout.headerLayout(_:)`.
|
|
30
|
-
public struct HeaderLayout: Equatable {
|
|
31
|
-
/// Short side >= 600, iPhone Duo excluded (it has its own layout).
|
|
32
|
-
public let isWide: Bool
|
|
33
|
-
/// Banner kept at `HeaderLayoutMetrics.bannerWidth`, centered: wide windows plus the iPhone Duo inner display.
|
|
34
|
-
public let isBannerCentered: Bool
|
|
35
|
-
/// Padding from each side of the safe area to the header row (back, title / search, right cluster).
|
|
36
|
-
public let frameInset: CGFloat
|
|
37
|
-
/// Width of the header row, so tabs and other header extensions can line up with it.
|
|
38
|
-
public let frameWidth: CGFloat
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public extension ScreenLayout {
|
|
42
|
-
func headerLayout(_ contentLayout: ContentLayout = .grid) -> HeaderLayout {
|
|
43
|
-
let isLargeWindow = min(width, height) >= ModalMetrics.foldableMinWidth
|
|
44
|
-
let isWide = !isIPhoneDuo && !isDuoDevice && isLargeWindow
|
|
45
|
-
let safeWidth = width - insets.leading - insets.trailing
|
|
46
|
-
let frameInset = isWide && contentLayout == .stretch
|
|
47
|
-
? max(HeaderLayoutMetrics.sidePadding, (safeWidth - HeaderLayoutMetrics.frameMaxWidth) / 2)
|
|
48
|
-
: HeaderLayoutMetrics.sidePadding
|
|
49
|
-
return HeaderLayout(
|
|
50
|
-
isWide: isWide,
|
|
51
|
-
isBannerCentered: isLargeWindow,
|
|
52
|
-
frameInset: frameInset,
|
|
53
|
-
frameWidth: safeWidth - frameInset * 2)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private struct ContentLayoutKey: EnvironmentKey {
|
|
58
|
-
static let defaultValue: ContentLayout = .grid
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
public extension EnvironmentValues {
|
|
62
|
-
/// The enclosing screen's `NavigationOptions.contentLayout`, set by `StackScreen`.
|
|
63
|
-
var contentLayout: ContentLayout {
|
|
64
|
-
get { self[ContentLayoutKey.self] }
|
|
65
|
-
set { self[ContentLayoutKey.self] = newValue }
|
|
66
|
-
}
|
|
67
|
-
}
|