@@ -33,14 +33,17 @@ private struct StoreInfoView: View {
3333 // Entry to render
3434 let entry : StoreInfoData
3535
36+ // Current size category
37+ @Environment ( \. sizeCategory) var category
38+
3639 var body : some View {
3740 ZStack {
3841 // Background
3942 Color ( . brand)
4043
41- VStack ( spacing: Layout . sectionSpacing) {
44+ VStack ( alignment : . leading , spacing: Layout . sectionSpacing) {
4245
43- VStack ( spacing: Layout . cardSpacing) {
46+ VStack ( alignment : . leading , spacing: Layout . cardSpacing) {
4447 // Store Name
4548 HStack {
4649 Text ( entry. name)
@@ -55,53 +58,93 @@ private struct StoreInfoView: View {
5558 // Updated at
5659 Text ( Localization . updatedAt ( entry. updatedTime) )
5760 . statRangeStyle ( )
58- . frame ( maxWidth: . infinity, alignment: . leading)
5961 }
6062
61- // Revenue & Visitors
62- HStack ( ) {
63- VStack ( alignment: . leading, spacing: Layout . cardSpacing) {
64- Text ( Localization . revenue)
65- . statTitleStyle ( )
63+ if category. isAccessibilityCategory {
64+ AccessibilityStatsCard ( entry: entry)
65+ } else {
66+ StatsCard ( entry: entry)
67+ }
68+ }
69+ . padding ( . horizontal)
70+ }
71+ }
72+ }
6673
67- Text ( entry. revenue)
68- . statValueStyle ( )
74+ /// Stats card sub view.
75+ /// To be used inside `StoreInfoView`.
76+ ///
77+ private struct StatsCard : View {
78+ // Entry to render
79+ let entry : StoreInfoData
6980
70- }
71- . frame ( maxWidth: . infinity, alignment: . leading)
81+ var body : some View {
82+ Group {
83+ // Revenue & Visitors
84+ HStack ( ) {
85+ VStack ( alignment: . leading, spacing: StoreInfoView . Layout. cardSpacing) {
86+ Text ( StoreInfoView . Localization. revenue)
87+ . statTitleStyle ( )
7288
73- VStack ( alignment: . leading, spacing: Layout . cardSpacing) {
74- Text ( Localization . visitors)
75- . statTitleStyle ( )
89+ Text ( entry. revenue)
90+ . statValueStyle ( )
7691
77- Text ( entry. visitors)
78- . statValueStyle ( )
79- }
80- . frame ( maxWidth: . infinity, alignment: . leading)
8192 }
93+ . frame ( maxWidth: . infinity, alignment: . leading)
8294
83- // Orders & Conversion
84- HStack {
85- VStack ( alignment: . leading, spacing: Layout . cardSpacing) {
86- Text ( Localization . orders)
87- . statTitleStyle ( )
95+ VStack ( alignment: . leading, spacing: StoreInfoView . Layout. cardSpacing) {
96+ Text ( StoreInfoView . Localization. visitors)
97+ . statTitleStyle ( )
8898
89- Text ( entry. orders)
90- . statValueStyle ( )
91- }
92- . frame ( maxWidth: . infinity, alignment: . leading)
99+ Text ( entry. visitors)
100+ . statValueStyle ( )
101+ }
102+ . frame ( maxWidth: . infinity, alignment: . leading)
103+ }
93104
94- VStack ( alignment: . leading, spacing: Layout . cardSpacing) {
95- Text ( Localization . conversion)
96- . statTitleStyle ( )
105+ // Orders & Conversion
106+ HStack {
107+ VStack ( alignment: . leading, spacing: StoreInfoView . Layout. cardSpacing) {
108+ Text ( StoreInfoView . Localization. orders)
109+ . statTitleStyle ( )
97110
98- Text ( entry. conversion)
99- . statValueStyle ( )
100- }
101- . frame ( maxWidth: . infinity, alignment: . leading)
111+ Text ( entry. orders)
112+ . statValueStyle ( )
102113 }
114+ . frame ( maxWidth: . infinity, alignment: . leading)
115+
116+ VStack ( alignment: . leading, spacing: StoreInfoView . Layout. cardSpacing) {
117+ Text ( StoreInfoView . Localization. conversion)
118+ . statTitleStyle ( )
119+
120+ Text ( entry. conversion)
121+ . statValueStyle ( )
122+ }
123+ . frame ( maxWidth: . infinity, alignment: . leading)
103124 }
104- . padding ( . horizontal)
125+ }
126+ }
127+ }
128+
129+ /// Accessibility card sub view.
130+ /// To be used inside `StoreInfoView`.
131+ ///
132+ private struct AccessibilityStatsCard : View {
133+ // Entry to render
134+ let entry : StoreInfoData
135+
136+ var body : some View {
137+ Group {
138+ VStack ( alignment: . leading, spacing: StoreInfoView . Layout. cardSpacing) {
139+ Text ( StoreInfoView . Localization. revenue)
140+ . statTitleStyle ( )
141+
142+ Text ( entry. revenue)
143+ . statValueStyle ( )
144+ }
145+
146+ Text ( StoreInfoView . Localization. viewMore)
147+ . statButtonStyle ( )
105148 }
106149 }
107150}
@@ -198,6 +241,11 @@ private extension StoreInfoView {
198241 value: " Conversion " ,
199242 comment: " Conversion title label for the store info widget "
200243 )
244+ static let viewMore = AppLocalizedString (
245+ " storeWidgets.infoView.viewMore " ,
246+ value: " View More " ,
247+ comment: " Title for the button indicator to display more stats in the Today's Stat widget when using accessibility fonts. "
248+ )
201249 static func updatedAt( _ updatedTime: String ) -> LocalizedString {
202250 let format = AppLocalizedString ( " storeWidgets.infoView.updatedAt " ,
203251 value: " As of %1$@ " ,
@@ -266,6 +314,18 @@ struct StoreWidgets_Previews: PreviewProvider {
266314 )
267315 . previewContext ( WidgetPreviewContext ( family: . systemMedium) )
268316
317+ StoreInfoView (
318+ entry: StoreInfoData ( range: " Today " ,
319+ name: " Ernest Shop " ,
320+ revenue: " $132.234 " ,
321+ visitors: " 67 " ,
322+ orders: " 23 " ,
323+ conversion: " 37% " ,
324+ updatedTime: " 10:24 PM " )
325+ )
326+ . previewContext ( WidgetPreviewContext ( family: . systemMedium) )
327+ . environment ( \. sizeCategory, . accessibilityMedium)
328+
269329 NotLoggedInView ( )
270330 . previewContext ( WidgetPreviewContext ( family: . systemMedium) )
271331
0 commit comments