mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-18 07:28:28 +02:00
Made StateStoreViewModel state mutable and removed the reducer for all the features using it.
This commit is contained in:
committed by
Stefan Ceriu
parent
fc9e95aee8
commit
313b05485a
@@ -19,7 +19,7 @@ import Combine
|
||||
|
||||
@available(iOS 14, *)
|
||||
typealias OnboardingSplashScreenViewModelType = StateStoreViewModel<OnboardingSplashScreenViewState,
|
||||
OnboardingSplashScreenStateAction,
|
||||
Never,
|
||||
OnboardingSplashScreenViewAction>
|
||||
|
||||
protocol OnboardingSplashScreenViewModelProtocol {
|
||||
@@ -54,31 +54,18 @@ class OnboardingSplashScreenViewModel: OnboardingSplashScreenViewModelType, Onbo
|
||||
register()
|
||||
case .login:
|
||||
login()
|
||||
case .nextPage, .previousPage, .hiddenPage:
|
||||
dispatch(action: .viewAction(viewAction))
|
||||
case .nextPage:
|
||||
// Wrap back round to the first page index when reaching the end.
|
||||
state.bindings.pageIndex = (state.bindings.pageIndex + 1) % state.content.count
|
||||
case .previousPage:
|
||||
// Prevent the hidden page at index -1 from being shown.
|
||||
state.bindings.pageIndex = max(0, (state.bindings.pageIndex - 1))
|
||||
case .hiddenPage:
|
||||
// Hidden page for a nicer animation when looping back to the start.
|
||||
state.bindings.pageIndex = -1
|
||||
}
|
||||
}
|
||||
|
||||
override class func reducer(state: inout OnboardingSplashScreenViewState, action: OnboardingSplashScreenStateAction) {
|
||||
switch action {
|
||||
case .viewAction(let viewAction):
|
||||
switch viewAction {
|
||||
case .nextPage:
|
||||
// Wrap back round to the first page index when reaching the end.
|
||||
state.bindings.pageIndex = (state.bindings.pageIndex + 1) % state.content.count
|
||||
case .previousPage:
|
||||
// Prevent the hidden page at index -1 from being shown.
|
||||
state.bindings.pageIndex = max(0, (state.bindings.pageIndex - 1))
|
||||
case .hiddenPage:
|
||||
// Hidden page for a nicer animation when looping back to the start.
|
||||
state.bindings.pageIndex = -1
|
||||
case .login, .register:
|
||||
break
|
||||
}
|
||||
}
|
||||
UILog.debug("[OnboardingSplashScreenViewModel] reducer with action \(action) produced state: \(state)")
|
||||
}
|
||||
|
||||
private func register() {
|
||||
completion?(.register)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user