Update code for changes in KMM lib

This commit is contained in:
William Brawner 2023-01-08 19:47:53 -07:00
parent 811341b139
commit aab7b0a6ac
2 changed files with 10 additions and 19 deletions

View file

@ -40,23 +40,14 @@ extension Digest {
extension Status {
var localizedStringKey: LocalizedStringKey {
var key: String
switch self {
case .enabled:
key = "enabled"
case .disabled:
key = "disabled"
default:
key = "unknown"
}
return LocalizedStringKey(key)
return LocalizedStringKey(self.name)
}
var foregroundColor: Color {
switch self {
case .enabled:
case is Enabled:
return .green
case .disabled:
case is Disabled:
return .red
default:
return .gray

View file

@ -56,12 +56,12 @@ struct PiholeStatusView: View {
if let status = store.state.status {
Text(status.localizedStringKey)
.foregroundColor(status.foregroundColor)
if status is Status.Disabled, let timeRemaining = (status as! Status.Disabled).timeRemaining {
Text("(\(timeRemaining))")
.monospacedDigit()
.foregroundColor(status.foregroundColor)
}
}
// if case let .disabled(duration) = store.state.status, let durationString = duration {
// Text("(\(durationString))")
// .monospacedDigit()
// .foregroundColor(store.state.status.foregroundColor)
// }
}
}
}
@ -77,13 +77,13 @@ struct PiHoleActions: View {
@ViewBuilder
var stateContent: some View {
switch self.store.state.status {
case Pihelper.Status.disabled:
case is Pihelper.Status.Disabled:
Button(action: {
self.store.dispatch(ActionEnable())
}, label: { Text("enable") })
.buttonStyle(PiHelperButtonStyle(.green))
.padding(Edge.Set(arrayLiteral: [.bottom, .top]), 5.0)
case Pihelper.Status.enabled:
case is Pihelper.Status.Enabled:
VStack {
Button(action: {
self.store.dispatch(ActionDisable(duration: 10))