Skip to content

Commit

Permalink
⚡️ :: logout ViewModel
Browse files Browse the repository at this point in the history
  • Loading branch information
jangseoyoung committed Nov 23, 2021
1 parent 0a5058d commit ecc6141
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Sources/View/MyPage/MyPageMenuTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import UIKit
import SnapKit
import Then
import RxCocoa
import RxSwift

class MyPageMenuTableViewCell: UITableViewCell {

Expand Down Expand Up @@ -78,4 +80,8 @@ class MyPageMenuTableViewCell: UITableViewCell {
$0.right.equalToSuperview().offset(-13)
}
}

private func bind() {

}
}
22 changes: 21 additions & 1 deletion Sources/View/MyPage/MyPageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
import UIKit
import SnapKit
import Then
import RxSwift
import RxCocoa
import KeychainSwift
import Loaf

class MyPageViewController: UIViewController {

private let viewModel = MyPageViewModel()

private let logOutButtonTapped = PublishSubject<Void>()

private lazy var profileImageView = UIImageView().then {
$0.image = R.image.profileImage()
}
Expand All @@ -37,7 +43,7 @@ class MyPageViewController: UIViewController {
setupSubview()
setNavigationBar()
}

override func viewWillAppear(_ animated: Bool) {
tabBarController?.tabBar.isHidden = false
}
Expand Down Expand Up @@ -142,8 +148,22 @@ extension MyPageViewController: UITableViewDelegate, UITableViewDataSource {
navigationController?.pushViewController(LikedProductViewController(), animated: true)
case [1, 1]:
navigationController?.pushViewController(EditProfileViewController(), animated: true)
case [1, 2]:
KeychainSwift().delete("ACCESS-TOKEN")
Loaf(
"로그아웃되었습니다.",
state: .success,
location: .bottom,
presentingDirection: .vertical,
dismissingDirection: .vertical,
sender: self).show()

default:
break
}
}

private func bindViewModel() {

}
}
12 changes: 12 additions & 0 deletions Sources/ViewModel/MyPage/MyPageViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,31 @@

import Foundation
import RxSwift
import RxCocoa
import KeychainSwift

class MyPageViewModel: ViewModel {

let disposeBag = DisposeBag()
let output = Output()

struct Input {
let logOutButtonIsTapped: Driver<Void>
let notificationSwitchIsOn: Driver<Void>
}

struct Output {
var logOutResult = PublishRelay<Bool>()
}

func transform(_ input: Input) -> Output {
input.logOutButtonIsTapped.asObservable()
.subscribe(
onNext: {
KeychainSwift().delete("ACCESS-TOKEN")
}
).disposed(by: disposeBag)

return output
}
}

0 comments on commit ecc6141

Please sign in to comment.