@momo-kits/native-kits 0.168.1-beta.37 → 0.168.1-beta.38

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 CHANGED
@@ -77,12 +77,11 @@ Publishing is automated (`publish.sh` + GitLab CI on `[ci build]` / `main`). Do
77
77
  - iPhone Duo with a side strip ≥ 60pt: back + toolkit leave the bar for `HeaderSideBar` (`navigation/component/SideBar.kt`, 48pt glass controls); custom header-right stays in the bar. `sideBar.top` is 170pt in portrait, 120pt on the inner display in landscape (height ≥ 600), 24pt on the outer display in landscape, or below the header when the status bar is on top; UIKit's `statusBarFrame` is useless on Duo. Unlike RN the column is clamped above footer (24pt gap) / rail (12pt gap).
78
78
  - Reserved regions (iOS 27.1 `reservedRegionsOfKind:`, reached through the ObjC runtime so older SDKs still build): a probe `UIView` (`platform/ReservedRegions.ios.kt` on the Compose root view; `ReservedRegionsProbe` inside SwiftUI `momoScreenLayout()`) re-reads them in `layoutSubviews`, which UIKit re-runs when they change. They push `sideBar.top` below the status cluster as it grows for calls / Live Activities, and `sideBar.bottom` (≥ 24pt) above a camera at the bottom end of the strip.
79
79
  - Tab bar on Duo is `bottomtab/DuoTabBar.kt`: a rail in the side strip (`sideBar.bottom` above the window bottom, QR below it) or, without a side bar, a floating bar spanning 6/8 grid columns. Both overlay the content; `duoFloatingTabBarInset` pads tab content, footer and FAB.
80
- - Duo tab selection motion (`bottomtab/DuoLiquidSelection.kt` / `ios/Navigation/BottomTab/DuoLiquidSelection.swift`, port of RN `useLiquidSelection.ts`, momo-kits !682): press lifts the lens, a drag past 10pt takes over (Compose: the bar's `pointerInput` consumes and so cancels the tab's clickable; SwiftUI: one `DragGesture` over the bar, tabs are not `Button`s), long press calls `BottomTab(onTabLongPress)` and release still selects, Reduce Motion (`platform/ReduceMotion`) falls back to a plain slide. SwiftUI integrates the lens spring on a display link because the stretch and the tabs' active tint read it every frame. Constants mirror RN — change both together.
81
80
  - Bar compression (`bottomtab/DuoBarCompression.kt`, HIG "Vertical controls"): when toolbar + rail don't fit in the strip, one is compressed — the toolkit into a `navigation_menu` button, the rail into one button showing the current tab — and tapping it swaps them; `BottomTab(compressionBehavior)` picks which starts compressed. If neither fits beside the other compressed, both rest compressed and a tap opens one for a moment. Side bar columns report their full height (0 when the screen puts nothing there) so the decision follows each screen's toolkit.
