From bfc4dcf22c9e656002fe5c488f4b66ffff2beb60 Mon Sep 17 00:00:00 2001 From: Daniel Apatin Date: Fri, 20 Apr 2018 11:17:29 +0300 Subject: [PATCH] Update ItemsParsing.swift --- MTMR/ItemsParsing.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/MTMR/ItemsParsing.swift b/MTMR/ItemsParsing.swift index 39db97c..055fb09 100644 --- a/MTMR/ItemsParsing.swift +++ b/MTMR/ItemsParsing.swift @@ -73,12 +73,13 @@ class SupportedTypesHolder { return (item: .staticButton(title: ""), action: .hidKey(keycode: NX_KEYTYPE_NEXT), parameters: [.image: imageParameter]) }, "weather": { decoder in - enum CodingKeys: String, CodingKey { case refreshInterval; case units; case api_key } + enum CodingKeys: String, CodingKey { case refreshInterval; case units; case api_key ; case icon_type } let container = try decoder.container(keyedBy: CodingKeys.self) let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) let units = try container.decodeIfPresent(String.self, forKey: .units) let api_key = try container.decodeIfPresent(String.self, forKey: .api_key) - return (item: .weather(interval: interval ?? 1800.00, units: units ?? "metric", api_key: api_key ?? "32c4256d09a4c52b38aecddba7a078f6"), action: .none, parameters: [:]) + let icon_type = try container.decodeIfPresent(String.self, forKey: .icon_type) + return (item: .weather(interval: interval ?? 1800.00, units: units ?? "metric", api_key: api_key ?? "32c4256d09a4c52b38aecddba7a078f6", icon_type: icon_type ?? "text"), action: .none, parameters: [:]) }, "currency": { decoder in enum CodingKeys: String, CodingKey { case refreshInterval; case from; case to } @@ -148,7 +149,7 @@ enum ItemType: Decodable { case dock() case volume() case brightness(refreshInterval: Double) - case weather(interval: Double, units: String, api_key: String) + case weather(interval: Double, units: String, api_key: String, icon_type: String) case currency(interval: Double, from: String, to: String) private enum CodingKeys: String, CodingKey { @@ -160,6 +161,7 @@ enum ItemType: Decodable { case to case units case api_key + case icon_type case formatTemplate case image } @@ -200,7 +202,8 @@ enum ItemType: Decodable { let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0 let units = try container.decodeIfPresent(String.self, forKey: .units) ?? "metric" let api_key = try container.decodeIfPresent(String.self, forKey: .api_key) ?? "32c4256d09a4c52b38aecddba7a078f6" - self = .weather(interval: interval, units: units, api_key: api_key) + let icon_type = try container.decodeIfPresent(String.self, forKey: .icon_type) ?? "text" + self = .weather(interval: interval, units: units, api_key: api_key, icon_type: icon_type) case .currency: let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0 let from = try container.decodeIfPresent(String.self, forKey: .from) ?? "RUB"