Skip to content

Commit

Permalink
Fix modal bg (#3171)
Browse files Browse the repository at this point in the history
* Fix modal bg

* Fix button padding
  • Loading branch information
rlepinski authored Jul 30, 2024
1 parent 6a35cde commit c6603d8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
1 change: 1 addition & 0 deletions Airship/AirshipCore/Source/LabelButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct LabelButton : View {
actions: self.model.actions
) {
Label(model: self.model.label, constraints: constraints)
.padding(self.model.border?.strokeWidth ?? 0)
.constraints(constraints, fixedSize: true)
.applyIf(self.constraints.height == nil) { view in
view.padding([.bottom, .top], 12)
Expand Down
39 changes: 24 additions & 15 deletions Airship/AirshipCore/Source/ModalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,34 @@ struct ModalView: View {

@ViewBuilder
private func modalBackground(_ placement: ModalPlacement) -> some View {
if placement.isFullScreen() && placement.ignoreSafeArea != true {
Rectangle()
.foregroundColor(statusBarShimColor())
.edgesIgnoringSafeArea(.all)

} else {
Rectangle()
.foreground(placement.shade)
.edgesIgnoringSafeArea(.all)
.applyIf(self.presentation.dismissOnTouchOutside == true) {
view in
// Add tap gesture outside of view to dismiss
view.addTapGesture {
self.thomasEnvironment.dismiss()
GeometryReader { reader in
VStack(spacing: 0) {
if placement.isFullscreen, placement.ignoreSafeArea != true {
statusBarShimColor()
.frame(height: reader.safeAreaInsets.top)
}

Rectangle()
.foreground(placement.shade)
.edgesIgnoringSafeArea(.all)
.applyIf(self.presentation.dismissOnTouchOutside == true) {
view in
// Add tap gesture outside of view to dismiss
view.addTapGesture {
self.thomasEnvironment.dismiss()
}
}

if placement.isFullscreen, placement.ignoreSafeArea != true {
statusBarShimColor()
.frame(height: reader.safeAreaInsets.bottom)
}
}
.edgesIgnoringSafeArea(.all)
}
}


private func resolvePlacement(
orientation: Orientation,
windowSize: WindowSize
Expand Down Expand Up @@ -242,7 +251,7 @@ struct ModalView: View {


extension ModalPlacement {
fileprivate func isFullScreen() -> Bool {
fileprivate var isFullscreen: Bool {
if let horiztonalMargins = self.margin?.horiztonalMargins, horiztonalMargins > 0 {
return false
}
Expand Down

0 comments on commit c6603d8

Please sign in to comment.