diff --git a/secant/Features/AddressDetails/AddressDetailsStore.swift b/secant/Features/AddressDetails/AddressDetailsStore.swift index c1b2feb..a9214a9 100644 --- a/secant/Features/AddressDetails/AddressDetailsStore.swift +++ b/secant/Features/AddressDetails/AddressDetailsStore.swift @@ -8,73 +8,35 @@ import Foundation import ComposableArchitecture -typealias AddressDetailsReducer = Reducer -typealias AddressDetailsStore = Store -typealias AddressDetailsViewStore = ViewStore +typealias AddressDetailsStore = Store -// MARK: - State +struct AddressDetailsReducer: ReducerProtocol { + struct State: Equatable { } -struct AddressDetailsState: Equatable { -} - -// MARK: - Action - -enum AddressDetailsAction: Equatable { - case copyToPastboard(String) -} - -// MARK: - Environment - -struct AddressDetailsEnvironment { - let pasteboard: WrappedPasteboard -} - -extension AddressDetailsEnvironment { - static let live = AddressDetailsEnvironment( - pasteboard: .live - ) - - static let mock = AddressDetailsEnvironment( - pasteboard: .test - ) -} - -// MARK: - Reducer - -extension AddressDetailsReducer { - static let `default` = AddressDetailsReducer { _, action, environment in + enum Action: Equatable { + case copyToPastboard(String) + } + + @Dependency(\.pasteboard) var pasteboard + + func reduce(into state: inout State, action: Action) -> ComposableArchitecture.EffectTask { switch action { case .copyToPastboard(let value): - environment.pasteboard.setString(value) + pasteboard.setString(value) } - return .none } } -// MARK: - Store - -extension AddressDetailsStore { -} - -// MARK: - ViewStore - -extension AddressDetailsViewStore { -} - // MARK: - Placeholders -extension AddressDetailsState { - static let placeholder = AddressDetailsState( - ) +extension AddressDetailsReducer.State { + static let placeholder = AddressDetailsReducer.State() } extension AddressDetailsStore { static let placeholder = AddressDetailsStore( initialState: .placeholder, - reducer: .default, - environment: AddressDetailsEnvironment( - pasteboard: .test - ) + reducer: AddressDetailsReducer() ) } diff --git a/secant/Features/Profile/ProfileStore.swift b/secant/Features/Profile/ProfileStore.swift index af47dff..2ca54f5 100644 --- a/secant/Features/Profile/ProfileStore.swift +++ b/secant/Features/Profile/ProfileStore.swift @@ -6,6 +6,7 @@ typealias ProfileStore = Store typealias ProfileViewStore = ViewStore typealias AnySettingsReducer = AnyReducer +typealias AnyAddressDetailsReducer = AnyReducer // MARK: - State @@ -16,7 +17,7 @@ struct ProfileState: Equatable { } var address = "" - var addressDetailsState: AddressDetailsState + var addressDetailsState: AddressDetailsReducer.State var appBuild = "" var appVersion = "" var route: Route? @@ -27,7 +28,7 @@ struct ProfileState: Equatable { // MARK: - Action enum ProfileAction: Equatable { - case addressDetails(AddressDetailsAction) + case addressDetails(AddressDetailsReducer.Action) case back case onAppear case settings(SettingsReducer.Action) @@ -97,14 +98,13 @@ extension ProfileReducer { } } - private static let addressDetailsReducer: ProfileReducer = AddressDetailsReducer.default.pullback( + private static let addressDetailsReducer: ProfileReducer = AnyAddressDetailsReducer { _ in + AddressDetailsReducer() + } + .pullback( state: \ProfileState.addressDetailsState, action: /ProfileAction.addressDetails, - environment: { _ in - AddressDetailsEnvironment( - pasteboard: .live - ) - } + environment: { $0 } ) private static let settingsReducer: ProfileReducer = AnySettingsReducer { _ in