Skip to content

Commit fb0fc62

Browse files
authored
Merge pull request #7721 from woocommerce/widgets/update-deployment-target
Widgets: Update deployment target
2 parents f378109 + a4aa3cf commit fb0fc62

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

WooCommerce/StoreWidgets/StoreInfoProvider.swift

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,7 @@ final class StoreInfoProvider: TimelineProvider {
6666
///
6767
func placeholder(in context: Context) -> StoreInfoEntry {
6868
let dependencies = Self.fetchDependencies()
69-
return StoreInfoEntry.data(.init(range: Localization.today,
70-
name: dependencies?.storeName ?? Localization.myShop,
71-
revenue: Self.formattedAmountString(for: 132.234, with: dependencies?.storeCurrencySettings),
72-
visitors: "67",
73-
orders: "23",
74-
conversion: Self.formattedConversionString(for: 23/67),
75-
updatedTime: Self.currentFormattedTime()))
69+
return Self.placeholderEntry(for: dependencies)
7670
}
7771

7872
/// Quick Snapshot. Required when previewing the widget.
@@ -93,21 +87,11 @@ final class StoreInfoProvider: TimelineProvider {
9387
Task {
9488
do {
9589
let todayStats = try await strongService.fetchTodayStats(for: dependencies.storeID)
96-
97-
let entry = StoreInfoEntry.data(.init(range: Localization.today,
98-
name: dependencies.storeName,
99-
revenue: Self.formattedAmountString(for: todayStats.revenue, with: dependencies.storeCurrencySettings),
100-
visitors: "\(todayStats.totalVisitors)",
101-
orders: "\(todayStats.totalOrders)",
102-
conversion: Self.formattedConversionString(for: todayStats.conversion),
103-
updatedTime: Self.currentFormattedTime()))
104-
90+
let entry = Self.dataEntry(for: todayStats, with: dependencies)
10591
let reloadDate = Date(timeIntervalSinceNow: reloadInterval)
10692
let timeline = Timeline<StoreInfoEntry>(entries: [entry], policy: .after(reloadDate))
10793
completion(timeline)
108-
10994
} catch {
110-
11195
// WooFoundation does not expose `DDLOG` types. Should we include them?
11296
print("⛔️ Error fetching today's widget stats: \(error)")
11397

@@ -148,8 +132,34 @@ private extension StoreInfoProvider {
148132
}
149133
}
150134

135+
/// Data configuration
136+
///
151137
private extension StoreInfoProvider {
152138

139+
/// Redacted entry with sample data. If dependencies are available - store name and currency settings will be used.
140+
///
141+
static func placeholderEntry(for dependencies: Dependencies?) -> StoreInfoEntry {
142+
StoreInfoEntry.data(.init(range: Localization.today,
143+
name: dependencies?.storeName ?? Localization.myShop,
144+
revenue: Self.formattedAmountString(for: 132.234, with: dependencies?.storeCurrencySettings),
145+
visitors: "67",
146+
orders: "23",
147+
conversion: Self.formattedConversionString(for: 23/67),
148+
updatedTime: Self.currentFormattedTime()))
149+
}
150+
151+
/// Real data entry.
152+
///
153+
static func dataEntry(for todayStats: StoreInfoDataService.Stats, with dependencies: Dependencies) -> StoreInfoEntry {
154+
StoreInfoEntry.data(.init(range: Localization.today,
155+
name: dependencies.storeName,
156+
revenue: Self.formattedAmountString(for: todayStats.revenue, with: dependencies.storeCurrencySettings),
157+
visitors: "\(todayStats.totalVisitors)",
158+
orders: "\(todayStats.totalOrders)",
159+
conversion: Self.formattedConversionString(for: todayStats.conversion),
160+
updatedTime: Self.currentFormattedTime()))
161+
}
162+
153163
static func formattedAmountString(for amountValue: Decimal, with currencySettings: CurrencySettings?) -> String {
154164
let currencyFormatter = CurrencyFormatter(currencySettings: currencySettings ?? CurrencySettings())
155165
return currencyFormatter.formatAmount(amountValue) ?? Constants.valuePlaceholderText

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11100,7 +11100,6 @@
1110011100
INFOPLIST_FILE = StoreWidgets/Info.plist;
1110111101
INFOPLIST_KEY_CFBundleDisplayName = StoreWidgets;
1110211102
INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2022 Automattic. All rights reserved.";
11103-
IPHONEOS_DEPLOYMENT_TARGET = 15.5;
1110411103
LD_RUNPATH_SEARCH_PATHS = (
1110511104
"$(inherited)",
1110611105
"@executable_path/Frameworks",
@@ -11135,7 +11134,6 @@
1113511134
INFOPLIST_FILE = StoreWidgets/Info.plist;
1113611135
INFOPLIST_KEY_CFBundleDisplayName = StoreWidgets;
1113711136
INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2022 Automattic. All rights reserved.";
11138-
IPHONEOS_DEPLOYMENT_TARGET = 15.5;
1113911137
LD_RUNPATH_SEARCH_PATHS = (
1114011138
"$(inherited)",
1114111139
"@executable_path/Frameworks",
@@ -11169,7 +11167,6 @@
1116911167
INFOPLIST_FILE = StoreWidgets/Info.plist;
1117011168
INFOPLIST_KEY_CFBundleDisplayName = StoreWidgets;
1117111169
INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2022 Automattic. All rights reserved.";
11172-
IPHONEOS_DEPLOYMENT_TARGET = 15.5;
1117311170
LD_RUNPATH_SEARCH_PATHS = (
1117411171
"$(inherited)",
1117511172
"@executable_path/Frameworks",

0 commit comments

Comments
 (0)