Skip to content

Commit

Permalink
Merge branch 'main' into twn
Browse files Browse the repository at this point in the history
  • Loading branch information
tonisevener authored Nov 6, 2024
2 parents c3d531b + b07b1a1 commit 2c37e6e
Show file tree
Hide file tree
Showing 12 changed files with 561 additions and 70 deletions.
8 changes: 4 additions & 4 deletions WMF Framework/CommonStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -763,13 +763,13 @@ public class CommonStrings: NSObject {

// Donation history

public static let deleteDonationHistory = WMFLocalizedString("donate-history-delete", value: "Delete local donation history", comment: "Text for delete locally saved donation history button")
@objc public static let deleteDonationHistory = WMFLocalizedString("donate-history-delete", value: "Delete local donation history", comment: "Text for delete locally saved donation history button")

public static let confirmDeletionTitle = WMFLocalizedString("confirm-donation-history-deletion-title", value: "Confirm deletion", comment: "Title for confirm local donation history deletion alert")
@objc public static let confirmDeletionTitle = WMFLocalizedString("confirm-donation-history-deletion-title", value: "Confirm deletion", comment: "Title for confirm local donation history deletion alert")

public static let confirmDeletionSubitle = WMFLocalizedString("confirm-donation-history-deletion-subtitle", value: "This will only apply to donations made from this device.", comment: "Subtitle for confirm local donation history deletion alert")
@objc public static let confirmDeletionSubtitle = WMFLocalizedString("confirm-donation-history-deletion-subtitle", value: "This will only apply to donations made from this device.", comment: "Subtitle for confirm local donation history deletion alert")

public static let confirmedDeletion = WMFLocalizedString("confirmed-donation-history-deletion", value: "Local history deleted", comment: "Title for confirming deletion of locally saved donations alert")
@objc public static let confirmedDeletion = WMFLocalizedString("confirmed-donation-history-deletion", value: "Local history deleted", comment: "Title for confirming deletion of locally saved donations alert")

// Year In Review

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "illustration (2).svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public struct WMFYearInReviewView: View {
scrollViewContents: scrollViewContent,
contents: { AnyView(buttons) },
imageName: "intro",
imageOverlay: "globe")
.frame(maxWidth: .infinity, maxHeight: .infinity)
.padding(.top, 48)
.onAppear {
viewModel.logYearInReviewSlideDidAppear()
}
imageOverlay: "globe_yir")
.frame(maxWidth: .infinity, maxHeight: .infinity)
.padding(.top, 48)
.onAppear {
viewModel.logYearInReviewSlideDidAppear()
}
} else {
VStack {
TabView(selection: $viewModel.currentSlide) {
Expand Down Expand Up @@ -150,3 +150,4 @@ public struct WMFYearInReviewView: View {
}
}
}

8 changes: 8 additions & 0 deletions Wikipedia.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,9 @@
832289DB1F7291BA0081A5FB /* SizeThatFitsReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 832289DA1F7291BA0081A5FB /* SizeThatFitsReusableView.swift */; };
832289DC1F7291BA0081A5FB /* SizeThatFitsReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 832289DA1F7291BA0081A5FB /* SizeThatFitsReusableView.swift */; };
832289DD1F7291BA0081A5FB /* SizeThatFitsReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 832289DA1F7291BA0081A5FB /* SizeThatFitsReusableView.swift */; };
83250BEC2CDA7CED00DA42DC /* WMFDonateDataControllerWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83250BEB2CDA7CEC00DA42DC /* WMFDonateDataControllerWrapper.swift */; };
83250BED2CDA7CED00DA42DC /* WMFDonateDataControllerWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83250BEB2CDA7CEC00DA42DC /* WMFDonateDataControllerWrapper.swift */; };
83250BEE2CDA7CED00DA42DC /* WMFDonateDataControllerWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83250BEB2CDA7CEC00DA42DC /* WMFDonateDataControllerWrapper.swift */; };
832A7A5B23EA138C00D0A750 /* ArticleViewController+References.swift in Sources */ = {isa = PBXBuildFile; fileRef = 832A7A5A23EA138C00D0A750 /* ArticleViewController+References.swift */; };
832A7A5C23EA138C00D0A750 /* ArticleViewController+References.swift in Sources */ = {isa = PBXBuildFile; fileRef = 832A7A5A23EA138C00D0A750 /* ArticleViewController+References.swift */; };
832A7A5D23EA138C00D0A750 /* ArticleViewController+References.swift in Sources */ = {isa = PBXBuildFile; fileRef = 832A7A5A23EA138C00D0A750 /* ArticleViewController+References.swift */; };
Expand Down Expand Up @@ -3719,6 +3722,7 @@
83222DAF1F8E554800338BE5 /* WMFContent+CoreDataClass.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "WMFContent+CoreDataClass.m"; sourceTree = "<group>"; };
83222DB01F8E554800338BE5 /* WMFContent+CoreDataProperties.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "WMFContent+CoreDataProperties.m"; sourceTree = "<group>"; };
832289DA1F7291BA0081A5FB /* SizeThatFitsReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SizeThatFitsReusableView.swift; sourceTree = "<group>"; };
83250BEB2CDA7CEC00DA42DC /* WMFDonateDataControllerWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMFDonateDataControllerWrapper.swift; sourceTree = "<group>"; };
832A7A5A23EA138C00D0A750 /* ArticleViewController+References.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ArticleViewController+References.swift"; sourceTree = "<group>"; };
832A7A5F23EAE03200D0A750 /* String+JavaScript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+JavaScript.swift"; sourceTree = "<group>"; };
832B2B8323D9F9420087EB5F /* NSRegularExpression+Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSRegularExpression+Utilities.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -7563,6 +7567,7 @@
BC45D5871C32F849007C72F3 /* Settings */ = {
isa = PBXGroup;
children = (
83250BEB2CDA7CEC00DA42DC /* WMFDonateDataControllerWrapper.swift */,
7A0DE4F120CEEBE40032AB57 /* Explore Feed */,
BAFCE8401F1D7F8A0077D5E9 /* Appearance */,
D84BF6281DB96D4700E0C85E /* Notifications */,
Expand Down Expand Up @@ -10337,6 +10342,7 @@
B0E8036D1C0CD98B0065EBC0 /* TableOfContentsViewController.swift in Sources */,
7A9F2776225E3462002119B3 /* InsertMediaSearchResultsCollectionViewController.swift in Sources */,
0036C8B3282C2AAA00EADB35 /* Notification+NotificationsCenter.swift in Sources */,
83250BEE2CDA7CED00DA42DC /* WMFDonateDataControllerWrapper.swift in Sources */,
B0DF6F811CFE1D0B0046E507 /* WKWebView+WMFWebViewControllerJavascript.m in Sources */,
0EC044791C7917860033D773 /* WMFArticleTextActivitySource.m in Sources */,
83AE025C299D9CDD00C45F73 /* SearchFunnel.swift in Sources */,
Expand Down Expand Up @@ -11293,6 +11299,7 @@
B0524B70214854E900D8FD8D /* DescriptionWelcomeContentsViewController.swift in Sources */,
7A2FE55D20517BAE00F92F8F /* EraseSavedArticlesView.swift in Sources */,
6730FD1028998EFD000E5F40 /* TalkPageReplyComposeContentView.swift in Sources */,
83250BED2CDA7CED00DA42DC /* WMFDonateDataControllerWrapper.swift in Sources */,
D8CE256D1E698E2400DAE2E0 /* UIViewController+WMFHideKeyboard.swift in Sources */,
673C55CD2ACC684E00E2EBF6 /* DonateFunnel.swift in Sources */,
BA4524191F324C3100439C42 /* FontSizeSliderViewController.swift in Sources */,
Expand Down Expand Up @@ -11867,6 +11874,7 @@
7A393283236CBDD500A89C2F /* PageHistoryComparisonSelectionViewController.swift in Sources */,
7A9524CD22665E6400C55CDC /* InsertMediaSettingsImageView.swift in Sources */,
B0524B71214854E900D8FD8D /* DescriptionWelcomeContentsViewController.swift in Sources */,
83250BEC2CDA7CED00DA42DC /* WMFDonateDataControllerWrapper.swift in Sources */,
6730FD0F28998EFD000E5F40 /* TalkPageReplyComposeContentView.swift in Sources */,
D8EC3E5D1E9BDA35006712EB /* AboutViewController.m in Sources */,
673C55CC2ACC684E00E2EBF6 /* DonateFunnel.swift in Sources */,
Expand Down
49 changes: 1 addition & 48 deletions Wikipedia/Code/AccountViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ protocol AccountViewControllerDelegate: AnyObject {
private enum ItemType {
case talkPageAutoSignDiscussions
case vanishAccount
case donationHistory
case informational
}

Expand Down Expand Up @@ -57,15 +56,6 @@ class AccountViewController: SubSettingsViewController {
type: .informational
)

let donationHistory = Item(
title: CommonStrings.deleteDonationHistory,
subtitle: nil,
iconName: "settings-support",
iconColor: .white,
iconBackgroundColor: WMFColor.gray400,
type: .donationHistory
)

let vanishAccount = Item(
title: CommonStrings.vanishAccount,
subtitle: nil,
Expand All @@ -75,15 +65,8 @@ class AccountViewController: SubSettingsViewController {
type: .vanishAccount
)

let sectionItems: [Item]
if donateDataController.hasLocallySavedDonations {
sectionItems = [userName, donationHistory, vanishAccount]
} else {
sectionItems = [userName, vanishAccount]
}

let account = Section(
items: sectionItems,
items: [userName, vanishAccount],
headerTitle: WMFLocalizedString("account-group-title", value: "Your Account", comment: "Title for account group on account settings screen."),
footerTitle: nil
)
Expand Down Expand Up @@ -149,9 +132,6 @@ class AccountViewController: SubSettingsViewController {
case .vanishAccount:
cell.disclosureType = .viewController
cell.accessibilityTraits = .button
case .donationHistory:
cell.disclosureType = .none
cell.accessibilityTraits = .button
case .informational:
cell.accessibilityTraits = .staticText
cell.disclosureType = .none
Expand Down Expand Up @@ -181,38 +161,11 @@ class AccountViewController: SubSettingsViewController {
let warningViewController = VanishAccountWarningViewHostingViewController(theme: theme)
warningViewController.delegate = self
present(warningViewController, animated: true)
case .donationHistory:
let alertController = UIAlertController(title: CommonStrings.confirmDeletionTitle, message: CommonStrings.confirmDeletionSubitle, preferredStyle: .alert)
let deleteAction = UIAlertAction(title: CommonStrings.deleteActionTitle, style: .destructive) { [weak self] (action) in
guard let self = self else {
return
}
self.deleteLocalHistory()
DispatchQueue.main.async {
self.sections = self.createSections()
self.tableView.reloadData()
self.showDeletionConfirmation()
}
}
let cancelAction = UIAlertAction(title: CommonStrings.cancelActionTitle, style: .cancel, handler: nil)
alertController.addAction(deleteAction)
alertController.addAction(cancelAction)
self.navigationController?.present(alertController, animated: true, completion: nil)
default:
break
}
}

private func deleteLocalHistory() {
donateDataController.deleteLocalDonationHistory()
}

private func showDeletionConfirmation() {
let alertController = UIAlertController(title: CommonStrings.confirmedDeletion, message: nil, preferredStyle: .alert)
let okAction = UIAlertAction(title: CommonStrings.okTitle, style: .default, handler: nil)
alertController.addAction(okAction)
self.navigationController?.present(alertController, animated: true)
}

@objc func goToWatchlist() {

Expand Down
11 changes: 10 additions & 1 deletion Wikipedia/Code/RootNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import UIKit

@objc(WMFRootNavigationController)
class RootNavigationController: WMFThemeableNavigationController {
var forcePortrait = false

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return topViewController?.supportedInterfaceOrientations ?? .all
return forcePortrait ? .portrait : topViewController?.supportedInterfaceOrientations ?? .all
}

override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
Expand All @@ -20,5 +21,13 @@ class RootNavigationController: WMFThemeableNavigationController {
/// `1..<count-2`: If first controller is Search (from tab bar item Search), it must be kept. Also, if VC prior to top one is Search, it is kept.
viewControllers[1..<count-2].forEach({ ($0 as? SearchViewController)?.removeFromParent() })
}

func turnOnForcePortrait() {
forcePortrait = true
}

func turnOffForcePortrait() {
forcePortrait = false
}

}
25 changes: 25 additions & 0 deletions Wikipedia/Code/WMFDonateDataControllerWrapper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import WMFData

@objc public class WMFDonateDataControllerWrapper: NSObject {

private let dataController = WMFDonateDataController.shared

@objc public var hasLocallySavedDonations: Bool {
get {
return dataController.hasLocallySavedDonations
}
set {
dataController.hasLocallySavedDonations = newValue
}
}

@objc public func deleteLocalDonationHistory() {
dataController.deleteLocalDonationHistory()
}

@objc public static let shared = WMFDonateDataControllerWrapper()

private override init() {
super.init()
}
}
1 change: 1 addition & 0 deletions Wikipedia/Code/WMFSettingsMenuItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ typedef NS_ENUM(NSUInteger, WMFSettingsMenuItemType) {
WMFSettingsMenuItemType_Notifications,
WMFSettingsMenuItemType_PrivacyPolicy,
WMFSettingsMenuItemType_Terms,
WMFSettingsMenuItemType_DonateHistory,
WMFSettingsMenuItemType_ZeroFAQ,
WMFSettingsMenuItemType_RateApp,
WMFSettingsMenuItemType_SendFeedback,
Expand Down
9 changes: 9 additions & 0 deletions Wikipedia/Code/WMFSettingsMenuItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ + (WMFSettingsMenuItem *)itemForType:(WMFSettingsMenuItemType)type {
disclosureText:nil
isSwitchOn:NO];
}
case WMFSettingsMenuItemType_DonateHistory: {
return [[WMFSettingsMenuItem alloc] initWithType:type
title: WMFCommonStrings.deleteDonationHistory
iconName:@"settings-support"
iconColor:[UIColor wmf_gray_400]
disclosureType:WMFSettingsMenuItemDisclosureType_None
disclosureText:nil
isSwitchOn:NO];
}
}
}

Expand Down
Loading

0 comments on commit 2c37e6e

Please sign in to comment.