82
81
  - Glass header: on Duo with a side bar, Default/Extended headers without search and with a `ScrollState` let content scroll under the bar (`usesDuoGlassHeader`); the bar fades in a translucent surface + hairline over 16pt (Compose has no backdrop blur — RN's fallback look), the gradient leaves with the content.
83
82
  - Quick return header: glass headers and Animated headers (with a `ScrollState`) on the Duo side bar layout slide out with the content and back in on a reverse scroll; a half-shown header settles in or out once the scroll stops. The side bar is drawn apart from the header, so it stays put.
84
- - Overlays on foldables (`layout/ModalLayout.kt` / `ios/Layout/ModalLayout.swift`, Figma "Modal - Foldable Guideline", constants shared with RN): foldable = `isIPhoneDuoDevice` or a window short side ≥ 600, so phones (landscape too) keep their look. The resolver returns the placement (safe area, so left of the Duo control column; right of an active vertical division when a Duo is half folded — Swift also needs `UIHingeInteraction` `.partiallyOpen`; Android half fold stays flat), popup geometry (width clamp(placement − 2·margin, 280, 450), margin 24 or 12 on the Duo outer display / half fold, max height min(600, placement − 48), radius 24; only the PopupNotify description scrolls) and sheet geometry (width min(placement − 24, 653) ≥ 296, bottom anchored, max height window − top inset − 12, min height 230, radius 24 top). Scrim is black 20% over the whole window on foldables (0.6 on phones). Snackbars keep clear of the strip. On every device (RN parity) popup close and sheet header back / close are `ModalIconButton`: 32pt circle on `background.surface` with a 1pt `border.default` stroke, 20pt `text.default` icon; the popup close sits inside the card 12pt from the top right (`PopupPromotion` keeps its close under the image), the default sheet header is 56 tall, 12 padding, 8 gap.
85
- - Bottom sheet on Duo: stays in the placement, never on or under the side strip; back / close stay in the header row (no side column). `BottomHeader.Title(onBack)` / `.title(onBack:)` closes the sheet, then runs (RN `leftOptions.onPressIconLeft`).
83
+ - Overlays on Duo: the modal sits inside the safe area (all four insets, so clear of the side toolbar strip) and caps its content at `duoModalMaxWidth` / `duoModalMaxHeight` (440 × 640pt, at least XL off the safe area); popups fill that width with radius XL and drop their own side padding (body scrolls, actions stay). Snackbars keep clear of the strip.
84
+ - Bottom sheet on Duo: radius XL, window height less `duoTopInset` (it never passes the side status bar: unlike RN, nothing restyles the clock over it), centered when the short side ≥ 600 (inner display in either orientation, buttons stay in the header row; RN parity). Below that (outer display, landscape too) it floats `Spacing.M` off the side edges, pads header/content/footer by `inset − M` (the drag indicator still centers on the whole sheet), and a `Title` header moves back / close into 48pt side bar buttons on the strip part of the sheet (HIG: sheet controls go vertical on the outer display) when the strip fits one; they follow the header row while the sheet is short and stay below `sideBar.top` when it is tall. `BottomHeader.Title(onBack)` / `.title(onBack:)` closes the sheet, then runs (RN `leftOptions.onPressIconLeft`).
86
85
  - Font scale deliberately uses the short side (`min(w, h)`), unlike RN which reads the window width — landscape must not inflate every font.
87
86
  - Font scale measures the **window**, never `UIScreen.main`: on iPhone Duo the main screen stays on one display while the window follows the one in use. Compose iOS `getScreenDimensions()` reads `LocalWindowInfo.containerSize` (recomposes on fold/unfold); SwiftUI `DesignSystemKits` KVO-observes each `UIWindowScene.effectiveGeometry` and republishes `windowShortSide`.
88
87
  - `StackScreen` pads content/footer/search/FAB by the side insets and provides an inset-consumed layout to its content; a bottom-tab root stays full width (tab bar + each tab's StackScreen handle insets). Grid columns use `contentWidth`.
@@ -252,9 +252,7 @@ public struct Input: View {
252
252
  }
253
253
  .padding(.horizontal, Spacing.S)
254
254
  .background(theme.colors.background.surface)
255
- // A zero-height frame on the top edge centers the label on the border, re-laid out with font scale.
256
- .fixedSize(horizontal: false, vertical: true)
257
- .frame(height: 0)
255
+ .alignmentGuide(.top) { $0[VerticalAlignment.center] }
258
256
  .offset(x: Spacing.S)
259
257
  }
260
258
  }
@@ -279,9 +279,7 @@ public struct InputTextArea: View {
279
279
  }
280
280
  .padding(.horizontal, Spacing.S)
281
281
  .background(theme.colors.background.surface)
282
- // A zero-height frame on the top edge centers the label on the border, re-laid out with font scale.
283
- .fixedSize(horizontal: false, vertical: true)
284
- .frame(height: 0)
282
+ .alignmentGuide(.top) { $0[VerticalAlignment.center] }
285
283
  .offset(x: Spacing.S)
286
284
  }
287
285
  }
@@ -46,8 +46,6 @@ 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?
51
49
 
52
50
  public var headerBarHeight: CGFloat { headerHeight - headerStatusBarHeight }
53
51
  }
@@ -78,6 +76,11 @@ enum DuoMetrics {
78
76
  static let floatingTabBarHeight: CGFloat = 62
79
77
  static let floatingTabBarMargin: CGFloat = 20
80
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
81
84
  }
