Skip to content

Commit

Permalink
Merge branch 'task/20806-add-publicize-info-model' into task/20806-je…
Browse files Browse the repository at this point in the history
…tpack-social-service
  • Loading branch information
dvdchr committed Jun 26, 2023
2 parents df0214e + 6781b04 commit 5b53aff
Show file tree
Hide file tree
Showing 51 changed files with 736 additions and 615 deletions.
6 changes: 6 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
parent_config: https://raw.githubusercontent.com/Automattic/swiftlint-config/0f8ab6388bd8d15a04391825ab125f80cfb90704/.swiftlint.yml
remote_timeout: 10.0

opt_in_rules:
- overridden_super_call

overridden_super_call:
severity: error
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ workspace 'WordPress.xcworkspace'
## ===================================
##
def wordpress_shared
# pod 'WordPressShared', '~> 2.0-beta'
pod 'WordPressShared', '~> 2.2-beta'
# pod 'WordPressShared', git: 'https://github.com/wordpress-mobile/WordPress-iOS-Shared.git', tag: ''
pod 'WordPressShared', git: 'https://github.com/wordpress-mobile/WordPress-iOS-Shared.git', branch: 'trunk'
# pod 'WordPressShared', git: 'https://github.com/wordpress-mobile/WordPress-iOS-Shared.git', branch: 'trunk'
# pod 'WordPressShared', git: 'https://github.com/wordpress-mobile/WordPress-iOS-Shared.git', commit: ''
# pod 'WordPressShared', path: '../WordPress-iOS-Shared'
end
Expand Down
37 changes: 16 additions & 21 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -490,16 +490,16 @@ PODS:
- SDWebImageWebPCoder (0.8.5):
- libwebp (~> 1.0)
- SDWebImage/Core (~> 5.10)
- Sentry (8.6.0):
- Sentry/Core (= 8.6.0)
- SentryPrivate (= 8.6.0)
- Sentry/Core (8.6.0):
- SentryPrivate (= 8.6.0)
- SentryPrivate (8.6.0)
- Sentry (8.8.0):
- Sentry/Core (= 8.8.0)
- SentryPrivate (= 8.8.0)
- Sentry/Core (8.8.0):
- SentryPrivate (= 8.8.0)
- SentryPrivate (8.8.0)
- Sodium (0.9.1)
- Starscream (3.0.6)
- SVProgressHUD (2.2.5)
- SwiftLint (0.50.3)
- SwiftLint (0.52.2)
- UIDeviceIdentifier (2.3.0)
- WordPress-Aztec-iOS (1.19.8)
- WordPress-Editor-iOS (1.19.8):
Expand All @@ -512,7 +512,7 @@ PODS:
- WordPressKit (~> 8.0-beta)
- WordPressShared (~> 2.1-beta)
- WordPressUI (~> 1.7-beta)
- WordPressKit (8.4.0-beta.2):
- WordPressKit (8.4.0):
- Alamofire (~> 4.8.0)
- NSObject-SafeExpectations (~> 0.0.4)
- UIDeviceIdentifier (~> 2.0)
Expand Down Expand Up @@ -613,7 +613,7 @@ DEPENDENCIES:
- WordPress-Editor-iOS (~> 1.19.8)
- WordPressAuthenticator (~> 6.1-beta)
- WordPressKit (~> 8.4-beta)
- WordPressShared (from `https://github.com/wordpress-mobile/WordPress-iOS-Shared.git`, branch `trunk`)
- WordPressShared (~> 2.2-beta)
- WordPressUI (~> 1.12.5)
- WPMediaPicker (~> 1.8-beta)
- Yoga (from `https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.98.0/third-party-podspecs/Yoga.podspec.json`)
Expand All @@ -623,6 +623,7 @@ DEPENDENCIES:
SPEC REPOS:
https://github.com/wordpress-mobile/cocoapods-specs.git:
- WordPressAuthenticator
- WordPressKit
trunk:
- Alamofire
- AlamofireImage
Expand Down Expand Up @@ -661,7 +662,7 @@ SPEC REPOS:
- UIDeviceIdentifier
- WordPress-Aztec-iOS
- WordPress-Editor-iOS
- WordPressKit
- WordPressShared
- WordPressUI
- WPMediaPicker
- wpxmlrpc
Expand Down Expand Up @@ -776,9 +777,6 @@ EXTERNAL SOURCES:
:git: https://github.com/wordpress-mobile/gutenberg-mobile.git
:submodules: true
:tag: v1.98.0
WordPressShared:
:branch: trunk
:git: https://github.com/wordpress-mobile/WordPress-iOS-Shared.git
Yoga:
:podspec: https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.98.0/third-party-podspecs/Yoga.podspec.json

