Skip to content
Snippets Groups Projects
Commit c232f245 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Implement basic error view

parent 632620f4
Branches
Tags
1 merge request!1Client management
...@@ -2,7 +2,11 @@ import ComposableArchitecture ...@@ -2,7 +2,11 @@ import ComposableArchitecture
import SwiftUI import SwiftUI
public struct ErrorState: Equatable { public struct ErrorState: Equatable {
public init() {} public init(error: NSError) {
self.error = error
}
var error: NSError
} }
public enum ErrorAction: Equatable {} public enum ErrorAction: Equatable {}
......
...@@ -7,14 +7,33 @@ public struct ErrorView: View { ...@@ -7,14 +7,33 @@ public struct ErrorView: View {
} }
let store: Store<ErrorState, ErrorAction> let store: Store<ErrorState, ErrorAction>
@Environment(\.dismiss) var dismiss
struct ViewState: Equatable { struct ViewState: Equatable {
init(state: ErrorState) {} let error: NSError
init(state: ErrorState) {
error = state.error
}
} }
public var body: some View { public var body: some View {
WithViewStore(store.scope(state: ViewState.init)) { viewStore in WithViewStore(store.scope(state: ViewState.init)) { viewStore in
Text("ErrorView") NavigationView {
Form {
Text("\(viewStore.error)")
}
.navigationTitle("Error")
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button {
dismiss()
} label: {
Image(systemName: "xmark")
}
}
}
}
} }
} }
} }
...@@ -23,7 +42,9 @@ public struct ErrorView: View { ...@@ -23,7 +42,9 @@ public struct ErrorView: View {
public struct ErrorView_Previews: PreviewProvider { public struct ErrorView_Previews: PreviewProvider {
public static var previews: some View { public static var previews: some View {
ErrorView(store: .init( ErrorView(store: .init(
initialState: .init(), initialState: .init(
error: NSError(domain: "preview", code: 1234)
),
reducer: .empty, reducer: .empty,
environment: () environment: ()
)) ))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment