git.iko.soy/dashared/GDproject
on master help sign in
started developing log in - log out
665bd8eDarya Rednikina
GDproject.xcodeproj/project.pbxproj+13−1
@@ -15,6 +15,7 @@
15 1288B5CE221F1158002BE6B1 /* DataStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1288B5CD221F1158002BE6B1 /* DataStorage.swift */; };
15 1288B5CE221F1158002BE6B1 /* DataStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1288B5CD221F1158002BE6B1 /* DataStorage.swift */; };
16 1291BE2D2221312D009D3F23 /* ChannelsCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE2C2221312C009D3F23 /* ChannelsCoordinator.swift */; };
16 1291BE2D2221312D009D3F23 /* ChannelsCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE2C2221312C009D3F23 /* ChannelsCoordinator.swift */; };
17 1291BE342221569B009D3F23 /* TabbarCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE332221569B009D3F23 /* TabbarCoordinator.swift */; };
17 1291BE342221569B009D3F23 /* TabbarCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE332221569B009D3F23 /* TabbarCoordinator.swift */; };
18+ 1291BE3622218DBF009D3F23 /* LogInCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE3522218DBF009D3F23 /* LogInCoordinator.swift */; };
18 12D7D133221C321600B35452 /* ChannelListController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12D7D132221C321600B35452 /* ChannelListController.swift */; };
19 12D7D133221C321600B35452 /* ChannelListController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12D7D132221C321600B35452 /* ChannelListController.swift */; };
19 12D7D135221C42B700B35452 /* ChannelController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12D7D134221C42B700B35452 /* ChannelController.swift */; };
20 12D7D135221C42B700B35452 /* ChannelController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12D7D134221C42B700B35452 /* ChannelController.swift */; };
20 12D7D137221D78E800B35452 /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12D7D136221D78E800B35452 /* Channel.swift */; };
21 12D7D137221D78E800B35452 /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12D7D136221D78E800B35452 /* Channel.swift */; };
@@ -74,6 +75,7 @@
74 1288B5CD221F1158002BE6B1 /* DataStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataStorage.swift; sourceTree = "<group>"; };
75 1288B5CD221F1158002BE6B1 /* DataStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataStorage.swift; sourceTree = "<group>"; };
75 1291BE2C2221312C009D3F23 /* ChannelsCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelsCoordinator.swift; sourceTree = "<group>"; };
76 1291BE2C2221312C009D3F23 /* ChannelsCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelsCoordinator.swift; sourceTree = "<group>"; };
76 1291BE332221569B009D3F23 /* TabbarCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabbarCoordinator.swift; sourceTree = "<group>"; };
77 1291BE332221569B009D3F23 /* TabbarCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabbarCoordinator.swift; sourceTree = "<group>"; };
78+ 1291BE3522218DBF009D3F23 /* LogInCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogInCoordinator.swift; sourceTree = "<group>"; };
77 12D7D132221C321600B35452 /* ChannelListController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelListController.swift; sourceTree = "<group>"; };
79 12D7D132221C321600B35452 /* ChannelListController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelListController.swift; sourceTree = "<group>"; };
78 12D7D134221C42B700B35452 /* ChannelController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelController.swift; sourceTree = "<group>"; };
80 12D7D134221C42B700B35452 /* ChannelController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelController.swift; sourceTree = "<group>"; };
79 12D7D136221D78E800B35452 /* Channel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Channel.swift; sourceTree = "<group>"; };
81 12D7D136221D78E800B35452 /* Channel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Channel.swift; sourceTree = "<group>"; };
@@ -140,6 +142,15 @@
140 path = "Coordinator tab bar?";
142 path = "Coordinator tab bar?";
141 sourceTree = "<group>";
143 sourceTree = "<group>";
142 };
144 };
145+ 1291BE3722218DC4009D3F23 /* Log In */ = {
146+ isa = PBXGroup;
147+ children = (
148+ 123E37A4221F1B3200F6E42A /* LogInViewController.swift */,
149+ 1291BE3522218DBF009D3F23 /* LogInCoordinator.swift */,
150+ );
151+ path = "Log In";
152+ sourceTree = "<group>";
153+ };
143 12E36D8F221424EA006FCDD7 = {
154 12E36D8F221424EA006FCDD7 = {
144 isa = PBXGroup;
155 isa = PBXGroup;
145 children = (
156 children = (
@@ -203,7 +214,7 @@
203 isa = PBXGroup;
214 isa = PBXGroup;
204 children = (
215 children = (
205 1291BE32222154C3009D3F23 /* Coordinator tab bar? */,
216 1291BE32222154C3009D3F23 /* Coordinator tab bar? */,
206− 123E37A4221F1B3200F6E42A /* LogInViewController.swift */,
217+ 1291BE3722218DC4009D3F23 /* Log In */,
207 1288B5CC221F0EFE002BE6B1 /* Profile */,
218 1288B5CC221F0EFE002BE6B1 /* Profile */,
208 12E36DD322156519006FCDD7 /* News and channels */,
219 12E36DD322156519006FCDD7 /* News and channels */,
209 );
220 );
@@ -306,6 +317,7 @@
306 files = (
317 files = (
307 12E36DD522156559006FCDD7 /* MyStackView.swift in Sources */,
318 12E36DD522156559006FCDD7 /* MyStackView.swift in Sources */,
308 12D7D137221D78E800B35452 /* Channel.swift in Sources */,
319 12D7D137221D78E800B35452 /* Channel.swift in Sources */,
320+ 1291BE3622218DBF009D3F23 /* LogInCoordinator.swift in Sources */,
309 12E36DB922144016006FCDD7 /* User.swift in Sources */,
321 12E36DB922144016006FCDD7 /* User.swift in Sources */,
310 125BD5812217314A008A3575 /* NewsVC.swift in Sources */,
322 125BD5812217314A008A3575 /* NewsVC.swift in Sources */,
311 12E36DB72214400A006FCDD7 /* Post.swift in Sources */,
323 12E36DB72214400A006FCDD7 /* Post.swift in Sources */,
GDproject/Base.lproj/Main.storyboard+1−1
@@ -465,7 +465,7 @@
465 <!--Navigation Controller-->
465 <!--Navigation Controller-->
466 <scene sceneID="r0M-xH-UwU">
466 <scene sceneID="r0M-xH-UwU">
467 <objects>
467 <objects>
468− <navigationController id="609-2j-gc9" sceneMemberID="viewController">
468+ <navigationController storyboardIdentifier="root" id="609-2j-gc9" sceneMemberID="viewController">
469 <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Ah8-NU-AsD">
469 <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Ah8-NU-AsD">
470 <rect key="frame" x="0.0" y="20" width="375" height="44"/>
470 <rect key="frame" x="0.0" y="20" width="375" height="44"/>
471 <autoresizingMask key="autoresizingMask"/>
471 <autoresizingMask key="autoresizingMask"/>
GDproject/Controller/Log In/LogInCoordinator.swiftnew file+42
@@ -0,0 +1,42 @@
1+//
2+// LogInCoordinator.swift
3+// GDproject
4+//
5+// Created by cstore on 23/02/2019.
6+// Copyright © 2019 drHSE. All rights reserved.
7+//
8+
9+import UIKit
10+
11+class LogInCoordinator{
12+
13+ private weak var navigationController: UINavigationController?
14+ private var window: UIWindow!
15+ // MARK:- Init
16+ init(navigationController: UINavigationController, window: UIWindow) {
17+ self.navigationController = navigationController
18+ self.window = window
19+ }
20+
21+ func start(){
22+ showLogInPage()
23+ }
24+
25+ // MARK: - Private implementation
26+ private func showStatusPage(){
27+ let controller = TabbarCoordinator(window: window)
28+ controller.start()
29+ }
30+
31+ private func showLogInPage(){
32+ let controller = UIStoryboard.makeLogIn()
33+ //controller.channel = channel
34+ controller.onLogIn = { [weak self] in
35+ self?.showStatusPage()
36+ DataStorage.standard.setIsLoggedIn(value: true)
37+ }
38+ //navigationController?.setViewControllers([controller], animated: false)
39+ navigationController?.pushViewController(controller, animated: false)
40+ }
41+
42+}
GDproject/Controller/LogInViewController.swift → GDproject/Controller/Log In/LogInViewController.swiftrenamed+3−5
@@ -12,6 +12,8 @@ class LogInViewController: UIViewController {
12
12
13 @IBOutlet weak var mailTextField: UITextField!
13 @IBOutlet weak var mailTextField: UITextField!
14
14
15+ var onLogIn: (()->())?
16+
15 static let titleColor = UIColor(red: 0, green: 137/255, blue: 249/255, alpha: 0.5)
17 static let titleColor = UIColor(red: 0, green: 137/255, blue: 249/255, alpha: 0.5)
16
18
17 var bottomConstraint: NSLayoutConstraint?
19 var bottomConstraint: NSLayoutConstraint?
@@ -62,11 +64,7 @@ class LogInViewController: UIViewController {
62 @objc func activateLogInProcess(){
64 @objc func activateLogInProcess(){
63 if logInButton.isEnabled {
65 if logInButton.isEnabled {
64 // MARK:- when log in is succeeded do I need to go there?
66 // MARK:- when log in is succeeded do I need to go there?
65− let vc = storyboard!.instantiateViewController(withIdentifier: newsController) as! NewsController
67+ onLogIn?()
66− present(vc, animated: true) {
67− print("logged in")
68− }
69− DataStorage.standard.setIsLoggedIn(value: true)
70 view.endEditing(true)
68 view.endEditing(true)
71 }
69 }
72 }
70 }
GDproject/Controller/Profile/ProfileViewController.swift+10−2
@@ -104,12 +104,20 @@ class ProfileViewController: UIViewController
104 }
104 }
105
105
106 let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
106 let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
107− let shareAction = UIAlertAction(title: "Share", style: .default)
107+ let logoutAction = UIAlertAction(title: "Log out", style: .destructive)
108+ {
109+ [weak self] (_) in
110+
111+ let root = UIStoryboard.navRoot()
112+ UIApplication.shared.keyWindow?.rootViewController = root
113+ let coordinator = LogInCoordinator(navigationController: root, window: UIApplication.shared.keyWindow!)
114+ coordinator.start()
115+ }
108
116
109 optionMenu.addAction(editAction)
117 optionMenu.addAction(editAction)
110 optionMenu.addAction(settingsAction)
118 optionMenu.addAction(settingsAction)
111 optionMenu.addAction(copyLink)
119 optionMenu.addAction(copyLink)
112− optionMenu.addAction(shareAction)
120+ optionMenu.addAction(logoutAction)
113 optionMenu.addAction(cancelAction)
121 optionMenu.addAction(cancelAction)
114
122
115 self.present(optionMenu, animated: true, completion: nil)
123 self.present(optionMenu, animated: true, completion: nil)
GDproject/Extentions.swift+6−2
@@ -52,7 +52,11 @@ extension UIStoryboard {
52 return UIStoryboard.userEdit.instantiateViewController(withIdentifier: "TabBar") as! UITabBarController
52 return UIStoryboard.userEdit.instantiateViewController(withIdentifier: "TabBar") as! UITabBarController
53 }
53 }
54
54
55− class func navChannels() ->UINavigationController{
55+ class func navRoot() -> UINavigationController{
56− return UIStoryboard.userEdit.instantiateViewController(withIdentifier: "navChannels") as! UINavigationController
56+ return UIStoryboard.userEdit.instantiateViewController(withIdentifier: "root") as! UINavigationController
57+ }
58+
59+ class func makeLogIn() -> LogInViewController {
60+ return UIStoryboard.userEdit.instantiateViewController(withIdentifier: logInController) as! LogInViewController
57 }
61 }
58}
62}
GDproject/Supporting files/AppDelegate.swift+8−3
@@ -11,7 +11,7 @@ import UIKit
11@UIApplicationMain
11@UIApplicationMain
12class AppDelegate: UIResponder, UIApplicationDelegate {
12class AppDelegate: UIResponder, UIApplicationDelegate {
13
13
14− var coordinator: ChannelsCoordinator!
14+ var coordinator: LogInCoordinator!
15 var tabCoordinator: TabbarCoordinator!
15 var tabCoordinator: TabbarCoordinator!
16
16
17 var window: UIWindow?
17 var window: UIWindow?
@@ -27,8 +27,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
27 {
27 {
28
28
29 // TODO:- determine what to do here: log in or tabbar
29 // TODO:- determine what to do here: log in or tabbar
30+ if DataStorage.standard.isLoggedIn() {
30− tabCoordinator = TabbarCoordinator(window: window!)
31+ tabCoordinator = TabbarCoordinator(window: window!)
31− tabCoordinator.start()
32+ tabCoordinator.start()
33+ } else {
34+ coordinator = LogInCoordinator(navigationController: rootController!, window: window!)
35+ coordinator.start()
36+ }
32
37
33 return true
38 return true
34 }
39 }