@@ -18,17 +18,22 @@ class UbuntuSettingsApp extends StatefulWidget {
18
18
class _UbuntuSettingsAppState extends State <UbuntuSettingsApp > {
19
19
final _filteredItems = < YaruPageItem > [];
20
20
final _searchController = TextEditingController ();
21
+ late List <YaruPageItem > pageItems = getPageItems (context);
21
22
22
23
void _onEscape () => setState (() {
23
24
_filteredItems.clear ();
24
25
_searchController.clear ();
25
26
});
26
27
27
- void _onSearchChanged (String value) {
28
+ void _onSearchChanged (String value, BuildContext context ) {
28
29
setState (() {
29
30
_filteredItems.clear ();
30
- _filteredItems.addAll (pageItems.where ((element) =>
31
- element.title.toLowerCase ().contains (value.toLowerCase ())));
31
+ _filteredItems.addAll (pageItems.where ((pageItem) {
32
+ if (pageItem.searchMatches != null ) {
33
+ return pageItem.searchMatches !(value, context);
34
+ }
35
+ return false ;
36
+ }));
32
37
});
33
38
}
34
39
@@ -46,10 +51,10 @@ class _UbuntuSettingsAppState extends State<UbuntuSettingsApp> {
46
51
searchHint: context.l10n.searchHint,
47
52
searchIconData: YaruIcons .search,
48
53
appBar: YaruSearchAppBar (
49
- searchHint: 'Search...' ,
54
+ searchHint: context.l10n.searchHint ,
50
55
clearSearchIconData: YaruIcons .window_close,
51
56
searchController: _searchController,
52
- onChanged: _onSearchChanged,
57
+ onChanged: (v) => _onSearchChanged (v, context) ,
53
58
onEscape: _onEscape,
54
59
appBarHeight: 48 ,
55
60
searchIconData: YaruIcons .search,
@@ -65,3 +70,29 @@ class _UbuntuSettingsAppState extends State<UbuntuSettingsApp> {
65
70
);
66
71
}
67
72
}
73
+
74
+ class MySearchDelegate extends SearchDelegate <String > {
75
+ @override
76
+ List <Widget >? buildActions (BuildContext context) {
77
+ // TODO: implement buildActions
78
+ throw UnimplementedError ();
79
+ }
80
+
81
+ @override
82
+ Widget ? buildLeading (BuildContext context) {
83
+ // TODO: implement buildLeading
84
+ throw UnimplementedError ();
85
+ }
86
+
87
+ @override
88
+ Widget buildResults (BuildContext context) {
89
+ // TODO: implement buildResults
90
+ throw UnimplementedError ();
91
+ }
92
+
93
+ @override
94
+ Widget buildSuggestions (BuildContext context) {
95
+ // TODO: implement buildSuggestions
96
+ throw UnimplementedError ();
97
+ }
98
+ }
0 commit comments