Skip to content

Commit

Permalink
[DuckPlayer] 27. Contextual Two-word copy update (#3289)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/38424471409662/1208090252125289/f
Tech Design URL:
CC:

Description:
This PR changes two words on the DuckPlayer modal (yes).
  • Loading branch information
afterxleep authored Aug 30, 2024
1 parent a781648 commit 137dd1e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
14 changes: 11 additions & 3 deletions DuckDuckGo/DuckPlayer/DuckPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ final class DuckPlayer: DuckPlayerProtocol {
static let translationFileExtension = "json"
static let defaultLocale = "en"
static let translationPath = "pages/duckplayer/locales/"
static let featureNameKey = "featureName"
}

private(set) var settings: DuckPlayerSettingsProtocol
Expand Down Expand Up @@ -197,13 +198,20 @@ final class DuckPlayer: DuckPlayerProtocol {
}

@MainActor
public func presentDuckPlayerInfo() {
public func presentDuckPlayerInfo(context: DuckPlayerModalPresenter.PresentationContext) {
guard let hostView else { return }
DuckPlayerModalPresenter().presentDuckPlayerFeatureModal(on: hostView)
DuckPlayerModalPresenter(context: context).presentDuckPlayerFeatureModal(on: hostView)
}

@MainActor
public func openDuckPlayerInfo(params: Any, message: WKScriptMessage) async -> Encodable? {
await presentDuckPlayerInfo()
guard let body = message.body as? [String: Any],
let featureNameString = body[Constants.featureNameKey] as? String,
let featureName = FeatureName(rawValue: featureNameString) else {
return nil
}
let context: DuckPlayerModalPresenter.PresentationContext = featureName == .page ? .youtube : .SERP
presentDuckPlayerInfo(context: context)
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct DuckPlayerFeaturePresentationView: View {
@Environment(\.horizontalSizeClass) var horizontalSizeClass
@Environment(\.verticalSizeClass) var verticalSizeClass
@State private var isAnimating: Bool = false
@State var context: DuckPlayerModalPresenter.PresentationContext
var dismisPresentation: (() -> Void)?

var body: some View {
Expand All @@ -34,12 +35,14 @@ struct DuckPlayerFeaturePresentationView: View {
VStack(alignment: .center, spacing: stackVerticalSpacing) {
animation

Text(UserText.duckPlayerPresentationModalTitle)
Text(context == .SERP
? UserText.duckPlayerPresentationModalTitle
: UserText.duckPlayerPresentationModalTitleYouTube)
.daxTitle2()
.multilineTextAlignment(.center)
.foregroundColor(Color(designSystemColor: .textPrimary))
.minimumScaleFactor(Constants.textMinimumScaleFactor)

Text(UserText.duckPlayerPresentationModalBody)
.daxBodyRegular()
.multilineTextAlignment(.center)
Expand Down Expand Up @@ -118,5 +121,5 @@ extension DuckPlayerFeaturePresentationView {
}

#Preview {
DuckPlayerFeaturePresentationView()
DuckPlayerFeaturePresentationView(context: .SERP)
}
10 changes: 8 additions & 2 deletions DuckDuckGo/DuckPlayer/Modal/DuckPlayerModalPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ import SwiftUI

struct DuckPlayerModalPresenter {

enum PresentationContext {
case SERP, youtube
}

var context: PresentationContext = .SERP

func presentDuckPlayerFeatureModal(on viewController: UIViewController) {
let hostingController = createHostingController()
configurePresentationStyle(for: hostingController, on: viewController)
Expand All @@ -34,7 +40,7 @@ struct DuckPlayerModalPresenter {
}

private func createHostingController() -> UIHostingController<DuckPlayerFeaturePresentationView> {
let duckPlayerFeaturePresentationView = DuckPlayerFeaturePresentationView()
let duckPlayerFeaturePresentationView = DuckPlayerFeaturePresentationView(context: context)
let hostingController = UIHostingController(rootView: duckPlayerFeaturePresentationView)
hostingController.modalPresentationStyle = .pageSheet
hostingController.modalTransitionStyle = .coverVertical
Expand All @@ -56,7 +62,7 @@ struct DuckPlayerModalPresenter {

@available(iOS 16.0, *)
private func getTargetSizeForPresentationView(on viewController: UIViewController) -> CGSize {
let duckPlayerFeaturePresentationView = DuckPlayerFeaturePresentationView()
let duckPlayerFeaturePresentationView = DuckPlayerFeaturePresentationView(context: context)
let sizeHostingController = UIHostingController(rootView: duckPlayerFeaturePresentationView)
sizeHostingController.view.translatesAutoresizingMaskIntoConstraints = false

Expand Down
3 changes: 2 additions & 1 deletion DuckDuckGo/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,8 @@ But if you *do* want a peek under the hood, you can find more information about
public static let settingsDuckPlayerLearnMore = NSLocalizedString("duckplayer.settings.learn-more", value: "Learn More", comment: "Button that takes the user to learn more about Duck Player.")
public static let settingsDuckPlayerInfoText = NSLocalizedString("duckplayer.settings.info-text", value: "Duck Player lets you watch YouTube without targeted ads in DuckDuckGo and what you watch won’t influence your recommendations.", comment: "Text explaining what Duck Player is in the settings screen.")

public static let duckPlayerPresentationModalTitle = NSLocalizedString("duckplayer.presentation.modal.title", value: "Drowning in ads on YouTube? Not with Duck Player!", comment: "Two line title (separated by \n) for the feature explanation")
public static let duckPlayerPresentationModalTitle = NSLocalizedString("duckplayer.presentation.modal.title", value: "Drowning in ads on YouTube? Try Duck Player!", comment: "Two line title (separated by \n) for the feature explanation")
public static let duckPlayerPresentationModalTitleYouTube = NSLocalizedString("duckplayer.presentation.modal.title.youtube", value: "Drowning in ads on YouTube? Not with Duck Player!", comment: "Two line title (separated by \n) for the feature explanation")
public static let duckPlayerPresentationModalBody = NSLocalizedString("duckplayer.presentation.modal.body", value: "Duck Player lets you watch YouTube without targeted ads in DuckDuckGo and what you watch won’t influence your recommendations.", comment: "Body text for the modal feature explanation")
public static let duckPlayerPresentationModalDismissButton = NSLocalizedString("duckplayer.presentation.modal.dismiss-button", value: "Got it!", comment: "Button that will dismiss the modal")

Expand Down
5 changes: 4 additions & 1 deletion DuckDuckGo/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,10 @@
"duckplayer.presentation.modal.dismiss-button" = "Got it!";

/* Two line title (separated by \n) for the feature explanation */
"duckplayer.presentation.modal.title" = "Drowning in ads on YouTube? Not with Duck Player!";
"duckplayer.presentation.modal.title" = "Drowning in ads on YouTube? Try Duck Player!";

/* Two line title (separated by \n) for the feature explanation */
"duckplayer.presentation.modal.title.youtube" = "Drowning in ads on YouTube? Not with Duck Player!";

/* Footer label in the settings screen for Duck Player */
"duckplayer.settings.footer" = "DuckDuckGo provides all the privacy essentials you need to protect yourself as you browse the web.";
Expand Down

0 comments on commit 137dd1e

Please sign in to comment.