Skip to content

Commit c17fde5

Browse files
committed
Fix layout to keep modal corner radius visible during scroll
1 parent ab58d66 commit c17fde5

File tree

1 file changed

+66
-57
lines changed

1 file changed

+66
-57
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Creation/PaymentSection/Taxes/TaxEducationalDialogView.swift

Lines changed: 66 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,34 @@ struct TaxEducationalDialogView: View {
1616
ZStack {
1717
Color.black.opacity(Layout.backgroundOpacity).edgesIgnoringSafeArea(.all)
1818

19-
VStack {
20-
GeometryReader { geometry in
21-
ScrollView {
22-
VStack(alignment: .center, spacing: Layout.verticalSpacing) {
23-
Text(Localization.title)
24-
.headlineStyle()
25-
Text(Localization.bodyFirstParagraph)
26-
.bodyStyle()
27-
.fixedSize(horizontal: false, vertical: true)
28-
Text(Localization.bodySecondParagraph)
29-
.bodyStyle()
19+
VStack {
20+
GeometryReader { geometry in
21+
VStack(spacing: 0) {
22+
VStack {
23+
ScrollView {
24+
VStack(alignment: .center, spacing: Layout.verticalSpacing) {
25+
Text(Localization.title)
26+
.headlineStyle()
3027

28+
Text(Localization.bodyFirstParagraph)
29+
.bodyStyle()
30+
.fixedSize(horizontal: false, vertical: true)
3131

32-
VStack(alignment: .leading, spacing: Layout.verticalSpacing) {
33-
Divider()
34-
.frame(height: Layout.dividerHeight)
35-
.foregroundColor(Color(.opaqueSeparator))
36-
if let taxBasedOnSettingExplanatoryText = viewModel.taxBasedOnSettingExplanatoryText {
37-
Text(taxBasedOnSettingExplanatoryText)
38-
.bodyStyle()
39-
.fixedSize(horizontal: false, vertical: true)
40-
}
32+
Text(Localization.bodySecondParagraph)
33+
.bodyStyle()
34+
35+
VStack(alignment: .leading, spacing: Layout.verticalSpacing) {
36+
Divider()
37+
.frame(height: Layout.dividerHeight)
38+
.foregroundColor(Color(.opaqueSeparator))
39+
40+
if let explanatoryText = viewModel.taxBasedOnSettingExplanatoryText {
41+
Text(explanatoryText)
42+
.bodyStyle()
43+
.fixedSize(horizontal: false, vertical: true)
44+
}
4145

42-
ForEach(viewModel.taxLines, id: \.title) { taxLine in
43-
HStack {
46+
ForEach(viewModel.taxLines, id: \.title) { taxLine in
4447
AdaptiveStack(horizontalAlignment: .leading, spacing: Layout.taxLinesInnerSpacing) {
4548
Text(taxLine.title)
4649
.font(.body)
@@ -55,50 +58,56 @@ struct TaxEducationalDialogView: View {
5558
.frame(width: nil, alignment: .trailing)
5659
}
5760
}
61+
62+
Divider()
63+
.frame(height: Layout.dividerHeight)
64+
.foregroundColor(Color(.opaqueSeparator))
5865
}
59-
Divider()
60-
.frame(height: Layout.dividerHeight)
61-
.foregroundColor(Color(.opaqueSeparator))
62-
}.renderedIf(viewModel.taxLines.isNotEmpty)
66+
.renderedIf(viewModel.taxLines.isNotEmpty)
6367

64-
Button {
65-
viewModel.onGoToWpAdminButtonTapped()
66-
showingWPAdminWebview = true
67-
} label: {
68-
Label {
69-
Text(Localization.editTaxRatesInAdminButtonTitle)
70-
.font(.body)
71-
.fontWeight(.bold)
72-
} icon: {
73-
Image(systemName: "arrow.up.forward.square")
74-
.resizable()
75-
.frame(width: Layout.externalLinkImageSize * scale, height: Layout.externalLinkImageSize * scale)
68+
Button {
69+
viewModel.onGoToWpAdminButtonTapped()
70+
showingWPAdminWebview = true
71+
} label: {
72+
Label {
73+
Text(Localization.editTaxRatesInAdminButtonTitle)
74+
.font(.body)
75+
.fontWeight(.bold)
76+
} icon: {
77+
Image(systemName: "arrow.up.forward.square")
78+
.resizable()
79+
.frame(width: Layout.externalLinkImageSize * scale,
80+
height: Layout.externalLinkImageSize * scale)
81+
}
7682
}
77-
}
78-
.buttonStyle(PrimaryButtonStyle())
79-
.safariSheet(isPresented: $showingWPAdminWebview, url: viewModel.wpAdminTaxSettingsURL, onDismiss: {
80-
onDismissWpAdminWebView()
81-
showingWPAdminWebview = false
82-
})
83+
.buttonStyle(PrimaryButtonStyle())
84+
.safariSheet(
85+
isPresented: $showingWPAdminWebview,
86+
url: viewModel.wpAdminTaxSettingsURL,
87+
onDismiss: {
88+
onDismissWpAdminWebView()
89+
showingWPAdminWebview = false
90+
})
8391

84-
Button {
85-
dismiss()
86-
} label: {
87-
Text(Localization.doneButtonTitle)
92+
Button {
93+
dismiss()
94+
} label: {
95+
Text(Localization.doneButtonTitle)
96+
}
97+
.buttonStyle(SecondaryButtonStyle())
8898
}
89-
.buttonStyle(SecondaryButtonStyle())
99+
.padding(Layout.outterPadding)
90100
}
91-
.padding(Layout.outterPadding)
92-
.frame(maxWidth: .infinity, alignment: .center)
93-
.background(Color(.systemBackground))
94-
.cornerRadius(Layout.cornerRadius)
95-
.frame(width: geometry.size.width) // Make the scroll view full-width
96-
.frame(minHeight: geometry.size.height)
97101
}
102+
.background(Color(.systemBackground))
103+
.cornerRadius(Layout.cornerRadius)
104+
.padding(Layout.outterPadding)
105+
.frame(maxWidth: .infinity, alignment: .center)
106+
.frame(minHeight: geometry.size.height)
107+
.frame(width: geometry.size.width)
108+
}
98109
}
99110
}
100-
.padding(Layout.outterPadding)
101-
.frame(maxWidth: .infinity, alignment: .center)
102111
}
103112
}
104113
}

0 commit comments

Comments
 (0)