Skip to content

Commit

Permalink
✨ About 화면 닫기 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
O-O-wl committed Jan 3, 2021
1 parent 7f9b8d6 commit a8a3b82
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "back.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ final class AboutReactor: Reactor {

enum Action {
case initalize
case tapClose
case tapCrewInfo
case tapNotice
case tapVersion
Expand All @@ -21,6 +22,7 @@ final class AboutReactor: Reactor {
case setPresentCrewInfo(Bool)
case setPresentNotice(Bool)
case setPresentAppStore(Bool)
case setWillDismiss(Bool)
case setNoticeCount(Int)
case setCurrentVersion(String)
}
Expand All @@ -29,6 +31,7 @@ final class AboutReactor: Reactor {
@Revision var isPresentCrewInfo: Bool = false
@Revision var isPresentNotice: Bool = false
@Revision var isPresentAppStore: Bool = false
@Revision var willDismiss: Bool = false
var noticeCount: Int?
var currentVersion: String? = "10.1.1"
}
Expand All @@ -53,6 +56,9 @@ final class AboutReactor: Reactor {

case .tapVersion:
return .just(.setPresentAppStore(true))

case .tapClose:
return .just(.setWillDismiss(true))
}
}

Expand All @@ -74,6 +80,9 @@ final class AboutReactor: Reactor {

case .setCurrentVersion(let version):
newState.currentVersion = version

case .setWillDismiss(let willDismiss):
newState.willDismiss = willDismiss
}

return newState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ final class AboutViewController: UIViewController, View {
private let noticeInfoView: UIView = UIView()
private let noticeBadge: NoticeBadge = NoticeBadge()
private let versionInfoView: UIView = UIView()
private let versionLabel: UILabel = UILabel()
private let backButton: UIBarButtonItem = UIBarButtonItem(
image: UIImage(named: "back")!,
style: .plain,
target: nil,
action: nil
)

var disposeBag: DisposeBag = DisposeBag()

Expand All @@ -38,6 +45,9 @@ final class AboutViewController: UIViewController, View {
// MARK: 🎛 Setup
private func setupUI() {
view.backgroundColor = .breathingWhite
backButton.tintColor = .warmBlue
navigationItem.leftBarButtonItem = backButton
navigationItem.title = "About"

view.addSubview(stackView)
stackView.do {
Expand Down Expand Up @@ -108,7 +118,7 @@ final class AboutViewController: UIViewController, View {
$0.font = .systemFont(ofSize: 14)
$0.textColor = .warmBlue
}
let versionLabel: UILabel = UILabel().then {
versionLabel.do {
$0.text = "New Version"
$0.textColor = .livelyBlue
}
Expand Down Expand Up @@ -140,6 +150,12 @@ final class AboutViewController: UIViewController, View {
.bind(to: reactor.action)
.disposed(by: disposeBag)

backButton.rx.tap
.throttle(.milliseconds(300), scheduler: MainScheduler.instance)
.map { Action.tapClose }
.bind(to: reactor.action)
.disposed(by: disposeBag)

noticeInfoView.rx.tapGesture()
.when(.recognized)
.throttle(.milliseconds(300), scheduler: MainScheduler.instance)
Expand Down Expand Up @@ -188,5 +204,19 @@ final class AboutViewController: UIViewController, View {
print("isPresentAppStore")
})
.disposed(by: disposeBag)

reactor.state
.distinctUntilChanged(\.$willDismiss)
.map { $0.willDismiss }
.filter { $0 }
.subscribe(onNext: { [weak self] _ in
self?.dismiss(animated: true, completion: nil)
})
.disposed(by: disposeBag)

reactor.state.map { $0.currentVersion }
.distinctUntilChanged()
.bind(to: versionLabel.rx.text)
.disposed(by: disposeBag)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ final class CheeringMapViewController: UIViewController, ReactorKit.View {
})
.disposed(by: self.disposeBag)

aboutButton.rx.tap
.map { Action.tapAbout }
.bind(to: reactor.action)
.disposed(by: self.disposeBag)

rankingTableView.rx.didScroll
.map { [weak self] in self?.rankingTableView.contentOffset.y }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,20 @@ final class DiscoverViewController: UIViewController, View {
})
.disposed(by: self.disposeBag)

reactor.state
.distinctUntilChanged(\.$isPresentAboutPage)
.map { $0.isPresentAboutPage }
.subscribe(onNext: { [weak self] in
let viewController = AboutViewController().then {
$0.reactor = AboutReactor()
}
let naviController = UINavigationController(rootViewController: viewController).then {
$0.modalPresentationStyle = .fullScreen
}
self?.present(naviController, animated: false, completion: nil)
})
.disposed(by: self.disposeBag)

reactor.state
.map(\.isRefreshing)
.distinctUntilChanged()
Expand Down Expand Up @@ -199,23 +213,10 @@ final class DiscoverViewController: UIViewController, View {
.disposed(by: self.disposeBag)

self.aboutButton.rx.tap
.throttle(.milliseconds(300), scheduler: MainScheduler.instance)
.map { Reactor.Action.tapAbout }
.bind(to: reactor.action)
.disposed(by: self.disposeBag)

reactor.state
.distinctUntilChanged(\.$isPresentAboutPage)
.map { $0.isPresentAboutPage }
.subscribe(onNext: { [weak self] in
let viewController = AboutViewController().then {
$0.reactor = AboutReactor()
}
let naviController = UINavigationController(rootViewController: viewController).then {
$0.modalPresentationStyle = .fullScreen
}
self?.present(naviController, animated: false, completion: nil)
})
.disposed(by: self.disposeBag)
}
}
extension DiscoverViewController: UITableViewDelegate, UITableViewDataSource {
Expand Down

0 comments on commit a8a3b82

Please sign in to comment.