Add what needs to be done for better onboarding (#540)

This commit is contained in:
Nathan Mattes 2022-11-09 14:13:33 +01:00
parent 7e04dd3d31
commit 26d7287319
15 changed files with 23 additions and 9 deletions

View File

@ -149,6 +149,7 @@ extension SceneCoordinator {
case mastodonConfirmEmail(viewModel: MastodonConfirmEmailViewModel) case mastodonConfirmEmail(viewModel: MastodonConfirmEmailViewModel)
case mastodonResendEmail(viewModel: MastodonResendEmailViewModel) case mastodonResendEmail(viewModel: MastodonResendEmailViewModel)
case mastodonWebView(viewModel: WebViewModel) case mastodonWebView(viewModel: WebViewModel)
//TODO: @zeitschlag new case for welcome back select your server welcome-screen + Screen and ViewModel etc.
// search // search
case searchDetail(viewModel: SearchDetailViewModel) case searchDetail(viewModel: SearchDetailViewModel)

View File

@ -51,6 +51,7 @@ extension PickServerSection {
extension PickServerSection { extension PickServerSection {
static func configure(cell: PickServerCell, server: Mastodon.Entity.Server, attribute: PickServerItem.ServerItemAttribute) { 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.domainLabel.text = server.domain
cell.descriptionLabel.attributedText = { cell.descriptionLabel.attributedText = {
let content: String = { let content: String = {

View File

@ -172,7 +172,7 @@ extension MastodonPickServerViewController {
let alertController = UIAlertController(for: error, title: "Error", preferredStyle: .alert) let alertController = UIAlertController(for: error, title: "Error", preferredStyle: .alert)
let okAction = UIAlertAction(title: L10n.Common.Controls.Actions.ok, style: .default, handler: nil) let okAction = UIAlertAction(title: L10n.Common.Controls.Actions.ok, style: .default, handler: nil)
alertController.addAction(okAction) alertController.addAction(okAction)
self.coordinator.present( _ = self.coordinator.present(
scene: .alertController(alertController: alertController), scene: .alertController(alertController: alertController),
from: nil, from: nil,
transition: .alertController(animated: true, completion: nil) transition: .alertController(animated: true, completion: nil)
@ -394,7 +394,7 @@ extension MastodonPickServerViewController {
instance: response.instance.value, instance: response.instance.value,
applicationToken: response.applicationToken.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 { } else {
let mastodonRegisterViewModel = MastodonRegisterViewModel( let mastodonRegisterViewModel = MastodonRegisterViewModel(
context: self.context, context: self.context,
@ -403,7 +403,7 @@ extension MastodonPickServerViewController {
instance: response.instance.value, instance: response.instance.value,
applicationToken: response.applicationToken.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) .store(in: &disposeBag)
@ -499,6 +499,7 @@ extension MastodonPickServerViewController: PickServerServerSectionTableHeaderVi
} }
func pickServerServerSectionTableHeaderView(_ headerView: PickServerServerSectionTableHeaderView, searchTextDidChange searchText: String?) { func pickServerServerSectionTableHeaderView(_ headerView: PickServerServerSectionTableHeaderView, searchTextDidChange searchText: String?) {
//TODO: @zeitschlag Deselect server?
viewModel.searchText.send(searchText ?? "") viewModel.searchText.send(searchText ?? "")
} }
} }

View File

@ -178,6 +178,7 @@ extension MastodonPickServerViewModel {
.compactMap { [weak self] searchText -> AnyPublisher<Result<Mastodon.Response.Content<[Mastodon.Entity.Server]>, Error>, Never>? in .compactMap { [weak self] searchText -> AnyPublisher<Result<Mastodon.Response.Content<[Mastodon.Entity.Server]>, Error>, Never>? in
// Check if searchText is a valid mastodon server domain // Check if searchText is a valid mastodon server domain
guard let self = self else { return nil } guard let self = self else { return nil }
//TODO: @zeitschlag Also allow search for incomplete URLs?
guard let domain = AuthenticationViewModel.parseDomain(from: searchText) else { guard let domain = AuthenticationViewModel.parseDomain(from: searchText) else {
return Just(Result.failure(APIService.APIError.implicit(.badRequest))).eraseToAnyPublisher() return Just(Result.failure(APIService.APIError.implicit(.badRequest))).eraseToAnyPublisher()
} }

View File

@ -14,6 +14,7 @@ import Kanna
import MastodonAsset import MastodonAsset
import MastodonLocalization import MastodonLocalization
//TODO: @zeitschlag Remove Delegate
protocol PickServerCellDelegate: AnyObject { protocol PickServerCellDelegate: AnyObject {
// func pickServerCell(_ cell: PickServerCell, expandButtonPressed button: UIButton) // func pickServerCell(_ cell: PickServerCell, expandButtonPressed button: UIButton)
} }
@ -88,6 +89,8 @@ class PickServerCell: UITableViewCell {
label.adjustsFontForContentSizeCategory = true label.adjustsFontForContentSizeCategory = true
return label return label
}() }()
//TODO: @zeitschlag New label for "Registrations closed"
private var collapseConstraints: [NSLayoutConstraint] = [] private var collapseConstraints: [NSLayoutConstraint] = []
private var expandConstraints: [NSLayoutConstraint] = [] private var expandConstraints: [NSLayoutConstraint] = []

View File

@ -19,6 +19,7 @@ class PickServerCategoryView: UIView {
return view return view
}() }()
//TODO: @zeitschlag Remove emojiLabel
let emojiLabel: UILabel = { let emojiLabel: UILabel = {
let label = UILabel() let label = UILabel()
label.textAlignment = .center label.textAlignment = .center

View File

@ -10,6 +10,7 @@ import Combine
import MastodonAsset import MastodonAsset
import MastodonLocalization import MastodonLocalization
//TODO: @zeitschlag Remove
final class MastodonRegisterAvatarTableViewCell: UITableViewCell { final class MastodonRegisterAvatarTableViewCell: UITableViewCell {
static let containerSize = CGSize(width: 88, height: 88) static let containerSize = CGSize(width: 88, height: 88)

View File

@ -9,6 +9,7 @@ import UIKit
import MastodonAsset import MastodonAsset
import MastodonLocalization import MastodonLocalization
//TODO: @zeitschlag Remove
final class MastodonRegisterPasswordHintTableViewCell: UITableViewCell { final class MastodonRegisterPasswordHintTableViewCell: UITableViewCell {
let passwordRuleLabel: UILabel = { let passwordRuleLabel: UILabel = {

View File

@ -11,13 +11,13 @@ import MastodonUI
import MastodonAsset import MastodonAsset
import MastodonLocalization import MastodonLocalization
final class MastodonRegisterTextFieldTableViewCell: UITableViewCell { //TODO: @zeitschlag Removefinal class MastodonRegisterTextFieldTableViewCell: UITableViewCell {
static let textFieldHeight: CGFloat = 50 static let textFieldHeight: CGFloat = 50
static let textFieldLabelFont = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 22) static let textFieldLabelFont = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 22)
var disposeBag = Set<AnyCancellable>() var disposeBag = Set<AnyCancellable>()
let textFieldShadowContainer = ShadowBackgroundContainer() let textFieldShadowContainer = ShadowBackgroundContainer()
let textField: UITextField = { let textField: UITextField = {
let textField = UITextField() let textField = UITextField()

View File

@ -175,6 +175,7 @@ struct MastodonRegisterView: View {
case .valid: return Color(Asset.Colors.TextField.valid.color) case .valid: return Color(Asset.Colors.TextField.valid.color)
} }
}() }()
//TODO: @zeitschlag Replace shadow with border
Color(Asset.Scene.Onboarding.textFieldBackground.color) Color(Asset.Scene.Onboarding.textFieldBackground.color)
.cornerRadius(10) .cornerRadius(10)
.shadow(color: shadowColor, radius: 1, x: 0, y: 2) .shadow(color: shadowColor, radius: 1, x: 0, y: 2)

View File

@ -145,7 +145,7 @@ extension MastodonRegisterViewController {
let alertController = UIAlertController(for: error, title: "Sign Up Failure", preferredStyle: .alert) let alertController = UIAlertController(for: error, title: "Sign Up Failure", preferredStyle: .alert)
let okAction = UIAlertAction(title: L10n.Common.Controls.Actions.ok, style: .default, handler: nil) let okAction = UIAlertAction(title: L10n.Common.Controls.Actions.ok, style: .default, handler: nil)
alertController.addAction(okAction) alertController.addAction(okAction)
self.coordinator.present( _ = self.coordinator.present(
scene: .alertController(alertController: alertController), scene: .alertController(alertController: alertController),
from: nil, from: nil,
transition: .alertController(animated: true, completion: nil) transition: .alertController(animated: true, completion: nil)

View File

@ -11,6 +11,7 @@ import MastodonAsset
import MastodonLocalization import MastodonLocalization
extension MastodonRegisterViewModel { extension MastodonRegisterViewModel {
//TODO: @zeitschlag Remove, as the screen is based on SwiftUI now
func setupDiffableDataSource( func setupDiffableDataSource(
tableView: UITableView tableView: UITableView
) { ) {

View File

@ -127,7 +127,7 @@ extension MastodonServerRulesViewController {
instance: viewModel.instance, instance: viewModel.instance,
applicationToken: viewModel.applicationToken applicationToken: viewModel.applicationToken
) )
coordinator.present(scene: .mastodonRegister(viewModel: viewModel), from: self, transition: .show) _ = coordinator.present(scene: .mastodonRegister(viewModel: viewModel), from: self, transition: .show)
} }
} }

View File

@ -317,12 +317,13 @@ extension WelcomeViewController {
extension WelcomeViewController { extension WelcomeViewController {
@objc @objc
private func signUpButtonDidClicked(_ sender: UIButton) { 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 @objc
private func signInButtonDidClicked(_ sender: UIButton) { 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 @objc

View File

@ -22,6 +22,7 @@ extension Mastodon.Entity {
public let approvalRequired: Bool public let approvalRequired: Bool
public let language: String public let language: String
public let category: 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 { enum CodingKeys: String, CodingKey {
case domain case domain