I have this code that is intended to walk a user through allowing notifications and Bluetooth. I am having an issue where the NavigationLink
is never becoming active, and I am not quite sure where things are going wrong. Would love some help .
struct OOBEState: Equatable {
var allowedNotifications: Bool = false
var allowedBluetooth: Bool = false
}
enum OOBEAction: Equatable {
case allowNotifications
case allowedNotifications(Bool)
case allowBluetooth
case allowedBluetooth(Bool)
}
let OOBEReducer = Reducer<OOBEState, OOBEAction, AppEnvironment> { state, action, env in
switch action {
case .allowNotifications:
return Effect(value: .allowedNotifications(true))
case .allowedNotifications(let isAllowed):
state.allowedNotifications = isAllowed
return .none
case .allowBluetooth:
return Effect(value: .allowedBluetooth(true))
case .allowedBluetooth(let isAllowed):
state.allowedBluetooth = isAllowed
return .none
}
}
.debug()
struct OOBEView: View {
var store: Store<OOBEState, OOBEAction>
var body: some View {
WithViewStore(self.store) { viewStore in
VStack {
NavigationLink(
destination: NextView(store: self.store),
isActive: viewStore.binding(
get: { $0.allowedNotifications },
send: OOBEAction.allowedNotifications
),
label: {
Text("Navigate")
}
)
Button("Allow Notificatons") {
viewStore.send(.allowNotifications)
}
}
}
}
}