@momo-kits/native-kits 0.168.1-beta.38 → 0.168.1-beta.39-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.
Files changed (153) hide show
  1. package/CLAUDE.md +3 -2
  2. package/build.gradle.kts +11 -0
  3. package/compose/build.gradle.kts +198 -0
  4. package/compose/build.gradle.kts.backup +198 -0
  5. package/compose/compose.podspec +47 -0
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +20 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +154 -0
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +62 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1071 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +542 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +231 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +189 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +478 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +265 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +235 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +223 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +265 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +185 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +84 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +361 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +308 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +90 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +330 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +220 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +473 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +207 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +92 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +560 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +125 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +501 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +236 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +17 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +287 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +187 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +316 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +393 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +153 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +113 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +205 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +422 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +739 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +239 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +389 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +94 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +97 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +203 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +455 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +399 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +192 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +92 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +22 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +118 -0
  125. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +219 -0
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  132. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +144 -0
  133. package/gradle/libs.versions.toml +69 -0
  134. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  135. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  136. package/gradle.properties +26 -0
  137. package/gradlew +252 -0
  138. package/gradlew.bat +94 -0
  139. package/ios/Input/Input.swift +3 -1
  140. package/ios/Input/InputTextArea.swift +3 -1
  141. package/ios/Layout/ModalLayout.swift +152 -0
  142. package/ios/Layout/ScreenLayout.swift +28 -24
  143. package/ios/Navigation/BottomSheet.swift +29 -157
  144. package/ios/Navigation/Component/HeaderRight.swift +1 -1
  145. package/ios/Navigation/ModalScreen.swift +18 -7
  146. package/ios/Popup/PopupDisplay.swift +4 -2
  147. package/ios/Popup/PopupInput.swift +4 -2
  148. package/ios/Popup/PopupLayout.swift +10 -9
  149. package/ios/Popup/PopupNotify.swift +26 -23
  150. package/ios-demo/README.md +120 -0
  151. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +103 -0
  152. package/package.json +1 -1
  153. package/settings.gradle.kts +64 -0
