Add navigation-view (#540)
This commit is contained in:
parent
47401b0940
commit
9c220a6abc
|
@ -88,6 +88,7 @@
|
|||
62FD27D52893708A00B205C5 /* BookmarkViewModel+Diffable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62FD27D42893708A00B205C5 /* BookmarkViewModel+Diffable.swift */; };
|
||||
87FFDA5D898A5C42ADCB35E7 /* Pods_Mastodon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4ABE34829701A4496C5BB64 /* Pods_Mastodon.framework */; };
|
||||
C24C97032922F30500BAE8CB /* RefreshControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C24C97022922F30500BAE8CB /* RefreshControl.swift */; };
|
||||
D87BFC8B291D5C6B00FEE264 /* MastodonLoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87BFC8A291D5C6B00FEE264 /* MastodonLoginView.swift */; };
|
||||
D8A6AB6C291C5136003AB663 /* MastodonLoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8A6AB6B291C5136003AB663 /* MastodonLoginViewController.swift */; };
|
||||
DB0009A626AEE5DC009B9D2D /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = DB0009A926AEE5DC009B9D2D /* Intents.intentdefinition */; settings = {ATTRIBUTES = (codegen, ); }; };
|
||||
DB0009A726AEE5DC009B9D2D /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = DB0009A926AEE5DC009B9D2D /* Intents.intentdefinition */; };
|
||||
|
@ -609,6 +610,7 @@
|
|||
C3789232A52F43529CA67E95 /* Pods-MastodonIntent.asdk - debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MastodonIntent.asdk - debug.xcconfig"; path = "Target Support Files/Pods-MastodonIntent/Pods-MastodonIntent.asdk - debug.xcconfig"; sourceTree = "<group>"; };
|
||||
CD92E0F10BDE4FE7C4B999F2 /* Pods_MastodonTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MastodonTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D7D7CF93E262178800077512 /* Pods-Mastodon-AppShared.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Mastodon-AppShared.debug.xcconfig"; path = "Target Support Files/Pods-Mastodon-AppShared/Pods-Mastodon-AppShared.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
D87BFC8A291D5C6B00FEE264 /* MastodonLoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonLoginView.swift; sourceTree = "<group>"; };
|
||||
D8A6AB6B291C5136003AB663 /* MastodonLoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonLoginViewController.swift; sourceTree = "<group>"; };
|
||||
DB0009A826AEE5DC009B9D2D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; name = Base; path = Base.lproj/Intents.intentdefinition; sourceTree = "<group>"; };
|
||||
DB0009AD26AEE5E4009B9D2D /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Intents.strings; sourceTree = "<group>"; };
|
||||
|
@ -1500,6 +1502,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
D8A6AB6B291C5136003AB663 /* MastodonLoginViewController.swift */,
|
||||
D87BFC8A291D5C6B00FEE264 /* MastodonLoginView.swift */,
|
||||
);
|
||||
path = Login;
|
||||
sourceTree = "<group>";
|
||||
|
@ -3372,6 +3375,7 @@
|
|||
DBCC3B8F26148F7B0045B23D /* CachedProfileViewModel.swift in Sources */,
|
||||
DB4F097526A037F500D62E92 /* SearchHistoryViewModel.swift in Sources */,
|
||||
DB3EA8E9281B7A3700598866 /* DiscoveryCommunityViewModel.swift in Sources */,
|
||||
D87BFC8B291D5C6B00FEE264 /* MastodonLoginView.swift in Sources */,
|
||||
DB6180F826391D660018D199 /* MediaPreviewingViewController.swift in Sources */,
|
||||
DBEFCD71282A12B200C0ABEA /* ReportReasonViewController.swift in Sources */,
|
||||
DB0140CF25C42AEE00F9F3CF /* OSLog.swift in Sources */,
|
||||
|
|
|
@ -406,7 +406,10 @@ private extension SceneCoordinator {
|
|||
_viewController.viewModel = viewModel
|
||||
viewController = _viewController
|
||||
case .mastodonLogin:
|
||||
viewController = MastodonLoginViewController()
|
||||
let loginViewController = MastodonLoginViewController()
|
||||
loginViewController.delegate = self
|
||||
|
||||
viewController = loginViewController
|
||||
case .mastodonResendEmail(let viewModel):
|
||||
let _viewController = MastodonResendEmailViewController()
|
||||
_viewController.viewModel = viewModel
|
||||
|
@ -533,5 +536,16 @@ private extension SceneCoordinator {
|
|||
needs?.context = appContext
|
||||
needs?.coordinator = self
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//MARK: - MastodonLoginViewControllerDelegate
|
||||
|
||||
extension SceneCoordinator: MastodonLoginViewControllerDelegate {
|
||||
func backButtonPressed(_ viewController: MastodonLoginViewController) {
|
||||
viewController.navigationController?.popViewController(animated: true)
|
||||
}
|
||||
|
||||
func nextButtonPressed(_ viewController: MastodonLoginViewController) {
|
||||
//TODO: @zeitschlag implement, show ASWebAuthentication and stuff
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// MastodonLoginView.swift
|
||||
// Mastodon
|
||||
//
|
||||
// Created by Nathan Mattes on 10.11.22.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import MastodonAsset
|
||||
|
||||
class MastodonLoginView: UIView {
|
||||
|
||||
// Title, Subtitle
|
||||
// SearchBox, queries api.joinmastodon.org/servers with domain
|
||||
// List with (filtered) domains
|
||||
|
||||
let navigationActionView: NavigationActionView
|
||||
|
||||
override init(frame: CGRect) {
|
||||
navigationActionView = NavigationActionView()
|
||||
navigationActionView.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
super.init(frame: frame)
|
||||
|
||||
addSubview(navigationActionView)
|
||||
backgroundColor = .systemBackground
|
||||
|
||||
setupConstraints()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
private func setupConstraints() {
|
||||
let constraints = [
|
||||
navigationActionView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||
navigationActionView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||
bottomAnchor.constraint(equalTo: navigationActionView.bottomAnchor),
|
||||
]
|
||||
NSLayoutConstraint.activate(constraints)
|
||||
}
|
||||
|
||||
}
|
|
@ -7,19 +7,57 @@
|
|||
|
||||
import UIKit
|
||||
|
||||
class MastodonLoginViewController: UIViewController {
|
||||
|
||||
// Title, Subtitle
|
||||
// SearchBox, queries api.joinmastodon.org/servers with domain
|
||||
// List with (filtered) domains
|
||||
// back-button, next-button (enabled if user selectes a server or url is valid
|
||||
// next-button does MastodonPickServerViewController.doSignIn()
|
||||
|
||||
init() {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
view.backgroundColor = .systemGreen
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||
protocol MastodonLoginViewControllerDelegate: AnyObject {
|
||||
func backButtonPressed(_ viewController: MastodonLoginViewController)
|
||||
func nextButtonPressed(_ viewController: MastodonLoginViewController)
|
||||
}
|
||||
|
||||
class MastodonLoginViewController: UIViewController {
|
||||
|
||||
// back-button, next-button (enabled if user selectes a server or url is valid
|
||||
// next-button does MastodonPickServerViewController.doSignIn()
|
||||
|
||||
weak var delegate: MastodonLoginViewControllerDelegate?
|
||||
|
||||
var contentView: MastodonLoginView {
|
||||
view as! MastodonLoginView
|
||||
}
|
||||
|
||||
init() {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
navigationItem.hidesBackButton = true
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||
|
||||
override func loadView() {
|
||||
let loginView = MastodonLoginView()
|
||||
|
||||
loginView.navigationActionView.nextButton.addTarget(self, action: #selector(MastodonLoginViewController.nextButtonPressed(_:)), for: .touchUpInside)
|
||||
loginView.navigationActionView.backButton.addTarget(self, action: #selector(MastodonLoginViewController.backButtonPressed(_:)), for: .touchUpInside)
|
||||
|
||||
view = loginView
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
setupOnboardingAppearance()
|
||||
}
|
||||
|
||||
//MARK: - Actions
|
||||
|
||||
@objc func backButtonPressed(_ sender: Any) {
|
||||
delegate?.backButtonPressed(self)
|
||||
}
|
||||
|
||||
@objc func nextButtonPressed(_ sender: Any) {
|
||||
delegate?.nextButtonPressed(self)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - OnboardingViewControllerAppearance
|
||||
extension MastodonLoginViewController: OnboardingViewControllerAppearance { }
|
||||
|
||||
|
||||
|
|
|
@ -322,7 +322,7 @@ extension MastodonRegisterViewController {
|
|||
)
|
||||
}()
|
||||
let viewModel = MastodonConfirmEmailViewModel(context: self.context, email: email, authenticateInfo: self.viewModel.authenticateInfo, userToken: userToken, updateCredentialQuery: updateCredentialQuery)
|
||||
self.coordinator.present(scene: .mastodonConfirmEmail(viewModel: viewModel), from: self, transition: .show)
|
||||
_ = self.coordinator.present(scene: .mastodonConfirmEmail(viewModel: viewModel), from: self, transition: .show)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
|
|
@ -322,8 +322,7 @@ extension WelcomeViewController {
|
|||
|
||||
@objc
|
||||
private func signInButtonDidClicked(_ sender: UIButton) {
|
||||
//TODO: @zeitschlag Present new login-scene
|
||||
_ = coordinator.present(scene: .mastodonPickServer(viewMode: MastodonPickServerViewModel(context: context, mode: .signIn)), from: self, transition: .show)
|
||||
_ = coordinator.present(scene: .mastodonLogin, from: self, transition: .show)
|
||||
}
|
||||
|
||||
@objc
|
||||
|
|
Loading…
Reference in New Issue