Skip to content

Commit

Permalink
Fix padding top of IAA if media is first (#3361)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlepinski authored Jan 30, 2025
1 parent aeba96a commit f393940
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ struct FullscreenView: View, Sendable {
@ViewBuilder
private var mediaView: some View {
if let media = displayContent.media {
MediaView(mediaInfo: media, mediaTheme: self.theme.media)
if shouldRemoveMediaTopPadding {
MediaView(mediaInfo: media, mediaTheme: theme.media)
.padding(.top, -theme.padding.top)
} else {
MediaView(mediaInfo: media, mediaTheme: theme.media)
}
}
}

Expand All @@ -57,6 +62,18 @@ struct FullscreenView: View, Sendable {
}
}


var shouldRemoveMediaTopPadding: Bool {
switch displayContent.template {
case .headerMediaBody:
displayContent.heading == nil
case .headerBodyMedia:
displayContent.heading == nil && displayContent.body == nil
case .mediaHeaderBody, .none:
true
}
}

var body: some View {
ScrollView {
VStack(spacing:24) {
Expand All @@ -70,7 +87,7 @@ struct FullscreenView: View, Sendable {
bodyView
mediaView
case .mediaHeaderBody, .none:
mediaView.padding(.top, -theme.padding.top) /// Remove top padding when media is on top
mediaView
headerView
bodyView
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ struct InAppMessageModalView: View {
@ViewBuilder
private var mediaView: some View {
if let media = displayContent.media {
MediaView(mediaInfo: media, mediaTheme: theme.media)
if shouldRemoveMediaTopPadding {
MediaView(mediaInfo: media, mediaTheme: theme.media)
.padding(.top, -theme.padding.top)
} else {
MediaView(mediaInfo: media, mediaTheme: theme.media)
}
}
}

Expand Down Expand Up @@ -76,11 +81,22 @@ struct InAppMessageModalView: View {
self.theme = theme
}

var shouldRemoveMediaTopPadding: Bool {
switch displayContent.template {
case .headerMediaBody:
displayContent.heading == nil
case .headerBodyMedia:
displayContent.heading == nil && displayContent.body == nil
case .mediaHeaderBody, .none:
true
}
}

@ViewBuilder
private var content: some View {
VStack(spacing:24) {
VStack(spacing: 24) {
ScrollView {
VStack(spacing:24) {
VStack(spacing: 24) {
switch displayContent.template {
case .headerMediaBody:
headerView
Expand All @@ -91,7 +107,9 @@ struct InAppMessageModalView: View {
bodyView
mediaView
case .mediaHeaderBody, .none:
mediaView.padding(.top, -theme.padding.top) /// Remove top padding when media is on top
if displayContent.media != nil {
mediaView
}
headerView
bodyView
}
Expand Down

0 comments on commit f393940

Please sign in to comment.