@@ -0,0 +1,152 @@
1
+ //
2
+ // ModalLayout.swift
3
+ // MoMoUIKits
4
+ //
5
+ // Foldable spec for Popup and BottomSheet (Figma "Modal - Foldable Guideline"). Mirrors Compose
6
+ // `layout/ModalLayout.kt` and RN; keep the three in sync.
7
+ //
8
+
9
+ import SwiftUI
10
+
11
+ /// Foldable modal spec values, in points. Public so host apps can size their own popups and sheets the same way.
12
+ public enum ModalMetrics {
13
+ public static let popupMaxWidth: CGFloat = 450
14
+ public static let popupMinWidth: CGFloat = 280
15
+ public static let popupMaxHeight: CGFloat = 600
16
+ public static let sheetMaxWidth: CGFloat = 653
17
+ public static let sheetMinWidth: CGFloat = 296
18
+ public static let sheetMinHeight: CGFloat = 230
19
+ public static let foldableMinWidth: CGFloat = 600
20
+ public static let iconButtonSize: CGFloat = 32
21
+ public static let iconSize: CGFloat = 20
22
+ public static let phoneScrimOpacity: CGFloat = 0.6
23
+ public static let foldableScrimOpacity: CGFloat = 0.2
24
+ }
25
+
26
+ public struct PopupGeometry: Equatable {
27
+ public let minWidth: CGFloat
28
+ public let maxWidth: CGFloat
29
+ /// nil: as tall as the content, phones keep their own caps
30
+ public let maxHeight: CGFloat?
31
+ public let margin: CGFloat
32
+ public let radius: CGFloat
33
+ }
34
+
35
+ public struct SheetGeometry: Equatable {
36
+ /// nil: spans the window
37
+ public let width: CGFloat?
38
+ /// nil: phones keep their own cap
39
+ public let maxHeight: CGFloat?
40
+ public let minHeight: CGFloat
41
+ public let margin: CGFloat
42
+ public let radius: CGFloat
43
+ }
44
+
45
+ /// Popup / bottom sheet geometry for a window; see `ModalLayout.resolve` and `ScreenLayout.modalLayout`.
46
+ public struct ModalLayout: Equatable {
47
+ public let isFoldable: Bool
48
+ /// Window coordinates of the area popups center in and sheets rest on the bottom of.
49
+ public let placement: CGRect
50
+ public let popup: PopupGeometry
51
+ public let sheet: SheetGeometry
52
+ public let scrimOpacity: CGFloat
53
+ }
54
+
55
+ public extension ScreenLayout {
56
+ /// Foldable = iPhone Duo or a window whose short side is at least 600 (RN parity), so phones
57
+ /// in landscape keep their look.
58
+ var modalLayout: ModalLayout {
59
+ ModalLayout.resolve(width: width, height: height, safeInsets: insets, isDuoDevice: isDuoDevice, hinge: hinge)
60
+ }
61
+ }
62
+
63
+ public extension ModalLayout {
64
+ /// Resolves popup / bottom sheet geometry from plain window metrics, for hosts without a kits screen
65
+ /// (`ScreenLayout.current.modalLayout` covers the key window).
66
+ ///
67
+ /// Points, window coordinates. `safeInsets` is the window safe area; on iPhone Duo it also carries the
68
+ /// control column. `hinge` is the vertical hinge of a half-folded iPhone Duo, nil while flat.
69
+ static func resolve(
70
+ width: CGFloat,
71
+ height: CGFloat,
72
+ safeInsets insets: EdgeInsets = EdgeInsets(),
73
+ isDuoDevice: Bool = false,
74
+ hinge: CGRect? = nil
75
+ ) -> ModalLayout {
76
+ let isFoldable = isDuoDevice || min(width, height) >= ModalMetrics.foldableMinWidth
77
+ guard isFoldable else {
78
+ let placement = CGRect(x: 0, y: 0, width: width, height: height)
79
+ return ModalLayout(
80
+ isFoldable: false,
81
+ placement: placement,
82
+ popup: popupGeometry(placementWidth: width, maxHeight: nil, margin: Spacing.XL, radius: Radius.L),
83
+ sheet: SheetGeometry(width: nil, maxHeight: nil, minHeight: 0, margin: 0, radius: Radius.M),
84
+ scrimOpacity: ModalMetrics.phoneScrimOpacity
85
+ )
86
+ }
87
+
88
+ // the safe area keeps overlays clear of the iPhone Duo control column; half folded they move to the right half
89
+ let hinge = hinge.flatMap { isDuoDevice && $0.minX > 0 && $0.maxX < width ? $0 : nil }
90
+ let left = max(insets.leading, hinge?.maxX ?? 0)
91
+ let placement = CGRect(
92
+ x: left,
93
+ y: insets.top,
94
+ width: max(width - insets.trailing - left, 0),
95
+ height: max(height - insets.top - insets.bottom, 0)
96
+ )
97
+ // outer display and half fold leave little room, so the margins tighten
98
+ let isCompact = isDuoDevice && (hinge != nil || min(width, height) < ModalMetrics.foldableMinWidth)
99
+ let sheetMargin = Spacing.M
100
+ let sheetMaxHeight = height - insets.top - sheetMargin
101
+ let sheetMinWidth = min(ModalMetrics.sheetMinWidth, placement.width)
102
+ return ModalLayout(
103
+ isFoldable: true,
104
+ placement: placement,
105
+ popup: popupGeometry(
106
+ placementWidth: placement.width,
107
+ maxHeight: min(ModalMetrics.popupMaxHeight, placement.height - Spacing.XL * 2),
108
+ margin: isCompact ? Spacing.M : Spacing.XL,
109
+ radius: Radius.XL
110
+ ),
111
+ sheet: SheetGeometry(
112
+ width: max(min(placement.width - sheetMargin * 2, ModalMetrics.sheetMaxWidth), sheetMinWidth),
113
+ maxHeight: sheetMaxHeight,
114
+ minHeight: min(ModalMetrics.sheetMinHeight, sheetMaxHeight),
115
+ margin: sheetMargin,
116
+ radius: Radius.XL
117
+ ),
118
+ scrimOpacity: ModalMetrics.foldableScrimOpacity
119
+ )
120
+ }
121
+
122
+ /// clamp(placement - 2 margin, 280, 450); the 280 floor gives way to a narrower placement.
123
+ private static func popupGeometry(placementWidth: CGFloat, maxHeight: CGFloat?, margin: CGFloat, radius: CGFloat) -> PopupGeometry {
124
+ let minWidth = min(ModalMetrics.popupMinWidth, placementWidth)
125
+ let maxWidth = min(max(placementWidth - margin * 2, minWidth), max(ModalMetrics.popupMaxWidth, minWidth))
126
+ return PopupGeometry(minWidth: minWidth, maxWidth: maxWidth, maxHeight: maxHeight, margin: margin, radius: radius)
127
+ }
128
+ }
129
+
130
+ /// Popup close and sheet header back / close: 32 circle on the surface with a border, 20 icon.
131
+ public struct ModalIconButton: View {
132
+ @Environment(\.appTheme) private var theme
133
+ let icon: String
134
+ let accessibilityId: String
135
+ let action: () -> Void
136
+
137
+ public init(icon: String, accessibilityId: String, action: @escaping () -> Void) {
138
+ self.icon = icon
139
+ self.accessibilityId = accessibilityId
140
+ self.action = action
141
+ }
142
+
143
+ public var body: some View {
144
+ Icon(source: icon, size: ModalMetrics.iconSize, color: theme.colors.text.default)
145
+ .frame(width: ModalMetrics.iconButtonSize, height: ModalMetrics.iconButtonSize)
146
+ .background(Circle().fill(theme.colors.background.surface))
147
+ .overlay(Circle().strokeBorder(theme.colors.border.default, lineWidth: 1))
148
+ .contentShape(Circle())
149
+ .onTapGesture(perform: action)
150
+ .accessibilityIdentifier(accessibilityId)
151
+ }
152
+ }
@@ -46,6 +46,8 @@ public struct ScreenLayout: Equatable {
46
46
  public let sideBar: SideBarLayout?
47
47
  /// iPhone Duo inner display in portrait: the header row shares the status bar band, between its clusters.
48
48
  public let statusBarClearance: StatusBarClearance?
49
+ /// Half-folded iPhone Duo: the hinge in window coordinates, running top to bottom; nil while flat.
50
+ public let hinge: CGRect?
49
51
 
50
52
  public var headerBarHeight: CGFloat { headerHeight - headerStatusBarHeight }
51
53
  }
