@momo-kits/native-kits 0.168.1-beta.3-debug → 0.168.1-beta.30
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 +14 -10
- package/README.md +2 -10
- package/ios/Application/ApplicationEnvironment.swift +7 -6
- package/ios/Application/DesignSystemKits.swift +163 -0
- package/ios/Application/DesignSystemKitsPayload.swift +68 -0
- package/ios/Badge/BadgeRibbon.swift +8 -1
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Input/Input.swift +13 -3
- package/ios/Input/InputPhoneNumber.swift +1 -3
- package/ios/Input/InputSearch.swift +1 -2
- package/ios/Input/InputTextArea.swift +5 -3
- package/ios/InputMoney/InputMoney.swift +6 -7
- package/ios/Layout/ScreenLayout.swift +65 -10
- package/ios/Navigation/BottomSheet.swift +152 -21
- package/ios/Navigation/BottomTab/BottomTab.swift +12 -18
- package/ios/Navigation/BottomTab/BottomTabBar.swift +255 -114
- package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
- package/ios/Navigation/BottomTab/DuoTabBar.swift +63 -172
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +88 -0
- package/ios/Navigation/Component/HeaderBackground.swift +22 -1
- package/ios/Navigation/Component/SnackBar.swift +4 -0
- package/ios/Navigation/ModalScreen.swift +7 -3
- package/ios/Navigation/StackScreen.swift +6 -8
- package/ios/Popup/PopupDisplay.swift +2 -2
- package/ios/Popup/PopupInput.swift +2 -2
- package/ios/Popup/PopupLayout.swift +15 -10
- package/ios/Popup/PopupNotify.swift +2 -2
- package/ios/Stepper/Stepper.swift +1 -2
- package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
- package/ios/Typography/FontScale.swift +29 -15
- package/ios/Typography/Text.swift +86 -12
- package/ios/Typography/Typography.swift +2 -2
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +224 -59
- package/package.json +1 -1
- package/publish.sh +2 -7
- package/build.gradle.kts +0 -13
- package/compose/build.gradle.kts +0 -197
- package/compose/build.gradle.kts.backup +0 -197
- package/compose/compose.podspec +0 -47
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -124
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -65
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -361
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -16
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -283
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -309
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -338
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -137
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -215
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -404
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -233
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -217
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -98
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -312
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -103
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -413
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +0 -37
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -135
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +0 -44
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +0 -62
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -40
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -36
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -94
- package/gradle/libs.versions.toml +0 -76
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +0 -10
- package/gradle.properties +0 -26
- package/gradlew +0 -252
- package/gradlew.bat +0 -94
- package/ios/Typography/FontScaleStore.swift +0 -58
- package/ios/Typography/KitDesignSystem.swift +0 -17
- package/ios-demo/README.md +0 -120
- package/settings.gradle.kts +0 -64
|
@@ -32,6 +32,9 @@ public struct ScreenLayout: Equatable {
|
|
|
32
32
|
public let width: CGFloat
|
|
33
33
|
public let height: CGFloat
|
|
34
34
|
public let isIPhoneDuo: Bool
|
|
35
|
+
/// iPhone Duo folded or not, whatever the window size (its hinge, or the outer display's one-sided strip);
|
|
36
|
+
/// drives popups, modal and bottom sheet.
|
|
37
|
+
public let isDuoDevice: Bool
|
|
35
38
|
public let insets: EdgeInsets
|
|
36
39
|
public let insetLeft: CGFloat
|
|
37
40
|
public let insetRight: CGFloat
|
|
@@ -68,8 +71,16 @@ enum DuoMetrics {
|
|
|
68
71
|
// (x 550–643 of 669, clock digits centered on y 47); its reserved region is taller than the glyphs.
|
|
69
72
|
static let innerStatusBarCenterY: CGFloat = 47
|
|
70
73
|
static let innerStatusBarWidth: CGFloat = 120
|
|
71
|
-
//
|
|
72
|
-
|
|
74
|
+
// Host app's iOS 26 tab bar on the inner display in portrait: a 62pt glass pill sized to its tabs,
|
|
75
|
+
// QR as a 62pt platter beside it, ≥ 20pt from the sides, 13pt into the home indicator inset.
|
|
76
|
+
static let floatingTabBarHeight: CGFloat = 62
|
|
77
|
+
static let floatingTabBarMargin: CGFloat = 20
|
|
78
|
+
static let floatingTabBarInsetOverlap: CGFloat = 13
|
|
79
|
+
// Width of a system alert on the inner display, in both orientations.
|
|
80
|
+
static let modalMaxWidth: CGFloat = 440
|
|
81
|
+
// Fits a PopupNotify with image, scrolled description and actions at the max width (RN
|
|
82
|
+
// Application/device.ts); taller content scrolls instead of filling the inner display.
|
|
83
|
+
static let modalMaxHeight: CGFloat = 640
|
|
73
84
|
}
|
|
74
85
|
|
|
75
86
|
enum HeaderMetrics {
|
|
@@ -104,15 +115,17 @@ extension ScreenLayout {
|
|
|
104
115
|
size: CGSize,
|
|
105
116
|
insets: EdgeInsets,
|
|
106
117
|
reservedRegions: [CGRect] = ReservedRegions.current,
|
|
107
|
-
isPhone: Bool = isPhoneIdiom
|
|
118
|
+
isPhone: Bool = isPhoneIdiom,
|
|
119
|
+
isFoldable: Bool = FoldableDevice.isFoldable(measuredIn: keyWindow)
|
|
108
120
|
) -> ScreenLayout {
|
|
109
121
|
let width = size.width
|
|
110
122
|
let height = size.height
|
|
123
|
+
let isDuoDevice = isPhone && isFoldable
|
|
111
124
|
var (headerHeight, headerStatusBarHeight) = headerGeometry(topInset: insets.top, isPhone: isPhone)
|
|
112
125
|
let isDuo = isPhone && isIPhoneDuoWindow(width: width, height: height, insets: insets)
|
|
113
126
|
guard isDuo else {
|
|
114
127
|
return ScreenLayout(
|
|
115
|
-
width: width, height: height, isIPhoneDuo: false, insets: insets,
|
|
128
|
+
width: width, height: height, isIPhoneDuo: false, isDuoDevice: isDuoDevice, insets: insets,
|
|
116
129
|
insetLeft: 0, insetRight: 0, contentWidth: width,
|
|
117
130
|
headerHeight: headerHeight, headerStatusBarHeight: headerStatusBarHeight, sideBar: nil,
|
|
118
131
|
statusBarClearance: nil
|
|
@@ -171,8 +184,10 @@ extension ScreenLayout {
|
|
|
171
184
|
)
|
|
172
185
|
}
|
|
173
186
|
|
|
187
|
+
// the outer display reports no hinge; its one-sided strip still gives it away
|
|
174
188
|
return ScreenLayout(
|
|
175
|
-
width: width, height: height, isIPhoneDuo: true,
|
|
189
|
+
width: width, height: height, isIPhoneDuo: true,
|
|
190
|
+
isDuoDevice: isDuoDevice || insets.leading != insets.trailing, insets: insets,
|
|
176
191
|
insetLeft: insets.leading, insetRight: insets.trailing,
|
|
177
192
|
contentWidth: width - insets.leading - insets.trailing,
|
|
178
193
|
headerHeight: headerHeight, headerStatusBarHeight: headerStatusBarHeight, sideBar: sideBar,
|
|
@@ -249,15 +264,54 @@ extension ScreenLayout {
|
|
|
249
264
|
public var duoTopInset: CGFloat {
|
|
250
265
|
max(insets.top, height > width ? max(insets.leading, insets.trailing) * 2 : 0)
|
|
251
266
|
}
|
|
267
|
+
|
|
268
|
+
/// Room for a dialog on iPhone Duo: inside the safe area, so clear of the side toolbar strip, and
|
|
269
|
+
/// capped so it stays a dialog on the inner display.
|
|
270
|
+
var duoModalMaxWidth: CGFloat {
|
|
271
|
+
min(width - insets.leading - insets.trailing - Spacing.XL * 2, DuoMetrics.modalMaxWidth)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
var duoModalMaxHeight: CGFloat {
|
|
275
|
+
min(height - insets.top - insets.bottom - Spacing.XL * 2, DuoMetrics.modalMaxHeight)
|
|
276
|
+
}
|
|
252
277
|
}
|
|
253
278
|
|
|
254
|
-
///
|
|
255
|
-
///
|
|
279
|
+
/// Snapshot for call sites without `\.screenLayout`; not reactive. `windowSize` is ignored,
|
|
280
|
+
/// kept for host call sites.
|
|
256
281
|
public func isIPhoneDuoDevice(windowSize: CGSize? = nil) -> Bool {
|
|
257
282
|
guard isPhoneIdiom else { return false }
|
|
258
|
-
let
|
|
259
|
-
|
|
260
|
-
|
|
283
|
+
let insets = keyWindow?.safeAreaInsets
|
|
284
|
+
return FoldableDevice.isFoldable(measuredIn: keyWindow) || insets.map { $0.left != $0.right } == true
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/// Apple's foldable check (as the host's `SideTabRailView.isFoldableDevice`): only a device with a
|
|
288
|
+
/// hinge reports a `.division` region, inactive while flat but still there. Screen size cannot tell
|
|
289
|
+
/// it apart from a large iPhone in landscape or a narrowed window.
|
|
290
|
+
enum FoldableDevice {
|
|
291
|
+
// a hinge never goes away, so a positive answer is kept
|
|
292
|
+
private static var isKnownFoldable = false
|
|
293
|
+
|
|
294
|
+
static func isFoldable(measuredIn view: UIView?) -> Bool {
|
|
295
|
+
if isKnownFoldable { return true }
|
|
296
|
+
// compiled out on SDKs older than iOS 27.1 (UIKit 9127.0.85.28)
|
|
297
|
+
#if canImport(UIKit, _version: 9127.0.85.28)
|
|
298
|
+
guard #available(iOS 27.1, *), let view, view.window != nil || view is UIWindow else { return false }
|
|
299
|
+
isKnownFoldable = !view.reservedRegions(kind: .division, options: .includeInactive).isEmpty
|
|
300
|
+
#endif
|
|
301
|
+
return isKnownFoldable
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/// Catches the hinge when the regions were read too early (before the window had them).
|
|
305
|
+
static func observe(in view: UIView) {
|
|
306
|
+
#if canImport(UIKit, _version: 9127.0.85.28)
|
|
307
|
+
guard #available(iOS 27.1, *) else { return }
|
|
308
|
+
view.addInteraction(UIHingeInteraction { _, update in
|
|
309
|
+
guard update.hinge != nil, !isKnownFoldable else { return }
|
|
310
|
+
isKnownFoldable = true
|
|
311
|
+
NotificationCenter.default.post(name: ReservedRegions.didChange, object: nil)
|
|
312
|
+
})
|
|
313
|
+
#endif
|
|
314
|
+
}
|
|
261
315
|
}
|
|
262
316
|
|
|
263
317
|
// MARK: - Reserved regions
|
|
@@ -282,6 +336,7 @@ private final class ReservedRegionsProbe: UIView {
|
|
|
282
336
|
override init(frame: CGRect) {
|
|
283
337
|
super.init(frame: frame)
|
|
284
338
|
isUserInteractionEnabled = false
|
|
339
|
+
FoldableDevice.observe(in: self)
|
|
285
340
|
}
|
|
286
341
|
|
|
287
342
|
required init?(coder: NSCoder) { nil }
|
|
@@ -15,16 +15,25 @@ import SwiftUI
|
|
|
15
15
|
|
|
16
16
|
/// Mirrors Compose's `sealed class BottomHeader` (Title / Custom).
|
|
17
17
|
public struct BottomSheetHeader {
|
|
18
|
+
struct Back {
|
|
19
|
+
let icon: String
|
|
20
|
+
let action: () -> Void
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
enum Style {
|
|
19
|
-
case title(String)
|
|
24
|
+
case title(String, back: Back?)
|
|
20
25
|
case custom(() -> AnyView)
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
let style: Style
|
|
24
29
|
|
|
25
|
-
/// Mirrors `BottomHeader.Title`.
|
|
26
|
-
public static func title(
|
|
27
|
-
|
|
30
|
+
/// Mirrors `BottomHeader.Title`. `onBack` shows a back button; the sheet closes, then it runs.
|
|
31
|
+
public static func title(
|
|
32
|
+
_ text: String = "Bottom Sheet Title",
|
|
33
|
+
backIcon: String = "arrow-back",
|
|
34
|
+
onBack: (() -> Void)? = nil
|
|
35
|
+
) -> BottomSheetHeader {
|
|
36
|
+
BottomSheetHeader(style: .title(text, back: onBack.map { Back(icon: backIcon, action: $0) }))
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
/// Mirrors `BottomHeader.Custom`.
|
|
@@ -68,6 +77,9 @@ struct BottomSheetView<Content: View>: View {
|
|
|
68
77
|
/// Mirrors Compose's `sheetCloseOffset` (100dp drag threshold to dismiss).
|
|
69
78
|
private let closeThreshold: CGFloat = 100
|
|
70
79
|
|
|
80
|
+
private let indicatorHeight: CGFloat = 16
|
|
81
|
+
private let headerRowHeight: CGFloat = 56
|
|
82
|
+
|
|
71
83
|
/// Mirrors Compose's per-term peak (0.3f). Combined with `backgroundAlpha` the
|
|
72
84
|
/// steady-state (fully open) scrim peaks at 0.6, matching ModalScreen's peak.
|
|
73
85
|
private let maxDynamicAlpha: CGFloat = 0.3
|
|
@@ -77,7 +89,23 @@ struct BottomSheetView<Content: View>: View {
|
|
|
77
89
|
|
|
78
90
|
private var isDuo: Bool { layout.isDuoDevice }
|
|
79
91
|
// iPhone Duo inner display: center the sheet instead of spanning the width
|
|
80
|
-
|
|
92
|
+
// short side, as RN: the outer display stays floating in landscape (678pt wide) too
|
|
93
|
+
private var isDuoCentered: Bool { isDuo && min(layout.width, layout.height) >= 600 }
|
|
94
|
+
/// Outer display: the sheet floats Spacing.M off the side edges like system sheets, its content
|
|
95
|
+
/// stays in the safe area and its buttons move to the side bar column (HIG).
|
|
96
|
+
private var isDuoFloating: Bool { isDuo && !isDuoCentered }
|
|
97
|
+
|
|
98
|
+
private var titleBack: BottomSheetHeader.Back? {
|
|
99
|
+
if case .title(_, let back) = header.style { return back }
|
|
100
|
+
return nil
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private var sideColumn: SideBarLayout? {
|
|
104
|
+
guard isDuoFloating, case .title = header.style, let sideBar = layout.sideBar,
|
|
105
|
+
sideBar.width - Spacing.M >= DuoMetrics.controlSize + Spacing.M
|
|
106
|
+
else { return nil }
|
|
107
|
+
return sideBar
|
|
108
|
+
}
|
|
81
109
|
|
|
82
110
|
/// Keeps the portrait width in landscape, like system sheets.
|
|
83
111
|
private var duoCenteredWidth: CGFloat {
|
|
@@ -87,18 +115,20 @@ struct BottomSheetView<Content: View>: View {
|
|
|
87
115
|
)
|
|
88
116
|
}
|
|
89
117
|
|
|
90
|
-
///
|
|
91
|
-
/// side status bar only covers the top corner.
|
|
118
|
+
/// The floating sheet spans the side safe area, its content stays clear of it.
|
|
92
119
|
private var sideInsetLeading: CGFloat {
|
|
93
|
-
|
|
120
|
+
isDuoFloating ? max(layout.insets.leading - Spacing.M, 0) : 0
|
|
94
121
|
}
|
|
95
122
|
|
|
96
123
|
private var sideInsetTrailing: CGFloat {
|
|
97
|
-
|
|
124
|
+
isDuoFloating ? max(layout.insets.trailing - Spacing.M, 0) : 0
|
|
98
125
|
}
|
|
99
126
|
|
|
100
127
|
private var maxHeight: CGFloat {
|
|
101
|
-
isDuo
|
|
128
|
+
guard isDuo else { return screenHeight - 90 }
|
|
129
|
+
// stays below the side status bar: unlike RN (StatusBar.pushStackEntry) nothing restyles it, so a light
|
|
130
|
+
// clock over the sheet would vanish
|
|
131
|
+
return layout.height - max(layout.duoTopInset, Spacing.XL)
|
|
102
132
|
}
|
|
103
133
|
private var bottomInset: CGFloat { useBottomInset ? safeAreaBottomInset() : 0 }
|
|
104
134
|
/// While the keyboard is up, it already covers the home-indicator area, so it
|
|
@@ -169,20 +199,23 @@ struct BottomSheetView<Content: View>: View {
|
|
|
169
199
|
.fill(Colors.black06)
|
|
170
200
|
.frame(width: 40, height: 4)
|
|
171
201
|
Spacer().frame(height: 4)
|
|
202
|
+
// the handle centers on the whole sheet, only the header row keeps clear of the strip
|
|
172
203
|
headerView
|
|
173
|
-
.frame(height:
|
|
204
|
+
.frame(height: headerRowHeight)
|
|
174
205
|
.padding(.horizontal, Spacing.M)
|
|
175
206
|
.padding(.leading, sideInsetLeading)
|
|
176
207
|
.padding(.trailing, sideInsetTrailing)
|
|
177
208
|
}
|
|
178
209
|
.frame(maxWidth: .infinity)
|
|
179
|
-
.frame(height:
|
|
210
|
+
.frame(height: indicatorHeight + headerRowHeight)
|
|
180
211
|
.contentShape(Rectangle())
|
|
181
212
|
.gesture(dragGesture, including: draggable ? .all : .subviews)
|
|
182
213
|
|
|
183
214
|
Rectangle()
|
|
184
215
|
.fill(theme.colors.border.default)
|
|
185
216
|
.frame(height: 1)
|
|
217
|
+
.padding(.leading, sideInsetLeading)
|
|
218
|
+
.padding(.trailing, sideInsetTrailing)
|
|
186
219
|
|
|
187
220
|
content()
|
|
188
221
|
.padding(.leading, sideInsetLeading)
|
|
@@ -191,7 +224,7 @@ struct BottomSheetView<Content: View>: View {
|
|
|
191
224
|
.layoutPriority(-1)
|
|
192
225
|
|
|
193
226
|
if let footer {
|
|
194
|
-
BottomSheetFooter(content: footer)
|
|
227
|
+
BottomSheetFooter(content: footer, leadingInset: sideInsetLeading, trailingInset: sideInsetTrailing)
|
|
195
228
|
}
|
|
196
229
|
}
|
|
197
230
|
// The filler stays outside the cap, which shrinks by it instead: the sheet still ends at
|
|
@@ -209,27 +242,61 @@ struct BottomSheetView<Content: View>: View {
|
|
|
209
242
|
}
|
|
210
243
|
)
|
|
211
244
|
.background(backgroundColor)
|
|
212
|
-
.
|
|
245
|
+
.overlay {
|
|
246
|
+
if let sideColumn {
|
|
247
|
+
BottomSheetSideColumn(
|
|
248
|
+
sideBar: sideColumn,
|
|
249
|
+
windowHeight: layout.height,
|
|
250
|
+
topOffset: indicatorHeight + (headerRowHeight - DuoMetrics.controlSize) / 2,
|
|
251
|
+
back: titleBack,
|
|
252
|
+
onBack: goBack,
|
|
253
|
+
onClose: { close() }
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
.clipShape(RoundedCorner(radius: isDuo ? Radius.XL : Radius.M, corners: [.topLeft, .topRight]))
|
|
258
|
+
.padding(.horizontal, isDuoFloating ? Spacing.M : 0)
|
|
213
259
|
}
|
|
214
260
|
|
|
215
261
|
@ViewBuilder
|
|
216
262
|
private var headerView: some View {
|
|
217
263
|
switch header.style {
|
|
218
|
-
case .title(let text):
|
|
264
|
+
case .title(let text, let back):
|
|
265
|
+
// the side column holds back and close, the row keeps only the title
|
|
266
|
+
let showsButtons = sideColumn == nil
|
|
219
267
|
HStack(spacing: 0) {
|
|
220
|
-
|
|
268
|
+
if showsButtons {
|
|
269
|
+
if let back {
|
|
270
|
+
headerButton(icon: back.icon, accessibilityId: "btn_bottom_sheet_back") { goBack(back) }
|
|
271
|
+
} else {
|
|
272
|
+
Color.clear.frame(width: 24, height: 24)
|
|
273
|
+
}
|
|
274
|
+
}
|
|
221
275
|
MomoText(text, typography: .headerDefaultBold, color: Colors.black17)
|
|
222
276
|
.frame(maxWidth: .infinity, alignment: .center)
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
277
|
+
.padding(.horizontal, showsButtons ? 0 : Spacing.M)
|
|
278
|
+
if showsButtons {
|
|
279
|
+
headerButton(icon: "navigation_close", accessibilityId: "btn_bottom_sheet_close") { close() }
|
|
280
|
+
}
|
|
227
281
|
}
|
|
228
282
|
case .custom(let builder):
|
|
229
283
|
builder()
|
|
230
284
|
}
|
|
231
285
|
}
|
|
232
286
|
|
|
287
|
+
private func headerButton(icon: String, accessibilityId: String, action: @escaping () -> Void) -> some View {
|
|
288
|
+
Icon(source: icon, size: 24, color: Colors.black17)
|
|
289
|
+
.frame(width: 24, height: 24)
|
|
290
|
+
.contentShape(Rectangle())
|
|
291
|
+
.onTapGesture(perform: action)
|
|
292
|
+
.accessibilityIdentifier(accessibilityId)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/// RN `leftOptions.onPressIconLeft`: the sheet closes first, then the back runs.
|
|
296
|
+
private func goBack(_ back: BottomSheetHeader.Back) {
|
|
297
|
+
close(then: back.action)
|
|
298
|
+
}
|
|
299
|
+
|
|
233
300
|
// MARK: - Drag handling (mirrors Compose's detectDragGestures)
|
|
234
301
|
|
|
235
302
|
private var dragGesture: some Gesture {
|
|
@@ -282,7 +349,7 @@ struct BottomSheetView<Content: View>: View {
|
|
|
282
349
|
|
|
283
350
|
/// Mirrors Compose's `closeEvent`: slide out over 200ms, then fade the scrim
|
|
284
351
|
/// out over 100ms only after the slide finishes, then dismiss.
|
|
285
|
-
private func close() {
|
|
352
|
+
private func close(then onClosed: (() -> Void)? = nil) {
|
|
286
353
|
guard !isClosing else { return }
|
|
287
354
|
isClosing = true
|
|
288
355
|
withAnimation(.timingCurve(0.3, 0, 0.8, 0.15, duration: 0.2)) {
|
|
@@ -294,7 +361,67 @@ struct BottomSheetView<Content: View>: View {
|
|
|
294
361
|
}
|
|
295
362
|
}
|
|
296
363
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
|
364
|
+
// a newer overlay replaced this one: it stays, and this sheet's back is dropped
|
|
365
|
+
guard navigator.overplay?.id == overplayId else { return }
|
|
297
366
|
navigator.finishOverplayDismiss(id: overplayId)
|
|
367
|
+
onClosed?()
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/// iPhone Duo outer display: back and close sit on the part of the sheet under the side safe area,
|
|
373
|
+
/// 12pt from the strip's inner edge like the screen side bar. They follow the header row while the
|
|
374
|
+
/// sheet is short and stay below the status bar cluster while it is tall.
|
|
375
|
+
private struct BottomSheetSideColumn: View {
|
|
376
|
+
let sideBar: SideBarLayout
|
|
377
|
+
let windowHeight: CGFloat
|
|
378
|
+
/// Lines the controls up with the header row.
|
|
379
|
+
let topOffset: CGFloat
|
|
380
|
+
let back: BottomSheetHeader.Back?
|
|
381
|
+
let onBack: (BottomSheetHeader.Back) -> Void
|
|
382
|
+
let onClose: () -> Void
|
|
383
|
+
|
|
384
|
+
@Environment(\.appTheme) private var theme
|
|
385
|
+
|
|
386
|
+
private var isRight: Bool { sideBar.edge == .right }
|
|
387
|
+
|
|
388
|
+
private var columnHeight: CGFloat {
|
|
389
|
+
let count: CGFloat = back != nil ? 2 : 1
|
|
390
|
+
return count * DuoMetrics.controlSize + (count - 1) * Spacing.M
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
private var headerColor: HeaderColor {
|
|
394
|
+
getHeaderColor(isAnimated: false, isSurface: true, opacity: 1, tintColor: nil, defaultColor: theme.colors.text.default)
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
var body: some View {
|
|
398
|
+
GeometryReader { proxy in
|
|
399
|
+
let sheetHeight = proxy.size.height
|
|
400
|
+
// the sheet rests on the window bottom; its slide is an offset outside this layout
|
|
401
|
+
let sheetTop = windowHeight - sheetHeight
|
|
402
|
+
// clear of a camera at the bottom end of the strip when it can
|
|
403
|
+
let lowest = sheetHeight - sideBar.bottom - columnHeight
|
|
404
|
+
let top = max(min(max(sideBar.top - sheetTop, topOffset), lowest), 0)
|
|
405
|
+
VStack(alignment: isRight ? .leading : .trailing, spacing: Spacing.M) {
|
|
406
|
+
if let back {
|
|
407
|
+
SideBarButton(
|
|
408
|
+
icon: back.icon,
|
|
409
|
+
headerColor: headerColor,
|
|
410
|
+
accessibilityId: "btn_bottom_sheet_back",
|
|
411
|
+
action: { onBack(back) }
|
|
412
|
+
)
|
|
413
|
+
}
|
|
414
|
+
SideBarButton(
|
|
415
|
+
icon: "navigation_close",
|
|
416
|
+
headerColor: headerColor,
|
|
417
|
+
accessibilityId: "btn_bottom_sheet_close",
|
|
418
|
+
action: onClose
|
|
419
|
+
)
|
|
420
|
+
}
|
|
421
|
+
.padding(isRight ? .leading : .trailing, Spacing.M)
|
|
422
|
+
.frame(width: sideBar.width - Spacing.M, alignment: isRight ? .leading : .trailing)
|
|
423
|
+
.padding(.top, top)
|
|
424
|
+
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: isRight ? .topTrailing : .topLeading)
|
|
298
425
|
}
|
|
299
426
|
}
|
|
300
427
|
}
|
|
@@ -371,12 +498,16 @@ private struct CapHeightLayout: Layout {
|
|
|
371
498
|
/// Mirrors Compose's `BottomSheetFooter`: a surface band with a soft shadow cast on the content.
|
|
372
499
|
private struct BottomSheetFooter: View {
|
|
373
500
|
let content: () -> AnyView
|
|
501
|
+
var leadingInset: CGFloat = 0
|
|
502
|
+
var trailingInset: CGFloat = 0
|
|
374
503
|
|
|
375
504
|
@Environment(\.appTheme) private var theme
|
|
376
505
|
|
|
377
506
|
var body: some View {
|
|
378
507
|
content()
|
|
379
508
|
.frame(maxWidth: .infinity)
|
|
509
|
+
.padding(.leading, leadingInset)
|
|
510
|
+
.padding(.trailing, trailingInset)
|
|
380
511
|
.padding(.vertical, Spacing.S)
|
|
381
512
|
.background(theme.colors.background.surface)
|
|
382
513
|
.overlay(alignment: .top) {
|
|
@@ -53,10 +53,9 @@ public struct BottomTab: View {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
private var bottomInset: CGFloat { safeAreaBottomInset() }
|
|
56
|
-
// the
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
56
|
+
// the bars float over the content (tab screens keep clear of them through duoTabBarInsets) or sit
|
|
57
|
+
// in the side strip, so only the home indicator is kept clear
|
|
58
|
+
private var reservedBottom: CGFloat { layout.insets.bottom }
|
|
60
59
|
|
|
61
60
|
private var compression: DuoBarCompression {
|
|
62
61
|
DuoBarCompression.resolve(
|
|
@@ -104,18 +103,13 @@ public struct BottomTab: View {
|
|
|
104
103
|
compression: compression
|
|
105
104
|
)
|
|
106
105
|
} else {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
)
|
|
115
|
-
theme.colors.background.surface
|
|
116
|
-
.frame(height: bottomInset + Spacing.S)
|
|
117
|
-
.ignoresSafeArea(edges: .horizontal)
|
|
118
|
-
}
|
|
106
|
+
BottomTabBar(
|
|
107
|
+
items: items,
|
|
108
|
+
floatingButton: floatingButton,
|
|
109
|
+
selectedIndex: selectedIndex,
|
|
110
|
+
onTabSelected: selectTab,
|
|
111
|
+
bottomInset: bottomInset
|
|
112
|
+
)
|
|
119
113
|
}
|
|
120
114
|
}
|
|
121
115
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
@@ -137,6 +131,7 @@ public struct BottomTab: View {
|
|
|
137
131
|
}
|
|
138
132
|
|
|
139
133
|
private func selectTab(_ index: Int) {
|
|
134
|
+
navigator.maxApi?.triggerEventVibration("light")
|
|
140
135
|
let switchTab = { if index != selectedIndex { selectedIndex = index } }
|
|
141
136
|
if let onTabPress { onTabPress(index, switchTab) } else { switchTab() }
|
|
142
137
|
}
|
|
@@ -325,8 +320,7 @@ private struct TabCard: View {
|
|
|
325
320
|
|
|
326
321
|
/// Bottom safe-area inset (home indicator).
|
|
327
322
|
private func safeAreaBottomInset() -> CGFloat {
|
|
328
|
-
|
|
323
|
+
UIApplication.shared.connectedScenes
|
|
329
324
|
.compactMap { ($0 as? UIWindowScene)?.keyWindow?.safeAreaInsets.bottom }
|
|
330
325
|
.first ?? 0
|
|
331
|
-
return min(bottomInset, 21)
|
|
332
326
|
}
|