From 26d728731970c5565de03e37d061ec35445870d2 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Wed, 9 Nov 2022 14:13:33 +0100 Subject: [PATCH] Add what needs to be done for better onboarding (#540) --- Mastodon/Coordinator/SceneCoordinator.swift | 1 + Mastodon/Diffable/Onboarding/PickServerSection.swift | 1 + .../PickServer/MastodonPickServerViewController.swift | 7 ++++--- .../PickServer/MastodonPickServerViewModel.swift | 1 + .../PickServer/TableViewCell/PickServerCell.swift | 3 +++ .../PickServer/View/PickServerCategoryView.swift | 1 + .../Cell/MastodonRegisterAvatarTableViewCell.swift | 1 + .../Cell/MastodonRegisterPasswordHintTableViewCell.swift | 1 + .../Cell/MastodonRegisterTextFieldTableViewCell.swift | 4 ++-- .../Scene/Onboarding/Register/MastodonRegisterView.swift | 1 + .../Register/MastodonRegisterViewController.swift | 2 +- .../Register/MastodonRegisterViewModel+Diffable.swift | 1 + .../ServerRules/MastodonServerRulesViewController.swift | 2 +- .../Scene/Onboarding/Welcome/WelcomeViewController.swift | 5 +++-- .../MastodonSDK/Entity/Mastodon+Entity+Server.swift | 1 + 15 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Mastodon/Coordinator/SceneCoordinator.swift b/Mastodon/Coordinator/SceneCoordinator.swift index 8a0825969..eca818fe5 100644 --- a/Mastodon/Coordinator/SceneCoordinator.swift +++ b/Mastodon/Coordinator/SceneCoordinator.swift @@ -149,6 +149,7 @@ extension SceneCoordinator { case mastodonConfirmEmail(viewModel: MastodonConfirmEmailViewModel) case mastodonResendEmail(viewModel: MastodonResendEmailViewModel) case mastodonWebView(viewModel: WebViewModel) + //TODO: @zeitschlag new case for welcome back select your server welcome-screen + Screen and ViewModel etc. // search case searchDetail(viewModel: SearchDetailViewModel) diff --git a/Mastodon/Diffable/Onboarding/PickServerSection.swift b/Mastodon/Diffable/Onboarding/PickServerSection.swift index 01a31f6f6..2eb6fa7a3 100644 --- a/Mastodon/Diffable/Onboarding/PickServerSection.swift +++ b/Mastodon/Diffable/Onboarding/PickServerSection.swift @@ -51,6 +51,7 @@ extension PickServerSection { extension PickServerSection { static func configure(cell: PickServerCell, server: Mastodon.Entity.Server, attribute: PickServerItem.ServerItemAttribute) { + //TODO: @zeitschlag configure cell if server doesn't allow registrations cell.domainLabel.text = server.domain cell.descriptionLabel.attributedText = { let content: String = { diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift index eb26f75be..006d9bcb8 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift @@ -172,7 +172,7 @@ extension MastodonPickServerViewController { let alertController = UIAlertController(for: error, title: "Error", preferredStyle: .alert) let okAction = UIAlertAction(title: L10n.Common.Controls.Actions.ok, style: .default, handler: nil) alertController.addAction(okAction) - self.coordinator.present( + _ = self.coordinator.present( scene: .alertController(alertController: alertController), from: nil, transition: .alertController(animated: true, completion: nil) @@ -394,7 +394,7 @@ extension MastodonPickServerViewController { instance: response.instance.value, applicationToken: response.applicationToken.value ) - self.coordinator.present(scene: .mastodonServerRules(viewModel: mastodonServerRulesViewModel), from: self, transition: .show) + _ = self.coordinator.present(scene: .mastodonServerRules(viewModel: mastodonServerRulesViewModel), from: self, transition: .show) } else { let mastodonRegisterViewModel = MastodonRegisterViewModel( context: self.context, @@ -403,7 +403,7 @@ extension MastodonPickServerViewController { instance: response.instance.value, applicationToken: response.applicationToken.value ) - self.coordinator.present(scene: .mastodonRegister(viewModel: mastodonRegisterViewModel), from: nil, transition: .show) + _ = self.coordinator.present(scene: .mastodonRegister(viewModel: mastodonRegisterViewModel), from: nil, transition: .show) } } .store(in: &disposeBag) @@ -499,6 +499,7 @@ extension MastodonPickServerViewController: PickServerServerSectionTableHeaderVi } func pickServerServerSectionTableHeaderView(_ headerView: PickServerServerSectionTableHeaderView, searchTextDidChange searchText: String?) { + //TODO: @zeitschlag Deselect server? viewModel.searchText.send(searchText ?? "") } } diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift index 50c1d7aac..719de4cb4 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift @@ -178,6 +178,7 @@ extension MastodonPickServerViewModel { .compactMap { [weak self] searchText -> AnyPublisher, Error>, Never>? in // Check if searchText is a valid mastodon server domain guard let self = self else { return nil } + //TODO: @zeitschlag Also allow search for incomplete URLs? guard let domain = AuthenticationViewModel.parseDomain(from: searchText) else { return Just(Result.failure(APIService.APIError.implicit(.badRequest))).eraseToAnyPublisher() } diff --git a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift index 669067770..f33b1d2e2 100644 --- a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift +++ b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift @@ -14,6 +14,7 @@ import Kanna import MastodonAsset import MastodonLocalization +//TODO: @zeitschlag Remove Delegate protocol PickServerCellDelegate: AnyObject { // func pickServerCell(_ cell: PickServerCell, expandButtonPressed button: UIButton) } @@ -88,6 +89,8 @@ class PickServerCell: UITableViewCell { label.adjustsFontForContentSizeCategory = true return label }() + + //TODO: @zeitschlag New label for "Registrations closed" private var collapseConstraints: [NSLayoutConstraint] = [] private var expandConstraints: [NSLayoutConstraint] = [] diff --git a/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift b/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift index 9d6cfc85f..fca4bbf3a 100644 --- a/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift +++ b/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift @@ -19,6 +19,7 @@ class PickServerCategoryView: UIView { return view }() + //TODO: @zeitschlag Remove emojiLabel let emojiLabel: UILabel = { let label = UILabel() label.textAlignment = .center diff --git a/Mastodon/Scene/Onboarding/Register/Cell/MastodonRegisterAvatarTableViewCell.swift b/Mastodon/Scene/Onboarding/Register/Cell/MastodonRegisterAvatarTableViewCell.swift index 154385e6a..c4754bb35 100644 --- a/Mastodon/Scene/Onboarding/Register/Cell/MastodonRegisterAvatarTableViewCell.swift +++ b/Mastodon/Scene/Onboarding/Register/Cell/MastodonRegisterAvatarTableViewCell.swift @@ -10,6 +10,7 @@ import Combine import MastodonAsset import MastodonLocalization +//TODO: @zeitschlag Remove final class MastodonRegisterAvatarTableViewCell: UITableViewCell { static let containerSize = CGSize(width: 88, height: 88) diff --git a/Mastodon/Scene/Onboarding/Register/Cell/MastodonRegisterPasswordHintTableViewCell.swift b/Mastodon/Scene/Onboarding/Register/Cell/MastodonRegisterPasswordHintTableViewCell.swift index 1324c2822..ba088f061 100644 --- a/Mastodon/Scene/Onboarding/Register/Cell/MastodonRegisterPasswordHintTableViewCell.swift +++ b/Mastodon/Scene/Onboarding/Register/Cell/MastodonRegisterPasswordHintTableViewCell.swift @@ -9,6 +9,7 @@ import UIKit import MastodonAsset import MastodonLocalization +//TODO: @zeitschlag Remove final class MastodonRegisterPasswordHintTableViewCell: UITableViewCell { let passwordRuleLabel: UILabel = { diff --git a/Mastodon/Scene/Onboarding/Register/Cell/MastodonRegisterTextFieldTableViewCell.swift b/Mastodon/Scene/Onboarding/Register/Cell/MastodonRegisterTextFieldTableViewCell.swift index 15f234834..9bbdd8044 100644 --- a/Mastodon/Scene/Onboarding/Register/Cell/MastodonRegisterTextFieldTableViewCell.swift +++ b/Mastodon/Scene/Onboarding/Register/Cell/MastodonRegisterTextFieldTableViewCell.swift @@ -11,13 +11,13 @@ import MastodonUI import MastodonAsset import MastodonLocalization -final class MastodonRegisterTextFieldTableViewCell: UITableViewCell { +//TODO: @zeitschlag Removefinal class MastodonRegisterTextFieldTableViewCell: UITableViewCell { static let textFieldHeight: CGFloat = 50 static let textFieldLabelFont = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 22) var disposeBag = Set() - + let textFieldShadowContainer = ShadowBackgroundContainer() let textField: UITextField = { let textField = UITextField() diff --git a/Mastodon/Scene/Onboarding/Register/MastodonRegisterView.swift b/Mastodon/Scene/Onboarding/Register/MastodonRegisterView.swift index 2be7c61d7..787b79bd8 100644 --- a/Mastodon/Scene/Onboarding/Register/MastodonRegisterView.swift +++ b/Mastodon/Scene/Onboarding/Register/MastodonRegisterView.swift @@ -175,6 +175,7 @@ struct MastodonRegisterView: View { case .valid: return Color(Asset.Colors.TextField.valid.color) } }() + //TODO: @zeitschlag Replace shadow with border Color(Asset.Scene.Onboarding.textFieldBackground.color) .cornerRadius(10) .shadow(color: shadowColor, radius: 1, x: 0, y: 2) diff --git a/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift b/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift index 9b10bd48e..758c20888 100644 --- a/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift +++ b/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift @@ -145,7 +145,7 @@ extension MastodonRegisterViewController { let alertController = UIAlertController(for: error, title: "Sign Up Failure", preferredStyle: .alert) let okAction = UIAlertAction(title: L10n.Common.Controls.Actions.ok, style: .default, handler: nil) alertController.addAction(okAction) - self.coordinator.present( + _ = self.coordinator.present( scene: .alertController(alertController: alertController), from: nil, transition: .alertController(animated: true, completion: nil) diff --git a/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewModel+Diffable.swift b/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewModel+Diffable.swift index dda59843a..f1e0d8903 100644 --- a/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewModel+Diffable.swift +++ b/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewModel+Diffable.swift @@ -11,6 +11,7 @@ import MastodonAsset import MastodonLocalization extension MastodonRegisterViewModel { + //TODO: @zeitschlag Remove, as the screen is based on SwiftUI now func setupDiffableDataSource( tableView: UITableView ) { diff --git a/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift b/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift index 0d4e27d98..e22ea5748 100644 --- a/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift +++ b/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift @@ -127,7 +127,7 @@ extension MastodonServerRulesViewController { instance: viewModel.instance, applicationToken: viewModel.applicationToken ) - coordinator.present(scene: .mastodonRegister(viewModel: viewModel), from: self, transition: .show) + _ = coordinator.present(scene: .mastodonRegister(viewModel: viewModel), from: self, transition: .show) } } diff --git a/Mastodon/Scene/Onboarding/Welcome/WelcomeViewController.swift b/Mastodon/Scene/Onboarding/Welcome/WelcomeViewController.swift index a2b8df83a..612189243 100644 --- a/Mastodon/Scene/Onboarding/Welcome/WelcomeViewController.swift +++ b/Mastodon/Scene/Onboarding/Welcome/WelcomeViewController.swift @@ -317,12 +317,13 @@ extension WelcomeViewController { extension WelcomeViewController { @objc private func signUpButtonDidClicked(_ sender: UIButton) { - coordinator.present(scene: .mastodonPickServer(viewMode: MastodonPickServerViewModel(context: context, mode: .signUp)), from: self, transition: .show) + _ = coordinator.present(scene: .mastodonPickServer(viewMode: MastodonPickServerViewModel(context: context, mode: .signUp)), from: self, transition: .show) } @objc private func signInButtonDidClicked(_ sender: UIButton) { - coordinator.present(scene: .mastodonPickServer(viewMode: MastodonPickServerViewModel(context: context, mode: .signIn)), from: self, transition: .show) + //TODO: @zeitschlag Present new login-scene + _ = coordinator.present(scene: .mastodonPickServer(viewMode: MastodonPickServerViewModel(context: context, mode: .signIn)), from: self, transition: .show) } @objc diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Server.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Server.swift index 2d1f9953f..da1f0dfad 100644 --- a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Server.swift +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Server.swift @@ -22,6 +22,7 @@ extension Mastodon.Entity { public let approvalRequired: Bool public let language: String public let category: String + //TODO: @zeitschlag Is there a way to figure out in advance if a server accepts new registrations? Right now we'd have to query the server and it responts with a `AuthenticationViewModel.AuthenticationError.registrationClosed` enum CodingKeys: String, CodingKey { case domain