@@ -76,11 +78,6 @@ enum DuoMetrics {
76
78
  static let floatingTabBarHeight: CGFloat = 62
77
79
  static let floatingTabBarMargin: CGFloat = 20
78
80
  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
84
81
  }
85
82
 
86
83
  enum HeaderMetrics {
@@ -116,11 +113,14 @@ extension ScreenLayout {
116
113
  insets: EdgeInsets,
117
114
  reservedRegions: [CGRect] = ReservedRegions.current,
118
115
  isPhone: Bool = isPhoneIdiom,
119
- isFoldable: Bool = FoldableDevice.isFoldable(measuredIn: keyWindow)
116
+ isFoldable: Bool = FoldableDevice.isFoldable(measuredIn: keyWindow),
117
+ division: CGRect? = FoldableDevice.halfFoldedHinge
120
118
  ) -> ScreenLayout {
121
119
  let width = size.width
122
120
  let height = size.height
123
121
  let isDuoDevice = isPhone && isFoldable
122
+ // only a hinge splitting the window into left and right halves moves overlays
123
+ let hinge = division.flatMap { isPhone && $0.height > $0.width ? $0 : nil }
124
124
  var (headerHeight, headerStatusBarHeight) = headerGeometry(topInset: insets.top, isPhone: isPhone)
125
125
  let isDuo = isPhone && isIPhoneDuoWindow(width: width, height: height, insets: insets)
126
126
  guard isDuo else {
@@ -128,7 +128,7 @@ extension ScreenLayout {
128
128
  width: width, height: height, isIPhoneDuo: false, isDuoDevice: isDuoDevice, insets: insets,
129
129
  insetLeft: 0, insetRight: 0, contentWidth: width,
130
130
  headerHeight: headerHeight, headerStatusBarHeight: headerStatusBarHeight, sideBar: nil,
131
- statusBarClearance: nil
131
+ statusBarClearance: nil, hinge: hinge
132
132
  )
133
133
  }
134
134
 
@@ -191,7 +191,7 @@ extension ScreenLayout {
191
191
  insetLeft: insets.leading, insetRight: insets.trailing,
192
192
  contentWidth: width - insets.leading - insets.trailing,
193
193
  headerHeight: headerHeight, headerStatusBarHeight: headerStatusBarHeight, sideBar: sideBar,
194
- statusBarClearance: statusBarClearance
194
+ statusBarClearance: statusBarClearance, hinge: hinge
195
195
  )
196
196
  }
197
197
 
@@ -265,15 +265,6 @@ extension ScreenLayout {
265
265
  max(insets.top, height > width ? max(insets.leading, insets.trailing) * 2 : 0)
266
266
  }
267
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
- }
277
268
  }
