Update code for changes in KMM lib
This commit is contained in:
parent
811341b139
commit
aab7b0a6ac
2 changed files with 10 additions and 19 deletions
|
@ -40,23 +40,14 @@ extension Digest {
|
||||||
|
|
||||||
extension Status {
|
extension Status {
|
||||||
var localizedStringKey: LocalizedStringKey {
|
var localizedStringKey: LocalizedStringKey {
|
||||||
var key: String
|
return LocalizedStringKey(self.name)
|
||||||
switch self {
|
|
||||||
case .enabled:
|
|
||||||
key = "enabled"
|
|
||||||
case .disabled:
|
|
||||||
key = "disabled"
|
|
||||||
default:
|
|
||||||
key = "unknown"
|
|
||||||
}
|
|
||||||
return LocalizedStringKey(key)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var foregroundColor: Color {
|
var foregroundColor: Color {
|
||||||
switch self {
|
switch self {
|
||||||
case .enabled:
|
case is Enabled:
|
||||||
return .green
|
return .green
|
||||||
case .disabled:
|
case is Disabled:
|
||||||
return .red
|
return .red
|
||||||
default:
|
default:
|
||||||
return .gray
|
return .gray
|
||||||
|
|
|
@ -56,12 +56,12 @@ struct PiholeStatusView: View {
|
||||||
if let status = store.state.status {
|
if let status = store.state.status {
|
||||||
Text(status.localizedStringKey)
|
Text(status.localizedStringKey)
|
||||||
.foregroundColor(status.foregroundColor)
|
.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
|
@ViewBuilder
|
||||||
var stateContent: some View {
|
var stateContent: some View {
|
||||||
switch self.store.state.status {
|
switch self.store.state.status {
|
||||||
case Pihelper.Status.disabled:
|
case is Pihelper.Status.Disabled:
|
||||||
Button(action: {
|
Button(action: {
|
||||||
self.store.dispatch(ActionEnable())
|
self.store.dispatch(ActionEnable())
|
||||||
}, label: { Text("enable") })
|
}, label: { Text("enable") })
|
||||||
.buttonStyle(PiHelperButtonStyle(.green))
|
.buttonStyle(PiHelperButtonStyle(.green))
|
||||||
.padding(Edge.Set(arrayLiteral: [.bottom, .top]), 5.0)
|
.padding(Edge.Set(arrayLiteral: [.bottom, .top]), 5.0)
|
||||||
case Pihelper.Status.enabled:
|
case is Pihelper.Status.Enabled:
|
||||||
VStack {
|
VStack {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
self.store.dispatch(ActionDisable(duration: 10))
|
self.store.dispatch(ActionDisable(duration: 10))
|
||||||
|
|
Loading…
Reference in a new issue