Skip to content

Commit 256dfe4

Browse files
authored
Merge pull request #8141 from woocommerce/feat/8118-store-creation-success
Store creation M2: success screen
2 parents 0217932 + a696db6 commit 256dfe4

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
import SwiftUI
2+
3+
/// Hosting controller that wraps the `StoreCreationSuccessView`.
4+
final class StoreCreationSuccessHostingController: UIHostingController<StoreCreationSuccessView> {
5+
private let onContinue: () -> Void
6+
7+
init(siteURL: URL,
8+
onContinue: @escaping () -> Void) {
9+
self.onContinue = onContinue
10+
super.init(rootView: StoreCreationSuccessView(siteURL: siteURL))
11+
12+
rootView.onContinue = { [weak self] in
13+
self?.onContinue()
14+
}
15+
}
16+
17+
@available(*, unavailable)
18+
required dynamic init?(coder aDecoder: NSCoder) {
19+
fatalError("init(coder:) has not been implemented")
20+
}
21+
22+
override func viewDidLoad() {
23+
super.viewDidLoad()
24+
25+
configureNavigationBarAppearance()
26+
}
27+
28+
/// Shows a transparent navigation bar without a bottom border and with a close button to dismiss.
29+
func configureNavigationBarAppearance() {
30+
let appearance = UINavigationBarAppearance()
31+
appearance.configureWithTransparentBackground()
32+
appearance.backgroundColor = .systemBackground
33+
34+
navigationItem.standardAppearance = appearance
35+
navigationItem.scrollEdgeAppearance = appearance
36+
navigationItem.compactAppearance = appearance
37+
}
38+
}
39+
40+
struct StoreCreationSuccessView: View {
41+
/// Set in the hosting controller.
42+
var onContinue: () -> Void = {}
43+
44+
/// URL of the newly created site.
45+
let siteURL: URL
46+
47+
// Tracks the scale of the view due to accessibility changes.
48+
@ScaledMetric private var scale: CGFloat = 1.0
49+
50+
@State private var isPresentingWebview: Bool = false
51+
52+
var body: some View {
53+
ScrollView {
54+
VStack(alignment: .center, spacing: 33) {
55+
// Title label.
56+
Text(Localization.title)
57+
.fontWeight(.bold)
58+
.titleStyle()
59+
60+
// Readonly webview for the new site.
61+
WebView(isPresented: .constant(true), url: siteURL)
62+
.frame(height: 400 * scale)
63+
.disabled(true)
64+
.border(Color(.systemBackground), width: 8)
65+
.cornerRadius(8)
66+
.shadow(color: Color(.secondaryLabel), radius: 26)
67+
.padding(.horizontal, insets: Layout.webviewHorizontalPadding)
68+
}
69+
.padding(Layout.contentPadding)
70+
}
71+
.safeAreaInset(edge: .bottom) {
72+
VStack(spacing: 0) {
73+
Divider()
74+
.frame(height: 1)
75+
.foregroundColor(Color(.separator))
76+
77+
VStack(spacing: 16) {
78+
// Continue button.
79+
Button(Localization.continueButtonTitle) {
80+
onContinue()
81+
}
82+
.buttonStyle(PrimaryButtonStyle())
83+
84+
// Preview button.
85+
Button(Localization.previewButtonTitle) {
86+
isPresentingWebview = true
87+
}
88+
.buttonStyle(SecondaryButtonStyle())
89+
}
90+
.padding(insets: Layout.buttonContainerPadding)
91+
}
92+
.background(Color(.systemBackground))
93+
}
94+
.safariSheet(isPresented: $isPresentingWebview, url: siteURL)
95+
}
96+
}
97+
98+
private extension StoreCreationSuccessView {
99+
enum Layout {
100+
static let contentPadding: EdgeInsets = .init(top: 38, leading: 16, bottom: 16, trailing: 16)
101+
static let buttonContainerPadding: EdgeInsets = .init(top: 16, leading: 16, bottom: 16, trailing: 16)
102+
static let webviewHorizontalPadding: EdgeInsets = .init(top: 0, leading: 44, bottom: 0, trailing: 44)
103+
}
104+
105+
enum Localization {
106+
static let title = NSLocalizedString(
107+
"Your store has been created!",
108+
comment: "Title of the store creation success screen."
109+
)
110+
static let continueButtonTitle = NSLocalizedString(
111+
"Manage My Store",
112+
comment: "Title of the primary button on the store creation success screen to continue to the newly created store."
113+
)
114+
static let previewButtonTitle = NSLocalizedString(
115+
"Store Preview",
116+
comment: "Title of the secondary button on the store creation success screen to preview the newly created store."
117+
)
118+
}
119+
}
120+
121+
struct StoreCreationSuccessView_Previews: PreviewProvider {
122+
static var previews: some View {
123+
StoreCreationSuccessView(siteURL: URL(string: "https://woocommerce.com")!)
124+
StoreCreationSuccessView(siteURL: URL(string: "https://woocommerce.com")!)
125+
.preferredColorScheme(.dark)
126+
}
127+
}

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
0202B6952387AD1B00F3EBE0 /* UITabBar+Order.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0202B6942387AD1B00F3EBE0 /* UITabBar+Order.swift */; };
2727
0205021E27C8B6C600FB1C6B /* InboxEligibilityUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0205021D27C8B6C600FB1C6B /* InboxEligibilityUseCase.swift */; };
2828
020624F027951113000D024C /* StoreStatsDataOrRedactedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 020624EF27951113000D024C /* StoreStatsDataOrRedactedView.swift */; };
29+
02063C8929260AA000130906 /* StoreCreationSuccessView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02063C8829260A9F00130906 /* StoreCreationSuccessView.swift */; };
2930
0206483A23FA4160008441BB /* OrdersRootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0206483923FA4160008441BB /* OrdersRootViewController.swift */; };
3031
02077F72253816FF005A78EF /* ProductFormActionsFactory+ReadonlyProductTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02077F71253816FF005A78EF /* ProductFormActionsFactory+ReadonlyProductTests.swift */; };
3132
020886572499E643001D784E /* ProductExternalLinkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 020886562499E642001D784E /* ProductExternalLinkViewController.swift */; };
@@ -1988,6 +1989,7 @@
19881989
0202B6942387AD1B00F3EBE0 /* UITabBar+Order.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITabBar+Order.swift"; sourceTree = "<group>"; };
19891990
0205021D27C8B6C600FB1C6B /* InboxEligibilityUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxEligibilityUseCase.swift; sourceTree = "<group>"; };
19901991
020624EF27951113000D024C /* StoreStatsDataOrRedactedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreStatsDataOrRedactedView.swift; sourceTree = "<group>"; };
1992+
02063C8829260A9F00130906 /* StoreCreationSuccessView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoreCreationSuccessView.swift; sourceTree = "<group>"; };
19911993
0206483923FA4160008441BB /* OrdersRootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrdersRootViewController.swift; sourceTree = "<group>"; };
19921994
02077F71253816FF005A78EF /* ProductFormActionsFactory+ReadonlyProductTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProductFormActionsFactory+ReadonlyProductTests.swift"; sourceTree = "<group>"; };
19931995
020886562499E642001D784E /* ProductExternalLinkViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductExternalLinkViewController.swift; sourceTree = "<group>"; };
@@ -3971,6 +3973,14 @@
39713973
path = TabBar;
39723974
sourceTree = "<group>";
39733975
};
3976+
02063C8729260A6500130906 /* Installations */ = {
3977+
isa = PBXGroup;
3978+
children = (
3979+
02063C8829260A9F00130906 /* StoreCreationSuccessView.swift */,
3980+
);
3981+
path = Installations;
3982+
sourceTree = "<group>";
3983+
};
39743984
02077F70253816B1005A78EF /* Actions Factory */ = {
39753985
isa = PBXGroup;
39763986
children = (
@@ -4539,6 +4549,7 @@
45394549
children = (
45404550
020AF6642923C745007760E5 /* Store name */,
45414551
02EEA92929233F0F00D05F47 /* Plan */,
4552+
02063C8729260A6500130906 /* Installations */,
45424553
02759B9028FFA09600918176 /* StoreCreationWebViewModel.swift */,
45434554
02E3B63029066858007E0F13 /* StoreCreationCoordinator.swift */,
45444555
02EAA4C7290F992B00918DAB /* LoggedOutStoreCreationCoordinator.swift */,
@@ -9809,6 +9820,7 @@
98099820
029700EC24FE38C900D242F8 /* ScrollWatcher.swift in Sources */,
98109821
D8C11A4E22DD235F00D4A88D /* OrderDetailsResultsControllers.swift in Sources */,
98119822
D8C251D9230D256F00F49782 /* NoticePresenter.swift in Sources */,
9823+
02063C8929260AA000130906 /* StoreCreationSuccessView.swift in Sources */,
98129824
77E53EB8250E6A4E003D385F /* ProductDownloadListViewController.swift in Sources */,
98139825
E1325EFB28FD544E00EC9B2A /* InAppPurchasesDebugView.swift in Sources */,
98149826
74460D4022289B7600D7316A /* Coordinator.swift in Sources */,

0 commit comments

Comments
 (0)