Skip to content

Commit b7fd7ea

Browse files
committed
Refactor support button UI to a SwiftUI view.
1 parent 52f6813 commit b7fd7ea

File tree

6 files changed

+40
-40
lines changed

6 files changed

+40
-40
lines changed

WooCommerce/Classes/Authentication/Store Creation/Profiler/RequiredStoreCreationProfilerQuestionView.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,9 @@ struct RequiredStoreCreationProfilerQuestionView<QuestionContent: View>: View {
5151
}
5252
.toolbar {
5353
ToolbarItem(placement: .navigationBarTrailing) {
54-
Button {
54+
SupportButton{
5555
viewModel.supportButtonTapped()
56-
} label: {
57-
Image(uiImage: .helpOutlineImage)
58-
.renderingMode(.template)
59-
.linkStyle()
6056
}
61-
.accessibilityLabel(Localization.supportButtonAccessibilityLabel)
6257
}
6358
}
6459
// Disables large title to avoid a large gap below the navigation bar.
@@ -76,10 +71,6 @@ private enum Layout {
7671

7772
private enum Localization {
7873
static let continueButtonTitle = NSLocalizedString("Continue", comment: "Title of the button to continue with a profiler question.")
79-
static let supportButtonAccessibilityLabel = NSLocalizedString(
80-
"Help & Support",
81-
comment: "Accessibility label for the Help & Support image navigation bar button in the store creation flow."
82-
)
8374
}
8475

8576
#if DEBUG

WooCommerce/Classes/Authentication/Store Creation/Store name/StoreNameForm.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,9 @@ struct StoreNameForm: View {
8383
.buttonStyle(TextButtonStyle())
8484
}
8585
ToolbarItem(placement: .navigationBarTrailing) {
86-
Button {
86+
SupportButton {
8787
onSupport()
88-
} label: {
89-
Image(uiImage: .helpOutlineImage)
90-
.renderingMode(.template)
91-
.linkStyle()
9288
}
93-
.accessibilityLabel(Localization.supportButtonAccessibilityLabel)
9489
}
9590
}
9691
// Disables large title to avoid a large gap below the navigation bar.
@@ -141,10 +136,6 @@ private extension StoreNameForm {
141136
"Cancel",
142137
comment: "Navigation bar button on the store name form to leave the store creation flow."
143138
)
144-
static let supportButtonAccessibilityLabel = NSLocalizedString(
145-
"Help & Support",
146-
comment: "Accessibility label for the Help & Support image navigation bar button in the store creation flow."
147-
)
148139
}
149140
}
150141

WooCommerce/Classes/Authentication/Store Creation/StoreCreationSummaryView.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,9 @@ struct StoreCreationSummaryView: View {
128128
}
129129
.toolbar {
130130
ToolbarItem(placement: .navigationBarTrailing) {
131-
Button {
131+
SupportButton {
132132
onSupport()
133-
} label: {
134-
Image(uiImage: .helpOutlineImage)
135-
.renderingMode(.template)
136-
.linkStyle()
137133
}
138-
.accessibilityLabel(Localization.supportButtonAccessibilityLabel)
139134
}
140135
}
141136
.navigationTitle(Localization.title)
@@ -164,10 +159,6 @@ private extension StoreCreationSummaryView {
164159
"Continue to Payment",
165160
comment: "Title of the button on the store creation summary view to continue to payment."
166161
)
167-
static let supportButtonAccessibilityLabel = NSLocalizedString(
168-
"Help & Support",
169-
comment: "Accessibility label for the Help & Support image navigation bar button in the store creation flow."
170-
)
171162
}
172163
}
173164

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import SwiftUI
2+
3+
/// A support button with a help icon that is currently shown in the navigation bar.
4+
struct SupportButton: View {
5+
let onTapped: () -> Void
6+
7+
var body: some View {
8+
Button {
9+
onTapped()
10+
} label: {
11+
Image(uiImage: .helpOutlineImage)
12+
.renderingMode(.template)
13+
.linkStyle()
14+
}
15+
.accessibilityLabel(Localization.accessibilityLabel)
16+
}
17+
}
18+
19+
private extension SupportButton {
20+
enum Localization {
21+
static let accessibilityLabel = NSLocalizedString(
22+
"Help & Support",
23+
comment: "Accessibility label for the Help & Support image navigation bar button in the store creation flow."
24+
)
25+
}
26+
}
27+
28+
struct SupportButton_Previews: PreviewProvider {
29+
static var previews: some View {
30+
SupportButton(onTapped: {})
31+
}
32+
}

