chore: make sign in works
This commit is contained in:
parent
e6ad839d3c
commit
87a7a1e91f
|
@ -853,10 +853,10 @@
|
||||||
DB8AF55525C1379F002E6C99 /* Scene */ = {
|
DB8AF55525C1379F002E6C99 /* Scene */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
0FAA102525E1125D0017CCDE /* PickServer */,
|
|
||||||
0FAA0FDD25E0B5700017CCDE /* Welcome */,
|
|
||||||
2D7631A425C1532200929FB9 /* Share */,
|
2D7631A425C1532200929FB9 /* Share */,
|
||||||
DB8AF54E25C13703002E6C99 /* MainTab */,
|
DB8AF54E25C13703002E6C99 /* MainTab */,
|
||||||
|
0FAA0FDD25E0B5700017CCDE /* Welcome */,
|
||||||
|
0FAA102525E1125D0017CCDE /* PickServer */,
|
||||||
DB01409B25C40BB600F9F3CF /* Authentication */,
|
DB01409B25C40BB600F9F3CF /* Authentication */,
|
||||||
2D38F1D325CD463600561493 /* HomeTimeline */,
|
2D38F1D325CD463600561493 /* HomeTimeline */,
|
||||||
2D76316325C14BAC00929FB9 /* PublicTimeline */,
|
2D76316325C14BAC00929FB9 /* PublicTimeline */,
|
||||||
|
|
|
@ -59,8 +59,9 @@ extension SceneCoordinator {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
var rootViewController: UIViewController
|
var rootViewController: UIViewController
|
||||||
if fetchResult.isEmpty {
|
if fetchResult.isEmpty {
|
||||||
let welcomeNaviVC = UINavigationController(rootViewController: WelcomeViewController())
|
let welcomViewController = WelcomeViewController()
|
||||||
rootViewController = welcomeNaviVC
|
self.setupDependency(for: welcomViewController)
|
||||||
|
rootViewController = UINavigationController(rootViewController: welcomViewController)
|
||||||
} else {
|
} else {
|
||||||
rootViewController = MainTabBarController(context: self.appContext, coordinator: self)
|
rootViewController = MainTabBarController(context: self.appContext, coordinator: self)
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,6 @@
|
||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
</array>
|
</array>
|
||||||
<key>UIUserInterfaceStyle</key>
|
|
||||||
<string>Dark</string>
|
|
||||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||||
<true/>
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
|
|
|
@ -5,9 +5,18 @@
|
||||||
// Created by 高原 on 2021/2/20.
|
// Created by 高原 on 2021/2/20.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import os.log
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
final class WelcomeViewController: UIViewController {
|
final class WelcomeViewController: UIViewController, NeedsDependency {
|
||||||
|
|
||||||
|
weak var context: AppContext! { willSet { precondition(!isViewLoaded) } }
|
||||||
|
weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } }
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
let authenticationViewController = AuthenticationViewController()
|
||||||
|
#endif
|
||||||
|
|
||||||
let logoImageView: UIImageView = {
|
let logoImageView: UIImageView = {
|
||||||
let imageView = UIImageView(image: Asset.welcomeLogo.image)
|
let imageView = UIImageView(image: Asset.welcomeLogo.image)
|
||||||
imageView.translatesAutoresizingMaskIntoConstraints = false
|
imageView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
@ -27,6 +36,7 @@ final class WelcomeViewController: UIViewController {
|
||||||
|
|
||||||
let signUpButton: PrimaryActionButton = {
|
let signUpButton: PrimaryActionButton = {
|
||||||
let button = PrimaryActionButton(type: .system)
|
let button = PrimaryActionButton(type: .system)
|
||||||
|
button.titleLabel?.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold))
|
||||||
button.setTitle(L10n.Button.signUp, for: .normal)
|
button.setTitle(L10n.Button.signUp, for: .normal)
|
||||||
button.translatesAutoresizingMaskIntoConstraints = false
|
button.translatesAutoresizingMaskIntoConstraints = false
|
||||||
return button
|
return button
|
||||||
|
@ -34,9 +44,9 @@ final class WelcomeViewController: UIViewController {
|
||||||
|
|
||||||
let signInButton: UIButton = {
|
let signInButton: UIButton = {
|
||||||
let button = UIButton(type: .system)
|
let button = UIButton(type: .system)
|
||||||
|
button.titleLabel?.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 15, weight: .semibold))
|
||||||
button.setTitle(L10n.Button.signIn, for: .normal)
|
button.setTitle(L10n.Button.signIn, for: .normal)
|
||||||
button.setTitleColor(Asset.Colors.lightBrandBlue.color, for: .normal)
|
button.setTitleColor(Asset.Colors.lightBrandBlue.color, for: .normal)
|
||||||
button.titleLabel?.font = .preferredFont(forTextStyle: .subheadline)
|
|
||||||
button.setInsets(forContentPadding: UIEdgeInsets(top: 12, left: 0, bottom: 12, right: 0), imageTitlePadding: 0)
|
button.setInsets(forContentPadding: UIEdgeInsets(top: 12, left: 0, bottom: 12, right: 0), imageTitlePadding: 0)
|
||||||
button.translatesAutoresizingMaskIntoConstraints = false
|
button.translatesAutoresizingMaskIntoConstraints = false
|
||||||
return button
|
return button
|
||||||
|
@ -45,13 +55,10 @@ final class WelcomeViewController: UIViewController {
|
||||||
|
|
||||||
extension WelcomeViewController {
|
extension WelcomeViewController {
|
||||||
|
|
||||||
override var preferredStatusBarStyle: UIStatusBarStyle {
|
|
||||||
return .darkContent
|
|
||||||
}
|
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
overrideUserInterfaceStyle = .light
|
||||||
view.backgroundColor = Asset.Colors.Background.onboardingBackground.color
|
view.backgroundColor = Asset.Colors.Background.onboardingBackground.color
|
||||||
|
|
||||||
view.addSubview(logoImageView)
|
view.addSubview(logoImageView)
|
||||||
|
@ -80,10 +87,35 @@ extension WelcomeViewController {
|
||||||
view.readableContentGuide.trailingAnchor.constraint(equalTo: signUpButton.trailingAnchor, constant: 12),
|
view.readableContentGuide.trailingAnchor.constraint(equalTo: signUpButton.trailingAnchor, constant: 12),
|
||||||
signInButton.topAnchor.constraint(equalTo: signUpButton.bottomAnchor, constant: 5)
|
signInButton.topAnchor.constraint(equalTo: signUpButton.bottomAnchor, constant: 5)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
signInButton.addTarget(self, action: #selector(WelcomeViewController.signInButtonPressed(_:)), for: .touchUpInside)
|
||||||
|
signUpButton.addTarget(self, action: #selector(WelcomeViewController.signUpButtonPressed(_:)), for: .touchUpInside)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
super.viewWillAppear(animated)
|
super.viewWillAppear(animated)
|
||||||
navigationController?.setNavigationBarHidden(true, animated: false)
|
navigationController?.setNavigationBarHidden(true, animated: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension WelcomeViewController {
|
||||||
|
|
||||||
|
@objc private func signInButtonPressed(_ sender: UIButton) {
|
||||||
|
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
authenticationViewController.context = context
|
||||||
|
authenticationViewController.coordinator = coordinator
|
||||||
|
authenticationViewController.viewModel = AuthenticationViewModel(context: context, coordinator: coordinator, isAuthenticationExist: true)
|
||||||
|
authenticationViewController.viewModel.domain.value = "pawoo.net"
|
||||||
|
let _ = authenticationViewController.view // trigger view load
|
||||||
|
authenticationViewController.signInButton.sendActions(for: .touchUpInside)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func signUpButtonPressed(_ sender: UIButton) {
|
||||||
|
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue