Skip to content

Commit 2090de9

Browse files
authored
Merge branch 'main' into main
2 parents 1443cb8 + 5c6eef7 commit 2090de9

File tree

103 files changed

+1817
-1653
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+1817
-1653
lines changed

WMF Framework/CommonStrings.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,11 @@ public class CommonStrings: NSObject {
647647
public static let joinLoginTitle = WMFLocalizedString("profile-page-join-title", value: "Log in / Join Wikipedia", comment: "Link to sign up or sign in")
648648

649649
public static let noThanksTitle = WMFLocalizedString("variants-alert-dismiss-button", value: "No thanks", comment: "Dismiss button on alert used to inform users about variant support.")
650+
public static let continueWithoutLoggingIn = WMFLocalizedString("ip-account-cta-bottom", value: "Continue without logging in", comment: "Continue without logging in button title")
650651

651652
public static let notNowTitle = WMFLocalizedString("not-now-title", value: "Not now", comment: "Text for the dismiss button across various features.")
653+
654+
public static let youCanAccessYIR = WMFLocalizedString("year-in-review-intro-exit-toast-title", value: "You can access your Year in Review later in Profile.", comment: "Toast displayed to user after the exit Year in Review on the intro slide.")
652655

653656
// Donation history
654657

WMFComponents/Sources/WMFComponents/Base/Component Base Classes/WMFComponentNavigationController.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@ open class WMFComponentNavigationController: UINavigationController {
1717
return WMFAppEnvironment.current.theme
1818
}
1919

20+
private let customBarBackgroundColor: UIColor?
21+
2022
var forcePortrait = false
2123

2224
// MARK: - Public
2325

24-
@objc public convenience init(rootViewController: UIViewController, modalPresentationStyle: UIModalPresentationStyle) {
25-
self.init(rootViewController: rootViewController)
26-
self.modalPresentationStyle = modalPresentationStyle
27-
}
28-
29-
public override init(rootViewController: UIViewController) {
26+
@objc public init(rootViewController: UIViewController, modalPresentationStyle: UIModalPresentationStyle, customBarBackgroundColor: UIColor? = nil) {
27+
self.customBarBackgroundColor = customBarBackgroundColor
3028
super.init(rootViewController: rootViewController)
29+
self.modalPresentationStyle = modalPresentationStyle
3130
subscribeToAppEnvironmentChanges()
3231
setup()
3332
}
@@ -87,7 +86,11 @@ open class WMFComponentNavigationController: UINavigationController {
8786
let barAppearance = UINavigationBarAppearance()
8887
barAppearance.configureWithOpaqueBackground()
8988

90-
if modalPresentationStyle == .pageSheet {
89+
if let customBarBackgroundColor {
90+
barAppearance.backgroundColor = customBarBackgroundColor
91+
let backgroundImage = UIImage.roundedRectImage(with: customBarBackgroundColor, cornerRadius: 1)
92+
barAppearance.backgroundImage = backgroundImage
93+
} else if modalPresentationStyle == .pageSheet {
9194
barAppearance.backgroundColor = theme.midBackground
9295
let backgroundImage = UIImage.roundedRectImage(with: theme.midBackground, cornerRadius: 1)
9396
barAppearance.backgroundImage = backgroundImage

WMFComponents/Sources/WMFComponents/Components/Article Tabs/WMFArticleTabsHostingController.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class WMFArticleTabsHostingController<HostedView: View>: WMFComponentHost
6666
}
6767

6868
@objc func tappedDone() {
69-
dismiss(animated: true, completion: nil)
69+
viewModel.didTapDone()
7070
}
7171

7272
@objc private func tappedAdd() {
@@ -85,6 +85,7 @@ public class WMFArticleTabsHostingController<HostedView: View>: WMFComponentHost
8585
handler: { [weak self] _ in
8686
Task {
8787
await self?.presentCloseAllTabsConfirmationDialog()
88+
self?.viewModel.loggingDelegate?.logArticleTabsOverviewTappedCloseAllTabs()
8889
}
8990
})
9091

@@ -94,6 +95,7 @@ public class WMFArticleTabsHostingController<HostedView: View>: WMFComponentHost
9495
self.overflowButton.menu = self.overflowMenu
9596
viewModel.didToggleSuggestedArticles()
9697
viewModel.refreshShouldShowSuggestionsFromDataController()
98+
viewModel.loggingDelegate?.logArticleTabsOverviewTappedHideSuggestions()
9799
})
98100

99101
let showArticleSuggestions = UIAction(title: viewModel.localizedStrings.showSuggestedArticlesTitle, image: WMFSFSymbolIcon.for(symbol: .eye), handler: { [weak self] _ in
@@ -102,6 +104,7 @@ public class WMFArticleTabsHostingController<HostedView: View>: WMFComponentHost
102104
self.overflowButton.menu = self.overflowMenu
103105
viewModel.didToggleSuggestedArticles()
104106
viewModel.refreshShouldShowSuggestionsFromDataController()
107+
viewModel.loggingDelegate?.logArticleTabsOverviewTappedShowSuggestions()
105108
})
106109

107110
var children: [UIMenuElement]
@@ -135,12 +138,15 @@ public class WMFArticleTabsHostingController<HostedView: View>: WMFComponentHost
135138
preferredStyle: .alert
136139
)
137140

138-
let action1 = UIAlertAction(title: button1Title, style: .cancel)
141+
let action1 = UIAlertAction(title: button1Title, style: .cancel, handler: { [weak self] _ in
142+
self?.viewModel.loggingDelegate?.logArticleTabsOverviewTappedCloseAllTabsConfirmCancel()
143+
})
139144

140145
let action2 = UIAlertAction(title: button2Title, style: .destructive) { [weak self] _ in
141146
guard let self else { return }
142147
Task {
143148
self.viewModel.didTapCloseAllTabs()
149+
self.viewModel.loggingDelegate?.logArticleTabsOverviewTappedCloseAllTabsConfirmClose()
144150
}
145151
}
146152

WMFComponents/Sources/WMFComponents/Components/Article Tabs/WMFArticleTabsView.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ public struct WMFArticleTabsView: View {
2121
@State private var isReady: Bool = false
2222
@State private var cellFrames: [String: CGRect] = [:]
2323

24-
private var dykLinkDelegate: UITextViewDelegate?
25-
26-
public init(viewModel: WMFArticleTabsViewModel, dykLinkDelegate: UITextViewDelegate?) {
24+
public init(viewModel: WMFArticleTabsViewModel) {
2725
self.viewModel = viewModel
28-
self.dykLinkDelegate = dykLinkDelegate
2926
}
3027

3128
public var body: some View {

WMFComponents/Sources/WMFComponents/Components/Article Tabs/WMFArticleTabsViewModel.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ import WMFData
66
public protocol WMFArticleTabsLoggingDelegate: AnyObject {
77
func logArticleTabsOverviewImpression()
88
func logArticleTabsArticleClick(wmfProject: WMFProject?)
9+
func logArticleTabsOverviewTappedDone()
10+
func logArticleTabsOverviewTappedCloseTab()
11+
func logArticleTabsOverviewTappedHideSuggestions()
12+
func logArticleTabsOverviewTappedShowSuggestions()
13+
func logArticleTabsOverviewTappedCloseAllTabs()
14+
func logArticleTabsOverviewTappedCloseAllTabsConfirmCancel()
15+
func logArticleTabsOverviewTappedCloseAllTabsConfirmClose()
916
}
1017

1118
public class WMFArticleTabsViewModel: NSObject, ObservableObject {
@@ -41,6 +48,7 @@ public class WMFArticleTabsViewModel: NSObject, ObservableObject {
4148
public let didTapTab: (WMFArticleTabsDataController.WMFArticleTab) -> Void
4249
public let didTapAddTab: () -> Void
4350
public let didTapShareTab: (WMFArticleTabsDataController.WMFArticleTab, CGRect?) -> Void
51+
public let didTapDone: () -> Void
4452
public let didToggleSuggestedArticles: () -> Void
4553

4654
public let localizedStrings: LocalizedStrings
@@ -51,6 +59,7 @@ public class WMFArticleTabsViewModel: NSObject, ObservableObject {
5159
didTapTab: @escaping (WMFArticleTabsDataController.WMFArticleTab) -> Void,
5260
didTapAddTab: @escaping () -> Void,
5361
didTapShareTab: @escaping (WMFArticleTabsDataController.WMFArticleTab, CGRect?) -> Void,
62+
didTapDone: @escaping () -> Void,
5463
didToggleSuggestedArticles: @escaping () -> Void) {
5564
self.dataController = dataController
5665
self.localizedStrings = localizedStrings
@@ -61,6 +70,7 @@ public class WMFArticleTabsViewModel: NSObject, ObservableObject {
6170
self.didTapTab = didTapTab
6271
self.didTapAddTab = didTapAddTab
6372
self.didTapShareTab = didTapShareTab
73+
self.didTapDone = didTapDone
6474
self.didToggleSuggestedArticles = didToggleSuggestedArticles
6575
super.init()
6676
Task {
@@ -276,12 +286,14 @@ public class WMFArticleTabsViewModel: NSObject, ObservableObject {
276286
}
277287

278288
func closeTab(tab: ArticleTab) {
289+
279290
Task {
280291
do {
281292
try await dataController.deleteArticleTab(identifier: tab.data.identifier)
282293

283294
Task { @MainActor [weak self] in
284295
guard let self else { return }
296+
loggingDelegate?.logArticleTabsOverviewTappedCloseTab()
285297
articleTabs.removeAll { $0 == tab }
286298
updateHasMultipleTabs()
287299
maybeStartSecondaryLoads()

WMFComponents/Sources/WMFComponents/Components/Profile/WMFProfileViewModel.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ enum ProfileState {
112112

113113
var needsYiRNotification = false
114114
if let yearInReviewDependencies {
115-
needsYiRNotification = yearInReviewDependencies.dataController.shouldShowYiRNotification(primaryAppLanguageProject: yearInReviewDependencies.primaryAppLanguageProject, isLoggedOut: !isLoggedIn, isTemporaryAccount: isTemporaryAccount)
115+
needsYiRNotification = yearInReviewDependencies.dataController.shouldShowYiRNotification(isLoggedOut: !isLoggedIn, isTemporaryAccount: isTemporaryAccount)
116116
}
117117

118118
if isLoggedIn {
@@ -202,7 +202,7 @@ enum ProfileState {
202202

203203
var section3Items = [donateItem]
204204
if let yearInReviewDependencies,
205-
yearInReviewDependencies.dataController.shouldShowYearInReviewEntryPoint(countryCode: yearInReviewDependencies.countryCode, primaryAppLanguageProject: yearInReviewDependencies.primaryAppLanguageProject) {
205+
yearInReviewDependencies.dataController.shouldShowYearInReviewEntryPoint(countryCode: yearInReviewDependencies.countryCode) {
206206
section3Items = [donateItem, yearInReviewItem]
207207
}
208208

@@ -418,7 +418,7 @@ enum ProfileState {
418418

419419
var sections = [joinSection, donateSection, settingsSection]
420420
if let yearInReviewDependencies,
421-
yearInReviewDependencies.dataController.shouldShowYearInReviewEntryPoint(countryCode: yearInReviewDependencies.countryCode, primaryAppLanguageProject: yearInReviewDependencies.primaryAppLanguageProject) {
421+
yearInReviewDependencies.dataController.shouldShowYearInReviewEntryPoint(countryCode: yearInReviewDependencies.countryCode) {
422422
sections = [joinSection, donateSection, yearInReviewSection, settingsSection]
423423
}
424424

0 commit comments

Comments
 (0)