11import SwiftUI
22
3- struct PointOfSaleSettingsView : View {
3+ struct POSSettingsView : View {
44 @Environment ( \. dismiss) private var dismiss
55 @Environment ( \. posAnalytics) private var analytics
66 @State private var selection : SidebarNavigation ? = . store
@@ -20,7 +20,7 @@ struct PointOfSaleSettingsView: View {
2020 }
2121}
2222
23- extension PointOfSaleSettingsView {
23+ extension POSSettingsView {
2424 @ViewBuilder
2525 private var listView : some View {
2626 VStack ( alignment: . leading, spacing: POSSpacing . none) {
@@ -31,49 +31,36 @@ extension PointOfSaleSettingsView {
3131 analytics. track ( . pointOfSaleSettingsCloseButtonTapped)
3232 dismiss ( )
3333 } ,
34- buttonIcon: " xmark " ) )
34+ buttonIcon: " chevron.left " ) )
3535 . foregroundColor ( . posSurface)
3636 . accessibilityAddTraits ( . isHeader)
3737
3838 VStack ( spacing: POSSpacing . small) {
39- PointOfSaleSettingsCard (
40- item: . store,
41- isSelected: selection == . store,
42- onTap: {
43- analytics. track ( . pointOfSaleSettingsStoreDetailsTapped)
44- selection = . store
45- }
46- )
47-
48- PointOfSaleSettingsCard (
49- item: . hardware,
50- isSelected: selection == . hardware,
51- onTap: {
52- analytics. track ( . pointOfSaleSettingsHardwareTapped)
53- selection = . hardware
54- }
55- )
56-
39+ POSSettingsCardView ( title: POSSettingsView . SidebarNavigation. store. title,
40+ subtitle: POSSettingsView . SidebarNavigation. store. subtitle,
41+ isSelected: selection == . store,
42+ action: {
43+ analytics. track ( . pointOfSaleSettingsStoreDetailsTapped)
44+ selection = . store
45+ } )
46+ POSSettingsCardView ( title: POSSettingsView . SidebarNavigation. hardware. title,
47+ subtitle: POSSettingsView . SidebarNavigation. hardware. subtitle,
48+ isSelected: selection == . hardware,
49+ action: {
50+ analytics. track ( . pointOfSaleSettingsHardwareTapped)
51+ selection = . hardware
52+ } )
5753 if settingsController. isLocalCatalogEligible {
58- PointOfSaleSettingsCard (
59- item: . localCatalog,
60- isSelected: selection == . localCatalog,
61- onTap: {
62- selection = . localCatalog
63- }
64- )
54+ POSSettingsCardView ( title: POSSettingsView . SidebarNavigation. localCatalog. title,
55+ subtitle: POSSettingsView . SidebarNavigation. localCatalog. subtitle,
56+ isSelected: selection == . localCatalog,
57+ action: {
58+ selection = . localCatalog
59+ } )
6560 }
66-
6761 Spacer ( )
6862
69- PointOfSaleSettingsCard (
70- item: . help,
71- isSelected: selection == . help,
72- onTap: {
73- analytics. track ( . pointOfSaleSettingsHelpTapped)
74- selection = . help
75- }
76- )
63+ helpView
7764 }
7865 . padding ( . horizontal, POSPadding . medium)
7966 }
@@ -99,62 +86,41 @@ extension PointOfSaleSettingsView {
9986 EmptyView ( )
10087 }
10188 }
102- }
103-
104- extension PointOfSaleSettingsView {
105- enum Constants {
106- static let sidebarWidthFraction : CGFloat = 0.35
107- }
108- }
109-
110- struct PointOfSaleSettingsCard : View {
111- @Environment ( \. dynamicTypeSize) private var dynamicTypeSize
112- @Environment ( \. colorScheme) private var colorScheme
11389
114- let item : PointOfSaleSettingsView . SidebarNavigation
115- let isSelected : Bool
116- let onTap : ( ) -> Void
117-
118- private var selectionBackgroundColor : Color {
119- guard isSelected else { return Color . clear }
120- return colorScheme == . dark ? Color . posPrimary : Color . posSecondary
121- }
122-
123- var body : some View {
124- Button ( action: onTap) {
125- HStack ( spacing: POSSpacing . medium) {
126- Image ( systemName: item. icon)
127- . font ( . posBodyLargeRegular( ) )
128- . foregroundStyle ( Color . posOnSurface)
129- . accessibilityHidden ( true )
130- . renderedIf ( !dynamicTypeSize. isAccessibilitySize)
131-
132- VStack ( alignment: . leading, spacing: POSSpacing . xSmall) {
133- Text ( item. title)
134- . font ( . posBodyLargeRegular( ) )
135- . foregroundStyle ( Color . posOnSurface)
136- . dynamicTypeSize ( ... DynamicTypeSize . accessibility2)
137- Text ( item. subtitle)
138- . font ( . posBodyMediumRegular( ) )
90+ @ViewBuilder
91+ private var helpView : some View {
92+ Button {
93+ analytics. track ( . pointOfSaleSettingsHelpTapped)
94+ selection = . help
95+ } label: {
96+ HStack ( spacing: POSSpacing . small) {
97+ if let icon = SidebarNavigation . help. icon {
98+ Image ( systemName: icon)
99+ . font ( . posBodyMediumBold)
139100 . foregroundStyle ( Color . posOnSurface)
140- . dynamicTypeSize ( ... DynamicTypeSize . accessibility2)
141101 }
142- Spacer ( )
102+ Text ( SidebarNavigation . help. title)
103+ . font ( . posBodyMediumBold)
104+ . foregroundStyle ( Color . posOnSurface)
143105 }
144- . padding ( . vertical, POSPadding . small)
145- . padding ( . horizontal, POSPadding . medium)
106+ . padding ( )
107+ . frame ( maxWidth: . infinity, alignment: . leading)
108+ . dynamicTypeSize ( ... DynamicTypeSize . accessibility2)
146109 . contentShape ( Rectangle ( ) )
147110 }
148111 . buttonStyle ( . plain)
149112 . accessibilityAddTraits ( . isButton)
150- . background (
151- RoundedRectangle ( cornerRadius: POSCornerRadiusStyle . small. value, style: . continuous)
152- . fill ( selectionBackgroundColor)
153- )
113+ . accessibilityLabel ( SidebarNavigation . help. title)
154114 }
155115}
156116
157- extension PointOfSaleSettingsView {
117+ extension POSSettingsView {
118+ enum Constants {
119+ static let sidebarWidthFraction : CGFloat = 0.35
120+ }
121+ }
122+
123+ extension POSSettingsView {
158124 enum SidebarNavigation : String , CaseIterable , Identifiable {
159125 case store
160126 case hardware
@@ -181,12 +147,12 @@ extension PointOfSaleSettingsView {
181147 }
182148 }
183149
184- var icon : String {
150+ var icon : String ? {
185151 switch self {
186- case . store: return " bag "
187- case . hardware : return " wrench.and.screwdriver "
188- case . localCatalog : return " internaldrive "
189- case . help : return " questionmark.circle "
152+ case . store, . hardware , . localCatalog :
153+ return nil
154+ case . help :
155+ return " questionmark.circle "
190156 }
191157 }
192158 }
@@ -211,8 +177,8 @@ extension PointOfSaleSettingsView {
211177 )
212178
213179 static let sidebarNavigationHelpTitle = NSLocalizedString (
214- " pointOfSaleSettingsView.sidebarNavigationHelpTitle " ,
215- value: " Help " ,
180+ " pointOfSaleSettingsView.sidebarNavigationHelpTitle.1 " ,
181+ value: " Get help and support " ,
216182 comment: " Title of the Help section within Point of Sale settings. "
217183 )
218184
@@ -250,6 +216,6 @@ extension PointOfSaleSettingsView {
250216
251217#if DEBUG
252218#Preview {
253- PointOfSaleSettingsView ( settingsController: POSSettingsPreviewController ( ) )
219+ POSSettingsView ( settingsController: POSSettingsPreviewController ( ) )
254220}
255221#endif
0 commit comments