From cd552b43f2b0e0821e3c6b956327025b832883b4 Mon Sep 17 00:00:00 2001 From: Ray suh Date: Sat, 25 Sep 2021 15:29:03 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20[#195]=20LoginManager=20class=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FullStackCodingBot.xcodeproj/project.pbxproj | 16 ++++++++++++++-- .../Service/LoginManager/LoginManager.swift | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift diff --git a/FullStackCodingBot/FullStackCodingBot.xcodeproj/project.pbxproj b/FullStackCodingBot/FullStackCodingBot.xcodeproj/project.pbxproj index 64a2b49..19568b3 100644 --- a/FullStackCodingBot/FullStackCodingBot.xcodeproj/project.pbxproj +++ b/FullStackCodingBot/FullStackCodingBot.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ 71307AB126A53C7B00C3191F /* AlertMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71307AB026A53C7B00C3191F /* AlertMessage.swift */; }; 71307AB926A5437C00C3191F /* StorageTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71307AB826A5437C00C3191F /* StorageTest.swift */; }; 71307AC126A5461700C3191F /* Unit.swift in Sources */ = {isa = PBXBuildFile; fileRef = E45B0AC82692F9CF006FDE3D /* Unit.swift */; }; + 7130B74026FEF8FD00DE90F3 /* LoginManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7130B73F26FEF8FD00DE90F3 /* LoginManager.swift */; }; 71310C2C26AA596B00733361 /* CoreDataStorage.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 71310C2A26AA596B00733361 /* CoreDataStorage.xcdatamodeld */; }; 71310C2D26AA596B00733361 /* CoreDataStorage.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 71310C2A26AA596B00733361 /* CoreDataStorage.xcdatamodeld */; }; 715A83EE269FE96300C9CEFF /* StoryboardType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 715A83ED269FE96300C9CEFF /* StoryboardType.swift */; }; @@ -180,6 +181,7 @@ 71307AB626A5437C00C3191F /* Full StackTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Full StackTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 71307AB826A5437C00C3191F /* StorageTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageTest.swift; sourceTree = ""; }; 71307ABA26A5437C00C3191F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 7130B73F26FEF8FD00DE90F3 /* LoginManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginManager.swift; sourceTree = ""; }; 71310C2B26AA596B00733361 /* CoreDataStorage.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = CoreDataStorage.xcdatamodel; sourceTree = ""; }; 715A83ED269FE96300C9CEFF /* StoryboardType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryboardType.swift; sourceTree = ""; }; 715C1C9326BCF9FF0025C681 /* StoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryViewController.swift; sourceTree = ""; }; @@ -350,12 +352,21 @@ path = "Full StackTests"; sourceTree = ""; }; + 7130B73E26FEF8F100DE90F3 /* LoginManager */ = { + isa = PBXGroup; + children = ( + 7130B73F26FEF8FD00DE90F3 /* LoginManager.swift */, + ); + path = LoginManager; + sourceTree = ""; + }; 715BB20426943CD100286B31 /* Service */ = { isa = PBXGroup; children = ( - E4336F6426F08A8D0049A5D8 /* Storage */, - 717EAD3B26A656E200E0CDB7 /* GameLogic */, + 7130B73E26FEF8F100DE90F3 /* LoginManager */, 718F224726C377AA00B2648C /* ErrorManager */, + 717EAD3B26A656E200E0CDB7 /* GameLogic */, + E4336F6426F08A8D0049A5D8 /* Storage */, ); path = Service; sourceTree = ""; @@ -1141,6 +1152,7 @@ 71E91E1726BA33190016386E /* Extension.swift in Sources */, 7170CD4526B266BE00F03248 /* VersionErrorViewController.swift in Sources */, 719D0D9026F1863200913BBE /* MainScene.swift in Sources */, + 7130B74026FEF8FD00DE90F3 /* LoginManager.swift in Sources */, E4CA08B926A8287B00AA6F03 /* Font.swift in Sources */, E4BF710B26B1324500E8645F /* ReadyView.swift in Sources */, 71DF64B92692C13A00557693 /* ShopViewController.swift in Sources */, diff --git a/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift new file mode 100644 index 0000000..8234a46 --- /dev/null +++ b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift @@ -0,0 +1,5 @@ +import Foundation + +final class LoginManager { + +} From 995852dfc47e5ce676ebf8d9a6597b9c5d1053c8 Mon Sep 17 00:00:00 2001 From: Ray suh Date: Sat, 25 Sep 2021 15:41:47 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20[#195]=20GameKit=20import=20?= =?UTF-8?q?=EB=B0=8F=20NSObject=20=EC=B1=84=ED=83=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/LoginManager/LoginManager.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift index 8234a46..00ad168 100644 --- a/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift +++ b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift @@ -1,5 +1,13 @@ import Foundation +import RxSwift +import GameKit -final class LoginManager { +final class LoginManager: NSObject { } + +extension LoginManager: GKGameCenterControllerDelegate { + func gameCenterViewControllerDidFinish(_ gameCenterViewController: GKGameCenterViewController) { + + } +} From aacb04742418e54d0c5eb1ea899b0dcdd102960a Mon Sep 17 00:00:00 2001 From: Ray suh Date: Sat, 25 Sep 2021 15:47:23 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20[#195]=20LoginResult=20=EB=B0=8F=20?= =?UTF-8?q?LoginManagerType=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FullStackCodingBot.xcodeproj/project.pbxproj | 8 ++++++++ .../Service/LoginManager/LoginManager.swift | 7 +++++-- .../Service/LoginManager/LoginManagerType.swift | 8 ++++++++ .../Service/LoginManager/LoginResult.swift | 7 +++++++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManagerType.swift create mode 100644 FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginResult.swift diff --git a/FullStackCodingBot/FullStackCodingBot.xcodeproj/project.pbxproj b/FullStackCodingBot/FullStackCodingBot.xcodeproj/project.pbxproj index 19568b3..e6de1f2 100644 --- a/FullStackCodingBot/FullStackCodingBot.xcodeproj/project.pbxproj +++ b/FullStackCodingBot/FullStackCodingBot.xcodeproj/project.pbxproj @@ -22,6 +22,8 @@ 71307AB926A5437C00C3191F /* StorageTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71307AB826A5437C00C3191F /* StorageTest.swift */; }; 71307AC126A5461700C3191F /* Unit.swift in Sources */ = {isa = PBXBuildFile; fileRef = E45B0AC82692F9CF006FDE3D /* Unit.swift */; }; 7130B74026FEF8FD00DE90F3 /* LoginManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7130B73F26FEF8FD00DE90F3 /* LoginManager.swift */; }; + 7130B74426FEFC4700DE90F3 /* LoginManagerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7130B74326FEFC4700DE90F3 /* LoginManagerType.swift */; }; + 7130B74626FEFCDA00DE90F3 /* LoginResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7130B74526FEFCDA00DE90F3 /* LoginResult.swift */; }; 71310C2C26AA596B00733361 /* CoreDataStorage.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 71310C2A26AA596B00733361 /* CoreDataStorage.xcdatamodeld */; }; 71310C2D26AA596B00733361 /* CoreDataStorage.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 71310C2A26AA596B00733361 /* CoreDataStorage.xcdatamodeld */; }; 715A83EE269FE96300C9CEFF /* StoryboardType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 715A83ED269FE96300C9CEFF /* StoryboardType.swift */; }; @@ -182,6 +184,8 @@ 71307AB826A5437C00C3191F /* StorageTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageTest.swift; sourceTree = ""; }; 71307ABA26A5437C00C3191F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 7130B73F26FEF8FD00DE90F3 /* LoginManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginManager.swift; sourceTree = ""; }; + 7130B74326FEFC4700DE90F3 /* LoginManagerType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginManagerType.swift; sourceTree = ""; }; + 7130B74526FEFCDA00DE90F3 /* LoginResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginResult.swift; sourceTree = ""; }; 71310C2B26AA596B00733361 /* CoreDataStorage.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = CoreDataStorage.xcdatamodel; sourceTree = ""; }; 715A83ED269FE96300C9CEFF /* StoryboardType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryboardType.swift; sourceTree = ""; }; 715C1C9326BCF9FF0025C681 /* StoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryViewController.swift; sourceTree = ""; }; @@ -356,6 +360,8 @@ isa = PBXGroup; children = ( 7130B73F26FEF8FD00DE90F3 /* LoginManager.swift */, + 7130B74326FEFC4700DE90F3 /* LoginManagerType.swift */, + 7130B74526FEFCDA00DE90F3 /* LoginResult.swift */, ); path = LoginManager; sourceTree = ""; @@ -1073,6 +1079,7 @@ 7164BFD2269679C6009769E4 /* MainItemView.swift in Sources */, E4150E9726B8F3E00041DD32 /* TypeWriterView.swift in Sources */, 71310C2C26AA596B00733361 /* CoreDataStorage.xcdatamodeld in Sources */, + 7130B74426FEFC4700DE90F3 /* LoginManagerType.swift in Sources */, E4BF710526AFD45A00E8645F /* TimeManagerType.swift in Sources */, E4336F5F26F083840049A5D8 /* BackUpCenterType.swift in Sources */, 710D0D4F2693F6E500244A16 /* ItemCell.swift in Sources */, @@ -1135,6 +1142,7 @@ E4DF614126A92CE00061F6E9 /* ShopItem.swift in Sources */, E4F4304426C4F8F500F046E9 /* GameStoryManager.swift in Sources */, E4F4304626CA2E4500F046E9 /* UnitInfo.swift in Sources */, + 7130B74626FEFCDA00DE90F3 /* LoginResult.swift in Sources */, E4BF713B26B7D2CC00E8645F /* SingleSoundEffectStation.swift in Sources */, E4D7C6422693E7B200D58BA2 /* MainViewController.swift in Sources */, E4150EA126BE44BD0041DD32 /* FullImageStoryView.swift in Sources */, diff --git a/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift index 00ad168..5f205fb 100644 --- a/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift +++ b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift @@ -6,8 +6,11 @@ final class LoginManager: NSObject { } -extension LoginManager: GKGameCenterControllerDelegate { +extension LoginManager: GKGameCenterControllerDelegate, LoginManagerType { + func gameCenterViewControllerDidFinish(_ gameCenterViewController: GKGameCenterViewController) { - + } + + func getLoginResult() -> Observable { } } diff --git a/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManagerType.swift b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManagerType.swift new file mode 100644 index 0000000..7f00fce --- /dev/null +++ b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManagerType.swift @@ -0,0 +1,8 @@ +import Foundation +import RxSwift +import GameKit + +protocol LoginManagerType { + func getLoginResult() -> Observable +} + diff --git a/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginResult.swift b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginResult.swift new file mode 100644 index 0000000..e2717ca --- /dev/null +++ b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginResult.swift @@ -0,0 +1,7 @@ +import Foundation + +enum LoginResult { + case needToLogin + case success + case failure +} From f79b5c9923e29e7f9a44f56c412a22a0f85a9df5 Mon Sep 17 00:00:00 2001 From: Ray suh Date: Sat, 25 Sep 2021 15:59:58 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20[#195]=20LoginMethod=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/LoginManager/LoginManager.swift | 48 +++++++++++++++++-- .../Service/LoginManager/LoginResult.swift | 9 ++-- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift index 5f205fb..edc368c 100644 --- a/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift +++ b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginManager.swift @@ -1,16 +1,54 @@ import Foundation import RxSwift import GameKit +import FirebaseAuth -final class LoginManager: NSObject { +final class LoginManager: NSObject, LoginManagerType { + func getLoginResult() -> Observable { + Observable.create { observer in + var result = LoginResult() + GKLocalPlayer.local.authenticateHandler = { gcViewController, error in + + if let gcViewController = gcViewController { + result.gameVC = gcViewController + observer.onNext(result) + + } else if let error = error { + observer.onError(error) + + } else { + GameCenterAuthProvider.getCredential { credential, error in + + if let error = error { + observer.onError(error) + } + + guard let credential = credential else { + return + } + + Auth.auth().signIn(with: credential) { user, error in + if let error = error { + observer.onError(error) + } + + if let user = user { + result.uuid = user.user.uid + observer.onNext(result) + observer.onCompleted() + } + } + } + } + } + return Disposables.create() + } + } } -extension LoginManager: GKGameCenterControllerDelegate, LoginManagerType { +extension LoginManager: GKGameCenterControllerDelegate { func gameCenterViewControllerDidFinish(_ gameCenterViewController: GKGameCenterViewController) { } - - func getLoginResult() -> Observable { - } } diff --git a/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginResult.swift b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginResult.swift index e2717ca..6f18bd2 100644 --- a/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginResult.swift +++ b/FullStackCodingBot/FullStackCodingBot/Service/LoginManager/LoginResult.swift @@ -1,7 +1,6 @@ -import Foundation +import UIKit -enum LoginResult { - case needToLogin - case success - case failure +struct LoginResult { + var gameVC: UIViewController? + var uuid: String? }