Expand All @@ -794,9 +792,6 @@ CHECKOUT OPTIONS:
:git: https://github.com/wordpress-mobile/gutenberg-mobile.git
:submodules: true
:tag: v1.98.0
WordPressShared:
:commit: 9a010fdab8d31f9e1fa0511f231e7068ef0170b1
:git: https://github.com/wordpress-mobile/WordPress-iOS-Shared.git

SPEC CHECKSUMS:
Alamofire: 3ec537f71edc9804815215393ae2b1a8ea33a844
Expand Down Expand Up @@ -875,17 +870,17 @@ SPEC CHECKSUMS:
RNTAztecView: 6362ed78bcf0c68a2a0e25b779a84ad7096c9ecf
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
Sentry: d80553ff85ea72def75b792aaa5a71c158e51595
SentryPrivate: ef1c5b3dfe44ec0c70e2eb343a5be2689164c021
Sentry: 927dfb29d18a14d924229a59cc2ad149f43349f2
SentryPrivate: 4350d865f898224ab9fa02b37d6ee7fbb623f47e
Sodium: 23d11554ecd556196d313cf6130d406dfe7ac6da
Starscream: ef3ece99d765eeccb67de105bfa143f929026cf5
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
SwiftLint: 77f7cb2b9bb81ab4a12fcc86448ba3f11afa50c6
SwiftLint: 1ac76dac888ca05cb0cf24d0c85887ec1209961d
UIDeviceIdentifier: 442b65b4ff1832d4ca9c2a157815cb29ad981b17
WordPress-Aztec-iOS: 7d11d598f14c82c727c08b56bd35fbeb7dafb504
WordPress-Editor-iOS: 9eb9f12f21a5209cb837908d81ffe1e31cb27345
WordPressAuthenticator: b0b900696de5129a215adcd1e9ae6eb89da36ac8
WordPressKit: 3f3a45e11a21e39f500c73362e10149a7322ed67
WordPressKit: f445e6fc3c63ddf611513a435408f86fdf3808b3
WordPressShared: 87f3ee89b0a3e83106106f13a8b71605fb8eb6d2
WordPressUI: c5be816f6c7b3392224ac21de9e521e89fa108ac
WPMediaPicker: 0d40b8d66b6dfdaa2d6a41e3be51249ff5898775
Expand All @@ -900,6 +895,6 @@ SPEC CHECKSUMS:
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
ZIPFoundation: ae5b4b813d216d3bf0a148773267fff14bd51d37

PODFILE CHECKSUM: 3f47ee0c345c8439e137d677752d9c4166d2c695
PODFILE CHECKSUM: 623e3fe64f67d2c0352e26d1ac2bcd58c06b3494

COCOAPODS: 1.12.1
4 changes: 4 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
22.8
-----