WooCommerce/Classes/ViewRelated/Dashboard/Settings/Domains/DomainSelectorView.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,9 @@ struct DomainSelectorView: View {
183183
}
184184
.toolbar {
185185
ToolbarItem(placement: .navigationBarTrailing) {
186-
Button {
186+
SupportButton {
187187
onSupport()
188-
} label: {
189-
Image(uiImage: .helpOutlineImage)
190-
.renderingMode(.template)
191-
.linkStyle()
192188
}
193-
.accessibilityLabel(Localization.supportButtonAccessibilityLabel)
194189
}
195190
}
196191
.navigationTitle(Localization.title)
@@ -219,10 +214,6 @@ private extension DomainSelectorView {
219214
static let searchPlaceholder = NSLocalizedString("Type a name for your store", comment: "Placeholder of the search text field on the domain selector.")
220215
static let suggestionsHeader = NSLocalizedString("SUGGESTIONS", comment: "Header label of the domain suggestions on the domain selector.")
221216
static let continueButtonTitle = NSLocalizedString("Continue", comment: "Title of the button to continue with a selected domain.")
222-
static let supportButtonAccessibilityLabel = NSLocalizedString(
223-
"Help & Support",
224-
comment: "Accessibility label for the Help & Support image navigation bar button in the store creation flow."
225-
)
226217
}
227218
}
228219

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@
413413
02CEBB8024C9869E002EDF35 /* ProductFormActionsFactoryProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CEBB7F24C9869E002EDF35 /* ProductFormActionsFactoryProtocol.swift */; };
414414
02CEBB8224C98861002EDF35 /* ProductFormDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CEBB8124C98861002EDF35 /* ProductFormDataModel.swift */; };
415415
02CEBB8424C99A10002EDF35 /* Product+ShippingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CEBB8324C99A10002EDF35 /* Product+ShippingTests.swift */; };
416+
02D3B68529657061009BF0BC /* SupportButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02D3B68429657061009BF0BC /* SupportButton.swift */; };
416417
02D45647231CB1FB008CF0A9 /* UIImage+Dot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02D45646231CB1FB008CF0A9 /* UIImage+Dot.swift */; };
417418
02DAE7FC291B7B8B009342B7 /* DomainSelectorViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02DAE7FB291B7B8B009342B7 /* DomainSelectorViewModel.swift */; };
418419
02DAE7FF291B8C8A009342B7 /* DomainSelectorViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02DAE7FE291B8C8A009342B7 /* DomainSelectorViewModelTests.swift */; };
@@ -2468,6 +2469,7 @@
24682469
02CEBB7F24C9869E002EDF35 /* ProductFormActionsFactoryProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductFormActionsFactoryProtocol.swift; sourceTree = "<group>"; };
24692470
02CEBB8124C98861002EDF35 /* ProductFormDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductFormDataModel.swift; sourceTree = "<group>"; };
24702471
02CEBB8324C99A10002EDF35 /* Product+ShippingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Product+ShippingTests.swift"; sourceTree = "<group>"; };
2472+
02D3B68429657061009BF0BC /* SupportButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportButton.swift; sourceTree = "<group>"; };
24712473
02D45646231CB1FB008CF0A9 /* UIImage+Dot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Dot.swift"; sourceTree = "<group>"; };
24722474
02DAE7FB291B7B8B009342B7 /* DomainSelectorViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainSelectorViewModel.swift; sourceTree = "<group>"; };
24732475
02DAE7FE291B8C8A009342B7 /* DomainSelectorViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainSelectorViewModelTests.swift; sourceTree = "<group>"; };
@@ -4808,6 +4810,7 @@
48084810
02E3B63029066858007E0F13 /* StoreCreationCoordinator.swift */,
48094811
02EAA4C7290F992B00918DAB /* LoggedOutStoreCreationCoordinator.swift */,
48104812
021940E7291FDBF90090354E /* StoreCreationSummaryView.swift */,
4813+
02D3B68429657061009BF0BC /* SupportButton.swift */,
48114814
);
48124815
path = "Store Creation";
48134816
sourceTree = "<group>";
@@ -10337,6 +10340,7 @@
1033710340
451A04EC2386D2B300E368C9 /* ProductImagesCollectionViewDataSource.swift in Sources */,
1033810341
02DD81F9242CAA400060E50B /* WordPressMediaLibraryImagePickerViewController.swift in Sources */,
1033910342
D8C2A28823190B2300F503E9 /* StorageProductReview+Woo.swift in Sources */,
10343+
02D3B68529657061009BF0BC /* SupportButton.swift in Sources */,
1034010344
2664210126F3E1BB001FC5B4 /* ModalHostingPresentationController.swift in Sources */,
1034110345
D8B4D5F026C2C7EC00F34E94 /* InPersonPaymentsStripeAccountPendingView.swift in Sources */,
1034210346
B92639FF293E2D4C00A257E0 /* JustInTimeMessagesProvider.swift in Sources */,

0 commit comments

Comments
 (0)