82
85
 
83
86
  enum HeaderMetrics {
@@ -113,14 +116,11 @@ extension ScreenLayout {
113
116
  insets: EdgeInsets,
114
117
  reservedRegions: [CGRect] = ReservedRegions.current,
115
118
  isPhone: Bool = isPhoneIdiom,
116
- isFoldable: Bool = FoldableDevice.isFoldable(measuredIn: keyWindow),
117
- division: CGRect? = FoldableDevice.halfFoldedHinge
119
+ isFoldable: Bool = FoldableDevice.isFoldable(measuredIn: keyWindow)
118
120
  ) -> ScreenLayout {
119
121
  let width = size.width
120
122
  let height = size.height
121
123
  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, hinge: hinge
131
+ statusBarClearance: nil
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, hinge: hinge
194
+ statusBarClearance: statusBarClearance
195
195
  )
196
196
  }
197
197
 
@@ -265,6 +265,15 @@ 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
+ }
268
277
  }
269
278
 
270
279
  /// Snapshot for call sites without `\.screenLayout`; not reactive. `windowSize` is ignored,
@@ -281,12 +290,6 @@ public func isIPhoneDuoDevice(windowSize: CGSize? = nil) -> Bool {
281
290
  enum FoldableDevice {
282
291
  // a hinge never goes away, so a positive answer is kept
283
292
  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
- }
290
293
 
291
294
  static func isFoldable(measuredIn view: UIView?) -> Bool {
292
295
  if isKnownFoldable { return true }
@@ -303,11 +306,8 @@ enum FoldableDevice {
303
306
  #if canImport(UIKit, _version: 9127.0.85.28)
304
307
  guard #available(iOS 27.1, *) else { return }
305
308
  view.addInteraction(UIHingeInteraction { _, update in
306
- guard let hinge = update.hinge else { return }
307
- let partiallyOpen = hinge.status == .partiallyOpen
308
- guard !isKnownFoldable || partiallyOpen != isPartiallyOpen else { return }
309
+ guard update.hinge != nil, !isKnownFoldable else { return }
309
310
  isKnownFoldable = true
310
- isPartiallyOpen = partiallyOpen
311
311
  NotificationCenter.default.post(name: ReservedRegions.didChange, object: nil)
312
312
  })
313
313
  #endif
@@ -318,17 +318,14 @@ 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.
322
321
  enum ReservedRegions {
323
322
  // last report of a probe, so `ScreenLayout.current` includes it
324
323
  private(set) static var current: [CGRect] = []
325
- private(set) static var division: CGRect?
326
324
  static let didChange = Notification.Name("MoMoUIKitsReservedRegionsDidChange")
327
325
 
328
- fileprivate static func publish(_ regions: [CGRect], division: CGRect?) {
329
- guard regions != current || division != self.division else { return }
326
+ fileprivate static func publish(_ regions: [CGRect]) {
327
+ guard regions != current else { return }
330
328
  current = regions
331
- self.division = division
332
329
  NotificationCenter.default.post(name: didChange, object: nil)
333
330
  }
334
331
  }
@@ -347,13 +344,12 @@ private final class ReservedRegionsProbe: UIView {
347
344
  override func layoutSubviews() {
348
345
  super.layoutSubviews()
349
346
  // read even when not publishing, so UIKit keeps re-running this when they change
350
- let regions = activeRegions(kind: "occlusionRegionKind")
351
- let division = activeRegions(kind: "divisionRegionKind").first
347
+ let regions = occlusionRegions()
352
348
  // every screen has a probe but the regions are window-wide: one sliding in on a push or
353
349
  // a present, or off the window, would overwrite them with a partial read
354
350
  guard spansWindow else { return }
355
351
  // layout pass: publish on the next turn instead of mutating SwiftUI state mid-update
356
- DispatchQueue.main.async { ReservedRegions.publish(regions, division: division) }
352
+ DispatchQueue.main.async { ReservedRegions.publish(regions) }
357
353
  }
358
354
 
359
355
  private var spansWindow: Bool {
@@ -368,11 +364,11 @@ private final class ReservedRegionsProbe: UIView {
368
364
  }
369
365
 
370
366
  // The API is newer than the SDKs hosts may build with, so it is reached through the runtime.
371
- private func activeRegions(kind kindName: String) -> [CGRect] {
367
+ private func occlusionRegions() -> [CGRect] {
372
368
  let regionsOfKind = NSSelectorFromString("reservedRegionsOfKind:")
373
369
  guard window != nil, responds(to: regionsOfKind),
374
370
  let kindType = NSClassFromString("UIViewReservedRegionKind") as? NSObject.Type,
375
- let kind = (kindType as AnyObject).perform(NSSelectorFromString(kindName))?.takeUnretainedValue(),
371
+ let kind = (kindType as AnyObject).perform(NSSelectorFromString("occlusionRegionKind"))?.takeUnretainedValue(),
376
372
  let regions = perform(regionsOfKind, with: kind)?.takeUnretainedValue() as? [NSObject]
377
373
  else { return [] }
378
374
  return regions.compactMap { ($0.value(forKey: "frame") as? NSValue)?.cgRectValue }
@@ -80,17 +80,56 @@ struct BottomSheetView<Content: View>: View {
80
80
  private let indicatorHeight: CGFloat = 16
81
81
  private let headerRowHeight: CGFloat = 56
82
82
 
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
-
87
- private var modal: ModalLayout { layout.modalLayout }
88
- private var isFoldable: Bool { modal.isFoldable }
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
89
86
 
90
87
  // UIScreen stays on the outer display on iPhone Duo, even when unfolded
91
- private var screenHeight: CGFloat { isFoldable ? layout.height : UIScreen.main.bounds.height }
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
+ }
92
122
 
93
- private var maxHeight: CGFloat { modal.sheet.maxHeight ?? screenHeight - 90 }
123
+ private var sideInsetTrailing: CGFloat {
124
+ isDuoFloating ? max(layout.insets.trailing - Spacing.M, 0) : 0
125
+ }
126
+
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
+ }
94
133
  private var bottomInset: CGFloat { useBottomInset ? safeAreaBottomInset() : 0 }
95
134
  /// While the keyboard is up, it already covers the home-indicator area, so it
96
135
  /// replaces (rather than adds to) the usual bottom-inset filler.
@@ -112,15 +151,15 @@ struct BottomSheetView<Content: View>: View {
112
151
  return progress * maxDynamicAlpha
113
152
  }
114
153
 
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
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
117
156
  /// (backgroundAlpha holds steady until an explicit close()).
118
- private var totalScrimAlpha: CGFloat { (backgroundAlpha + dynamicAlpha) * modal.scrimOpacity }
157
+ private var totalScrimAlpha: CGFloat { backgroundAlpha + dynamicAlpha }
119
158
 
120
159
  var body: some View {
121
160
  ZStack(alignment: .bottom) {
122
- // Dimmed scrim — additive backgroundAlpha + dynamicAlpha (see above); full screen on foldables too.
123
- Colors.black20.opacity(totalScrimAlpha)
161
+ // Dimmed scrim — additive backgroundAlpha + dynamicAlpha (see above).
162
+ Color.black.opacity(totalScrimAlpha)
124
163
  .contentShape(Rectangle())
125
164
  .onTapGesture {
126
165
  if barrierDismissible { close() }
@@ -160,9 +199,12 @@ struct BottomSheetView<Content: View>: View {
160
199
  .fill(Colors.black06)
161
200
  .frame(width: 40, height: 4)
162
201
  Spacer().frame(height: 4)
202
+ // the handle centers on the whole sheet, only the header row keeps clear of the strip
163
203
  headerView
164
204
  .frame(height: headerRowHeight)
165
205
  .padding(.horizontal, Spacing.M)
206
+ .padding(.leading, sideInsetLeading)
207
+ .padding(.trailing, sideInsetTrailing)
166
208
  }
167
209
  .frame(maxWidth: .infinity)
168
210
  .frame(height: indicatorHeight + headerRowHeight)
@@ -172,18 +214,19 @@ struct BottomSheetView<Content: View>: View {
172
214
  Rectangle()
173
215
  .fill(theme.colors.border.default)
174
216
  .frame(height: 1)
217
+ .padding(.leading, sideInsetLeading)
218
+ .padding(.trailing, sideInsetTrailing)
175
219
 
176
220
  content()
221
+ .padding(.leading, sideInsetLeading)
222
+ .padding(.trailing, sideInsetTrailing)
177
223
  // a tall sheet keeps its header (and footer) and gives the content what is left
178
224
  .layoutPriority(-1)
179
225
 
180
226
  if let footer {
181
- // a sheet held at its min height keeps the footer at the bottom
182
- Spacer(minLength: 0).layoutPriority(-2)
183
- BottomSheetFooter(content: footer)
227
+ BottomSheetFooter(content: footer, leadingInset: sideInsetLeading, trailingInset: sideInsetTrailing)
184
228
  }
185
229
  }
186
- .frame(minHeight: max(modal.sheet.minHeight - effectiveBottomInset, 0), alignment: .top)
187
230
  // The filler stays outside the cap, which shrinks by it instead: the sheet still ends at
188
231
  // `maxHeight`, and the iOS 15 fallback never measures the keyboard as content.
189
232
  .modifier(CapHeight(maxHeight: maxHeight - effectiveBottomInset))
@@ -191,8 +234,7 @@ struct BottomSheetView<Content: View>: View {
191
234
  (footer != nil ? theme.colors.background.surface : backgroundColor)
192
235
  .frame(height: effectiveBottomInset)
193
236
  }
194
- .frame(width: modal.sheet.width)
195
- .frame(maxWidth: modal.sheet.width == nil ? .infinity : nil)
237
+ .frame(maxWidth: isDuoCentered ? duoCenteredWidth : .infinity)
196
238
  .clipped()
197
239
  .background(
198
240
  GeometryReader { geo in
@@ -200,31 +242,56 @@ struct BottomSheetView<Content: View>: View {
200
242
  }
201
243
  )
202
244
  .background(backgroundColor)
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)
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)
207
259
  }
208
260
 
209
261
  @ViewBuilder
210
262
  private var headerView: some View {
211
263
  switch header.style {
212
264
  case .title(let text, let back):
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)
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
+ }
218
274
  }
219
275
  MomoText(text, typography: .headerDefaultBold, color: Colors.black17)
220
276
  .frame(maxWidth: .infinity, alignment: .center)
221
- ModalIconButton(icon: "navigation_close", accessibilityId: "btn_bottom_sheet_close") { close() }
277
+ .padding(.horizontal, showsButtons ? 0 : Spacing.M)
278
+ if showsButtons {
279
+ headerButton(icon: "navigation_close", accessibilityId: "btn_bottom_sheet_close") { close() }
280
+ }
222
281
  }
223
282
  case .custom(let builder):
224
283
  builder()
225
284
  }
226
285
  }
227
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
+
228
295
  /// RN `leftOptions.onPressIconLeft`: the sheet closes first, then the back runs.
229
296
  private func goBack(_ back: BottomSheetHeader.Back) {
230
297
  close(then: back.action)
@@ -302,6 +369,63 @@ struct BottomSheetView<Content: View>: View {
302
369
  }
303
370
  }
304
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)
425
+ }
426
+ }
427
+ }
428
+
305
429
  /// Compose's `heightIn(max:)`. `.frame(maxHeight:)` grows to the cap whenever the proposal is
306
430
  /// larger, leaving a gap above the header; this sizes the sheet to its content and only caps it
307
431
  /// when taller.
@@ -374,12 +498,16 @@ private struct CapHeightLayout: Layout {
374
498
  /// Mirrors Compose's `BottomSheetFooter`: a surface band with a soft shadow cast on the content.
375
499
  private struct BottomSheetFooter: View {
376
500
  let content: () -> AnyView
501
+ var leadingInset: CGFloat = 0
502
+ var trailingInset: CGFloat = 0
377
503
 
378
504
  @Environment(\.appTheme) private var theme
379
505
 
380
506
  var body: some View {
381
507
  content()
382
508
  .frame(maxWidth: .infinity)
509
+ .padding(.leading, leadingInset)
510
+ .padding(.trailing, trailingInset)
383
511
  .padding(.vertical, Spacing.S)
384
512
  .background(theme.colors.background.surface)
385
513
  .overlay(alignment: .top) {