Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auth - 리펙토링 #351

Merged
merged 9 commits into from
Jun 26, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

// func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
// if (AuthApi.isKakaoTalkLoginUrl(url)) {
// return AuthController.handleOpenUrl(url: url)
// }
// return false
// }

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
KakaoSDK.initSDK(appKey: "dcfcd3ab4a997c5a53e2ab26a8ec2a63")
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,35 @@ import AuthFeatureInterface
class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?
var coordinator = FlowCoordinator()
var mainFlow: AuthFlow!

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
if let url = URLContexts.first?.url {
if (AuthApi.isKakaoTalkLoginUrl(url)) {
_ = AuthController.handleOpenUrl(url: url)
}
handleURL(url)
}
}

var coordinator = FlowCoordinator()
var mainFlow: AuthFlow!

func scene(_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
guard let scene = (scene as? UIWindowScene) else { return }
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let scene = scene as? UIWindowScene else { return }

window = UIWindow(frame: scene.coordinateSpace.bounds)
window?.windowScene = scene
configureMainFlow()
window?.makeKeyAndVisible()
}

mainFlow = AuthFlow()
private func handleURL(_ url: URL) {
if AuthApi.isKakaoTalkLoginUrl(url) {
_ = AuthController.handleOpenUrl(url: url)
}
}

private func configureMainFlow() {
mainFlow = AuthFlow()
coordinator.coordinate(flow: mainFlow, with: OneStepper(withSingleStep: MGStep.authSplashIsRequired))
Flows.use(mainFlow, when: .created) { root in
self.window?.rootViewController = root
self.window?.makeKey()
Flows.use(mainFlow, when: .created) { [weak self] root in
self?.window?.rootViewController = root
}
window?.makeKeyAndVisible()
}

// private func coordinatorLogStart() {
// coordinator.rx.willNavigate
// .subscribe(onNext: { flow, step in
// let currentFlow = "\(flow)".split(separator: ".").last ?? "no flow"
// print("➡️ will navigate to flow = \(currentFlow) and step = \(step)")
// })
// .disposed(by: disposeBag)
//
// // didNavigate
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ import RxCocoa
import BaseFeatureDependency
import Core

//public protocol AuthViewControllable: ViewControllable {}
public protocol AuthCoordintable {
// var goolgeButtonTap: (() -> Void)? { get set }
// var appleButtonTap: (() -> Void)? { get set }
// var kakaoButtonTap: (() -> Bool)? { get set }

var disposeBag: DisposeBag { get set }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,45 +48,33 @@ public class IntroViewModel: AuthViewModelType {

public func transform(_ input: Input, action: (Output) -> Void) -> Output {

let output = Output(introDatas: introModelSubject.asObservable(), showGoogleAlert: showGoogleAlertSubject.asObservable())
let output = Output(
introDatas: introModelSubject.asObservable(),
showGoogleAlert: showGoogleAlertSubject.asObservable()
)

action(output)

bindInputs(input)
bindOutput(output: output)

input.goolgeButtonTapped
.asObservable()
.withUnretained(self)
.subscribe(onNext: { owner, _ in
owner.showGoogleAlertSubject.onNext(())
})
.disposed(by: disposeBag)

input.kakaoButtonTapped
.asObservable()
.withUnretained(self)
.subscribe(onNext: { owner, _ in
owner.useCase.kakaoButtonTap()
})
.disposed(by: disposeBag)

input.appleButtonTapped
.asObservable()
.withUnretained(self)
.subscribe(onNext: { owner, _ in
owner.useCase.appleButtonTap()
})
.disposed(by: disposeBag)

input.getIntroData
return output
}

private func bindButtonTap(_ driver: Driver<Void>, handler: @escaping () -> Void) {
driver
.asObservable()
.withUnretained(self)
.subscribe(onNext: { owner, _ in
owner.useCase.getIntroData()
handler()
})
.disposed(by: disposeBag)

return output
}

private func bindInputs(_ input: Input) {
bindButtonTap(input.goolgeButtonTapped, handler: { self.showGoogleAlertSubject.onNext(()) })
bindButtonTap(input.appleButtonTapped, handler: { self.useCase.appleButtonTap() })
bindButtonTap(input.kakaoButtonTapped, handler: { self.useCase.kakaoButtonTap() })
bindButtonTap(input.getIntroData, handler: { self.useCase.getIntroData() })
}

private func bindOutput(output: Output) {
Expand All @@ -104,19 +92,3 @@ public class IntroViewModel: AuthViewModelType {
.disposed(by: disposeBag)
}
}

private extension IntroViewModel {
// func kakaoGetUserInfo() {
// UserApi.shared.me() { (user, error) in
// if let error = error {
// print(error)
// }
//
// let userName = user?.kakaoAccount?.name
//
// _ = "user name : \(String(describing: userName))"
//
// print("user - \(String(describing: user))")
// }
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public class SplashViewModel: AuthViewModelType {
self.useCase = authUseCase
self.disposeBag = DisposeBag()
useCase.tokenReIssue()
// useCase.getAllPoseData()

}

public func transform(_ input: Input, action: (Output) -> Void) -> Output {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import Core
import DSKit

public class AuthSeemoreButton: BaseButton {

// private var containerView = UIView()


private var textLabel = MGLabel(text: "자세히 보기", font: UIFont.Pretendard.labelSmall, textColor: DSKitAsset.Colors.gray300.color, isCenter: true)

private var lineView = MGLine(lineColor: DSKitAsset.Colors.gray300.color, lineWidth: 1.0)
Expand Down
Loading
Loading