From 92975cb8e4dbd8ad262d9e907e53f7d71d5e1c6b Mon Sep 17 00:00:00 2001 From: Serg Date: Sun, 13 Oct 2019 13:48:04 +0700 Subject: [PATCH] resolve existing varnings --- MTMR/ItemsParsing.swift | 30 +++++++++++++++--------------- MTMR/TouchBarController.swift | 22 +++++++++++----------- MTMR/Widgets/DarkModeBarItem.swift | 2 +- MTMR/Widgets/MusicBarItem.swift | 2 +- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/MTMR/ItemsParsing.swift b/MTMR/ItemsParsing.swift index ac888da..ac43767 100644 --- a/MTMR/ItemsParsing.swift +++ b/MTMR/ItemsParsing.swift @@ -225,7 +225,7 @@ class SupportedTypesHolder { "inputsource": { _ in ( - item: .inputsource(), + item: .inputsource, action: .none, longAction: .none, parameters: [:] @@ -237,14 +237,14 @@ class SupportedTypesHolder { let container = try decoder.container(keyedBy: CodingKeys.self) if var img = try container.decodeIfPresent(Source.self, forKey: .image) { return ( - item: .volume(), + item: .volume, action: .none, longAction: .none, parameters: [.image: .image(source: img)] ) } else { return ( - item: .volume(), + item: .volume, action: .none, longAction: .none, parameters: [:] @@ -345,21 +345,21 @@ enum ItemType: Decodable { case appleScriptTitledButton(source: SourceProtocol, refreshInterval: Double) case shellScriptTitledButton(source: SourceProtocol, refreshInterval: Double) case timeButton(formatTemplate: String, timeZone: String?, locale: String?) - case battery() + case battery case dock(autoResize: Bool) - case volume() + case volume case brightness(refreshInterval: Double) case weather(interval: Double, units: String, api_key: String, icon_type: String) case yandexWeather(interval: Double) case currency(interval: Double, from: String, to: String, full: Bool) - case inputsource() + case inputsource case music(interval: Double, disableMarquee: Bool) case groupBar(items: [BarItemDefinition]) - case nightShift() - case dnd() + case nightShift + case dnd case pomodoro(workTime: Double, restTime: Double) case network(flip: Bool) - case darkMode() + case darkMode private enum CodingKeys: String, CodingKey { case type @@ -433,14 +433,14 @@ enum ItemType: Decodable { self = .timeButton(formatTemplate: template, timeZone: timeZone, locale: locale) case .battery: - self = .battery() + self = .battery case .dock: let autoResize = try container.decodeIfPresent(Bool.self, forKey: .autoResize) ?? false self = .dock(autoResize: autoResize) case .volume: - self = .volume() + self = .volume case .brightness: let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 0.5 @@ -465,7 +465,7 @@ enum ItemType: Decodable { self = .currency(interval: interval, from: from, to: to, full: full) case .inputsource: - self = .inputsource() + self = .inputsource case .music: let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 5.0 @@ -477,10 +477,10 @@ enum ItemType: Decodable { self = .groupBar(items: items) case .nightShift: - self = .nightShift() + self = .nightShift case .dnd: - self = .dnd() + self = .dnd case .pomodoro: let workTime = try container.decodeIfPresent(Double.self, forKey: .workTime) ?? 1500.0 @@ -492,7 +492,7 @@ enum ItemType: Decodable { self = .network(flip: flip) case .darkMode: - self = .darkMode() + self = .darkMode } } } diff --git a/MTMR/TouchBarController.swift b/MTMR/TouchBarController.swift index 7e38e39..0900052 100644 --- a/MTMR/TouchBarController.swift +++ b/MTMR/TouchBarController.swift @@ -27,11 +27,11 @@ extension ItemType { return "com.toxblh.mtmr.shellScriptButton." case .timeButton(formatTemplate: _, timeZone: _, locale: _): return "com.toxblh.mtmr.timeButton." - case .battery(): + case .battery: return "com.toxblh.mtmr.battery." case .dock(autoResize: _): return "com.toxblh.mtmr.dock" - case .volume(): + case .volume: return "com.toxblh.mtmr.volume" case .brightness(refreshInterval: _): return "com.toxblh.mtmr.brightness" @@ -41,21 +41,21 @@ extension ItemType { return "com.toxblh.mtmr.yandexWeather" case .currency(interval: _, from: _, to: _, full: _): return "com.toxblh.mtmr.currency" - case .inputsource(): + case .inputsource: return "com.toxblh.mtmr.inputsource." case .music(interval: _): return "com.toxblh.mtmr.music." case .groupBar(items: _): return "com.toxblh.mtmr.groupBar." - case .nightShift(items: _): + case .nightShift: return "com.toxblh.mtmr.nightShift." - case .dnd(items: _): + case .dnd: return "com.toxblh.mtmr.dnd." case .pomodoro(interval: _): return PomodoroBarItem.identifier case .network(flip: _): return NetworkBarItem.identifier - case .darkMode(items: _): + case .darkMode: return DarkModeBarItem.identifier } } @@ -266,7 +266,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate { barItem = ShellScriptTouchBarItem(identifier: identifier, source: source, interval: interval) case let .timeButton(formatTemplate: template, timeZone: timeZone, locale: locale): barItem = TimeTouchBarItem(identifier: identifier, formatTemplate: template, timeZone: timeZone, locale: locale) - case .battery(): + case .battery: barItem = BatteryBarItem(identifier: identifier) case let .dock(autoResize: autoResize): barItem = AppScrubberTouchBarItem(identifier: identifier, autoResize: autoResize) @@ -288,21 +288,21 @@ class TouchBarController: NSObject, NSTouchBarDelegate { barItem = YandexWeatherBarItem(identifier: identifier, interval: interval) case let .currency(interval: interval, from: from, to: to, full: full): barItem = CurrencyBarItem(identifier: identifier, interval: interval, from: from, to: to, full: full) - case .inputsource(): + case .inputsource: barItem = InputSourceBarItem(identifier: identifier) case let .music(interval: interval, disableMarquee: disableMarquee): barItem = MusicBarItem(identifier: identifier, interval: interval, disableMarquee: disableMarquee) case let .groupBar(items: items): barItem = GroupBarItem(identifier: identifier, items: items) - case .nightShift(): + case .nightShift: barItem = NightShiftBarItem(identifier: identifier) - case .dnd(): + case .dnd: barItem = DnDBarItem(identifier: identifier) case let .pomodoro(workTime: workTime, restTime: restTime): barItem = PomodoroBarItem(identifier: identifier, workTime: workTime, restTime: restTime) case let .network(flip: flip): barItem = NetworkBarItem(identifier: identifier, flip: flip) - case .darkMode(): + case .darkMode: barItem = DarkModeBarItem(identifier: identifier) } diff --git a/MTMR/Widgets/DarkModeBarItem.swift b/MTMR/Widgets/DarkModeBarItem.swift index 60fecb6..ceaba78 100644 --- a/MTMR/Widgets/DarkModeBarItem.swift +++ b/MTMR/Widgets/DarkModeBarItem.swift @@ -47,7 +47,7 @@ struct DarkMode { static func toggle(force: Bool? = nil) { let value = force.map(String.init) ?? "not dark mode" - runAppleScript("\(prefix) set dark mode to \(value)") + _ = runAppleScript("\(prefix) set dark mode to \(value)") } } diff --git a/MTMR/Widgets/MusicBarItem.swift b/MTMR/Widgets/MusicBarItem.swift index 28a82b2..5bc8e7b 100644 --- a/MTMR/Widgets/MusicBarItem.swift +++ b/MTMR/Widgets/MusicBarItem.swift @@ -180,7 +180,7 @@ class MusicBarItem: CustomButtonTouchBarItem { var iconUpdated = false var titleUpdated = false - for var ident in playerBundleIdentifiers { + for ident in playerBundleIdentifiers { if let musicPlayer = SBApplication(bundleIdentifier: ident.rawValue) { if musicPlayer.isRunning { var tempTitle = ""