macOS widgets
This commit is contained in:
parent
c137b55c85
commit
ef6e7a206b
|
|
@ -4,5 +4,9 @@
|
|||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.com.invoiceninja.app</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
|||
|
|
@ -16,28 +16,42 @@ class IntentHandler: INExtension, ConfigurationIntentHandling {
|
|||
// Fetch list of top ten crypto from API
|
||||
//let assets = try await AssetFetcher.fetchTopTenAssets()
|
||||
|
||||
// 2
|
||||
// Transform `[Asset]` to `[Crypto]`
|
||||
/*
|
||||
let cryptos = assets.map { asset in
|
||||
|
||||
let crypto = Crypto(
|
||||
identifier: asset.id,
|
||||
display: "\(asset.name) (\(asset.symbol))"
|
||||
)
|
||||
crypto.symbol = asset.symbol
|
||||
crypto.name = asset.name
|
||||
|
||||
return crypto
|
||||
let sharedDefaults = UserDefaults.init(suiteName: "group.com.invoiceninja.app")
|
||||
var exampleData: WidgetData = WidgetData(tokens:[:])
|
||||
|
||||
if sharedDefaults != nil {
|
||||
do {
|
||||
let shared = sharedDefaults!.string(forKey: "widgetData")
|
||||
if shared != nil {
|
||||
let decoder = JSONDecoder()
|
||||
exampleData = try decoder.decode(WidgetData.self, from: shared!.data(using: .utf8)!)
|
||||
}
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
let companies = exampleData.tokens.keys.map { token in
|
||||
|
||||
let company = Company(
|
||||
identifier: token,
|
||||
display: exampleData.tokens[token] ?? ""
|
||||
)
|
||||
//company.symbol = asset.symbol
|
||||
//company.name = asset.name
|
||||
|
||||
return company
|
||||
}
|
||||
*/
|
||||
|
||||
// 3
|
||||
// Create a collection with the array of cryptos.
|
||||
let company1 = Company(identifier: "1", display: "Test 1")
|
||||
let company2 = Company(identifier: "2", display: "Test 2")
|
||||
//let company1 = Company(identifier: "1", display: "Test 1")
|
||||
//let company2 = Company(identifier: "2", display: "Test 2")
|
||||
//let collection = INObjectCollection(items: [company1, company2])
|
||||
|
||||
let collection = INObjectCollection(items: [company1, company2])
|
||||
let collection = INObjectCollection(items: companies)
|
||||
|
||||
// Return the collections
|
||||
return collection
|
||||
|
|
|
|||
|
|
@ -155,6 +155,11 @@
|
|||
<string>Field</string>
|
||||
<key>INIntentParameterEnumTypeNamespace</key>
|
||||
<string>88xZPY</string>
|
||||
<key>INIntentParameterMetadata</key>
|
||||
<dict>
|
||||
<key>INIntentParameterMetadataDefaultValue</key>
|
||||
<string>invoices</string>
|
||||
</dict>
|
||||
<key>INIntentParameterName</key>
|
||||
<string>field</string>
|
||||
<key>INIntentParameterPromptDialogs</key>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import sign_in_with_apple
|
|||
import smart_auth
|
||||
import sqflite
|
||||
import url_launcher_macos
|
||||
import widget_kit_plugin
|
||||
import window_manager
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
|
|
@ -38,5 +39,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
|||
SmartAuthPlugin.register(with: registry.registrar(forPlugin: "SmartAuthPlugin"))
|
||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
WidgetKitPlugin.register(with: registry.registrar(forPlugin: "WidgetKitPlugin"))
|
||||
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue