Skip to content

Commit

Permalink
Refactor User Text
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandroboron committed Dec 5, 2024
1 parent 2427b0a commit 678acbb
Show file tree
Hide file tree
Showing 18 changed files with 99 additions and 121 deletions.
8 changes: 4 additions & 4 deletions DuckDuckGo/DaxDialogs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ final class DaxDialogs: NewTabDialogSpecProvider, ContextualOnboardingLogic {
highlightAddressBar: false,
pixelName: .daxDialogsSiteOwnedByMajorUnique, type: .siteOwnedByMajorTracker)

static let withOneTracker = BrowsingSpec(message: UserText.DaxOnboardingExperiment.ContextualOnboarding.daxDialogBrowsingWithOneTracker,
static let withOneTracker = BrowsingSpec(message: UserText.Onboarding.ContextualOnboarding.daxDialogBrowsingWithOneTracker,
cta: UserText.daxDialogBrowsingWithOneTrackerCTA,
highlightAddressBar: false,
pixelName: .daxDialogsWithTrackersUnique, type: .withOneTracker)

static let withMultipleTrackers = BrowsingSpec(message: UserText.DaxOnboardingExperiment.ContextualOnboarding.daxDialogBrowsingWithMultipleTrackers,
static let withMultipleTrackers = BrowsingSpec(message: UserText.Onboarding.ContextualOnboarding.daxDialogBrowsingWithMultipleTrackers,
cta: UserText.daxDialogBrowsingWithMultipleTrackersCTA,
highlightAddressBar: false,
pixelName: .daxDialogsWithTrackersUnique, type: .withMultipleTrackers)
Expand Down Expand Up @@ -584,12 +584,12 @@ final class DaxDialogs: NewTabDialogSpecProvider, ContextualOnboardingLogic {
case 1:
settings.browsingWithTrackersShown = true
let args = entitiesBlocked[0]
spec = BrowsingSpec.withOneTracker.format(message: UserText.DaxOnboardingExperiment.ContextualOnboarding.daxDialogBrowsingWithOneTracker, args: args)
spec = BrowsingSpec.withOneTracker.format(message: UserText.Onboarding.ContextualOnboarding.daxDialogBrowsingWithOneTracker, args: args)

default:
settings.browsingWithTrackersShown = true
let args: [CVarArg] = [entitiesBlocked.count - 2, entitiesBlocked[0], entitiesBlocked[1]]
spec = BrowsingSpec.withMultipleTrackers.format(message: UserText.DaxOnboardingExperiment.ContextualOnboarding.daxDialogBrowsingWithMultipleTrackers, args: args)
spec = BrowsingSpec.withMultipleTrackers.format(message: UserText.Onboarding.ContextualOnboarding.daxDialogBrowsingWithMultipleTrackers, args: args)
}
return spec
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,22 @@ private extension AddressBarPosition {
var titleAndMessage: (title: NSAttributedString, message: String) {
switch self {
case .top:
let firstPart = NSAttributedString(string: UserText.OnboardingHighlights.AddressBarPosition.topTitle)
let firstPart = NSAttributedString(string: UserText.Onboarding.AddressBarPosition.topTitle)
.withFont(UIFont.daxBodyBold())
.withTextColor(UIColor.label)
let secondPart = NSAttributedString(string: UserText.OnboardingHighlights.AddressBarPosition.defaultOption)
let secondPart = NSAttributedString(string: UserText.Onboarding.AddressBarPosition.defaultOption)
.withFont(UIFont.daxBodyRegular())
.withTextColor(UIColor.secondaryLabel)

return (
firstPart + " " + secondPart,
UserText.OnboardingHighlights.AddressBarPosition.topMessage
UserText.Onboarding.AddressBarPosition.topMessage
)
case .bottom:
return (
NSAttributedString(string: UserText.OnboardingHighlights.AddressBarPosition.bottomTitle)
NSAttributedString(string: UserText.Onboarding.AddressBarPosition.bottomTitle)
.withFont(UIFont.daxBodyBold()),
UserText.OnboardingHighlights.AddressBarPosition.bottomMessage
UserText.Onboarding.AddressBarPosition.bottomMessage
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ extension BrowsersComparisonModel.PrivacyFeature {
var title: String {
switch self {
case .privateSearch:
UserText.DaxOnboardingExperiment.BrowsersComparison.Features.privateSearch
UserText.Onboarding.BrowsersComparison.Features.privateSearch
case .blockThirdPartyTrackers:
UserText.OnboardingHighlights.BrowsersComparison.Features.trackerBlockers
UserText.Onboarding.BrowsersComparison.Features.trackerBlockers
case .blockCookiePopups:
UserText.OnboardingHighlights.BrowsersComparison.Features.cookiePopups
UserText.Onboarding.BrowsersComparison.Features.cookiePopups
case .blockCreepyAds:
UserText.OnboardingHighlights.BrowsersComparison.Features.creepyAds
UserText.Onboarding.BrowsersComparison.Features.creepyAds
case .eraseBrowsingData:
UserText.OnboardingHighlights.BrowsersComparison.Features.eraseBrowsingData
UserText.Onboarding.BrowsersComparison.Features.eraseBrowsingData
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Onboarding
import DuckUI

struct OnboardingTrySearchDialog: View {
let title = UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASearchTitle
let title = UserText.Onboarding.ContextualOnboarding.onboardingTryASearchTitle
let message: String
let viewModel: OnboardingSearchSuggestionsViewModel

Expand Down Expand Up @@ -58,7 +58,7 @@ struct OnboardingTryVisitingSiteDialog: View {
}

struct OnboardingTryVisitingSiteDialogContent: View {
let message = NSAttributedString(string: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASiteMessage)
let message = NSAttributedString(string: UserText.Onboarding.ContextualOnboarding.onboardingTryASiteMessage)

let viewModel: OnboardingSiteSuggestionsViewModel

Expand All @@ -74,7 +74,7 @@ struct OnboardingTryVisitingSiteDialogContent: View {

struct OnboardingFireButtonDialogContent: View {
private let attributedMessage: NSAttributedString = {
let firstString = UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryFireButtonMessage
let firstString = UserText.Onboarding.ContextualOnboarding.onboardingTryFireButtonMessage
let boldString = "Fire Button."
let attributedString = NSMutableAttributedString(string: firstString)
let boldFontAttribute: [NSAttributedString.Key: Any] = [
Expand All @@ -95,7 +95,7 @@ struct OnboardingFireButtonDialogContent: View {
}

struct OnboardingFirstSearchDoneDialog: View {
let cta = UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingGotItButton
let cta = UserText.Onboarding.ContextualOnboarding.onboardingGotItButton
let message: NSAttributedString

@State private var showNextScreen: Bool = false
Expand Down Expand Up @@ -147,7 +147,7 @@ struct OnboardingFireDialog: View {
}

struct OnboardingTrackersDoneDialog: View {
let cta = UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingGotItButton
let cta = UserText.Onboarding.ContextualOnboarding.onboardingGotItButton

@State private var showNextScreen: Bool = false

Expand Down Expand Up @@ -202,7 +202,7 @@ struct OnboardingFinalDialog: View {
}
} else {
ContextualDaxDialogContent(
title: canShowAddToDockTutorial ? UserText.AddToDockOnboarding.Promo.title : UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingFinalScreenTitle,
title: canShowAddToDockTutorial ? UserText.AddToDockOnboarding.Promo.title : UserText.Onboarding.ContextualOnboarding.onboardingFinalScreenTitle,
titleFont: Font(UIFont.daxTitle3()),
message: NSAttributedString(string: message),
messageFont: Font.system(size: 16),
Expand Down Expand Up @@ -295,17 +295,17 @@ struct OnboardingAddToDockTutorialContent: View {
// MARK: - Preview

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

#Preview("Try Site Top") {
OnboardingTryVisitingSiteDialog(logoPosition: .top, viewModel: OnboardingSiteSuggestionsViewModel(title: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASiteTitle, suggestedSitesProvider: OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.DaxOnboardingExperiment.ContextualOnboarding.tryASearchOptionSurpriseMeTitle), pixelReporter: OnboardingPixelReporter()))
OnboardingTryVisitingSiteDialog(logoPosition: .top, viewModel: OnboardingSiteSuggestionsViewModel(title: UserText.Onboarding.ContextualOnboarding.onboardingTryASiteTitle, suggestedSitesProvider: OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.Onboarding.ContextualOnboarding.tryASearchOptionSurpriseMeTitle), pixelReporter: OnboardingPixelReporter()))
.padding()
}

#Preview("Try Site Left") {
OnboardingTryVisitingSiteDialog(logoPosition: .left, viewModel: OnboardingSiteSuggestionsViewModel(title: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASiteTitle, suggestedSitesProvider: OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.DaxOnboardingExperiment.ContextualOnboarding.tryASearchOptionSurpriseMeTitle), pixelReporter: OnboardingPixelReporter()))
OnboardingTryVisitingSiteDialog(logoPosition: .left, viewModel: OnboardingSiteSuggestionsViewModel(title: UserText.Onboarding.ContextualOnboarding.onboardingTryASiteTitle, suggestedSitesProvider: OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.Onboarding.ContextualOnboarding.tryASearchOptionSurpriseMeTitle), pixelReporter: OnboardingPixelReporter()))
.padding()
}

Expand All @@ -318,20 +318,20 @@ struct OnboardingAddToDockTutorialContent: View {

#Preview("First Search Dialog") {
let attributedMessage = {
let message = UserText.OnboardingHighlights.ContextualOnboarding.onboardingFirstSearchDoneMessage
let message = UserText.Onboarding.ContextualOnboarding.onboardingFirstSearchDoneMessage
let boldRange = message.range(of: "DuckDuckGo Search")
return message.attributed.with(attribute: .font, value: UIFont.daxBodyBold(), in: boldRange)
}()

return OnboardingFirstSearchDoneDialog(message: attributedMessage, shouldFollowUp: true, viewModel: OnboardingSiteSuggestionsViewModel(title: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASiteTitle, suggestedSitesProvider: OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.DaxOnboardingExperiment.ContextualOnboarding.tryASearchOptionSurpriseMeTitle), pixelReporter: OnboardingPixelReporter()), gotItAction: {})
return OnboardingFirstSearchDoneDialog(message: attributedMessage, shouldFollowUp: true, viewModel: OnboardingSiteSuggestionsViewModel(title: UserText.Onboarding.ContextualOnboarding.onboardingTryASiteTitle, suggestedSitesProvider: OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.Onboarding.ContextualOnboarding.tryASearchOptionSurpriseMeTitle), pixelReporter: OnboardingPixelReporter()), gotItAction: {})
.padding()
}

#Preview("Final Dialog - No Add to Dock Tutorial") {
OnboardingFinalDialog(
logoPosition: .top,
message: UserText.OnboardingHighlights.ContextualOnboarding.onboardingFinalScreenMessage,
cta: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingFinalScreenButton,
message: UserText.Onboarding.ContextualOnboarding.onboardingFinalScreenMessage,
cta: UserText.Onboarding.ContextualOnboarding.onboardingFinalScreenButton,
canShowAddToDockTutorial: false,
showAddToDockTutorialAction: {},
dismissAction: { _ in }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ final class NewTabDaxDialogFactory: NewTabDaxDialogProvider {

private func createInitialDialog() -> some View {
let viewModel = OnboardingSearchSuggestionsViewModel(suggestedSearchesProvider: OnboardingSuggestedSearchesProvider(), delegate: delegate, pixelReporter: onboardingPixelReporter)
let message = UserText.OnboardingHighlights.ContextualOnboarding.onboardingTryASearchMessage
let message = UserText.Onboarding.ContextualOnboarding.onboardingTryASearchMessage
return FadeInView {
OnboardingTrySearchDialog(message: message, viewModel: viewModel)
.onboardingDaxDialogStyle()
Expand All @@ -74,7 +74,7 @@ final class NewTabDaxDialogFactory: NewTabDaxDialogProvider {
}

private func createSubsequentDialog() -> some View {
let viewModel = OnboardingSiteSuggestionsViewModel(title: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASiteNTPTitle, suggestedSitesProvider: OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.DaxOnboardingExperiment.ContextualOnboarding.tryASearchOptionSurpriseMeTitle), delegate: delegate, pixelReporter: onboardingPixelReporter)
let viewModel = OnboardingSiteSuggestionsViewModel(title: UserText.Onboarding.ContextualOnboarding.onboardingTryASiteNTPTitle, suggestedSitesProvider: OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.Onboarding.ContextualOnboarding.tryASearchOptionSurpriseMeTitle), delegate: delegate, pixelReporter: onboardingPixelReporter)
return FadeInView {
OnboardingTryVisitingSiteDialog(logoPosition: .top, viewModel: viewModel)
.onboardingDaxDialogStyle()
Expand Down Expand Up @@ -104,8 +104,8 @@ final class NewTabDaxDialogFactory: NewTabDaxDialogProvider {
(UserText.AddToDockOnboarding.Promo.contextualMessage, UserText.AddToDockOnboarding.Buttons.startBrowsing)
} else {
(
UserText.OnboardingHighlights.ContextualOnboarding.onboardingFinalScreenMessage,
UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingFinalScreenButton
UserText.Onboarding.ContextualOnboarding.onboardingFinalScreenMessage,
UserText.Onboarding.ContextualOnboarding.onboardingFinalScreenButton
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class ExperimentContextualDaxDialogsFactory: ContextualDaxDialogsFactory {
contextualOnboardingLogic: ContextualOnboardingLogic,
contextualOnboardingSettings: ContextualOnboardingSettings = DefaultDaxDialogsSettings(),
contextualOnboardingPixelReporter: OnboardingPixelReporting,
contextualOnboardingSiteSuggestionsProvider: OnboardingSuggestionsItemsProviding = OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.DaxOnboardingExperiment.ContextualOnboarding.tryASearchOptionSurpriseMeTitle),
contextualOnboardingSiteSuggestionsProvider: OnboardingSuggestionsItemsProviding = OnboardingSuggestedSitesProvider(surpriseItemTitle: UserText.Onboarding.ContextualOnboarding.tryASearchOptionSurpriseMeTitle),
onboardingManager: OnboardingAddToDockManaging = OnboardingManager()
) {
self.contextualOnboardingSettings = contextualOnboardingSettings
Expand Down Expand Up @@ -112,12 +112,12 @@ final class ExperimentContextualDaxDialogsFactory: ContextualDaxDialogsFactory {
) -> some View {

func dialogMessage() -> NSAttributedString {
let message = UserText.OnboardingHighlights.ContextualOnboarding.onboardingFirstSearchDoneMessage
let message = UserText.Onboarding.ContextualOnboarding.onboardingFirstSearchDoneMessage
let boldRange = message.range(of: "DuckDuckGo Search")
return message.attributed.with(attribute: .font, value: UIFont.daxBodyBold(), in: boldRange)
}

let viewModel = OnboardingSiteSuggestionsViewModel(title: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASiteTitle, suggestedSitesProvider: contextualOnboardingSiteSuggestionsProvider, delegate: delegate, pixelReporter: contextualOnboardingPixelReporter)
let viewModel = OnboardingSiteSuggestionsViewModel(title: UserText.Onboarding.ContextualOnboarding.onboardingTryASiteTitle, suggestedSitesProvider: contextualOnboardingSiteSuggestionsProvider, delegate: delegate, pixelReporter: contextualOnboardingPixelReporter)

// If should not show websites search after searching inform the delegate that the user dimissed the dialog, otherwise let the dialog handle it.
let gotItAction: () -> Void = if shouldFollowUpToWebsiteSearch {
Expand All @@ -139,7 +139,7 @@ final class ExperimentContextualDaxDialogsFactory: ContextualDaxDialogsFactory {
}

private func tryVisitingSiteDialog(delegate: ContextualOnboardingDelegate) -> some View {
let viewModel = OnboardingSiteSuggestionsViewModel(title: UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingTryASiteTitle, suggestedSitesProvider: contextualOnboardingSiteSuggestionsProvider, delegate: delegate, pixelReporter: contextualOnboardingPixelReporter)
let viewModel = OnboardingSiteSuggestionsViewModel(title: UserText.Onboarding.ContextualOnboarding.onboardingTryASiteTitle, suggestedSitesProvider: contextualOnboardingSiteSuggestionsProvider, delegate: delegate, pixelReporter: contextualOnboardingPixelReporter)
return OnboardingTryVisitingSiteDialog(logoPosition: .left, viewModel: viewModel)
.onFirstAppear { [weak self] in
self?.contextualOnboardingPixelReporter.trackScreenImpression(event: .onboardingContextualTryVisitSiteUnique)
Expand Down Expand Up @@ -180,8 +180,8 @@ final class ExperimentContextualDaxDialogsFactory: ContextualDaxDialogsFactory {
(UserText.AddToDockOnboarding.Promo.contextualMessage, UserText.AddToDockOnboarding.Buttons.startBrowsing)
} else {
(
UserText.OnboardingHighlights.ContextualOnboarding.onboardingFinalScreenMessage,
UserText.DaxOnboardingExperiment.ContextualOnboarding.onboardingFinalScreenButton
UserText.Onboarding.ContextualOnboarding.onboardingFinalScreenMessage,
UserText.Onboarding.ContextualOnboarding.onboardingFinalScreenButton
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ extension OnboardingIntroViewModel {
extension OnboardingIntroViewModel.Copy {

static let `default` = OnboardingIntroViewModel.Copy(
introTitle: UserText.OnboardingHighlights.Intro.title,
browserComparisonTitle: UserText.OnboardingHighlights.BrowsersComparison.title,
trackerBlockers: UserText.OnboardingHighlights.BrowsersComparison.Features.trackerBlockers,
cookiePopups: UserText.OnboardingHighlights.BrowsersComparison.Features.cookiePopups,
creepyAds: UserText.OnboardingHighlights.BrowsersComparison.Features.creepyAds,
eraseBrowsingData: UserText.OnboardingHighlights.BrowsersComparison.Features.eraseBrowsingData
introTitle: UserText.Onboarding.Intro.title,
browserComparisonTitle: UserText.Onboarding.BrowsersComparison.title,
trackerBlockers: UserText.Onboarding.BrowsersComparison.Features.trackerBlockers,
cookiePopups: UserText.Onboarding.BrowsersComparison.Features.cookiePopups,
creepyAds: UserText.Onboarding.BrowsersComparison.Features.creepyAds,
eraseBrowsingData: UserText.Onboarding.BrowsersComparison.Features.eraseBrowsingData
)

}
Loading

0 comments on commit 678acbb

Please sign in to comment.