Skip to content

Commit 4470c01

Browse files
authored
[POS Settings] Store section design updates (#16070)
2 parents 4bad95d + 7679fd1 commit 4470c01

File tree

2 files changed

+89
-84
lines changed

2 files changed

+89
-84
lines changed

WooCommerce/Classes/POS/Presentation/Settings/PointOfSaleSettingsStoreDetailView.swift

Lines changed: 82 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -15,94 +15,21 @@ struct PointOfSaleSettingsStoreDetailView: View {
1515

1616
var body: some View {
1717
NavigationStack {
18-
List {
19-
Section {
20-
VStack(alignment: .leading, spacing: POSPadding.small) {
21-
Text(Localization.storeName)
22-
.font(.posBodyMediumRegular())
23-
Text(viewModel.storeName)
24-
.font(.posBodyMediumRegular())
25-
.foregroundStyle(.secondary)
26-
}
27-
.listRowSeparator(.hidden)
28-
29-
VStack(alignment: .leading, spacing: POSPadding.small) {
30-
Text(Localization.address)
31-
.font(.posBodyMediumRegular())
32-
Text(viewModel.storeAddress)
33-
.font(.posBodyMediumRegular())
34-
.foregroundStyle(.secondary)
35-
}
36-
.listRowSeparator(.hidden)
37-
} header: {
38-
ZStack {
39-
backgroundColor
40-
Text(Localization.storeInformation)
41-
.font(.posHeadingBold)
42-
.foregroundColor(.posOnSurface)
43-
.frame(maxWidth: .infinity, alignment: .leading)
44-
.padding(.horizontal, POSPadding.medium)
45-
.padding(.vertical, POSPadding.small)
46-
.textCase(nil)
47-
}
48-
.listRowInsets(EdgeInsets())
49-
}
50-
51-
Section {
52-
VStack(alignment: .leading, spacing: POSPadding.small) {
53-
Text(Localization.receiptStoreName)
54-
.font(.posBodyMediumRegular())
55-
settingValueView(for: viewModel.receiptInformation.storeName)
56-
}
57-
.listRowSeparator(.hidden)
18+
VStack(spacing: POSSpacing.none) {
19+
POSPageHeaderView(title: Localization.storeTitle)
20+
.foregroundColor(.posSurface)
21+
.accessibilityAddTraits(.isHeader)
5822

59-
VStack(alignment: .leading, spacing: POSPadding.small) {
60-
Text(Localization.physicalAddress)
61-
.font(.posBodyMediumRegular())
62-
settingValueView(for: viewModel.receiptInformation.storeAddress)
63-
}
64-
.listRowSeparator(.hidden)
65-
66-
VStack(alignment: .leading, spacing: POSPadding.small) {
67-
Text(Localization.phoneNumber)
68-
.font(.posBodyMediumRegular())
69-
settingValueView(for: viewModel.receiptInformation.phone)
70-
}
71-
.listRowSeparator(.hidden)
72-
73-
VStack(alignment: .leading, spacing: POSPadding.small) {
74-
Text(Localization.email)
75-
.font(.posBodyMediumRegular())
76-
settingValueView(for: viewModel.receiptInformation.email)
77-
}
78-
.listRowSeparator(.hidden)
23+
ScrollView {
24+
VStack(spacing: POSSpacing.medium) {
25+
storeInformationView
7926

80-
VStack(alignment: .leading, spacing: POSPadding.small) {
81-
Text(Localization.refundReturnsPolicy)
82-
.font(.posBodyMediumRegular())
83-
settingValueView(for: viewModel.receiptInformation.refundReturnsPolicy)
27+
receiptInformationView
28+
.renderedIf(viewModel.shouldShowReceiptInformation)
8429
}
85-
.listRowSeparator(.hidden)
86-
} header: {
87-
ZStack {
88-
backgroundColor
89-
Text(Localization.receiptInformation)
90-
.font(.posHeadingBold)
91-
.foregroundColor(.posOnSurface)
92-
.frame(maxWidth: .infinity, alignment: .leading)
93-
.padding(.horizontal, POSPadding.medium)
94-
.padding(.vertical, POSPadding.small)
95-
.textCase(nil)
96-
}
97-
.listRowInsets(EdgeInsets())
9830
}
99-
.renderedIf(viewModel.shouldShowReceiptInformation)
31+
.background(backgroundColor)
10032
}
101-
.listStyle(.plain)
102-
.scrollContentBackground(.hidden)
103-
.background(backgroundColor)
104-
.listRowSeparator(.hidden)
105-
.listSectionSeparator(.hidden)
10633
.task {
10734
isLoading = true
10835
await viewModel.retrievePOSReceiptSettings()
@@ -111,6 +38,72 @@ struct PointOfSaleSettingsStoreDetailView: View {
11138
}
11239
}
11340

41+
@ViewBuilder
42+
private var storeInformationView: some View {
43+
VStack(spacing: POSSpacing.none) {
44+
sectionHeaderView(title: Localization.storeInformation)
45+
46+
VStack(spacing: POSSpacing.medium) {
47+
fieldRowView(label: Localization.storeName, value: viewModel.storeName)
48+
fieldRowView(label: Localization.address, value: viewModel.storeAddress)
49+
}
50+
.padding(.bottom, POSPadding.medium)
51+
}
52+
}
53+
54+
@ViewBuilder
55+
private var receiptInformationView: some View {
56+
VStack(spacing: POSSpacing.none) {
57+
sectionHeaderView(title: Localization.receiptInformation)
58+
59+
VStack(spacing: POSSpacing.medium) {
60+
receiptFieldRowView(label: Localization.receiptStoreName, value: viewModel.receiptInformation.storeName)
61+
receiptFieldRowView(label: Localization.physicalAddress, value: viewModel.receiptInformation.storeAddress)
62+
receiptFieldRowView(label: Localization.phoneNumber, value: viewModel.receiptInformation.phone)
63+
receiptFieldRowView(label: Localization.email, value: viewModel.receiptInformation.email)
64+
receiptFieldRowView(label: Localization.refundReturnsPolicy, value: viewModel.receiptInformation.refundReturnsPolicy)
65+
}
66+
.padding(.bottom, POSPadding.medium)
67+
}
68+
}
69+
70+
@ViewBuilder
71+
private func sectionHeaderView(title: String) -> some View {
72+
ZStack {
73+
backgroundColor
74+
Text(title)
75+
.font(.posBodyLargeBold)
76+
.foregroundColor(.posOnSurface)
77+
.frame(maxWidth: .infinity, alignment: .leading)
78+
.padding(.horizontal, POSPadding.medium)
79+
.padding(.vertical, POSPadding.small)
80+
}
81+
}
82+
83+
@ViewBuilder
84+
private func fieldRowView(label: String, value: String) -> some View {
85+
VStack(alignment: .leading, spacing: POSPadding.small) {
86+
Text(label)
87+
.font(.posBodyMediumRegular())
88+
Text(value)
89+
.font(.posBodyMediumRegular())
90+
.foregroundStyle(.secondary)
91+
}
92+
.frame(maxWidth: .infinity, alignment: .leading)
93+
.padding(.horizontal, POSPadding.medium)
94+
}
95+
96+
@ViewBuilder
97+
private func receiptFieldRowView(label: String, value: String?) -> some View {
98+
VStack(alignment: .leading, spacing: POSPadding.small) {
99+
Text(label)
100+
.font(.posBodyMediumRegular())
101+
settingValueView(for: value)
102+
}
103+
.frame(maxWidth: .infinity, alignment: .leading)
104+
.padding(.horizontal, POSPadding.medium)
105+
}
106+
114107
@ViewBuilder
115108
private func settingValueView(for value: String?) -> some View {
116109
if isLoading {
@@ -135,6 +128,12 @@ private extension PointOfSaleSettingsStoreDetailView {
135128
}
136129

137130
enum Localization {
131+
static let storeTitle = NSLocalizedString(
132+
"pointOfSaleSettingsStoreDetailView.storeTitle",
133+
value: "Store",
134+
comment: "Navigation title for the store details in POS settings."
135+
)
136+
138137
static let notSet = NSLocalizedString(
139138
"pointOfSaleSettingsStoreDetailView.notSet",
140139
value: "Not set",

WooCommerce/Classes/POS/Presentation/Settings/PointOfSaleSettingsView.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,17 @@ extension PointOfSaleSettingsView {
9292

9393
struct PointOfSaleSettingsCard: View {
9494
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
95+
@Environment(\.colorScheme) private var colorScheme
9596

9697
let item: PointOfSaleSettingsView.SidebarNavigation
9798
let isSelected: Bool
9899
let onTap: () -> Void
99100

101+
private var selectionBackgroundColor: Color {
102+
guard isSelected else { return Color.clear }
103+
return colorScheme == .dark ? Color.posPrimary : Color.posSecondary
104+
}
105+
100106
var body: some View {
101107
Button(action: onTap) {
102108
HStack(spacing: POSSpacing.medium) {
@@ -126,7 +132,7 @@ struct PointOfSaleSettingsCard: View {
126132
.accessibilityAddTraits(.isButton)
127133
.background(
128134
RoundedRectangle(cornerRadius: POSCornerRadiusStyle.small.value, style: .continuous)
129-
.fill(isSelected ? Color.posSecondary : Color.clear)
135+
.fill(selectionBackgroundColor)
130136
)
131137
}
132138
}

0 commit comments

Comments
 (0)