@momo-kits/native-kits 0.300.7-debug → 0.300.8-beta.1-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/CLAUDE.md +12 -8
- package/README.md +8 -7
- package/compose/build.gradle.kts +2 -4
- package/compose/build.gradle.kts.backup +1 -3
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +1 -2
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +60 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +20 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +5 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +7 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +18 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +13 -73
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +1 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -53
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +3 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +12 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +17 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +20 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +83 -82
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +6 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +9 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +13 -35
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +5 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +6 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +3 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +22 -50
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +18 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +123 -64
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +24 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +59 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +69 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +5 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +43 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +330 -149
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +87 -70
- 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 +92 -261
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +31 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +46 -72
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +8 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +29 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +8 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +9 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +26 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +4 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +2 -3
- package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +44 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +2 -7
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +9 -18
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +1 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +3 -6
- 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 +12 -12
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +11 -6
- package/gradle/libs.versions.toml +1 -3
- package/gradle.properties +1 -3
- package/ios/Application/ApplicationEnvironment.swift +6 -4
- package/ios/Application/DesignSystemKits.swift +59 -13
- package/ios/Application/DesignSystemKitsPayload.swift +0 -8
- package/ios/Application/LanguageSource.swift +2 -11
- package/ios/Application/Localize.swift +8 -35
- package/ios/Application/LocalizeModifier.swift +2 -11
- package/ios/Application/MaxApi.swift +3 -11
- package/ios/Avatar/Avatar.swift +0 -1
- package/ios/Badge/Badge.swift +5 -8
- package/ios/Badge/BadgeRibbon.swift +2 -5
- package/ios/Button/Button.swift +4 -8
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
- package/ios/Carousel/Carousel.swift +4 -17
- package/ios/Checkbox/Checkbox.swift +0 -2
- package/ios/Collapse/Collapse.swift +17 -11
- package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
- package/ios/DateTimePicker/DateTimePicker.swift +4 -10
- package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
- package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
- package/ios/DateTimePicker/WheelPicker.swift +2 -4
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Extensions/SkeletonUICompat.swift +0 -8
- package/ios/Icon/Icon.swift +3 -6
- package/ios/IconButton/IconButton.swift +2 -5
- package/ios/Input/ErrorView.swift +0 -7
- package/ios/Input/Input.swift +9 -20
- package/ios/Input/InputPhoneNumber.swift +37 -20
- package/ios/Input/InputSearch.swift +23 -12
- package/ios/Input/InputTextArea.swift +4 -13
- package/ios/InputDropDown/InputDropDown.swift +1 -11
- package/ios/InputMoney/InputMoney.swift +9 -28
- package/ios/InputOTP/InputOTP.swift +2 -9
- package/ios/Layout/HeaderLayout.swift +72 -0
- package/ios/Layout/Item.swift +1 -2
- package/ios/Layout/ModalLayout.swift +144 -0
- package/ios/Layout/ScreenLayout.swift +48 -31
- package/ios/Layout/Section.swift +2 -3
- package/ios/Loader/Loader.swift +3 -12
- package/ios/Lottie/LottieView.swift +0 -11
- package/ios/Navigation/BottomSheet.swift +73 -94
- package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
- package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
- package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
- package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
- package/ios/Navigation/Component/FloatingButton.swift +4 -11
- package/ios/Navigation/Component/Header.swift +35 -54
- package/ios/Navigation/Component/HeaderBackground.swift +2 -8
- package/ios/Navigation/Component/HeaderJourney.swift +4 -8
- package/ios/Navigation/Component/HeaderLocation.swift +4 -8
- package/ios/Navigation/Component/HeaderRight.swift +20 -22
- package/ios/Navigation/Component/HeaderTitle.swift +1 -6
- package/ios/Navigation/Component/HeaderUser.swift +4 -10
- package/ios/Navigation/Component/SideBar.swift +6 -21
- package/ios/Navigation/Component/SnackBar.swift +9 -13
- package/ios/Navigation/HostBackGestureBridge.swift +2 -9
- package/ios/Navigation/ModalScreen.swift +24 -13
- package/ios/Navigation/Navigation.swift +35 -19
- package/ios/Navigation/NavigationContainer.swift +4 -15
- package/ios/Navigation/Navigator.swift +21 -39
- package/ios/Navigation/StackScreen.swift +64 -51
- package/ios/Navigation/StackTransition.swift +7 -14
- package/ios/Navigation/SwipeBackHaptic.swift +2 -7
- package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
- package/ios/Pagination/PaginationDot.swift +0 -9
- package/ios/Pagination/PaginationNumber.swift +1 -9
- package/ios/Pagination/PaginationScroll.swift +2 -14
- package/ios/Pagination/PaginationWhiteDot.swift +1 -10
- package/ios/Popup/PopupDisplay.swift +7 -5
- package/ios/Popup/PopupInput.swift +6 -4
- package/ios/Popup/PopupLayout.swift +17 -9
- package/ios/Popup/PopupNotify.swift +32 -25
- package/ios/PopupView/FullscreenPopup.swift +3 -4
- package/ios/PopupView/PopupView.swift +2 -2
- package/ios/PopupView/Utils++.swift +1 -2
- package/ios/ProgressInfo/ProgressInfo.swift +2 -13
- package/ios/Skeleton/Skeleton.swift +5 -16
- package/ios/Slider/Slider.swift +5 -12
- package/ios/StatusBarTap/StatusBarTap.h +2 -3
- package/ios/StatusBarTap/StatusBarTap.m +3 -16
- package/ios/Stepper/Stepper.swift +8 -27
- package/ios/Steps/Steps.swift +29 -26
- package/ios/Swipeable/SwipeCell.swift +2 -2
- package/ios/Swipeable/SwipeCellModel.swift +3 -6
- package/ios/TabView/TabView.swift +14 -28
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
- package/ios/Title/Title.swift +1 -3
- package/ios/Tooltip/Tooltip.swift +4 -9
- package/ios/Typography/FontScale.swift +79 -24
- package/ios/Typography/Text.swift +6 -12
- package/ios/Typography/Typography.swift +8 -11
- package/ios/Uploader/Uploader.swift +2 -17
- package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
- package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
- package/package.json +1 -1
- package/publish.sh +8 -2
- package/scripts/ci/build-swiftui.sh +22 -0
- package/scripts/ci/resolve-version.mjs +144 -0
- package/settings.gradle.kts +0 -1
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// InputDropDown.swift
|
|
3
|
-
// Pods
|
|
4
|
-
//
|
|
5
|
-
// Hand-written SwiftUI reimplementation of Compose `InputDropDown`.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
1
|
import SwiftUI
|
|
9
2
|
|
|
10
3
|
// MARK: - RenderRightIcon (mirrors Compose RenderRightIcon for InputDropDown)
|
|
@@ -16,8 +9,7 @@ private struct RenderRightIcon: View {
|
|
|
16
9
|
let onPressed: () -> Void
|
|
17
10
|
|
|
18
11
|
var body: some View {
|
|
19
|
-
//
|
|
20
|
-
// can both render at once, not exclusively (not an if/else).
|
|
12
|
+
// Not if/else, as in Compose: the spinner and the icon can show together.
|
|
21
13
|
if loading {
|
|
22
14
|
ActivityIndicator(isAnimating: .constant(true), style: .medium, color: color)
|
|
23
15
|
.frame(width: 16, height: 16)
|
|
@@ -100,7 +92,6 @@ public struct InputDropDown: View {
|
|
|
100
92
|
public var body: some View {
|
|
101
93
|
VStack(alignment: .leading, spacing: 0) {
|
|
102
94
|
ZStack(alignment: .topLeading) {
|
|
103
|
-
// Floating label
|
|
104
95
|
if !floatingValue.isEmpty || !floatingIcon.isEmpty {
|
|
105
96
|
HStack(spacing: 0) {
|
|
106
97
|
MomoText(floatingValue, typography: .labelSMedium, color: floatingTitleColor)
|
|
@@ -118,7 +109,6 @@ public struct InputDropDown: View {
|
|
|
118
109
|
.zIndex(10)
|
|
119
110
|
}
|
|
120
111
|
|
|
121
|
-
// Input container
|
|
122
112
|
HStack(alignment: .center, spacing: 0) {
|
|
123
113
|
if !leadingIcon.isEmpty {
|
|
124
114
|
Icon(source: leadingIcon, size: size == .small ? 24 : 32, color: leadingIconTintColor)
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// InputMoney.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// Native SwiftUI reimplementation of Compose `InputMoney`.
|
|
6
|
-
// The bound `text` holds RAW DIGITS only, as in Compose; the field shows
|
|
7
|
-
// the thousands-separated currency and edits apply at the caret.
|
|
8
|
-
//
|
|
9
|
-
|
|
10
1
|
import Foundation
|
|
11
2
|
import SwiftUI
|
|
12
3
|
import UIKit
|
|
@@ -35,7 +26,6 @@ public func formatNumberToMoney(_ digits: String, currency: String = "đ") -> St
|
|
|
35
26
|
for i in 0..<reversed.count {
|
|
36
27
|
count += 1
|
|
37
28
|
chars.append(reversed[i])
|
|
38
|
-
// i counts from the least significant digit; original index = len-1-i.
|
|
39
29
|
let originalIndex = reversed.count - 1 - i
|
|
40
30
|
if count == 3 && originalIndex >= 1 {
|
|
41
31
|
chars.append(".")
|
|
@@ -47,9 +37,8 @@ public func formatNumberToMoney(_ digits: String, currency: String = "đ") -> St
|
|
|
47
37
|
|
|
48
38
|
private func isMoneyDigit(_ char: Character) -> Bool { char.isASCII && char.isNumber }
|
|
49
39
|
|
|
50
|
-
/// Applies
|
|
51
|
-
///
|
|
52
|
-
/// digit before it instead, removing only the currency leaves the digits untouched. Returns the new digits and the caret as a digit index.
|
|
40
|
+
/// Applies the edit `display[start..<end]` → `inserted` to the digits of `display`. Separators and
|
|
41
|
+
/// currency are never deleted: removing a separator deletes the digit before it instead.
|
|
53
42
|
private func applyMoneyEdit(_ display: String, start: Int, end: Int, inserted: String) -> (digits: String, caretDigit: Int) {
|
|
54
43
|
let chars = Array(display)
|
|
55
44
|
let start = min(start, chars.count)
|
|
@@ -83,6 +72,8 @@ private func moneyCaret(_ display: String, digitIndex: Int) -> Int {
|
|
|
83
72
|
|
|
84
73
|
// MARK: - InputMoney
|
|
85
74
|
|
|
75
|
+
/// Compose `InputMoney`: the bound `text` holds raw digits only; the field shows the
|
|
76
|
+
/// thousands-separated currency and edits apply at the caret.
|
|
86
77
|
public struct InputMoney: View {
|
|
87
78
|
@Environment(\.appTheme) private var theme
|
|
88
79
|
@Environment(\.momoFontScale) private var fontScale
|
|
@@ -166,7 +157,6 @@ public struct InputMoney: View {
|
|
|
166
157
|
public var body: some View {
|
|
167
158
|
VStack(alignment: .leading, spacing: 0) {
|
|
168
159
|
ZStack(alignment: .topLeading) {
|
|
169
|
-
// Floating label
|
|
170
160
|
if !floatingValue.isEmpty || !floatingIcon.isEmpty {
|
|
171
161
|
HStack(spacing: 0) {
|
|
172
162
|
MomoText(floatingValue, typography: .labelSMedium, color: floatingTitleColor)
|
|
@@ -185,24 +175,18 @@ public struct InputMoney: View {
|
|
|
185
175
|
}
|
|
186
176
|
)
|
|
187
177
|
.background(theme.colors.background.surface)
|
|
188
|
-
//
|
|
189
|
-
//
|
|
190
|
-
// the label ends up centered exactly on the box's top border. Our ZStack
|
|
191
|
-
// anchors top-leading instead, so matching that requires offsetting by
|
|
192
|
-
// half the label's OWN measured height, not half the box height.
|
|
178
|
+
// Compose centers the label in the box and offsets it by -box height / 2, onto the
|
|
179
|
+
// top border; this ZStack anchors top-leading, so it offsets by half the label height.
|
|
193
180
|
.offset(x: Spacing.S, y: -floatingLabelHeight / 2)
|
|
194
181
|
.zIndex(10)
|
|
195
182
|
}
|
|
196
183
|
|
|
197
|
-
// Input container
|
|
198
184
|
HStack(alignment: .center, spacing: 0) {
|
|
199
|
-
// Leading icon
|
|
200
185
|
if !leadingIcon.isEmpty {
|
|
201
186
|
Icon(source: leadingIcon, size: size == .small ? 24 : 32, color: leadingIconTintColor)
|
|
202
187
|
.padding(.trailing, Spacing.XS)
|
|
203
188
|
}
|
|
204
189
|
|
|
205
|
-
// Money field
|
|
206
190
|
ZStack(alignment: .leading) {
|
|
207
191
|
if !hasDigits {
|
|
208
192
|
MomoText(
|
|
@@ -226,7 +210,6 @@ public struct InputMoney: View {
|
|
|
226
210
|
}
|
|
227
211
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
228
212
|
|
|
229
|
-
// Clear button (focused + has value)
|
|
230
213
|
if isFocused && hasDigits {
|
|
231
214
|
SwiftUI.Button(action: {
|
|
232
215
|
text = ""
|
|
@@ -238,8 +221,7 @@ public struct InputMoney: View {
|
|
|
238
221
|
}
|
|
239
222
|
}
|
|
240
223
|
|
|
241
|
-
//
|
|
242
|
-
// Compose's two independent `if` blocks, not if/else).
|
|
224
|
+
// Not if/else, as in Compose: the spinner and the icon can show together.
|
|
243
225
|
if loading {
|
|
244
226
|
ActivityIndicator(isAnimating: .constant(true), style: .medium, color: iconTintColor)
|
|
245
227
|
.frame(width: 16, height: 16)
|
|
@@ -303,9 +285,8 @@ public struct InputMoney: View {
|
|
|
303
285
|
|
|
304
286
|
// MARK: - MoneyTextField (UIViewRepresentable)
|
|
305
287
|
|
|
306
|
-
///
|
|
307
|
-
///
|
|
308
|
-
/// but never past the trailing currency symbol; edits apply at the caret.
|
|
288
|
+
/// Shows the formatted currency while `digits` holds the raw value; the caret never passes the
|
|
289
|
+
/// currency suffix.
|
|
309
290
|
private struct MoneyTextField: UIViewRepresentable {
|
|
310
291
|
@Binding var digits: String
|
|
311
292
|
var keyboardType: UIKeyboardType
|
|
@@ -27,11 +27,8 @@ private struct OTPCaret: View {
|
|
|
27
27
|
|
|
28
28
|
// MARK: - InputOTP
|
|
29
29
|
|
|
30
|
-
///
|
|
31
|
-
///
|
|
32
|
-
/// A row of OTP cells driven by a hidden `TextField`. When `length` is provided
|
|
33
|
-
/// it renders fixed-count slots (`-` placeholders + blinking caret); otherwise it
|
|
34
|
-
/// renders the typed characters followed by a trailing caret while focused.
|
|
30
|
+
/// Compose `InputOTP`: cells driven by a hidden `TextField`. With `length`, fixed slots (`-`
|
|
31
|
+
/// placeholders + blinking caret); without, the typed characters and a trailing caret while focused.
|
|
35
32
|
public struct InputOTP: View {
|
|
36
33
|
@Environment(\.appTheme) private var theme
|
|
37
34
|
@Binding public var value: String
|
|
@@ -80,10 +77,8 @@ public struct InputOTP: View {
|
|
|
80
77
|
public var body: some View {
|
|
81
78
|
VStack(alignment: .leading, spacing: 0) {
|
|
82
79
|
ZStack {
|
|
83
|
-
// Hidden text field that owns the keyboard / cursor.
|
|
84
80
|
hiddenField
|
|
85
81
|
|
|
86
|
-
// Floating label over the border.
|
|
87
82
|
if !floatingValue.isEmpty {
|
|
88
83
|
HStack {
|
|
89
84
|
MomoText(floatingValue, typography: .labelSMedium, color: theme.colors.text.hint)
|
|
@@ -94,7 +89,6 @@ public struct InputOTP: View {
|
|
|
94
89
|
.zIndex(10)
|
|
95
90
|
}
|
|
96
91
|
|
|
97
|
-
// Bordered container with cells.
|
|
98
92
|
cells
|
|
99
93
|
.frame(maxWidth: .infinity)
|
|
100
94
|
.frame(height: 56)
|
|
@@ -103,7 +97,6 @@ public struct InputOTP: View {
|
|
|
103
97
|
.stroke(borderColor, lineWidth: 1)
|
|
104
98
|
)
|
|
105
99
|
|
|
106
|
-
// Trailing clear button.
|
|
107
100
|
HStack {
|
|
108
101
|
Spacer()
|
|
109
102
|
SwiftUI.Button(action: clearText) {
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
/// Stretch frame on hold until design confirms it: `.stretch` lays out like `.grid`.
|
|
7
|
+
private let isStretchFrameEnabled = false
|
|
8
|
+
|
|
9
|
+
/// Header spec values, in points. Public so custom header rights and extensions can match them.
|
|
10
|
+
public enum HeaderLayoutMetrics {
|
|
11
|
+
public static let buttonSize: CGFloat = 32
|
|
12
|
+
public static let iconSize: CGFloat = 20
|
|
13
|
+
public static let pillWidth: CGFloat = 72
|
|
14
|
+
public static let searchHeight: CGFloat = 32
|
|
15
|
+
public static let titleGap: CGFloat = Spacing.S
|
|
16
|
+
public static let sidePadding: CGFloat = Spacing.M
|
|
17
|
+
/// shortcut + gap + help/home pill
|
|
18
|
+
public static let clusterWidth: CGFloat = buttonSize + titleGap + pillWidth
|
|
19
|
+
public static let frameMaxWidth: CGFloat = 600
|
|
20
|
+
/// Banner image width on every device: wide windows keep the phone size, centered.
|
|
21
|
+
public static let bannerWidth: CGFloat = 375
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// How a screen lays out its content on wide windows; the header row follows it.
|
|
25
|
+
public enum ContentLayout: Equatable {
|
|
26
|
+
/// 12 column grid: the header keeps the 12pt side padding.
|
|
27
|
+
case grid
|
|
28
|
+
/// One column of at most `HeaderLayoutMetrics.frameMaxWidth`, centered: the header row sits in the same frame.
|
|
29
|
+
/// On hold: same as `.grid` for now.
|
|
30
|
+
case stretch
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// Header geometry for a window; see `ScreenLayout.headerLayout(_:)`.
|
|
34
|
+
public struct HeaderLayout: Equatable {
|
|
35
|
+
/// Short side >= 600, iPhone Duo excluded (it has its own layout).
|
|
36
|
+
public let isWide: Bool
|
|
37
|
+
/// Banner kept at `HeaderLayoutMetrics.bannerWidth`, centered: wide windows plus the iPhone Duo inner display.
|
|
38
|
+
public let isBannerCentered: Bool
|
|
39
|
+
/// Padding from each side of the safe area to the header row (back, title / search, right cluster).
|
|
40
|
+
public let frameInset: CGFloat
|
|
41
|
+
/// Width of the header row, so tabs and other header extensions can line up with it.
|
|
42
|
+
public let frameWidth: CGFloat
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public extension ScreenLayout {
|
|
46
|
+
func headerLayout(_ contentLayout: ContentLayout = .grid) -> HeaderLayout {
|
|
47
|
+
let isLargeWindow = min(width, height) >= ModalMetrics.foldableMinWidth
|
|
48
|
+
let isWide = !isIPhoneDuo && !isDuoDevice && isLargeWindow
|
|
49
|
+
let safeWidth = width - insets.leading - insets.trailing
|
|
50
|
+
let isStretch = isStretchFrameEnabled && contentLayout == .stretch
|
|
51
|
+
let frameInset = isWide && isStretch
|
|
52
|
+
? max(HeaderLayoutMetrics.sidePadding, (safeWidth - HeaderLayoutMetrics.frameMaxWidth) / 2)
|
|
53
|
+
: HeaderLayoutMetrics.sidePadding
|
|
54
|
+
return HeaderLayout(
|
|
55
|
+
isWide: isWide,
|
|
56
|
+
isBannerCentered: isLargeWindow,
|
|
57
|
+
frameInset: frameInset,
|
|
58
|
+
frameWidth: safeWidth - frameInset * 2)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private struct ContentLayoutKey: EnvironmentKey {
|
|
63
|
+
static let defaultValue: ContentLayout = .grid
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public extension EnvironmentValues {
|
|
67
|
+
/// The enclosing screen's `NavigationOptions.contentLayout`, set by `StackScreen`.
|
|
68
|
+
var contentLayout: ContentLayout {
|
|
69
|
+
get { self[ContentLayoutKey.self] }
|
|
70
|
+
set { self[ContentLayoutKey.self] = newValue }
|
|
71
|
+
}
|
|
72
|
+
}
|
package/ios/Layout/Item.swift
CHANGED
|
@@ -19,8 +19,7 @@ public struct ItemView<Content: View>: View {
|
|
|
19
19
|
// MARK: Public
|
|
20
20
|
|
|
21
21
|
public var body: some View {
|
|
22
|
-
//
|
|
23
|
-
// on top of each other — matches the React Item's flex-column content.
|
|
22
|
+
// VStack, not ZStack: children flow vertically like RN Item's flex-column content.
|
|
24
23
|
VStack(alignment: .leading, spacing: 0) { content() }
|
|
25
24
|
.frame(width: width, height: height, alignment: .topLeading)
|
|
26
25
|
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Foldable spec for Popup and BottomSheet (Figma "Modal - Foldable Guideline"). Mirrors Compose
|
|
2
|
+
// `layout/ModalLayout.kt` and RN; keep the three in sync.
|
|
3
|
+
|
|
4
|
+
import SwiftUI
|
|
5
|
+
|
|
6
|
+
/// Foldable modal spec values, in points. Public so host apps can size their own popups and sheets the same way.
|
|
7
|
+
public enum ModalMetrics {
|
|
8
|
+
public static let popupMaxWidth: CGFloat = 450
|
|
9
|
+
public static let popupMinWidth: CGFloat = 280
|
|
10
|
+
public static let popupMaxHeight: CGFloat = 600
|
|
11
|
+
public static let sheetMaxWidth: CGFloat = 653
|
|
12
|
+
public static let sheetMinWidth: CGFloat = 296
|
|
13
|
+
public static let sheetMinHeight: CGFloat = 230
|
|
14
|
+
public static let foldableMinWidth: CGFloat = 600
|
|
15
|
+
public static let iconButtonSize: CGFloat = 32
|
|
16
|
+
public static let iconSize: CGFloat = 20
|
|
17
|
+
public static let phoneScrimOpacity: CGFloat = 0.6
|
|
18
|
+
public static let foldableScrimOpacity: CGFloat = 0.2
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public struct PopupGeometry: Equatable {
|
|
22
|
+
public let minWidth: CGFloat
|
|
23
|
+
public let maxWidth: CGFloat
|
|
24
|
+
/// nil: as tall as the content, phones keep their own caps
|
|
25
|
+
public let maxHeight: CGFloat?
|
|
26
|
+
public let margin: CGFloat
|
|
27
|
+
public let radius: CGFloat
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public struct SheetGeometry: Equatable {
|
|
31
|
+
/// nil: spans the window
|
|
32
|
+
public let width: CGFloat?
|
|
33
|
+
/// nil: phones keep their own cap
|
|
34
|
+
public let maxHeight: CGFloat?
|
|
35
|
+
public let minHeight: CGFloat
|
|
36
|
+
public let margin: CGFloat
|
|
37
|
+
public let radius: CGFloat
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/// Popup / bottom sheet geometry for a window; see `ModalLayout.resolve` and `ScreenLayout.modalLayout`.
|
|
41
|
+
public struct ModalLayout: Equatable {
|
|
42
|
+
public let isFoldable: Bool
|
|
43
|
+
/// Window coordinates of the area popups center in and sheets rest on the bottom of.
|
|
44
|
+
public let placement: CGRect
|
|
45
|
+
public let popup: PopupGeometry
|
|
46
|
+
public let sheet: SheetGeometry
|
|
47
|
+
public let scrimOpacity: CGFloat
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public extension ScreenLayout {
|
|
51
|
+
/// Foldable = iPhone Duo or a window whose short side is at least 600 (RN parity), so phones
|
|
52
|
+
/// in landscape keep their look.
|
|
53
|
+
var modalLayout: ModalLayout {
|
|
54
|
+
ModalLayout.resolve(width: width, height: height, safeInsets: insets, isDuoDevice: isDuoDevice, hinge: hinge)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public extension ModalLayout {
|
|
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).
|
|
61
|
+
static func resolve(
|
|
62
|
+
width: CGFloat,
|
|
63
|
+
height: CGFloat,
|
|
64
|
+
safeInsets insets: EdgeInsets = EdgeInsets(),
|
|
65
|
+
isDuoDevice: Bool = false,
|
|
66
|
+
hinge: CGRect? = nil
|
|
67
|
+
) -> ModalLayout {
|
|
68
|
+
let isFoldable = isDuoDevice || min(width, height) >= ModalMetrics.foldableMinWidth
|
|
69
|
+
guard isFoldable else {
|
|
70
|
+
let placement = CGRect(x: 0, y: 0, width: width, height: height)
|
|
71
|
+
return ModalLayout(
|
|
72
|
+
isFoldable: false,
|
|
73
|
+
placement: placement,
|
|
74
|
+
popup: popupGeometry(placementWidth: width, maxHeight: nil, margin: Spacing.XL, radius: Radius.XL),
|
|
75
|
+
sheet: SheetGeometry(width: nil, maxHeight: nil, minHeight: 0, margin: 0, radius: Radius.XL),
|
|
76
|
+
scrimOpacity: ModalMetrics.phoneScrimOpacity
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// the safe area keeps overlays clear of the iPhone Duo control column; half folded they move to the right half
|
|
81
|
+
let hinge = hinge.flatMap { isDuoDevice && $0.minX > 0 && $0.maxX < width ? $0 : nil }
|
|
82
|
+
let left = max(insets.leading, hinge?.maxX ?? 0)
|
|
83
|
+
let placement = CGRect(
|
|
84
|
+
x: left,
|
|
85
|
+
y: insets.top,
|
|
86
|
+
width: max(width - insets.trailing - left, 0),
|
|
87
|
+
height: max(height - insets.top - insets.bottom, 0)
|
|
88
|
+
)
|
|
89
|
+
// outer display and half fold leave little room, so the margins tighten
|
|
90
|
+
let isCompact = isDuoDevice && (hinge != nil || min(width, height) < ModalMetrics.foldableMinWidth)
|
|
91
|
+
let sheetMargin = Spacing.M
|
|
92
|
+
let sheetMaxHeight = height - insets.top - sheetMargin
|
|
93
|
+
let sheetMinWidth = min(ModalMetrics.sheetMinWidth, placement.width)
|
|
94
|
+
return ModalLayout(
|
|
95
|
+
isFoldable: true,
|
|
96
|
+
placement: placement,
|
|
97
|
+
popup: popupGeometry(
|
|
98
|
+
placementWidth: placement.width,
|
|
99
|
+
maxHeight: min(ModalMetrics.popupMaxHeight, placement.height - Spacing.XL * 2),
|
|
100
|
+
margin: isCompact ? Spacing.M : Spacing.XL,
|
|
101
|
+
radius: Radius.XL
|
|
102
|
+
),
|
|
103
|
+
sheet: SheetGeometry(
|
|
104
|
+
width: max(min(placement.width - sheetMargin * 2, ModalMetrics.sheetMaxWidth), sheetMinWidth),
|
|
105
|
+
maxHeight: sheetMaxHeight,
|
|
106
|
+
minHeight: min(ModalMetrics.sheetMinHeight, sheetMaxHeight),
|
|
107
|
+
margin: sheetMargin,
|
|
108
|
+
radius: Radius.XL
|
|
109
|
+
),
|
|
110
|
+
scrimOpacity: ModalMetrics.foldableScrimOpacity
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/// clamp(placement - 2 margin, 280, 450); the 280 floor gives way to a narrower placement.
|
|
115
|
+
private static func popupGeometry(placementWidth: CGFloat, maxHeight: CGFloat?, margin: CGFloat, radius: CGFloat) -> PopupGeometry {
|
|
116
|
+
let minWidth = min(ModalMetrics.popupMinWidth, placementWidth)
|
|
117
|
+
let maxWidth = min(max(placementWidth - margin * 2, minWidth), max(ModalMetrics.popupMaxWidth, minWidth))
|
|
118
|
+
return PopupGeometry(minWidth: minWidth, maxWidth: maxWidth, maxHeight: maxHeight, margin: margin, radius: radius)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// Popup close and sheet header back / close: 32 circle on the surface with a border, 20 icon.
|
|
123
|
+
public struct ModalIconButton: View {
|
|
124
|
+
@Environment(\.appTheme) private var theme
|
|
125
|
+
let icon: String
|
|
126
|
+
let accessibilityId: String
|
|
127
|
+
let action: () -> Void
|
|
128
|
+
|
|
129
|
+
public init(icon: String, accessibilityId: String, action: @escaping () -> Void) {
|
|
130
|
+
self.icon = icon
|
|
131
|
+
self.accessibilityId = accessibilityId
|
|
132
|
+
self.action = action
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public var body: some View {
|
|
136
|
+
Icon(source: icon, size: ModalMetrics.iconSize, color: theme.colors.text.default)
|
|
137
|
+
.frame(width: ModalMetrics.iconButtonSize, height: ModalMetrics.iconButtonSize)
|
|
138
|
+
.background(Circle().fill(theme.colors.background.surface))
|
|
139
|
+
.overlay(Circle().strokeBorder(theme.colors.border.default, lineWidth: 1))
|
|
140
|
+
.contentShape(Circle())
|
|
141
|
+
.onTapGesture(perform: action)
|
|
142
|
+
.accessibilityIdentifier(accessibilityId)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// Port of momo-kits RN `useScreenLayout` (Layout/utils.ts) and `Application/device.ts`:
|
|
6
|
-
// window size, safe-area insets, content width, header geometry and the iPhone Duo side bar.
|
|
7
|
-
//
|
|
1
|
+
// Port of momo-kits RN `useScreenLayout` (Layout/utils.ts) and `Application/device.ts`:
|
|
2
|
+
// window size, safe-area insets, content width, header geometry and the iPhone Duo side bar.
|
|
8
3
|
|
|
9
4
|
import SwiftUI
|
|
10
5
|
import UIKit
|
|
@@ -32,7 +27,8 @@ public struct ScreenLayout: Equatable {
|
|
|
32
27
|
public let width: CGFloat
|
|
33
28
|
public let height: CGFloat
|
|
34
29
|
public let isIPhoneDuo: Bool
|
|
35
|
-
///
|
|
30
|
+
/// iPhone Duo folded or not, whatever the window size (its hinge, or the outer display's one-sided strip);
|
|
31
|
+
/// drives popups, modal and bottom sheet.
|
|
36
32
|
public let isDuoDevice: Bool
|
|
37
33
|
public let insets: EdgeInsets
|
|
38
34
|
public let insetLeft: CGFloat
|
|
@@ -45,6 +41,8 @@ public struct ScreenLayout: Equatable {
|
|
|
45
41
|
public let sideBar: SideBarLayout?
|
|
46
42
|
/// iPhone Duo inner display in portrait: the header row shares the status bar band, between its clusters.
|
|
47
43
|
public let statusBarClearance: StatusBarClearance?
|
|
44
|
+
/// Half-folded iPhone Duo: the hinge in window coordinates, running top to bottom; nil while flat.
|
|
45
|
+
public let hinge: CGRect?
|
|
48
46
|
|
|
49
47
|
public var headerBarHeight: CGFloat { headerHeight - headerStatusBarHeight }
|
|
50
48
|
}
|
|
@@ -110,11 +108,14 @@ extension ScreenLayout {
|
|
|
110
108
|
insets: EdgeInsets,
|
|
111
109
|
reservedRegions: [CGRect] = ReservedRegions.current,
|
|
112
110
|
isPhone: Bool = isPhoneIdiom,
|
|
113
|
-
isFoldable: Bool = FoldableDevice.isFoldable(measuredIn: keyWindow)
|
|
111
|
+
isFoldable: Bool = FoldableDevice.isFoldable(measuredIn: keyWindow),
|
|
112
|
+
division: CGRect? = FoldableDevice.halfFoldedHinge
|
|
114
113
|
) -> ScreenLayout {
|
|
115
114
|
let width = size.width
|
|
116
115
|
let height = size.height
|
|
117
116
|
let isDuoDevice = isPhone && isFoldable
|
|
117
|
+
// only a hinge splitting the window into left and right halves moves overlays
|
|
118
|
+
let hinge = division.flatMap { isPhone && $0.height > $0.width ? $0 : nil }
|
|
118
119
|
var (headerHeight, headerStatusBarHeight) = headerGeometry(topInset: insets.top, isPhone: isPhone)
|
|
119
120
|
let isDuo = isPhone && isIPhoneDuoWindow(width: width, height: height, insets: insets)
|
|
120
121
|
guard isDuo else {
|
|
@@ -122,7 +123,7 @@ extension ScreenLayout {
|
|
|
122
123
|
width: width, height: height, isIPhoneDuo: false, isDuoDevice: isDuoDevice, insets: insets,
|
|
123
124
|
insetLeft: 0, insetRight: 0, contentWidth: width,
|
|
124
125
|
headerHeight: headerHeight, headerStatusBarHeight: headerStatusBarHeight, sideBar: nil,
|
|
125
|
-
statusBarClearance: nil
|
|
126
|
+
statusBarClearance: nil, hinge: hinge
|
|
126
127
|
)
|
|
127
128
|
}
|
|
128
129
|
|
|
@@ -146,9 +147,10 @@ extension ScreenLayout {
|
|
|
146
147
|
// Activities; region frames already include the system's margin
|
|
147
148
|
let occlusion = stripOcclusion(reservedRegions, stripLeft: stripLeft, stripRight: stripLeft + sideInset, windowHeight: height)
|
|
148
149
|
|
|
149
|
-
var top =
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
var top = insets.top + HeaderMetrics.barHeight + Spacing.M
|
|
151
|
+
if statusBarClearance != nil {
|
|
152
|
+
top = headerHeight + Spacing.M
|
|
153
|
+
}
|
|
152
154
|
if insets.top < HeaderMetrics.statusBarMinInset {
|
|
153
155
|
// status bar lives in the strip: start under its cluster, as the native bar does
|
|
154
156
|
if width <= height {
|
|
@@ -178,12 +180,14 @@ extension ScreenLayout {
|
|
|
178
180
|
)
|
|
179
181
|
}
|
|
180
182
|
|
|
183
|
+
// the outer display reports no hinge; its one-sided strip still gives it away
|
|
181
184
|
return ScreenLayout(
|
|
182
|
-
width: width, height: height, isIPhoneDuo: true,
|
|
185
|
+
width: width, height: height, isIPhoneDuo: true,
|
|
186
|
+
isDuoDevice: isDuoDevice || insets.leading != insets.trailing, insets: insets,
|
|
183
187
|
insetLeft: insets.leading, insetRight: insets.trailing,
|
|
184
188
|
contentWidth: width - insets.leading - insets.trailing,
|
|
185
189
|
headerHeight: headerHeight, headerStatusBarHeight: headerStatusBarHeight, sideBar: sideBar,
|
|
186
|
-
statusBarClearance: statusBarClearance
|
|
190
|
+
statusBarClearance: statusBarClearance, hinge: hinge
|
|
187
191
|
)
|
|
188
192
|
}
|
|
189
193
|
|
|
@@ -203,9 +207,8 @@ extension ScreenLayout {
|
|
|
203
207
|
return (height, max(0, centerY * 2 - height))
|
|
204
208
|
}
|
|
205
209
|
|
|
206
|
-
/// How far system regions reach into a side strip from its top and
|
|
207
|
-
///
|
|
208
|
-
/// 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.
|
|
209
212
|
private static func stripOcclusion(
|
|
210
213
|
_ regions: [CGRect],
|
|
211
214
|
stripLeft: CGFloat,
|
|
@@ -256,20 +259,28 @@ extension ScreenLayout {
|
|
|
256
259
|
public var duoTopInset: CGFloat {
|
|
257
260
|
max(insets.top, height > width ? max(insets.leading, insets.trailing) * 2 : 0)
|
|
258
261
|
}
|
|
262
|
+
|
|
259
263
|
}
|
|
260
264
|
|
|
261
265
|
/// Snapshot for call sites without `\.screenLayout`; not reactive. `windowSize` is ignored,
|
|
262
266
|
/// kept for host call sites.
|
|
263
267
|
public func isIPhoneDuoDevice(windowSize: CGSize? = nil) -> Bool {
|
|
264
|
-
isPhoneIdiom
|
|
268
|
+
guard isPhoneIdiom else { return false }
|
|
269
|
+
let insets = keyWindow?.safeAreaInsets
|
|
270
|
+
return FoldableDevice.isFoldable(measuredIn: keyWindow) || insets.map { $0.left != $0.right } == true
|
|
265
271
|
}
|
|
266
272
|
|
|
267
|
-
/// Apple's foldable check (
|
|
268
|
-
///
|
|
269
|
-
/// 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.
|
|
270
275
|
enum FoldableDevice {
|
|
271
276
|
// a hinge never goes away, so a positive answer is kept
|
|
272
277
|
private static var isKnownFoldable = false
|
|
278
|
+
private static var isPartiallyOpen = false
|
|
279
|
+
|
|
280
|
+
/// The active division region while the hinge reports partially open; nil while flat.
|
|
281
|
+
static var halfFoldedHinge: CGRect? {
|
|
282
|
+
isPartiallyOpen ? ReservedRegions.division : nil
|
|
283
|
+
}
|
|
273
284
|
|
|
274
285
|
static func isFoldable(measuredIn view: UIView?) -> Bool {
|
|
275
286
|
if isKnownFoldable { return true }
|
|
@@ -286,8 +297,11 @@ enum FoldableDevice {
|
|
|
286
297
|
#if canImport(UIKit, _version: 9127.0.85.28)
|
|
287
298
|
guard #available(iOS 27.1, *) else { return }
|
|
288
299
|
view.addInteraction(UIHingeInteraction { _, update in
|
|
289
|
-
guard update.hinge
|
|
300
|
+
guard let hinge = update.hinge else { return }
|
|
301
|
+
let partiallyOpen = hinge.status == .partiallyOpen
|
|
302
|
+
guard !isKnownFoldable || partiallyOpen != isPartiallyOpen else { return }
|
|
290
303
|
isKnownFoldable = true
|
|
304
|
+
isPartiallyOpen = partiallyOpen
|
|
291
305
|
NotificationCenter.default.post(name: ReservedRegions.didChange, object: nil)
|
|
292
306
|
})
|
|
293
307
|
#endif
|
|
@@ -296,16 +310,18 @@ enum FoldableDevice {
|
|
|
296
310
|
|
|
297
311
|
// MARK: - Reserved regions
|
|
298
312
|
|
|
299
|
-
/// System occlusion regions (iOS 27.1
|
|
300
|
-
///
|
|
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.
|
|
301
315
|
enum ReservedRegions {
|
|
302
316
|
// last report of a probe, so `ScreenLayout.current` includes it
|
|
303
317
|
private(set) static var current: [CGRect] = []
|
|
318
|
+
private(set) static var division: CGRect?
|
|
304
319
|
static let didChange = Notification.Name("MoMoUIKitsReservedRegionsDidChange")
|
|
305
320
|
|
|
306
|
-
fileprivate static func publish(_ regions: [CGRect]) {
|
|
307
|
-
guard regions != current else { return }
|
|
321
|
+
fileprivate static func publish(_ regions: [CGRect], division: CGRect?) {
|
|
322
|
+
guard regions != current || division != self.division else { return }
|
|
308
323
|
current = regions
|
|
324
|
+
self.division = division
|
|
309
325
|
NotificationCenter.default.post(name: didChange, object: nil)
|
|
310
326
|
}
|
|
311
327
|
}
|
|
@@ -324,12 +340,13 @@ private final class ReservedRegionsProbe: UIView {
|
|
|
324
340
|
override func layoutSubviews() {
|
|
325
341
|
super.layoutSubviews()
|
|
326
342
|
// read even when not publishing, so UIKit keeps re-running this when they change
|
|
327
|
-
let regions =
|
|
343
|
+
let regions = activeRegions(kind: "occlusionRegionKind")
|
|
344
|
+
let division = activeRegions(kind: "divisionRegionKind").first
|
|
328
345
|
// every screen has a probe but the regions are window-wide: one sliding in on a push or
|
|
329
346
|
// a present, or off the window, would overwrite them with a partial read
|
|
330
347
|
guard spansWindow else { return }
|
|
331
348
|
// layout pass: publish on the next turn instead of mutating SwiftUI state mid-update
|
|
332
|
-
DispatchQueue.main.async { ReservedRegions.publish(regions) }
|
|
349
|
+
DispatchQueue.main.async { ReservedRegions.publish(regions, division: division) }
|
|
333
350
|
}
|
|
334
351
|
|
|
335
352
|
private var spansWindow: Bool {
|
|
@@ -344,11 +361,11 @@ private final class ReservedRegionsProbe: UIView {
|
|
|
344
361
|
}
|
|
345
362
|
|
|
346
363
|
// The API is newer than the SDKs hosts may build with, so it is reached through the runtime.
|
|
347
|
-
private func
|
|
364
|
+
private func activeRegions(kind kindName: String) -> [CGRect] {
|
|
348
365
|
let regionsOfKind = NSSelectorFromString("reservedRegionsOfKind:")
|
|
349
366
|
guard window != nil, responds(to: regionsOfKind),
|
|
350
367
|
let kindType = NSClassFromString("UIViewReservedRegionKind") as? NSObject.Type,
|
|
351
|
-
let kind = (kindType as AnyObject).perform(NSSelectorFromString(
|
|
368
|
+
let kind = (kindType as AnyObject).perform(NSSelectorFromString(kindName))?.takeUnretainedValue(),
|
|
352
369
|
let regions = perform(regionsOfKind, with: kind)?.takeUnretainedValue() as? [NSObject]
|
|
353
370
|
else { return [] }
|
|
354
371
|
return regions.compactMap { ($0.value(forKey: "frame") as? NSValue)?.cgRectValue }
|
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
|
|
package/ios/Loader/Loader.swift
CHANGED
|
@@ -7,12 +7,8 @@ public enum LoaderType {
|
|
|
7
7
|
case spinner
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
///
|
|
11
|
-
///
|
|
12
|
-
/// Mirrors Compose `Loader(type:, tintColor:, modifier:)` which delegates to
|
|
13
|
-
/// `DotLoader` / `SpinnerLoader`. Both variants render Lottie animations
|
|
14
|
-
/// (`files/dot_loading` and `files/lottie_circle_loader`) and optionally tint
|
|
15
|
-
/// the fill/stroke through a Lottie color value provider.
|
|
10
|
+
/// Compose `Loader`: the `dot_loading` / `lottie_circle_loader` Lottie animations, with the
|
|
11
|
+
/// fill/stroke optionally tinted through a Lottie color value provider.
|
|
16
12
|
public struct Loader: View {
|
|
17
13
|
private let type: LoaderType
|
|
18
14
|
private let tintColor: Color?
|
|
@@ -60,12 +56,7 @@ public struct SpinnerLoader: View {
|
|
|
60
56
|
}
|
|
61
57
|
}
|
|
62
58
|
|
|
63
|
-
///
|
|
64
|
-
///
|
|
65
|
-
/// Mirrors Compose `ProgressBar(percent:, color:, modifier:)`:
|
|
66
|
-
/// - `percent` clamped to 0...100, animated with a 200ms ease.
|
|
67
|
-
/// - track = theme background default (`0xFFF2F2F6`), fill = `color` or primary (pink_03).
|
|
68
|
-
/// - height 4, corner radius `Radius.XXS`, fills max width.
|
|
59
|
+
/// Compose `ProgressBar`: `percent` is clamped to 0...100 and animated with a 200ms ease.
|
|
69
60
|
public struct ProgressBar: View {
|
|
70
61
|
@Environment(\.appTheme) private var theme
|
|
71
62
|
|