Przeglądaj źródła

Add text for empty search result in settings search

Deniz Cengiz 1 rok temu
rodzic
commit
c7bd9fa75e

+ 0 - 0
FreeAPS/Sources/Modules/Home/View/Chart/ChartElements/GlucoseTargetsView.swift


+ 15 - 23
FreeAPS/Sources/Modules/Settings/View/SettingsRootView.swift

@@ -192,34 +192,26 @@ extension Settings {
                     Section(
                         header: Text("Search Results"),
                         content: {
-                            ForEach(filteredItems) { filteredItem in
-                                VStack(alignment: .leading) {
-                                    Text(filteredItem.matchedContent).bold()
-                                    if let path = filteredItem.settingItem.path {
-                                        Text(path.map(\.stringValue).joined(separator: " > "))
-                                            .font(.caption)
-                                            .foregroundColor(.secondary)
-                                    }
-                                }.navigationLink(to: filteredItem.settingItem.view, from: self)
+                            if filteredItems.isNotEmpty {
+                                ForEach(filteredItems) { filteredItem in
+                                    VStack(alignment: .leading) {
+                                        Text(filteredItem.matchedContent).bold()
+                                        if let path = filteredItem.settingItem.path {
+                                            Text(path.map(\.stringValue).joined(separator: " > "))
+                                                .font(.caption)
+                                                .foregroundColor(.secondary)
+                                        }
+                                    }.navigationLink(to: filteredItem.settingItem.view, from: self)
+                                }
+                            } else {
+                                Text("No settings matching your search query")
+                                Text(" »\(searchText)« ").bold()
+                                Text("found.")
                             }
                         }
                     ).listRowBackground(Color.chart)
                 }
 
-//                Section {
-//                    Text("Targets")
-//                        .navigationLink(to: .configEditor(file: OpenAPS.Settings.bgTargets), from: self)
-//                    Text("Sensitivities")
-//                        .navigationLink(to: .configEditor(file: OpenAPS.Settings.insulinSensitivities), from: self)
-//                    Text("Profile")
-//                        .navigationLink(to: .configEditor(file: OpenAPS.Settings.profile), from: self)
-//                    Text("Preferences")
-//                        .navigationLink(
-//                            to: .configEditor(file: OpenAPS.Settings.preferences),
-//                            from: self
-//                        )
-//                }.listRowBackground(Color.chart)
-
                 // TODO: remove this more or less entirely; add build-time flag to enable Middleware; add settings export feature
 //                Section {
 //                    Toggle("Developer Options", isOn: $state.debugOptions)