Browse Source

coding

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 years ago
parent
commit
1f033a15da

+ 37 - 2
Widget/Dashboard.intentdefinition

@@ -6,7 +6,7 @@
 	<array>
 		<dict>
 			<key>INEnumDisplayName</key>
-			<string>Applications category</string>
+			<string>Applications</string>
 			<key>INEnumDisplayNameID</key>
 			<string>9yMkyI</string>
 			<key>INEnumGeneratesHeader</key>
@@ -124,7 +124,42 @@
 						<string>recommendations</string>
 					</dict>
 					<key>INIntentParameterName</key>
-					<string>parameter</string>
+					<string>Applications</string>
+					<key>INIntentParameterPromptDialogs</key>
+					<array>
+						<dict>
+							<key>INIntentParameterPromptDialogCustom</key>
+							<true/>
+							<key>INIntentParameterPromptDialogType</key>
+							<string>Configuration</string>
+						</dict>
+						<dict>
+							<key>INIntentParameterPromptDialogCustom</key>
+							<true/>
+							<key>INIntentParameterPromptDialogType</key>
+							<string>Primary</string>
+						</dict>
+						<dict>
+							<key>INIntentParameterPromptDialogCustom</key>
+							<true/>
+							<key>INIntentParameterPromptDialogFormatString</key>
+							<string>There are ${count} options matching ‘${Applications}’.</string>
+							<key>INIntentParameterPromptDialogFormatStringID</key>
+							<string>qZKu0p</string>
+							<key>INIntentParameterPromptDialogType</key>
+							<string>DisambiguationIntroduction</string>
+						</dict>
+						<dict>
+							<key>INIntentParameterPromptDialogCustom</key>
+							<true/>
+							<key>INIntentParameterPromptDialogFormatString</key>
+							<string>Just to confirm, you wanted ‘${Applications}’?</string>
+							<key>INIntentParameterPromptDialogFormatStringID</key>
+							<string>XKkeMc</string>
+							<key>INIntentParameterPromptDialogType</key>
+							<string>Confirmation</string>
+						</dict>
+					</array>
 					<key>INIntentParameterTag</key>
 					<integer>6</integer>
 					<key>INIntentParameterType</key>

+ 16 - 2
Widget/Dashboard/DashboardData.swift

@@ -65,9 +65,24 @@ let dashboardDatasTest: [DashboardData] = [
     .init(id: 9, title: "title9", subTitle: "subTitle-description9", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "nextcloud")!, buttons: nil)
 ]
 
-func getDashboardDataEntry(isPreview: Bool, displaySize: CGSize, completion: @escaping (_ entry: DashboardDataEntry) -> Void) {
+func getDashboardDataEntry(intent: Applications, isPreview: Bool, displaySize: CGSize, completion: @escaping (_ entry: DashboardDataEntry) -> Void) {
 
     let datasPlaceholder = Array(dashboardDatasTest[0...dashboaardItems - 1])
+    var id = "recommendations"
+    switch intent {
+    case .unknown:
+        id = "recommendations"
+    case .notes:
+        id = "notes"
+    case .deck:
+        id = "deck"
+    case .recommendations:
+        id = "recommendations"
+    case .activity:
+        id = "activity"
+    case .user_status:
+        id = "user_status"
+    }
     
     if isPreview {
         return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, titleImage: UIImage(named: "nextcloud")!, title: "Dashboard", footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " dashboard"))
@@ -104,7 +119,6 @@ func getDashboardDataEntry(isPreview: Bool, displaySize: CGSize, completion: @es
         NKCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) dashboard widget session with level \(levelLog) " + versionNextcloudiOS)
     }
     
-    let id = "recommendations"
     let result = NCManageDatabase.shared.getDashboardWidget(account: account.account, id: id)
     let options = NKRequestOptions(queue: NKCommon.shared.backgroundQueue)
     let title = result?.title ?? id

+ 2 - 2
Widget/Dashboard/DashboardWidgetProvider.swift

@@ -38,13 +38,13 @@ struct DashboardWidgetProvider: IntentTimelineProvider {
     }
 
     func getSnapshot(for configuration: DashboardIntent, in context: Context, completion: @escaping (DashboardDataEntry) -> Void) {
-        getDashboardDataEntry(isPreview: false, displaySize: context.displaySize) { entry in
+        getDashboardDataEntry(intent: configuration.Applications, isPreview: false, displaySize: context.displaySize) { entry in
             completion(entry)
         }
     }
 
     func getTimeline(for configuration: DashboardIntent, in context: Context, completion: @escaping (Timeline<DashboardDataEntry>) -> Void) {
-        getDashboardDataEntry(isPreview: context.isPreview, displaySize: context.displaySize) { entry in
+        getDashboardDataEntry(intent: configuration.Applications, isPreview: context.isPreview, displaySize: context.displaySize) { entry in
             let timeLine = Timeline(entries: [entry], policy: .atEnd)
             completion(timeLine)
         }