macOS widgets
This commit is contained in:
parent
0641983a4f
commit
e5400cec81
|
|
@ -40,7 +40,7 @@ class WidgetData {
|
|||
dateRanges = Map.fromIterable(
|
||||
DateRange.values.where((value) => value != DateRange.custom),
|
||||
key: (dynamic item) => toSnakeCase('$item'),
|
||||
value: (dynamic item) => localization.lookup('$item'));
|
||||
value: (dynamic item) => localization.lookup(toSnakeCase('$item')));
|
||||
|
||||
WidgetData.fromJson(Map<String, dynamic> json)
|
||||
: url = json['url'],
|
||||
|
|
|
|||
|
|
@ -2,27 +2,18 @@ import Intents
|
|||
|
||||
class IntentHandler: INExtension, ConfigurationIntentHandling {
|
||||
private func loadWidgetData() -> WidgetData {
|
||||
let sharedDefaults = UserDefaults(suiteName: "group.com.invoiceninja.app")
|
||||
var widgetData: WidgetData = WidgetData(url: "",
|
||||
companyId: "",
|
||||
companies: [:],
|
||||
dateRanges: [:],
|
||||
dashboardFields: [:])
|
||||
|
||||
if let sharedDefaults = sharedDefaults {
|
||||
do {
|
||||
if let shared = sharedDefaults.string(forKey: "widget_data") {
|
||||
|
||||
//print("## Shared: \(shared)")
|
||||
|
||||
let decoder = JSONDecoder()
|
||||
widgetData = try decoder.decode(WidgetData.self, from: shared.data(using: .utf8)!)
|
||||
}
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
widgetData = try getWidgetData()
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
|
||||
return widgetData
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue