diff --git a/Localization/app.json b/Localization/app.json index 19bf46537..cb74deb8c 100644 --- a/Localization/app.json +++ b/Localization/app.json @@ -79,17 +79,19 @@ "title": "One last thing.", "subtitle": "We just sent an email to %@,\ntap the link to confirm your account.", "button": { - "open_email_app": "Open email app", + "open_email_app": "Open Email App", "dont_receive_email": "I never got an email" }, "dont_receive_email": { - "alert_title": "It’s too soon to tell.", - "alert_description": "Give our servers another n seconds before sending another email.\nCheck if your email address is correct as well as your junk folder if you haven’t." + "title": "Check your email", + "description": "Check if your email address is correct as well as your junk folder if you haven’t.", + "resend_email": "Resend email" }, "open_email_app": { - "alert_title": "Check your inbox.", - "alert_description": "We just sent you another email. Check your junk folder if you haven’t.", - "mail": "Mail" + "title": "Check your inbox.", + "description": "We just sent you an email. Check your junk folder if you haven’t.", + "mail": "Mail", + "open_email_client": "Open Email Client" } }, "home_timeline": { diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index b4eb91e4f..27e648a55 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -57,6 +57,8 @@ 2D76319F25C1521200929FB9 /* StatusSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D76319E25C1521200929FB9 /* StatusSection.swift */; }; 2D7631A825C1535600929FB9 /* StatusTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D7631A725C1535600929FB9 /* StatusTableViewCell.swift */; }; 2D7631B325C159F700929FB9 /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D7631B225C159F700929FB9 /* Item.swift */; }; + 2D82B9FF25E7863200E36F0F /* OnboardingViewControllerAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D82B9FE25E7863200E36F0F /* OnboardingViewControllerAppearance.swift */; }; + 2D82BA0525E7897700E36F0F /* MastodonResendEmailViewModelNavigationDelegateShim.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D82BA0425E7897700E36F0F /* MastodonResendEmailViewModelNavigationDelegateShim.swift */; }; 2D927F0225C7E4F2004F19B8 /* Mention.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D927F0125C7E4F2004F19B8 /* Mention.swift */; }; 2D927F0825C7E9A8004F19B8 /* Tag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D927F0725C7E9A8004F19B8 /* Tag.swift */; }; 2D927F0E25C7E9C9004F19B8 /* History.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D927F0D25C7E9C9004F19B8 /* History.swift */; }; @@ -251,6 +253,8 @@ 2D76319E25C1521200929FB9 /* StatusSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusSection.swift; sourceTree = ""; }; 2D7631A725C1535600929FB9 /* StatusTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusTableViewCell.swift; sourceTree = ""; }; 2D7631B225C159F700929FB9 /* Item.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Item.swift; sourceTree = ""; }; + 2D82B9FE25E7863200E36F0F /* OnboardingViewControllerAppearance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingViewControllerAppearance.swift; sourceTree = ""; }; + 2D82BA0425E7897700E36F0F /* MastodonResendEmailViewModelNavigationDelegateShim.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonResendEmailViewModelNavigationDelegateShim.swift; sourceTree = ""; }; 2D927F0125C7E4F2004F19B8 /* Mention.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Mention.swift; sourceTree = ""; }; 2D927F0725C7E9A8004F19B8 /* Tag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tag.swift; sourceTree = ""; }; 2D927F0D25C7E9C9004F19B8 /* History.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = History.swift; sourceTree = ""; }; @@ -455,6 +459,7 @@ children = ( 2D364F7125E66D7500204FDC /* MastodonResendEmailViewController.swift */, 2D364F7725E66D8300204FDC /* MastodonResendEmailViewModel.swift */, + 2D82BA0425E7897700E36F0F /* MastodonResendEmailViewModelNavigationDelegateShim.swift */, ); path = ResendEmail; sourceTree = ""; @@ -548,6 +553,7 @@ 2D38F1C525CD37F400561493 /* ContentOffsetAdjustableTimelineViewControllerDelegate.swift */, 2D38F20725CD491300561493 /* DisposeBagCollectable.swift */, 2D5A3D3725CF8D9F002347D6 /* ScrollViewContainer.swift */, + 2D82B9FE25E7863200E36F0F /* OnboardingViewControllerAppearance.swift */, ); path = Protocol; sourceTree = ""; @@ -1386,6 +1392,7 @@ 2DA7D04425CA52B200804E11 /* TimelineLoaderTableViewCell.swift in Sources */, DB8AF52F25C13561002E6C99 /* DocumentStore.swift in Sources */, DB9D6C2425E502C60051B173 /* MosaicImageViewModel.swift in Sources */, + 2D82BA0525E7897700E36F0F /* MastodonResendEmailViewModelNavigationDelegateShim.swift in Sources */, 2D38F1EB25CD477000561493 /* HomeTimelineViewModel+LoadLatestState.swift in Sources */, DBD9149025DF6D8D00903DFD /* APIService+Onboarding.swift in Sources */, DB98337F25C9452D00AD9700 /* APIService+APIError.swift in Sources */, @@ -1393,6 +1400,7 @@ DBE0822425CD3F1E00FD6BBD /* MastodonRegisterViewModel.swift in Sources */, 2DF75B9B25D0E27500694EC8 /* StatusProviderFacade.swift in Sources */, DB5086A525CC0B7000C2C187 /* AvatarBarButtonItem.swift in Sources */, + 2D82B9FF25E7863200E36F0F /* OnboardingViewControllerAppearance.swift in Sources */, 2D38F1E525CD46C100561493 /* HomeTimelineViewModel.swift in Sources */, 2D76316B25C14D4C00929FB9 /* PublicTimelineViewModel.swift in Sources */, 2D38F1DF25CD46A400561493 /* HomeTimelineViewController+StatusProvider.swift in Sources */, diff --git a/Mastodon/Generated/Strings.swift b/Mastodon/Generated/Strings.swift index a5cd7a9d7..bfb8db80e 100644 --- a/Mastodon/Generated/Strings.swift +++ b/Mastodon/Generated/Strings.swift @@ -86,17 +86,21 @@ internal enum L10n { } internal enum DontReceiveEmail { /// Give our servers another n seconds before sending another email.\nCheck if your email address is correct as well as your junk folder if you haven’t. - internal static let alertDescription = L10n.tr("Localizable", "Scene.ConfirmEmail.DontReceiveEmail.AlertDescription") + internal static let description = L10n.tr("Localizable", "Scene.ConfirmEmail.DontReceiveEmail.Description") + /// Resend Email + internal static let resendEmail = L10n.tr("Localizable", "Scene.ConfirmEmail.DontReceiveEmail.ResendEmail") /// It’s too soon to tell. - internal static let alertTitle = L10n.tr("Localizable", "Scene.ConfirmEmail.DontReceiveEmail.AlertTitle") + internal static let title = L10n.tr("Localizable", "Scene.ConfirmEmail.DontReceiveEmail.Title") } internal enum OpenEmailApp { /// We just sent you another email. Check your junk folder if you haven’t. - internal static let alertDescription = L10n.tr("Localizable", "Scene.ConfirmEmail.OpenEmailApp.AlertDescription") - /// Check your inbox. - internal static let alertTitle = L10n.tr("Localizable", "Scene.ConfirmEmail.OpenEmailApp.AlertTitle") + internal static let description = L10n.tr("Localizable", "Scene.ConfirmEmail.OpenEmailApp.Description") /// Mail internal static let mail = L10n.tr("Localizable", "Scene.ConfirmEmail.OpenEmailApp.Mail") + /// Open Email Client + internal static let openEmailClient = L10n.tr("Localizable", "Scene.ConfirmEmail.OpenEmailApp.OpenEmailClient") + /// Check your inbox. + internal static let title = L10n.tr("Localizable", "Scene.ConfirmEmail.OpenEmailApp.Title") } } internal enum HomeTimeline { diff --git a/Mastodon/Protocol/OnboardingViewControllerAppearance.swift b/Mastodon/Protocol/OnboardingViewControllerAppearance.swift new file mode 100644 index 000000000..8e1a5a122 --- /dev/null +++ b/Mastodon/Protocol/OnboardingViewControllerAppearance.swift @@ -0,0 +1,30 @@ +// +// OnboardingViewControllerAppearance.swift +// Mastodon +// +// Created by sxiaojian on 2021/2/25. +// + +import UIKit + +protocol OnboardingViewControllerAppearance: UIViewController { + func setupOnboardingAppearance() +} + +extension OnboardingViewControllerAppearance { + func setupOnboardingAppearance() { + overrideUserInterfaceStyle = .light + view.backgroundColor = Asset.Colors.Background.onboardingBackground.color + + // set navigationBar transparent + let barAppearance = UINavigationBarAppearance() + barAppearance.configureWithTransparentBackground() + navigationController?.navigationBar.standardAppearance = barAppearance + navigationController?.navigationBar.compactAppearance = barAppearance + navigationController?.navigationBar.scrollEdgeAppearance = barAppearance + + let backItem = UIBarButtonItem() + backItem.title = "back" + navigationController?.navigationBar.topItem?.backBarButtonItem = backItem + } +} diff --git a/Mastodon/Resources/en.lproj/Localizable.strings b/Mastodon/Resources/en.lproj/Localizable.strings index c9c731c6b..1311dcc60 100644 --- a/Mastodon/Resources/en.lproj/Localizable.strings +++ b/Mastodon/Resources/en.lproj/Localizable.strings @@ -21,12 +21,14 @@ "Common.Countable.Photo.Single" = "photo"; "Scene.ConfirmEmail.Button.DontReceiveEmail" = "I never got an email"; "Scene.ConfirmEmail.Button.OpenEmailApp" = "Open email app"; -"Scene.ConfirmEmail.DontReceiveEmail.AlertDescription" = "Give our servers another n seconds before sending another email. +"Scene.ConfirmEmail.DontReceiveEmail.Description" = "Give our servers another n seconds before sending another email. Check if your email address is correct as well as your junk folder if you haven’t."; -"Scene.ConfirmEmail.DontReceiveEmail.AlertTitle" = "It’s too soon to tell."; -"Scene.ConfirmEmail.OpenEmailApp.AlertDescription" = "We just sent you another email. Check your junk folder if you haven’t."; -"Scene.ConfirmEmail.OpenEmailApp.AlertTitle" = "Check your inbox."; +"Scene.ConfirmEmail.DontReceiveEmail.ResendEmail" = "Resend Email"; +"Scene.ConfirmEmail.DontReceiveEmail.Title" = "It’s too soon to tell."; +"Scene.ConfirmEmail.OpenEmailApp.Description" = "We just sent you another email. Check your junk folder if you haven’t."; "Scene.ConfirmEmail.OpenEmailApp.Mail" = "Mail"; +"Scene.ConfirmEmail.OpenEmailApp.OpenEmailClient" = "Open Email Client"; +"Scene.ConfirmEmail.OpenEmailApp.Title" = "Check your inbox."; "Scene.ConfirmEmail.Subtitle" = "We just sent an email to %@, tap the link to confirm your account."; "Scene.ConfirmEmail.Title" = "One last thing."; diff --git a/Mastodon/Scene/Authentication/AuthenticationViewController.swift b/Mastodon/Scene/Authentication/AuthenticationViewController.swift index d93651ba5..5236bb927 100644 --- a/Mastodon/Scene/Authentication/AuthenticationViewController.swift +++ b/Mastodon/Scene/Authentication/AuthenticationViewController.swift @@ -11,7 +11,7 @@ import Combine import MastodonSDK import UITextField_Shake -final class AuthenticationViewController: UIViewController, NeedsDependency { +final class AuthenticationViewController: UIViewController, NeedsDependency, OnboardingViewControllerAppearance{ var disposeBag = Set() @@ -77,9 +77,7 @@ extension AuthenticationViewController { override func viewDidLoad() { super.viewDidLoad() - overrideUserInterfaceStyle = .dark // FIXME: - - view.backgroundColor = Asset.Colors.Background.systemBackground.color + self.setupOnboardingAppearance() domainLabel.translatesAutoresizingMaskIntoConstraints = false view.addSubview(domainLabel) diff --git a/Mastodon/Scene/Authentication/ConfirmEmail/MastodonConfirmEmailViewController.swift b/Mastodon/Scene/Authentication/ConfirmEmail/MastodonConfirmEmailViewController.swift index ff41740b2..b83cb80d1 100644 --- a/Mastodon/Scene/Authentication/ConfirmEmail/MastodonConfirmEmailViewController.swift +++ b/Mastodon/Scene/Authentication/ConfirmEmail/MastodonConfirmEmailViewController.swift @@ -6,11 +6,12 @@ // import Combine +import MastodonSDK +import os.log import ThirdPartyMailer import UIKit -import MastodonSDK -final class MastodonConfirmEmailViewController: UIViewController, NeedsDependency { +final class MastodonConfirmEmailViewController: UIViewController, NeedsDependency, OnboardingViewControllerAppearance { var disposeBag = Set() weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } @@ -39,7 +40,7 @@ final class MastodonConfirmEmailViewController: UIViewController, NeedsDependenc let button = UIButton(type: .system) button.titleLabel?.font = .preferredFont(forTextStyle: .headline) button.setBackgroundImage(UIImage.placeholder(color: Asset.Colors.lightBrandBlue.color), for: .normal) - button.setTitleColor(.white, for: .normal) + button.setTitleColor(Asset.Colors.Label.primary.color, for: .normal) button.setTitle(L10n.Scene.ConfirmEmail.Button.openEmailApp, for: .normal) button.layer.masksToBounds = true button.layer.cornerRadius = 8 @@ -63,17 +64,11 @@ extension MastodonConfirmEmailViewController { super.viewWillAppear(animated) navigationController?.setNavigationBarHidden(false, animated: false) } - override func viewDidLoad() { - overrideUserInterfaceStyle = .light - view.backgroundColor = Asset.Colors.Background.onboardingBackground.color - - // set navigationBar transparent - let barAppearance = UINavigationBarAppearance() - barAppearance.configureWithTransparentBackground() - navigationController?.navigationBar.standardAppearance = barAppearance - navigationController?.navigationBar.compactAppearance = barAppearance - navigationController?.navigationBar.scrollEdgeAppearance = barAppearance + override func viewDidLoad() { + + self.setupOnboardingAppearance() + // resizedView let resizedView = UIView() resizedView.translatesAutoresizingMaskIntoConstraints = false @@ -103,12 +98,31 @@ extension MastodonConfirmEmailViewController { NSLayoutConstraint.activate([ self.openEmailButton.heightAnchor.constraint(equalToConstant: 46), ]) + + self.viewModel.timestampUpdatePublisher + .sink { [weak self] _ in + guard let self = self else { return } + AuthenticationViewModel.verifyAndSaveAuthentication(context: self.context, info: self.viewModel.authenticateInfo, userToken: self.viewModel.userToken) + .receive(on: DispatchQueue.main) + .sink { completion in + switch completion { + case .failure(let error): + os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: swap user access token swap fail: %s", (#file as NSString).lastPathComponent, #line, #function, error.localizedDescription) + case .finished: + break + } + } receiveValue: { _ in + self.coordinator.setup() + } + .store(in: &self.disposeBag) + } + .store(in: &self.disposeBag) } } extension MastodonConfirmEmailViewController { @objc private func openEmailButtonPressed(_ sender: UIButton) { - let alertController = UIAlertController(title: L10n.Scene.ConfirmEmail.OpenEmailApp.alertTitle, message: L10n.Scene.ConfirmEmail.OpenEmailApp.alertDescription, preferredStyle: .alert) + let alertController = UIAlertController(title: L10n.Scene.ConfirmEmail.OpenEmailApp.title, message: L10n.Scene.ConfirmEmail.OpenEmailApp.description, preferredStyle: .alert) let openEmailAction = UIAlertAction(title: L10n.Scene.ConfirmEmail.Button.openEmailApp, style: .default) { [weak self] _ in guard let self = self else { return } self.showEmailAppAlert() @@ -121,12 +135,15 @@ extension MastodonConfirmEmailViewController { } @objc private func dontReceiveButtonPressed(_ sender: UIButton) { - let alertController = UIAlertController(title: L10n.Scene.ConfirmEmail.DontReceiveEmail.alertTitle, message: L10n.Scene.ConfirmEmail.DontReceiveEmail.alertDescription, preferredStyle: .alert) - let okAction = UIAlertAction(title: L10n.Common.Controls.Actions.ok, style: .default) { _ in - let url = Mastodon.API.resendEmailURL(domain:self.viewModel.authenticateInfo.domain) + let alertController = UIAlertController(title: L10n.Scene.ConfirmEmail.DontReceiveEmail.title, message: L10n.Scene.ConfirmEmail.DontReceiveEmail.description, preferredStyle: .alert) + let resendAction = UIAlertAction(title: L10n.Scene.ConfirmEmail.DontReceiveEmail.resendEmail, style: .default) { _ in + let url = Mastodon.API.resendEmailURL(domain: self.viewModel.authenticateInfo.domain) let viewModel = MastodonResendEmailViewModel(resendEmailURL: url, email: self.viewModel.email) - self.coordinator.present(scene: .mastodonResendEmail(viewModel: viewModel), from: self, transition: .show) + self.coordinator.present(scene: .mastodonResendEmail(viewModel: viewModel), from: self, transition: .modal(animated: true, completion: nil)) } + let okAction = UIAlertAction(title: L10n.Common.Controls.Actions.ok, style: .default) { _ in + } + alertController.addAction(resendAction) alertController.addAction(okAction) self.coordinator.present(scene: .alertController(alertController: alertController), from: self, transition: .alertController(animated: true, completion: nil)) } @@ -137,7 +154,7 @@ extension MastodonConfirmEmailViewController { let avaliableClients = clients.filter { client -> Bool in ThirdPartyMailer.application(application, isMailClientAvailable: client) } - let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .alert) + let alertController = UIAlertController(title: L10n.Scene.ConfirmEmail.OpenEmailApp.openEmailClient, message: nil, preferredStyle: .alert) let alertAction = UIAlertAction(title: L10n.Scene.ConfirmEmail.OpenEmailApp.mail, style: .default) { _ in UIApplication.shared.open(URL(string: "message://")!, options: [:], completionHandler: nil) @@ -153,6 +170,5 @@ extension MastodonConfirmEmailViewController { let cancelAction = UIAlertAction(title: L10n.Common.Controls.Actions.cancel, style: .cancel, handler: nil) alertController.addAction(cancelAction) self.coordinator.present(scene: .alertController(alertController: alertController), from: self, transition: .alertController(animated: true, completion: nil)) - } } diff --git a/Mastodon/Scene/Authentication/ConfirmEmail/MastodonConfirmEmailViewModel.swift b/Mastodon/Scene/Authentication/ConfirmEmail/MastodonConfirmEmailViewModel.swift index d1e3936a2..aff254741 100644 --- a/Mastodon/Scene/Authentication/ConfirmEmail/MastodonConfirmEmailViewModel.swift +++ b/Mastodon/Scene/Authentication/ConfirmEmail/MastodonConfirmEmailViewModel.swift @@ -8,13 +8,11 @@ import Combine import Foundation import MastodonSDK -import os.log final class MastodonConfirmEmailViewModel { var disposeBag = Set() let context: AppContext - let coordinator: SceneCoordinator var email: String let authenticateInfo: AuthenticationViewModel.AuthenticateInfo let userToken: Mastodon.Entity.Token @@ -24,30 +22,10 @@ final class MastodonConfirmEmailViewModel { .share() .eraseToAnyPublisher() - init(context: AppContext,coordinator: SceneCoordinator, email: String, authenticateInfo: AuthenticationViewModel.AuthenticateInfo, userToken: Mastodon.Entity.Token) { + init(context: AppContext, email: String, authenticateInfo: AuthenticationViewModel.AuthenticateInfo, userToken: Mastodon.Entity.Token) { self.context = context - self.coordinator = coordinator self.email = email self.authenticateInfo = authenticateInfo self.userToken = userToken - timestampUpdatePublisher - .sink { [weak self] _ in - guard let self = self else { return } - AuthenticationViewModel.verifyAndSaveAuthentication(context: self.context, info: authenticateInfo, userToken: userToken) - .receive(on: DispatchQueue.main) - .sink { completion in - switch completion { - case .failure(let error): - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: swap user access token swap fail: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) - case .finished: - break - } - } receiveValue: { _ in - self.coordinator.setup() - } - .store(in: &self.disposeBag) - - } - .store(in: &disposeBag) } } diff --git a/Mastodon/Scene/Authentication/Register/MastodonRegisterViewController.swift b/Mastodon/Scene/Authentication/Register/MastodonRegisterViewController.swift index 1ee306cf1..aaded394c 100644 --- a/Mastodon/Scene/Authentication/Register/MastodonRegisterViewController.swift +++ b/Mastodon/Scene/Authentication/Register/MastodonRegisterViewController.swift @@ -11,7 +11,7 @@ import os.log import UIKit import UITextField_Shake -final class MastodonRegisterViewController: UIViewController, NeedsDependency { +final class MastodonRegisterViewController: UIViewController, NeedsDependency, OnboardingViewControllerAppearance { var disposeBag = Set() weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } @@ -196,8 +196,8 @@ extension MastodonRegisterViewController { override func viewDidLoad() { super.viewDidLoad() - overrideUserInterfaceStyle = .light - view.backgroundColor = Asset.Colors.Background.onboardingBackground.color + self.setupOnboardingAppearance() + domainLabel.text = "@" + viewModel.domain + " " domainLabel.sizeToFit() passwordCheckLabel.attributedText = viewModel.attributeStringForPassword() @@ -451,7 +451,7 @@ extension MastodonRegisterViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - navigationController?.setNavigationBarHidden(true, animated: false) + navigationController?.setNavigationBarHidden(false, animated: false) } } @@ -568,11 +568,11 @@ extension MastodonRegisterViewController { } receiveValue: { [weak self] response in guard let self = self else { return } let userToken = response.value - // TODO: + let alertController = UIAlertController(title: L10n.Scene.Register.success, message: L10n.Scene.Register.checkEmail, preferredStyle: .alert) let okAction = UIAlertAction(title: L10n.Common.Controls.Actions.ok, style: .default) { [weak self] _ in guard let self = self else { return } - let viewModel = MastodonConfirmEmailViewModel(context: self.context, coordinator: self.coordinator, email: email, authenticateInfo: self.viewModel.authenticateInfo, userToken: userToken) + let viewModel = MastodonConfirmEmailViewModel(context: self.context, email: email, authenticateInfo: self.viewModel.authenticateInfo, userToken: userToken) self.coordinator.present(scene: .mastodonConfirmEmail(viewModel: viewModel), from: self, transition: .show) } alertController.addAction(okAction) diff --git a/Mastodon/Scene/Authentication/ResendEmail/MastodonResendEmailViewController.swift b/Mastodon/Scene/Authentication/ResendEmail/MastodonResendEmailViewController.swift index e54baa137..1a16067cf 100644 --- a/Mastodon/Scene/Authentication/ResendEmail/MastodonResendEmailViewController.swift +++ b/Mastodon/Scene/Authentication/ResendEmail/MastodonResendEmailViewController.swift @@ -53,7 +53,7 @@ extension MastodonResendEmailViewController { ]) let request = URLRequest(url: viewModel.resendEmailURL) - webView.navigationDelegate = self + webView.navigationDelegate = self.viewModel.navigationDelegate webView.load(request) os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: resendEmail via: %s", (#file as NSString).lastPathComponent, #line, #function, viewModel.resendEmailURL.debugDescription) } diff --git a/Mastodon/Scene/Authentication/ResendEmail/MastodonResendEmailViewModel.swift b/Mastodon/Scene/Authentication/ResendEmail/MastodonResendEmailViewModel.swift index 861d7d7f7..e8e16e6e5 100644 --- a/Mastodon/Scene/Authentication/ResendEmail/MastodonResendEmailViewModel.swift +++ b/Mastodon/Scene/Authentication/ResendEmail/MastodonResendEmailViewModel.swift @@ -15,6 +15,8 @@ final class MastodonResendEmailViewModel { let resendEmailURL: URL let email: String + private var navigationDelegateShim: MastodonResendEmailViewModelNavigationDelegateShim? + init(resendEmailURL: URL, email: String) { self.resendEmailURL = resendEmailURL self.email = email @@ -24,3 +26,12 @@ final class MastodonResendEmailViewModel { os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", (#file as NSString).lastPathComponent, #line, #function) } } +extension MastodonResendEmailViewModel { + + var navigationDelegate: WKNavigationDelegate { + let navigationDelegateShim = MastodonResendEmailViewModelNavigationDelegateShim(viewModel: self) + self.navigationDelegateShim = navigationDelegateShim + return navigationDelegateShim + } + +} diff --git a/Mastodon/Scene/Authentication/ResendEmail/MastodonResendEmailViewModelNavigationDelegateShim.swift b/Mastodon/Scene/Authentication/ResendEmail/MastodonResendEmailViewModelNavigationDelegateShim.swift new file mode 100644 index 000000000..ae7047f45 --- /dev/null +++ b/Mastodon/Scene/Authentication/ResendEmail/MastodonResendEmailViewModelNavigationDelegateShim.swift @@ -0,0 +1,33 @@ +// +// MastodonResendEmailViewModelNavigationDelegateShim.swift +// Mastodon +// +// Created by sxiaojian on 2021/2/25. +// + +import os.log +import Foundation +import WebKit + +final class MastodonResendEmailViewModelNavigationDelegateShim: NSObject { + + weak var viewModel: MastodonResendEmailViewModel? + + init(viewModel: MastodonResendEmailViewModel) { + self.viewModel = viewModel + } + + deinit { + os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) + } +} + + +// MARK: - WKNavigationDelegate +extension MastodonResendEmailViewModelNavigationDelegateShim: WKNavigationDelegate { + + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { + + } + +} diff --git a/Mastodon/Scene/Authentication/ServerRules/MastodonServerRulesViewController.swift b/Mastodon/Scene/Authentication/ServerRules/MastodonServerRulesViewController.swift index 826a8731a..4f23a6134 100644 --- a/Mastodon/Scene/Authentication/ServerRules/MastodonServerRulesViewController.swift +++ b/Mastodon/Scene/Authentication/ServerRules/MastodonServerRulesViewController.swift @@ -8,7 +8,7 @@ import os.log import UIKit -final class MastodonServerRulesViewController: UIViewController, NeedsDependency { +final class MastodonServerRulesViewController: UIViewController, NeedsDependency ,OnboardingViewControllerAppearance{ weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -78,8 +78,7 @@ extension MastodonServerRulesViewController { override func viewDidLoad() { super.viewDidLoad() - overrideUserInterfaceStyle = .light - view.backgroundColor = Asset.Colors.Background.onboardingBackground.color + self.setupOnboardingAppearance() bottonContainerView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(bottonContainerView) @@ -144,7 +143,7 @@ extension MastodonServerRulesViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - navigationController?.setNavigationBarHidden(true, animated: false) + navigationController?.setNavigationBarHidden(false, animated: false) } }