Run swift-format

This commit is contained in:
mbrandonw
2021-05-04 14:30:23 +00:00
committed by GitHub Actions
parent 6f1bc259e4
commit 2bd9b7568e
6 changed files with 21 additions and 17 deletions

View File

@@ -51,36 +51,36 @@ public let loginReducer = Reducer<LoginState, LoginAction, LoginEnvironment>.com
)
}
),
.init {
state, action, environment in
switch action {
case .alertDismissed:
state.alert = nil
return .none
case let .emailChanged(email):
state.email = email
state.isFormValid = !state.email.isEmpty && !state.password.isEmpty
return .none
case let .loginResponse(.success(response)):
state.isLoginRequestInFlight = false
if response.twoFactorRequired {
state.twoFactor = TwoFactorState(token: response.token)
}
return .none
case let .loginResponse(.failure(error)):
state.alert = .init(title: TextState(error.localizedDescription))
state.isLoginRequestInFlight = false
return .none
case let .passwordChanged(password):
state.password = password
state.isFormValid = !state.email.isEmpty && !state.password.isEmpty
return .none
case .loginButtonTapped:
state.isLoginRequestInFlight = true
return environment.authenticationClient
@@ -88,10 +88,10 @@ public let loginReducer = Reducer<LoginState, LoginAction, LoginEnvironment>.com
.receive(on: environment.mainQueue)
.catchToEffect()
.map(LoginAction.loginResponse)
case .twoFactor:
return .none
case .twoFactorDismissed:
state.twoFactor = nil
return .cancel(id: TwoFactorTearDownToken())

View File

@@ -15,7 +15,8 @@ public struct GameView: View {
self.board = state.board.map { $0.map { $0?.label ?? "" } }
self.isGameDisabled = state.board.hasWinner || state.board.isFilled
self.isPlayAgainButtonVisible = state.board.hasWinner || state.board.isFilled
self.title = state.board.hasWinner
self.title =
state.board.hasWinner
? "Winner! Congrats \(state.currentPlayerName)!"
: state.board.isFilled
? "Tied game!"

View File

@@ -97,7 +97,8 @@ public struct LoginView: View {
.padding(.horizontal)
}
}
.navigationBarTitle("Login") }
.navigationBarTitle("Login")
}
}
extension LoginAction {

View File

@@ -35,7 +35,8 @@ public struct NewGameView: View {
}
public var body: some View {
WithViewStore(self.store.scope(state: ViewState.init, action: NewGameAction.init)) { viewStore in
WithViewStore(self.store.scope(state: ViewState.init, action: NewGameAction.init)) {
viewStore in
ScrollView {
VStack(spacing: 16) {
VStack(alignment: .leading) {

View File

@@ -18,7 +18,8 @@ public final class GameViewController: UIViewController {
self.board = state.board.map { $0.map { $0?.label ?? "" } }
self.isGameEnabled = !state.board.hasWinner && !state.board.isFilled
self.isPlayAgainButtonHidden = !state.board.hasWinner && !state.board.isFilled
self.title = state.board.hasWinner
self.title =
state.board.hasWinner
? "Winner! Congrats \(state.currentPlayerName)!"
: state.board.isFilled
? "Tied game!"

View File

@@ -128,8 +128,8 @@ struct AppView: View {
self.store.scope(state: \.filteredTodos, action: AppAction.todo(id:action:)),
content: TodoView.init(store:)
)
.onDelete { self.viewStore.send(.delete($0)) }
.onMove { self.viewStore.send(.move($0, $1)) }
.onDelete { self.viewStore.send(.delete($0)) }
.onMove { self.viewStore.send(.move($0, $1)) }
}
}
.navigationBarTitle("Todos")
@@ -143,9 +143,9 @@ struct AppView: View {
Button("Add Todo") { self.viewStore.send(.addTodoButtonTapped, animation: .default) }
}
)
.environment(
\.editMode,
self.viewStore.binding(get: \.editMode, send: AppAction.editModeChanged)
.environment(
\.editMode,
self.viewStore.binding(get: \.editMode, send: AppAction.editModeChanged)
)
}
.navigationViewStyle(StackNavigationViewStyle())