Skip to content

Commit ebae30f

Browse files
committed
Show WooCommerce blog from Learn More button
1 parent 4139ee7 commit ebae30f

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed

Modules/Sources/PointOfSale/Presentation/Orders/POSOrderListView.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ struct POSOrderListView: View {
101101
analytics.track(event: WooAnalyticsEvent.PointOfSale.ordersListPullToRefresh())
102102
await orderListModel.ordersController.refreshOrders()
103103
}
104-
.task {
105-
await orderListModel.ordersController.loadOrders()
106-
}
107104
}
108105

109106
@ViewBuilder

Modules/Sources/PointOfSale/Presentation/Orders/POSOrdersView.swift

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import SwiftUI
22
import UIKit
33
import struct WooFoundation.WooAnalyticsEvent
4+
import struct WooFoundation.SafariView
45

56
struct POSOrdersView: View {
67
@Binding var isPresented: Bool
@@ -9,8 +10,17 @@ struct POSOrdersView: View {
910
@Environment(\.posAnalytics) private var analytics
1011
@State private var isSearching: Bool = false
1112
@State private var searchTerm: String = ""
13+
@State private var showBlog = false
1214

1315
var body: some View {
16+
contentView
17+
.task {
18+
await orderListModel.ordersController.loadOrders()
19+
}
20+
}
21+
22+
@ViewBuilder
23+
private var contentView: some View {
1424
switch (orderListModel.ordersController.ordersViewState, isSearching) {
1525
case (.error(let error), false):
1626
errorView(error)
@@ -70,16 +80,6 @@ struct POSOrdersView: View {
7080
@ViewBuilder
7181
private func errorView(_ error: PointOfSaleErrorState) -> some View {
7282
ZStack {
73-
VStack {
74-
POSPageHeaderView(
75-
title: POSOrderListView.Localization.ordersTitle,
76-
backButtonConfiguration: .init(state: .enabled, action: {
77-
isPresented = false
78-
}))
79-
.posHeaderBackButtonIcon(systemName: "xmark")
80-
Spacer()
81-
}
82-
8383
VStack {
8484
Spacer()
8585
POSListErrorView(error: error) {
@@ -89,12 +89,7 @@ struct POSOrdersView: View {
8989
}
9090
Spacer()
9191
}
92-
}
93-
}
9492

95-
@ViewBuilder
96-
private func emptyView() -> some View {
97-
ZStack {
9893
VStack {
9994
POSPageHeaderView(
10095
title: POSOrderListView.Localization.ordersTitle,
@@ -104,18 +99,34 @@ struct POSOrdersView: View {
10499
.posHeaderBackButtonIcon(systemName: "xmark")
105100
Spacer()
106101
}
102+
}
103+
}
107104

105+
@ViewBuilder
106+
private func emptyView() -> some View {
107+
ZStack {
108108
VStack {
109109
Spacer()
110110
POSListEmptyView(
111111
viewModel: POSOrderListEmptyViewModel(isSearching: false)
112112
) {
113-
Task { @MainActor in
114-
await orderListModel.ordersController.loadOrders()
115-
}
113+
showBlog = true
116114
}
117115
Spacer()
118116
}
117+
118+
VStack {
119+
POSPageHeaderView(
120+
title: POSOrderListView.Localization.ordersTitle,
121+
backButtonConfiguration: .init(state: .enabled, action: {
122+
isPresented = false
123+
}))
124+
.posHeaderBackButtonIcon(systemName: "xmark")
125+
Spacer()
126+
}
127+
}
128+
.posFullScreenCover(isPresented: $showBlog) {
129+
SafariView(url: POSConstants.URLs.wooCommerceBlog.asURL())
119130
}
120131
}
121132
}

Modules/Sources/PointOfSale/Utils/POSConstants.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ enum POSConstants {
2020
///
2121
case inPersonPaymentsLearnMoreWCPay =
2222
"https://woocommerce.com/document/woocommerce-payments/in-person-payments/getting-started-with-in-person-payments/"
23+
24+
/// URL for WooCommerce blog
25+
///
26+
case wooCommerceBlog = "https://woocommerce.com/blog/"
2327
}
2428
}
2529

0 commit comments

Comments
 (0)