22.7
-----
* [**] [internal] Blaze: Switch to using new canBlaze property to determine Blaze eligiblity. [#20916]
Expand Down
11 changes: 11 additions & 0 deletions WordPress/Classes/Extensions/CATransaction+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import UIKit

extension CATransaction {

static func perform(block: () -> Void, completion: @escaping () -> Void) {
CATransaction.begin()
CATransaction.setCompletionBlock(completion)
block()
CATransaction.commit()
}
}
144 changes: 144 additions & 0 deletions WordPress/Classes/System/RootViewPresenter+AppSettingsNavigation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import UIKit

extension RootViewPresenter {

/// Navigates to "Me > App Settings > Privacy Settings"
func navigateToPrivacySettings() {
navigateToMeScene()
.then(navigateToAppSettings())
.then(navigateToPrivacySettings())
.start(on: rootViewController, animated: true)
}

// MARK: - Navigators

/// Creates a navigation action to navigate to the "Me" scene.
///
/// The "Me" scene's navigation controller is popped to the root in case the "Me" scene was already presented.
private func navigateToMeScene() -> ViewControllerNavigationAction {
return .init { [weak self] context, completion in
guard let self else {
return
}
self.showMeScene(animated: context.animated) { meViewController in
self.popMeTabToRoot()
completion(meViewController)
}
}
}

/// Creates a navigation action to navigate to the "App Settings" from the "Me" scene.
private func navigateToAppSettings() -> ViewControllerNavigationAction {
return .init { context, completion in
let me: MeViewController = try context.fromViewController()
CATransaction.perform {
me.navigateToAppSettings()
} completion: {
completion(me.navigationController?.topViewController)
}
}
}

/// Creates a navigation action to navigate to the "Privacy Settings" from the "App Settings" scene.
private func navigateToPrivacySettings() -> ViewControllerNavigationAction {
return .init { context, completion in
let appSettings: AppSettingsViewController = try context.fromViewController()
appSettings.navigateToPrivacySettings(animated: context.animated) { privacySettings in
completion(privacySettings)
}
}
}
}

// MARK: - Private Tools

/// `ViewControllerNavigationAction` encapsulates a navigation action performed on a view controller.
/// It includes the capability to chain these actions together to perform a sequence of navigations.
/// This sequence is internally represented as a linked list where each node represents a navigation action.
/// The `then` method is used to chain navigation actions, and the `start` method initiates the sequence.
private class ViewControllerNavigationAction {

/// Reference to the first navigation action. It also represents the first node in a Linked List.
private var first: ViewControllerNavigationAction?

/// Reference to the next navigation action. It is called when the current one is complete.
private var next: ViewControllerNavigationAction?

/// The navigation action to perform.
private let action: Action

/// Initializes the navigation with an action to perform.
init(action: @escaping Action) {
self.action = action
}

/// Assigns the next action to perform.
@discardableResult func then(_ navigator: ViewControllerNavigationAction) -> ViewControllerNavigationAction {
self.next = navigator
self.next?.first = first ?? self
return navigator
}

/// Convenience method to start the navigation flow from the first navigator in the chain.
func start(on rootViewController: UIViewController, animated: Bool = true) {
let context = Context(animated: animated, sourceViewController: rootViewController)
let navigator = first ?? self
navigator.perform(with: context)
}

/// Performs the navigation action, then calls the next navigation action.
private func perform(with context: Context) {
do {
try self.action(context) { presented in
if let next = self.next, let presented {
let context = Context(animated: context.animated, sourceViewController: presented)
next.perform(with: context)
} else {
self.free()
}
}
} catch {
DDLogError("Failed to perform navigation action with error: \(error.localizedDescription)")
self.free()
}
}

/// Recursively nullifies the `next`, `first`references of all nodes in the Linked List.
///
/// This method must be called at the end of the navigation to prevent memory leaks.
private func free() {
if let first {
first.free()
return
}
let next = self.next
self.next = nil
self.first = nil
next?.first = nil
next?.free()
}

// MARK: Types

typealias Action = (Context, @escaping Completion) throws -> Void
typealias Completion = (UIViewController?) -> Void
}

extension ViewControllerNavigationAction {

/// `Context` provides the necessary data for a navigation action, including whether
/// the navigation is animated and the view controller initiating the navigation.
struct Context {

let animated: Bool

fileprivate let sourceViewController: UIViewController

func fromViewController<T: UIViewController>() throws -> T {
guard let sourceVC = self.sourceViewController as? T else {
throw NSError(domain: "ViewControllerNavigationActionCastError", code: 1)
}
return sourceVC
}
}
}
20 changes: 12 additions & 8 deletions WordPress/Classes/System/RootViewPresenter+MeNavigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,34 @@ extension RootViewPresenter {
func popMeTabToRoot() {
getNavigationController()?.popToRootViewController(animated: false)
}

/// presents the Me scene. If the feature flag is disabled, replaces the previously defined `showMeTab`
func showMeScene(animated: Bool = true, completion: (() -> Void)? = nil) {
func showMeScene(animated: Bool = true, completion: ((MeViewController?) -> Void)? = nil) {
let meScenePresenter = getMeScenePresenter()
meScenePresenter.present(on: rootViewController, animated: animated, completion: completion)
meScenePresenter.present(on: rootViewController, animated: animated) { [weak self] in
completion?(self?.getMeViewController())
}
}

/// access to sub levels
func navigateToAccountSettings() {
showMeScene(animated: false) {
showMeScene(animated: false) { meViewController in
self.popMeTabToRoot()
self.getMeViewController()?.navigateToAccountSettings()
meViewController?.navigateToAccountSettings()
}
}

func navigateToAppSettings() {
showMeScene() {
showMeScene() { meViewController in
self.popMeTabToRoot()
self.getMeViewController()?.navigateToAppSettings()
meViewController?.navigateToAppSettings()
}
}

func navigateToSupport() {
showMeScene() {
showMeScene() { meViewController in
self.popMeTabToRoot()
self.getMeViewController()?.navigateToHelpAndSupport()
meViewController?.navigateToHelpAndSupport()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class ActivityDetailViewController: UIViewController, StoryboardLoadable {
var router: ActivityContentRouter?

override func viewDidLoad() {
super.viewDidLoad()

setupLabelStyles()
setupViews()
setupText()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ class BaseActivityListViewController: UIViewController, TableViewContainer, Immu
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)

SVProgressHUD.dismiss()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class CalendarViewController: UIViewController {
}

override func viewDidLoad() {
super.viewDidLoad()

title = NSLocalizedString("Choose date range", comment: "Title to choose date range in a calendar")

// Configure Calendar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ final class BlogDashboardViewController: UIViewController {
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)

stopAlertTimer()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ class MySiteViewController: UIViewController, NoResultsViewHost {
// MARK: - View Lifecycle

override func viewDidLoad() {
super.viewDidLoad()

setupView()
setupConstraints()
setupNavigationItem()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ final class SettingsTitleSubtitleController: UITableViewController {
}

override func viewDidLoad() {
super.viewDidLoad()

setupNavigationBar()
setupTitle()
setupTable()
Expand Down
Loading

0 comments on commit 5b53aff

Please sign in to comment.