Skip to content

Commit

Permalink
Update Contextual copy
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandroboron committed Sep 11, 2024
1 parent 9cf1789 commit 0d03459
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import DuckUI

struct OnboardingTrySearchDialog: View {
let title = UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASearchTitle
let message = NSAttributedString(string: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASearchMessage)
let message: String
let viewModel: OnboardingSearchSuggestionsViewModel

var body: some View {
Expand All @@ -33,7 +33,7 @@ struct OnboardingTrySearchDialog: View {
ContextualDaxDialogContent(
title: title,
titleFont: Font(UIFont.daxTitle3()),
message: message,
message: NSAttributedString(string: message),
list: viewModel.itemsList,
listAction: viewModel.listItemPressed
)
Expand Down Expand Up @@ -95,8 +95,8 @@ struct OnboardingFireButtonDialogContent: View {
}

struct OnboardingFirstSearchDoneDialog: View {
let message = NSAttributedString(string: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingFirstSearchDoneMessage)
let cta = UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingGotItButton
let message: String

@State private var showNextScreen: Bool = false

Expand All @@ -112,7 +112,7 @@ struct OnboardingFirstSearchDoneDialog: View {
OnboardingTryVisitingSiteDialogContent(viewModel: viewModel)
} else {
ContextualDaxDialogContent(
message: message,
message: NSAttributedString(string: message),
customActionView: AnyView(
OnboardingCTAButton(title: cta) {
gotItAction()
Expand Down Expand Up @@ -185,7 +185,7 @@ struct OnboardingTrackersDoneDialog: View {

struct OnboardingFinalDialog: View {
let title = UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingFinalScreenTitle
let message = NSAttributedString(string: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingFinalScreenMessage)
let message: String
let cta = UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingFinalScreenButton

let highFiveAction: () -> Void
Expand All @@ -196,7 +196,7 @@ struct OnboardingFinalDialog: View {
ContextualDaxDialogContent(
title: title,
titleFont: Font(UIFont.daxTitle3()),
message: message,
message: NSAttributedString(string: message),
customActionView: AnyView(
OnboardingCTAButton(
title: cta,
Expand Down Expand Up @@ -226,7 +226,7 @@ struct OnboardingCTAButton: View {
// MARK: - Preview

#Preview("Try Search") {
OnboardingTrySearchDialog(viewModel: OnboardingSearchSuggestionsViewModel(suggestedSearchesProvider: OnboardingSuggestedSearchesProvider(), pixelReporter: OnboardingPixelReporter()))
OnboardingTrySearchDialog(message: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASearchMessage, viewModel: OnboardingSearchSuggestionsViewModel(suggestedSearchesProvider: OnboardingSuggestedSearchesProvider(), pixelReporter: OnboardingPixelReporter()))
.padding()
}

Expand All @@ -248,12 +248,12 @@ struct OnboardingCTAButton: View {
}

#Preview("First Search Dialog") {
OnboardingFirstSearchDoneDialog(shouldFollowUp: true, viewModel: OnboardingSiteSuggestionsViewModel(title: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASiteTitle, suggestedSitesProvider: OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.DaxOnboardingExperiment.ContextualOnboarding.tryASearchOptionSurpriseMeTitle), pixelReporter: OnboardingPixelReporter()), gotItAction: {})
OnboardingFirstSearchDoneDialog(message: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingFirstSearchDoneMessage, shouldFollowUp: true, viewModel: OnboardingSiteSuggestionsViewModel(title: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASiteTitle, suggestedSitesProvider: OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.DaxOnboardingExperiment.ContextualOnboarding.tryASearchOptionSurpriseMeTitle), pixelReporter: OnboardingPixelReporter()), gotItAction: {})
.padding()
}

#Preview("Final Dialog") {
OnboardingFinalDialog(highFiveAction: {})
OnboardingFinalDialog(message: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingFinalScreenMessage, highFiveAction: {})

Check failure on line 256 in DuckDuckGo/OnboardingExperiment/ContextualDaxDialogs/ContextualOnboardingDialogs.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)
.padding()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ final class NewTabDaxDialogFactory: NewTabDaxDialogProvider {
private var delegate: OnboardingNavigationDelegate?
private let contextualOnboardingLogic: ContextualOnboardingLogic
private let onboardingPixelReporter: OnboardingPixelReporting
private let onboardingManager: OnboardingHighlightsManaging

init(
delegate: OnboardingNavigationDelegate?,
contextualOnboardingLogic: ContextualOnboardingLogic,
onboardingPixelReporter: OnboardingPixelReporting
onboardingPixelReporter: OnboardingPixelReporting,
onboardingManager: OnboardingHighlightsManaging = OnboardingManager()
) {
self.delegate = delegate
self.contextualOnboardingLogic = contextualOnboardingLogic
self.onboardingPixelReporter = onboardingPixelReporter
self.onboardingManager = onboardingManager
}

@ViewBuilder
Expand All @@ -60,8 +63,9 @@ final class NewTabDaxDialogFactory: NewTabDaxDialogProvider {

private func createInitialDialog() -> some View {
let viewModel = OnboardingSearchSuggestionsViewModel(suggestedSearchesProvider: OnboardingSuggestedSearchesProvider(), delegate: delegate, pixelReporter: onboardingPixelReporter)
let message = onboardingManager.isOnboardingHighlightsEnabled ? UserText.HighlightsOnboardingExperiment.ContextualOnboarding.onboardingTryASearchMessage : UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASearchMessage
return FadeInView {
OnboardingTrySearchDialog(viewModel: viewModel)
OnboardingTrySearchDialog(message: message, viewModel: viewModel)
.onboardingDaxDialogStyle()
}
.onboardingContextualBackgroundStyle()
Expand Down Expand Up @@ -92,8 +96,10 @@ final class NewTabDaxDialogFactory: NewTabDaxDialogProvider {
}

private func createFinalDialog(onDismiss: @escaping () -> Void) -> some View {
FadeInView {
OnboardingFinalDialog(highFiveAction: {
let message = onboardingManager.isOnboardingHighlightsEnabled ? UserText.HighlightsOnboardingExperiment.ContextualOnboarding.onboardingFinalScreenMessage : UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingFinalScreenMessage

return FadeInView {
OnboardingFinalDialog(message: message, highFiveAction: {
onDismiss()
})
.onboardingDaxDialogStyle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,20 @@ final class ExperimentContextualDaxDialogsFactory: ContextualDaxDialogsFactory {
private let contextualOnboardingSettings: ContextualOnboardingSettings
private let contextualOnboardingPixelReporter: OnboardingPixelReporting
private let contextualOnboardingSiteSuggestionsProvider: OnboardingSuggestionsItemsProviding
private let onboardingManager: OnboardingHighlightsManaging

init(
contextualOnboardingLogic: ContextualOnboardingLogic,
contextualOnboardingSettings: ContextualOnboardingSettings = DefaultDaxDialogsSettings(),
contextualOnboardingPixelReporter: OnboardingPixelReporting,
contextualOnboardingSiteSuggestionsProvider: OnboardingSuggestionsItemsProviding = OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.DaxOnboardingExperiment.ContextualOnboarding.tryASearchOptionSurpriseMeTitle)
contextualOnboardingSiteSuggestionsProvider: OnboardingSuggestionsItemsProviding = OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.DaxOnboardingExperiment.ContextualOnboarding.tryASearchOptionSurpriseMeTitle),
onboardingManager: OnboardingHighlightsManaging = OnboardingManager()
) {
self.contextualOnboardingSettings = contextualOnboardingSettings
self.contextualOnboardingLogic = contextualOnboardingLogic
self.contextualOnboardingPixelReporter = contextualOnboardingPixelReporter
self.contextualOnboardingSiteSuggestionsProvider = contextualOnboardingSiteSuggestionsProvider
self.onboardingManager = onboardingManager
}

func makeView(for spec: DaxDialogs.BrowsingSpec, delegate: ContextualOnboardingDelegate, onSizeUpdate: @escaping () -> Void) -> UIHostingController<AnyView> {
Expand Down Expand Up @@ -122,7 +125,9 @@ final class ExperimentContextualDaxDialogsFactory: ContextualDaxDialogsFactory {
}
}

return OnboardingFirstSearchDoneDialog(shouldFollowUp: shouldFollowUpToWebsiteSearch, viewModel: viewModel, gotItAction: gotItAction)
let message = onboardingManager.isOnboardingHighlightsEnabled ? UserText.HighlightsOnboardingExperiment.ContextualOnboarding.onboardingFirstSearchDoneMessage : UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingFirstSearchDoneMessage

return OnboardingFirstSearchDoneDialog(message: message, shouldFollowUp: shouldFollowUpToWebsiteSearch, viewModel: viewModel, gotItAction: gotItAction)
.onFirstAppear { [weak self] in
self?.contextualOnboardingPixelReporter.trackScreenImpression(event: afterSearchPixelEvent)
}
Expand Down Expand Up @@ -164,7 +169,9 @@ final class ExperimentContextualDaxDialogsFactory: ContextualDaxDialogsFactory {
}

private func endOfJourneyDialog(delegate: ContextualOnboardingDelegate, pixelName: Pixel.Event) -> some View {
OnboardingFinalDialog(highFiveAction: { [weak delegate] in
let message = onboardingManager.isOnboardingHighlightsEnabled ? UserText.HighlightsOnboardingExperiment.ContextualOnboarding.onboardingFinalScreenMessage : UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingFinalScreenMessage

return OnboardingFinalDialog(message: message, highFiveAction: { [weak delegate] in
delegate?.didTapDismissContextualOnboardingAction()
})
.onFirstAppear { [weak self] in
Expand Down

0 comments on commit 0d03459

Please sign in to comment.