@@ -7,14 +7,14 @@ final class DomainSelectorHostingController: UIHostingController<DomainSelectorV
77 /// - Parameters:
88 /// - viewModel: View model for the domain selector.
99 /// - onDomainSelection: Called when the user continues with a selected domain name.
10+ /// - onSupport: Called when the user taps to contact support.
1011 init ( viewModel: DomainSelectorViewModel ,
11- onDomainSelection: @escaping ( String ) async -> Void ) {
12+ onDomainSelection: @escaping ( String ) async -> Void ,
13+ onSupport: @escaping ( ) -> Void ) {
1214 self . viewModel = viewModel
13- super. init ( rootView: DomainSelectorView ( viewModel: viewModel) )
14-
15- rootView. onDomainSelection = { domain in
16- await onDomainSelection ( domain)
17- }
15+ super. init ( rootView: DomainSelectorView ( viewModel: viewModel,
16+ onDomainSelection: onDomainSelection,
17+ onSupport: onSupport) )
1818 }
1919
2020 required dynamic init ? ( coder aDecoder: NSCoder ) {
@@ -55,8 +55,8 @@ struct DomainSelectorView: View {
5555 case results( domains: [ String ] )
5656 }
5757
58- /// Set in the hosting controller.
59- var onDomainSelection : ( ( String ) async -> Void ) = { _ in }
58+ private let onDomainSelection : ( String ) async -> Void
59+ private let onSupport : ( ) -> Void
6060
6161 /// View model to drive the view.
6262 @ObservedObject private var viewModel : DomainSelectorViewModel
@@ -70,8 +70,12 @@ struct DomainSelectorView: View {
7070
7171 @FocusState private var textFieldIsFocused : Bool
7272
73- init ( viewModel: DomainSelectorViewModel ) {
73+ init ( viewModel: DomainSelectorViewModel ,
74+ onDomainSelection: @escaping ( String ) async -> Void ,
75+ onSupport: @escaping ( ) -> Void ) {
7476 self . viewModel = viewModel
77+ self . onDomainSelection = onDomainSelection
78+ self . onSupport = onSupport
7579 }
7680
7781 var body : some View {
@@ -177,6 +181,18 @@ struct DomainSelectorView: View {
177181 . background ( Color ( . systemBackground) )
178182 }
179183 }
184+ . toolbar {
185+ ToolbarItem ( placement: . navigationBarTrailing) {
186+ Button {
187+ onSupport ( )
188+ } label: {
189+ Image ( uiImage: . helpOutlineImage)
190+ . renderingMode ( . template)
191+ . linkStyle ( )
192+ }
193+ . accessibilityLabel ( Localization . supportButtonAccessibilityLabel)
194+ }
195+ }
180196 . navigationTitle ( Localization . title)
181197 . navigationBarTitleDisplayMode ( . large)
182198 . onChange ( of: viewModel. isLoadingDomainSuggestions) { isLoadingDomainSuggestions in
@@ -203,6 +219,10 @@ private extension DomainSelectorView {
203219 static let searchPlaceholder = NSLocalizedString ( " Type a name for your store " , comment: " Placeholder of the search text field on the domain selector. " )
204220 static let suggestionsHeader = NSLocalizedString ( " SUGGESTIONS " , comment: " Header label of the domain suggestions on the domain selector. " )
205221 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+ )
206226 }
207227}
208228
@@ -237,7 +257,9 @@ struct DomainSelectorView_Previews: PreviewProvider {
237257 // Empty query state.
238258 DomainSelectorView ( viewModel:
239259 . init( initialSearchTerm: " " ,
240- stores: DomainSelectorViewStores ( result: nil ) ) )
260+ stores: DomainSelectorViewStores ( result: nil ) ) ,
261+ onDomainSelection: { _ in } ,
262+ onSupport: { } )
241263 // Results state.
242264 DomainSelectorView ( viewModel:
243265 . init( initialSearchTerm: " Fruit smoothie " ,
@@ -248,18 +270,24 @@ struct DomainSelectorView_Previews: PreviewProvider {
248270 . init( name: " freesmoothieeee.com " , isFree: true ) ,
249271 . init( name: " greatfruitsmoothie1.com " , isFree: true ) ,
250272 . init( name: " tropicalsmoothie.com " , isFree: true )
251- ] ) ) ) )
273+ ] ) ) ) ,
274+ onDomainSelection: { _ in } ,
275+ onSupport: { } )
252276 // Error state.
253277 DomainSelectorView ( viewModel:
254278 . init( initialSearchTerm: " test " ,
255279 stores: DomainSelectorViewStores ( result: . failure(
256280 DotcomError . unknown ( code: " invalid_query " ,
257281 message: " Domain searches must contain a word with the following characters. " )
258- ) ) ) )
282+ ) ) ) ,
283+ onDomainSelection: { _ in } ,
284+ onSupport: { } )
259285 // Loading state.
260286 DomainSelectorView ( viewModel:
261287 . init( initialSearchTerm: " test " ,
262- stores: DomainSelectorViewStores ( result: nil ) ) )
288+ stores: DomainSelectorViewStores ( result: nil ) ) ,
289+ onDomainSelection: { _ in } ,
290+ onSupport: { } )
263291 }
264292 }
265293}
0 commit comments