File tree Expand file tree Collapse file tree 2 files changed +48
-4
lines changed
Expand file tree Collapse file tree 2 files changed +48
-4
lines changed Original file line number Diff line number Diff line change @@ -98,10 +98,14 @@ final class StoreInfoProvider: TimelineProvider {
9898 completion ( timeline)
9999
100100 } catch {
101- // TODO: Dispatch network error entry.
102- print ( " Error: \( error) " )
103- }
104101
102+ // WooFoundation does not expose `DDLOG` types. Should we include them?
103+ print ( " ⛔️ Error fetching today's widget stats: \( error) " )
104+
105+ let reloadDate = Date ( timeIntervalSinceNow: 30 * 60 ) // Ask for a 30 minutes reload.
106+ let timeline = Timeline < StoreInfoEntry > ( entries: [ . error] , policy: . after( reloadDate) )
107+ completion ( timeline)
108+ }
105109 }
106110 }
107111}
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ struct StoreInfoWidget: Widget {
1616 case . notConnected:
1717 NotLoggedInView ( )
1818 case . error:
19- EmptyView ( ) // TODO:
19+ UnableToFetchView ( )
2020 case . data( let data) :
2121 StoreInfoView ( entry: data)
2222 }
@@ -126,6 +126,29 @@ private struct NotLoggedInView: View {
126126 }
127127}
128128
129+ private struct UnableToFetchView : View {
130+ var body : some View {
131+ ZStack {
132+ // Background
133+ Color ( . brand)
134+
135+ VStack {
136+ Image ( uiImage: . wooLogoWhite)
137+ . resizable ( )
138+ . frame ( width: Layout . logoSize. width, height: Layout . logoSize. height)
139+
140+ Spacer ( )
141+
142+ Text ( Localization . unableToFetch)
143+ . statTextStyle ( )
144+
145+ Spacer ( )
146+ }
147+ . padding ( . vertical, Layout . cardVerticalPadding)
148+ }
149+ }
150+ }
151+
129152// MARK: Constants
130153
131154/// Constants definition
@@ -160,6 +183,20 @@ private extension NotLoggedInView {
160183 }
161184}
162185
186+ /// Constants definition
187+ ///
188+ private extension UnableToFetchView {
189+ enum Localization {
190+ static let unableToFetch = NSLocalizedString ( " Unable to fetch today's stats " ,
191+ comment: " Title label when the widget can't fetch data. " )
192+ }
193+
194+ enum Layout {
195+ static let cardVerticalPadding = 22.0
196+ static let logoSize = CGSize ( width: 24 , height: 16 )
197+ }
198+ }
199+
163200// MARK: Previews
164201
165202struct StoreWidgets_Previews : PreviewProvider {
@@ -176,5 +213,8 @@ struct StoreWidgets_Previews: PreviewProvider {
176213
177214 NotLoggedInView ( )
178215 . previewContext ( WidgetPreviewContext ( family: . systemMedium) )
216+
217+ UnableToFetchView ( )
218+ . previewContext ( WidgetPreviewContext ( family: . systemMedium) )
179219 }
180220}
You can’t perform that action at this time.
0 commit comments