278
269
 
279
270
  /// Snapshot for call sites without `\.screenLayout`; not reactive. `windowSize` is ignored,
@@ -290,6 +281,12 @@ public func isIPhoneDuoDevice(windowSize: CGSize? = nil) -> Bool {
290
281
  enum FoldableDevice {
291
282
  // a hinge never goes away, so a positive answer is kept
292
283
  private static var isKnownFoldable = false
284
+ private static var isPartiallyOpen = false
285
+
286
+ /// The active division region while the hinge reports partially open; nil while flat.
287
+ static var halfFoldedHinge: CGRect? {
288
+ isPartiallyOpen ? ReservedRegions.division : nil
289
+ }
293
290
 
294
291
  static func isFoldable(measuredIn view: UIView?) -> Bool {
295
292
  if isKnownFoldable { return true }
@@ -306,8 +303,11 @@ enum FoldableDevice {
306
303
  #if canImport(UIKit, _version: 9127.0.85.28)
307
304
  guard #available(iOS 27.1, *) else { return }
308
305
  view.addInteraction(UIHingeInteraction { _, update in
309
- guard update.hinge != nil, !isKnownFoldable else { return }
306
+ guard let hinge = update.hinge else { return }
307
+ let partiallyOpen = hinge.status == .partiallyOpen
308
+ guard !isKnownFoldable || partiallyOpen != isPartiallyOpen else { return }
310
309
  isKnownFoldable = true
310
+ isPartiallyOpen = partiallyOpen
311
311
  NotificationCenter.default.post(name: ReservedRegions.didChange, object: nil)
312
312
  })
313
313
  #endif
@@ -318,14 +318,17 @@ enum FoldableDevice {
318
318
 
319
319
  /// System occlusion regions (iOS 27.1+) in window coordinates: the iPhone Duo camera, and the
320
320
  /// status bar cluster as it grows for a call or a Live Activity. Empty before iOS 27.1.
321
+ /// `division` is the active hinge region, there only while the device is half folded.
321
322
  enum ReservedRegions {
322
323
  // last report of a probe, so `ScreenLayout.current` includes it
323
324
  private(set) static var current: [CGRect] = []
325
+ private(set) static var division: CGRect?
324
326
  static let didChange = Notification.Name("MoMoUIKitsReservedRegionsDidChange")
325
327
 
326
- fileprivate static func publish(_ regions: [CGRect]) {
327
- guard regions != current else { return }
328
+ fileprivate static func publish(_ regions: [CGRect], division: CGRect?) {
329
+ guard regions != current || division != self.division else { return }
328
330
  current = regions
331
+ self.division = division
329
332
  NotificationCenter.default.post(name: didChange, object: nil)
330
333
  }
331
334
  }
@@ -344,12 +347,13 @@ private final class ReservedRegionsProbe: UIView {
344
347
  override func layoutSubviews() {
345
348
  super.layoutSubviews()
346
349
  // read even when not publishing, so UIKit keeps re-running this when they change
347
- let regions = occlusionRegions()
350
+ let regions = activeRegions(kind: "occlusionRegionKind")
351
+ let division = activeRegions(kind: "divisionRegionKind").first
348
352
  // every screen has a probe but the regions are window-wide: one sliding in on a push or
349
353
  // a present, or off the window, would overwrite them with a partial read
350
354
  guard spansWindow else { return }
351
355
  // layout pass: publish on the next turn instead of mutating SwiftUI state mid-update
352
- DispatchQueue.main.async { ReservedRegions.publish(regions) }
356
+ DispatchQueue.main.async { ReservedRegions.publish(regions, division: division) }
353
357
  }
354
358
 
355
359
  private var spansWindow: Bool {
@@ -364,11 +368,11 @@ private final class ReservedRegionsProbe: UIView {
364
368
  }
365
369
 
366
370
  // The API is newer than the SDKs hosts may build with, so it is reached through the runtime.
367
- private func occlusionRegions() -> [CGRect] {
371
+ private func activeRegions(kind kindName: String) -> [CGRect] {
368
372
  let regionsOfKind = NSSelectorFromString("reservedRegionsOfKind:")
369
373
  guard window != nil, responds(to: regionsOfKind),
370
374
  let kindType = NSClassFromString("UIViewReservedRegionKind") as? NSObject.Type,
371
- let kind = (kindType as AnyObject).perform(NSSelectorFromString("occlusionRegionKind"))?.takeUnretainedValue(),
375
+ let kind = (kindType as AnyObject).perform(NSSelectorFromString(kindName))?.takeUnretainedValue(),
372
376
  let regions = perform(regionsOfKind, with: kind)?.takeUnretainedValue() as? [NSObject]
373
377
  else { return [] }
374
378
  return regions.compactMap { ($0.value(forKey: "frame") as? NSValue)?.cgRectValue }
@@ -80,56 +80,17 @@ struct BottomSheetView<Content: View>: View {
80
80
  private let indicatorHeight: CGFloat = 16
81
81
  private let headerRowHeight: CGFloat = 56
82
82
 
83
- /// Mirrors Compose's per-term peak (0.3f). Combined with `backgroundAlpha` the
84
- /// steady-state (fully open) scrim peaks at 0.6, matching ModalScreen's peak.
85
- private let maxDynamicAlpha: CGFloat = 0.3
83
+ /// Half the scrim fades in first, the other half follows the sheet; together they reach
84
+ /// `scrimOpacity` (0.6 on phones, as ModalScreen; 0.2 on foldables).
85
+ private let maxDynamicAlpha: CGFloat = 0.5
86
86
 
87
- // UIScreen stays on the outer display on iPhone Duo, even when unfolded
88
- private var screenHeight: CGFloat { isDuo ? layout.height : UIScreen.main.bounds.height }
89
-
90
- private var isDuo: Bool { layout.isDuoDevice }
91
- // iPhone Duo inner display: center the sheet instead of spanning the width
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
- }
109
-
110
- /// Keeps the portrait width in landscape, like system sheets.
111
- private var duoCenteredWidth: CGFloat {
112
- min(
113
- min(layout.width, layout.height) - Spacing.L * 2,
114
- layout.width - max(layout.insets.leading, layout.insets.trailing, Spacing.L) * 2
115
- )
116
- }
117
-
118
- /// The floating sheet spans the side safe area, its content stays clear of it.
119
- private var sideInsetLeading: CGFloat {
120
- isDuoFloating ? max(layout.insets.leading - Spacing.M, 0) : 0
121
- }
87
+ private var modal: ModalLayout { layout.modalLayout }
88
+ private var isFoldable: Bool { modal.isFoldable }
122
89
 
123
- private var sideInsetTrailing: CGFloat {
124
- isDuoFloating ? max(layout.insets.trailing - Spacing.M, 0) : 0
125
- }
90
+ // UIScreen stays on the outer display on iPhone Duo, even when unfolded
91
+ private var screenHeight: CGFloat { isFoldable ? layout.height : UIScreen.main.bounds.height }
126
92
 
127
- private var maxHeight: CGFloat {
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)
132
- }
93
+ private var maxHeight: CGFloat { modal.sheet.maxHeight ?? screenHeight - 90 }
133
94
  private var bottomInset: CGFloat { useBottomInset ? safeAreaBottomInset() : 0 }
134
95
  /// While the keyboard is up, it already covers the home-indicator area, so it
135
96
  /// replaces (rather than adds to) the usual bottom-inset filler.
@@ -151,15 +112,15 @@ struct BottomSheetView<Content: View>: View {
151
112
  return progress * maxDynamicAlpha
152
113
  }
153
114
 
154
- /// Mirrors Compose's `alpha = backgroundAlpha + dynamicAlpha`: additive, so the
155
- /// scrim peaks at 0.6 at rest and only fades to a 0.3 floor while dragging
115
+ /// Mirrors Compose's `alpha = (backgroundAlpha + dynamicAlpha) * scrimOpacity`: additive, so the
116
+ /// scrim peaks at `scrimOpacity` at rest and only fades to half of it while dragging
156
117
  /// (backgroundAlpha holds steady until an explicit close()).
157
- private var totalScrimAlpha: CGFloat { backgroundAlpha + dynamicAlpha }
118
+ private var totalScrimAlpha: CGFloat { (backgroundAlpha + dynamicAlpha) * modal.scrimOpacity }
158
119
 
159
120
  var body: some View {
160
121
  ZStack(alignment: .bottom) {
161
- // Dimmed scrim — additive backgroundAlpha + dynamicAlpha (see above).
162
- Color.black.opacity(totalScrimAlpha)
122
+ // Dimmed scrim — additive backgroundAlpha + dynamicAlpha (see above); full screen on foldables too.
123
+ Colors.black20.opacity(totalScrimAlpha)
163
124
  .contentShape(Rectangle())
164
125
  .onTapGesture {
165
126
  if barrierDismissible { close() }
@@ -199,12 +160,9 @@ struct BottomSheetView<Content: View>: View {
199
160
  .fill(Colors.black06)
200
161
  .frame(width: 40, height: 4)
201
162
  Spacer().frame(height: 4)
202
- // the handle centers on the whole sheet, only the header row keeps clear of the strip
203
163
  headerView
204
164
  .frame(height: headerRowHeight)
205
165
  .padding(.horizontal, Spacing.M)
206
- .padding(.leading, sideInsetLeading)
207
- .padding(.trailing, sideInsetTrailing)
208
166
  }
209
167
  .frame(maxWidth: .infinity)
210
168
  .frame(height: indicatorHeight + headerRowHeight)
@@ -214,19 +172,18 @@ struct BottomSheetView<Content: View>: View {
214
172
  Rectangle()
215
173
  .fill(theme.colors.border.default)
216
174
  .frame(height: 1)
217
- .padding(.leading, sideInsetLeading)
218
- .padding(.trailing, sideInsetTrailing)
219
175
 
220
176
  content()
221
- .padding(.leading, sideInsetLeading)
222
- .padding(.trailing, sideInsetTrailing)
223
177
  // a tall sheet keeps its header (and footer) and gives the content what is left
224
178
  .layoutPriority(-1)
225
179
 
226
180
  if let footer {
227
- BottomSheetFooter(content: footer, leadingInset: sideInsetLeading, trailingInset: sideInsetTrailing)
181
+ // a sheet held at its min height keeps the footer at the bottom
182
+ Spacer(minLength: 0).layoutPriority(-2)
183
+ BottomSheetFooter(content: footer)
228
184
  }
229
185
  }
186
+ .frame(minHeight: max(modal.sheet.minHeight - effectiveBottomInset, 0), alignment: .top)
230
187
  // The filler stays outside the cap, which shrinks by it instead: the sheet still ends at
231
188
  // `maxHeight`, and the iOS 15 fallback never measures the keyboard as content.
232
189
  .modifier(CapHeight(maxHeight: maxHeight - effectiveBottomInset))
@@ -234,7 +191,8 @@ struct BottomSheetView<Content: View>: View {
234
191
  (footer != nil ? theme.colors.background.surface : backgroundColor)
235
192
  .frame(height: effectiveBottomInset)
236
193
  }
237
- .frame(maxWidth: isDuoCentered ? duoCenteredWidth : .infinity)
194
+ .frame(width: modal.sheet.width)
195
+ .frame(maxWidth: modal.sheet.width == nil ? .infinity : nil)
238
196
  .clipped()
239
197
  .background(
240
198
  GeometryReader { geo in
@@ -242,56 +200,31 @@ struct BottomSheetView<Content: View>: View {
242
200
  }
243
201
  )
244
202
  .background(backgroundColor)
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)
203
+ .clipShape(RoundedCorner(radius: modal.sheet.radius, corners: [.topLeft, .topRight]))
204
+ // centered in the placement: off the iPhone Duo control column, the right half when half folded
205
+ .padding(.leading, isFoldable ? modal.placement.minX : 0)
206
+ .padding(.trailing, isFoldable ? layout.width - modal.placement.maxX : 0)
259
207
  }
260
208
 
261
209
  @ViewBuilder
262
210
  private var headerView: some View {
263
211
  switch header.style {
264
212
  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
267
- HStack(spacing: 0) {
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
- }
213
+ HStack(spacing: Spacing.S) {
214
+ if let back {
215
+ ModalIconButton(icon: back.icon, accessibilityId: "btn_bottom_sheet_back") { goBack(back) }
216
+ } else {
217
+ Color.clear.frame(width: ModalMetrics.iconButtonSize, height: ModalMetrics.iconButtonSize)
274
218
  }
275
219
  MomoText(text, typography: .headerDefaultBold, color: Colors.black17)
276
220
  .frame(maxWidth: .infinity, alignment: .center)
277
- .padding(.horizontal, showsButtons ? 0 : Spacing.M)
278
- if showsButtons {
279
- headerButton(icon: "navigation_close", accessibilityId: "btn_bottom_sheet_close") { close() }
280
- }
221
+ ModalIconButton(icon: "navigation_close", accessibilityId: "btn_bottom_sheet_close") { close() }
281
222
  }
282
223
  case .custom(let builder):
283
224
  builder()
284
225
  }
285
226
  }
286
227
 
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
228
  /// RN `leftOptions.onPressIconLeft`: the sheet closes first, then the back runs.
296
229
  private func goBack(_ back: BottomSheetHeader.Back) {
297
230
  close(then: back.action)
@@ -369,63 +302,6 @@ struct BottomSheetView<Content: View>: View {
369
302
  }
370
303
  }
371
304
 
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)
425
- }
426
- }
427
- }
428
-
429
305
  /// Compose's `heightIn(max:)`. `.frame(maxHeight:)` grows to the cap whenever the proposal is
430
306
  /// larger, leaving a gap above the header; this sizes the sheet to its content and only caps it
431
307
  /// when taller.
@@ -498,16 +374,12 @@ private struct CapHeightLayout: Layout {
498
374
  /// Mirrors Compose's `BottomSheetFooter`: a surface band with a soft shadow cast on the content.
499
375
  private struct BottomSheetFooter: View {
500
376
  let content: () -> AnyView
501
- var leadingInset: CGFloat = 0
502
- var trailingInset: CGFloat = 0
503
377
 
504
378
  @Environment(\.appTheme) private var theme
505
379
 
506
380
  var body: some View {
507
381
  content()
508
382
  .frame(maxWidth: .infinity)
509
- .padding(.leading, leadingInset)
510
- .padding(.trailing, trailingInset)
511
383
  .padding(.vertical, Spacing.S)
512
384
  .background(theme.colors.background.surface)
513
385
  .overlay(alignment: .top) {
@@ -359,7 +359,7 @@ struct Toolkit: View {
359
359
  }
360
360
  toolButton(icon: headerRight.closeIcon, accessibilityId: "btn_navigation_close", action: onPressClose)
361
361
  }
362
- .frame(width: 65, height: 28)
362
+ .frame(width: usesHelpCenter(context) ? 65 : 28, height: 28)
363
363
  .background(headerColor.backgroundButton)
364
364
  .cornerRadius(14)
365
365
  .overlay(RoundedRectangle(cornerRadius: 14).stroke(headerColor.borderColor, lineWidth: 0.2))
@@ -24,9 +24,11 @@ struct ModalScreen<Content: View>: View {
24
24
  @State private var didAppear = false
25
25
 
26
26
  var body: some View {
27
+ let modal = layout.modalLayout
28
+ let placement = modal.placement
27
29
  ZStack {
28
- // Dimmed scrim (mirrors `Color.Black.copy(alpha = 0.6f * alpha)`).
29
- Color.black.opacity(0.6 * scrimOpacity)
30
+ // full screen on foldables too, over the iPhone Duo control column
31
+ Colors.black20.opacity(modal.scrimOpacity * scrimOpacity)
30
32
  .ignoresSafeArea()
31
33
  .contentShape(Rectangle())
32
34
  .onTapGesture {
@@ -34,15 +36,24 @@ struct ModalScreen<Content: View>: View {
34
36
  }
35
37
 
36
38
  content()
37
- // iPhone Duo: capped so it stays a dialog on the inner display; nil leaves the size alone
39
+ // foldables: capped by the spec; nil leaves the size alone
38
40
  .frame(
39
- maxWidth: layout.isDuoDevice ? layout.duoModalMaxWidth : nil,
40
- maxHeight: layout.isDuoDevice ? layout.duoModalMaxHeight : nil
41
+ maxWidth: modal.isFoldable ? modal.popup.maxWidth : nil,
42
+ maxHeight: modal.isFoldable ? (modal.popup.maxHeight ?? placement.height) : nil
41
43
  )
42
44
  .scaleEffect(contentScale)
43
45
  .opacity(contentOpacity)
44
- // iPhone Duo: center in the safe area, clear of the side toolbar strip and the home indicator
45
- .padding(layout.isDuoDevice ? layout.insets : EdgeInsets())
46
+ // center in the placement: the safe area, or the right half of a half-folded iPhone Duo
47
+ .padding(
48
+ modal.isFoldable
49
+ ? EdgeInsets(
50
+ top: placement.minY,
51
+ leading: placement.minX,
52
+ bottom: layout.height - placement.maxY,
53
+ trailing: layout.width - placement.maxX
54
+ )
55
+ : EdgeInsets()
56
+ )
46
57
  }
47
58
  // Full screen like RN's Modal, so asymmetric landscape insets don't shift the content sideways.
48
59
  .frame(maxWidth: .infinity, maxHeight: .infinity)
@@ -70,6 +70,7 @@ public struct PopupDisplay: View {
70
70
  }
71
71
  VStack(alignment: .leading, spacing: 0) {
72
72
  MomoText(title, typography: .headerDefaultBold, maxLines: 2, accessibilityId: "title_popup_permission")
73
+ .padding(.trailing, isShowCloseIcon && url.isEmpty ? ModalMetrics.iconButtonSize + Spacing.M - Spacing.XL : 0)
73
74
  .padding(.top, 24)
74
75
  .padding(.bottom, 8)
75
76
 
@@ -110,8 +111,9 @@ public struct PopupDisplay: View {
110
111
  .clipShape(RoundedRectangle(cornerRadius: layout.popupRadius()))
111
112
 
112
113
  if isShowCloseIcon {
113
- PopupCloseButton(action: onClose)
114
- .offset(x: 11, y: -11)
114
+ ModalIconButton(icon: "navigation_close", accessibilityId: "ic_popup_close", action: onClose)
115
+ .padding(.top, Spacing.M)
116
+ .padding(.trailing, Spacing.M)
115
117
  }
116
118
  }
117
119
  .frame(maxWidth: layout.popupMaxWidth)