Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
../.DS_Store
.DS_Store
DoSport/.DS_Store

## User settings
xcuserdata/
Expand Down
12 changes: 12 additions & 0 deletions DoSport/DoSport.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
6511D76C25B0CC880063EF76 /* FormTextFieldView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6511D76B25B0CC880063EF76 /* FormTextFieldView.swift */; };
6511D77125B0DB130063EF76 /* DSTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6511D77025B0DB130063EF76 /* DSTextField.swift */; };
6511D77625B0E5A10063EF76 /* DSButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6511D77525B0E5A10063EF76 /* DSButton.swift */; };
651FBF0225FDE5F10018C6B1 /* AuthManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 651FBF0125FDE5F10018C6B1 /* AuthManager.swift */; };
6527303425C1B15B00550ED1 /* FeedFilterButtonsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6527303325C1B15B00550ED1 /* FeedFilterButtonsView.swift */; };
65294D9A25B38311003E7ED2 /* DatePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65294D9925B38311003E7ED2 /* DatePicker.swift */; };
6529500C258D6EE2002AA621 /* UIColor+inits.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6529500B258D6EE2002AA621 /* UIColor+inits.swift */; };
Expand Down Expand Up @@ -301,6 +302,7 @@
6511D76B25B0CC880063EF76 /* FormTextFieldView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormTextFieldView.swift; sourceTree = "<group>"; };
6511D77025B0DB130063EF76 /* DSTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DSTextField.swift; sourceTree = "<group>"; };
6511D77525B0E5A10063EF76 /* DSButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DSButton.swift; sourceTree = "<group>"; };
651FBF0125FDE5F10018C6B1 /* AuthManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthManager.swift; sourceTree = "<group>"; };
6527303325C1B15B00550ED1 /* FeedFilterButtonsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedFilterButtonsView.swift; sourceTree = "<group>"; };
65294D9925B38311003E7ED2 /* DatePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePicker.swift; sourceTree = "<group>"; };
6529500B258D6EE2002AA621 /* UIColor+inits.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+inits.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -611,6 +613,14 @@
path = PasswordEntry;
sourceTree = "<group>";
};
651FBF0025FDE5E50018C6B1 /* SocialMediaSignIn */ = {
isa = PBXGroup;
children = (
651FBF0125FDE5F10018C6B1 /* AuthManager.swift */,
);
path = SocialMediaSignIn;
sourceTree = "<group>";
};
6531791D25D10DF6001DBA4B /* EventCreate */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1292,6 +1302,7 @@
CEDEB83B258CE0EF007B2BCA /* Service */ = {
isa = PBXGroup;
children = (
651FBF0025FDE5E50018C6B1 /* SocialMediaSignIn */,
CEDEB83C258CE0FE007B2BCA /* Network */,
);
path = Service;
Expand Down Expand Up @@ -1731,6 +1742,7 @@
6568F8ED25B4F98200225043 /* FeedView.swift in Sources */,
CE0A6B58258FBA26007E02CC /* CustomPageControl.swift in Sources */,
65A62A0925E70109000AA184 /* DSEventCardView.swift in Sources */,
651FBF0225FDE5F10018C6B1 /* AuthManager.swift in Sources */,
653DA7D025B3590A000263C9 /* ImagePicker.swift in Sources */,
6572954825D9540500996440 /* TableViewMemberCell.swift in Sources */,
65CD774425EB3ECE00D042FD /* SoundListDataSource.swift in Sources */,
Expand Down
7 changes: 6 additions & 1 deletion DoSport/DoSport/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ final class AppCoordinator: Coordinator {
let coordinator: Coordinator

if isAuthorised {
coordinator = MainTabBarCoordinator(navController: navigationController)
if #available(iOS 13.0, *) {
coordinator = AuthCoordinator(navController: navigationController)
} else {
coordinator = MainTabBarCoordinator(navController: navigationController)
}

self.store(coordinator: coordinator)
coordinator.start()
} else {
Expand Down
7 changes: 6 additions & 1 deletion DoSport/DoSport/Flow/Auth/AuthAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@

import Foundation

@available(iOS 13.0, *)
final class AuthAssembly: Assembly {

func makeModule() -> AuthViewController {
let viewModel = AuthViewModel()
let viewController = AuthViewController(viewModel: viewModel)
let viewController: AuthViewController

let authManeger: AuthManagerProtocol = AuthManager()
viewController = AuthViewController(viewModel: viewModel, authManeger: authManeger)

return viewController
}
}
1 change: 1 addition & 0 deletions DoSport/DoSport/Flow/Auth/AuthCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import UIKit

@available(iOS 13.0, *)
final class AuthCoordinator: Coordinator {

let rootViewController: AuthViewController
Expand Down
100 changes: 67 additions & 33 deletions DoSport/DoSport/Flow/Auth/AuthView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
//

import UIKit
import SnapKit
import AuthenticationServices

protocol AuthViewDelegate: AnyObject {
func submitButtonTapped(with text: String)
func regionSelectionButtonTapped()
func appleSignInButtomClicked()
}

final class AuthView: UIView {
Expand Down Expand Up @@ -60,7 +61,13 @@ final class AuthView: UIView {
return $0
}(CommonButton(title: Texts.Auth.submit, state: .normal))

//MARK: - Init
@available(iOS 13.0, *)
private lazy var appleSignInButton: ASAuthorizationAppleIDButton = {
$0.addTarget(self, action: #selector(handleAppleSignInButton), for: .touchUpInside)
return $0
}(ASAuthorizationAppleIDButton())

//MARK: Init

init() {
super.init(frame: .zero)
Expand All @@ -80,7 +87,20 @@ final class AuthView: UIView {
object: nil
)

addSubviews(logoImageView,titleLabel,descriptionLabel,phoneNumberAddView,regulationsLabel,submitButton)
addSubviews(
logoImageView,
titleLabel,
descriptionLabel,
phoneNumberAddView,
regulationsLabel,
submitButton
)

if #available(iOS 13.0, *) {
addSubview(appleSignInButton)
} else {

}
}

required init?(coder: NSCoder) {
Expand Down Expand Up @@ -128,29 +148,61 @@ final class AuthView: UIView {
$0.height.equalTo(descriptionLabel)
}

submitButton.snp.makeConstraints {
if #available(iOS 11.0, *) {
$0.bottom.equalTo(self.safeAreaLayoutGuide.snp.bottom).offset(-20)
$0.width.centerX.height.equalTo(phoneNumberAddView)
} else {
$0.bottom.equalToSuperview().offset(-16)
$0.width.centerX.height.equalTo(phoneNumberAddView)
if #available(iOS 13.0, *) {
appleSignInButton.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.width.equalToSuperview()
$0.centerY.equalToSuperview()
$0.height.equalTo(submitButton.snp.height)
}
} else {

}

submitButton.snp.makeConstraints {
$0.bottom.equalTo(self.safeAreaInsets.bottom).offset(-20)
$0.width.centerX.height.equalTo(phoneNumberAddView)
}
}
}

//MARK: Public API

extension AuthView {

func bind(callingCode: String) {
phoneNumberAddView.bind(callingCode: callingCode)
submitButton.bind(state: .normal) // for test purposes, can be removed
layoutIfNeeded()
}

func becomeTextFieldResponder() {
phoneNumberAddView.becomeResponder()
}

func removeTextFieldResponder() {
phoneNumberAddView.removeFirstResponder()
}
}

//MARK: Actions

@objc private extension AuthView {

//MARK: - Actions
func handleAppleSignInButton() {
delegate?.appleSignInButtomClicked()
}

@objc private func handleSubmitButton() {
func handleSubmitButton() {
let text = phoneNumberAddView.text
delegate?.submitButtonTapped(with: text)
}

@objc private func handleRegionSelectionButton() {
func handleRegionSelectionButton() {
delegate?.regionSelectionButtonTapped()
}

@objc private func handleKeybordWillShow(_ notification: Notification) {
func handleKeybordWillShow(_ notification: Notification) {
guard
let userInfo = notification.userInfo,
let keyboardFrame = (
Expand All @@ -163,28 +215,10 @@ final class AuthView: UIView {
}
}

@objc private func handleKeybordWillHide() {
func handleKeybordWillHide() {
UIView.animate(withDuration: 0.3) {
self.submitButton.transform = .identity
}
}
}

//MARK: - Public Methods

extension AuthView {
func bind(callingCode: String) {
phoneNumberAddView.bind(callingCode: callingCode)
submitButton.bind(state: .normal) // for test purposes, can be removed
layoutIfNeeded()
}

func becomeTextFieldResponder() {
phoneNumberAddView.becomeResponder()
}

func removeTextFieldResponder() {
phoneNumberAddView.removeFirstResponder()
}
}

20 changes: 16 additions & 4 deletions DoSport/DoSport/Flow/Auth/AuthViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,33 @@

import UIKit

@available(iOS 13.0, *)
final class AuthViewController: UIViewController {

weak var coordinator: AuthCoordinator?
private let viewModel: AuthViewModel

private let authManager: AuthManagerProtocol?

private lazy var authView = self.view as! AuthView

override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}

// MARK: - Init
// MARK: Init

init(viewModel: AuthViewModel) {
init(viewModel: AuthViewModel, authManeger: AuthManagerProtocol?) {
self.viewModel = viewModel
self.authManager = authManeger
super.init(nibName: nil, bundle: nil)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - Life Cycle
// MARK: Life Cycle

override func loadView() {
let view = AuthView()
Expand All @@ -39,7 +43,7 @@ final class AuthViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

}

/// Hide navigation bar before this ViewController will appear
Expand Down Expand Up @@ -69,7 +73,15 @@ final class AuthViewController: UIViewController {
}
}

//MARK: - AuthViewDelegate -

@available(iOS 13.0, *)
extension AuthViewController: AuthViewDelegate {

func appleSignInButtomClicked() {
authManager?.signInWithApple(for: self)
}

func regionSelectionButtonTapped() {
coordinator?.goToCountryListModule { callingCode in
self.authView.bind(callingCode: callingCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ final class OnBoardingCoordinator: Coordinator {
}

func goToAuthView() {
let coordiator = AuthCoordinator(navController: navigationController)
store(coordinator: coordiator)
coordiator.start()
if #available(iOS 13.0, *) {
let coordiator = AuthCoordinator(navController: navigationController)
store(coordinator: coordiator)
coordiator.start()
}
}
}
Loading