From aab7b0a6ac9e20c6807fa672a08a0c8753f1baa8 Mon Sep 17 00:00:00 2001 From: William Brawner Date: Sun, 8 Jan 2023 19:47:53 -0700 Subject: [PATCH] Update code for changes in KMM lib --- Pi-helper/Extensions.swift | 15 +++------------ Pi-helper/PiHoleDetailsView.swift | 14 +++++++------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Pi-helper/Extensions.swift b/Pi-helper/Extensions.swift index b011c2c..f8f7dac 100644 --- a/Pi-helper/Extensions.swift +++ b/Pi-helper/Extensions.swift @@ -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 diff --git a/Pi-helper/PiHoleDetailsView.swift b/Pi-helper/PiHoleDetailsView.swift index 6ea9158..ed74559 100644 --- a/Pi-helper/PiHoleDetailsView.swift +++ b/Pi-helper/PiHoleDetailsView.swift @@ -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))