mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 09:28:38 +00:00
Update ItemsParsing.swift
This commit is contained in:
parent
4eb14ea166
commit
bfc4dcf22c
@ -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"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user