-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
293 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
Dear-World/Dear-World/Source/Presentation/Scene/About/AboutReactor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// AboutReactor.swift | ||
// Dear-World | ||
// | ||
// Created by dongyoung.lee on 2021/01/03. | ||
// | ||
|
||
import Foundation | ||
import ReactorKit | ||
|
||
final class AboutReactor: Reactor { | ||
|
||
enum Action { | ||
case initalize | ||
case tapCrewInfo | ||
case tapNotice | ||
case tapVersion | ||
} | ||
|
||
enum Mutation { | ||
case setPresentCrewInfo(Bool) | ||
case setPresentNotice(Bool) | ||
case setPresentAppStore(Bool) | ||
case setNoticeCount(Int) | ||
case setCurrentVersion(String) | ||
} | ||
|
||
struct State { | ||
@Revision var isPresentCrewInfo: Bool = false | ||
@Revision var isPresentNotice: Bool = false | ||
@Revision var isPresentAppStore: Bool = false | ||
var noticeCount: Int? | ||
var currentVersion: String? = "10.1.1" | ||
} | ||
|
||
var initialState: State | ||
|
||
// MARK: 🏁 Initialize | ||
init() { | ||
initialState = State() | ||
} | ||
|
||
// MARK: 🔫 Mutate | ||
func mutate(action: Action) -> Observable<Mutation> { | ||
switch action { | ||
case .initalize: | ||
return .empty() | ||
case .tapCrewInfo: | ||
return .just(.setPresentCrewInfo(true)) | ||
|
||
case .tapNotice: | ||
return .just(.setPresentNotice(true)) | ||
|
||
case .tapVersion: | ||
return .just(.setPresentAppStore(true)) | ||
} | ||
} | ||
|
||
// MARK: ⚡️ Reduce | ||
func reduce(state: State, mutation: Mutation) -> State { | ||
var newState: State = state | ||
switch mutation { | ||
case .setPresentCrewInfo(let isPresentCrewInfo): | ||
newState.isPresentCrewInfo = isPresentCrewInfo | ||
|
||
case .setPresentNotice(let isPresentNotice): | ||
newState.isPresentNotice = isPresentNotice | ||
|
||
case .setPresentAppStore(let isPresentAppStore): | ||
newState.isPresentAppStore = isPresentAppStore | ||
|
||
case .setNoticeCount(let count): | ||
newState.noticeCount = count | ||
|
||
case .setCurrentVersion(let version): | ||
newState.currentVersion = version | ||
} | ||
|
||
return newState | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.