-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- this needs an update to how the search works - took the opportunity and move the app into its own file
- Loading branch information
1 parent
185c8e0
commit 230b706
Showing
4 changed files
with
86 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:settings/l10n/l10n.dart'; | ||
import 'package:settings/view/app_theme.dart'; | ||
import 'package:settings/view/pages/page_items.dart'; | ||
import 'package:yaru_icons/yaru_icons.dart'; | ||
import 'package:yaru_widgets/yaru_widgets.dart'; | ||
|
||
class UbuntuSettingsApp extends StatefulWidget { | ||
const UbuntuSettingsApp({ | ||
Key? key, | ||
}) : super(key: key); | ||
|
||
@override | ||
State<UbuntuSettingsApp> createState() => _UbuntuSettingsAppState(); | ||
} | ||
|
||
class _UbuntuSettingsAppState extends State<UbuntuSettingsApp> { | ||
final _filteredItems = <YaruPageItem>[]; | ||
final _searchController = TextEditingController(); | ||
|
||
void _onEscape() => setState(() { | ||
_filteredItems.clear(); | ||
_searchController.clear(); | ||
}); | ||
|
||
void _onSearchChanged(String value) { | ||
setState(() { | ||
_filteredItems.clear(); | ||
_filteredItems.addAll(pageItems.where((element) => | ||
element.title.toLowerCase().contains(value.toLowerCase()))); | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
debugShowCheckedModeBanner: false, | ||
onGenerateTitle: (context) => context.l10n.appTitle, | ||
routes: { | ||
Navigator.defaultRouteName: (context) { | ||
return YaruMasterDetailPage( | ||
leftPaneWidth: 280, | ||
pageItems: _filteredItems.isNotEmpty ? _filteredItems : pageItems, | ||
previousIconData: YaruIcons.go_previous, | ||
searchHint: context.l10n.searchHint, | ||
searchIconData: YaruIcons.search, | ||
appBar: YaruSearchAppBar( | ||
searchHint: 'Search...', | ||
clearSearchIconData: YaruIcons.window_close, | ||
searchController: _searchController, | ||
onChanged: _onSearchChanged, | ||
onEscape: _onEscape, | ||
appBarHeight: 48, | ||
searchIconData: YaruIcons.search, | ||
), | ||
); | ||
}, | ||
}, | ||
theme: context.watch<LightTheme>().value, | ||
darkTheme: context.watch<DarkTheme>().value, | ||
themeMode: context.watch<AppTheme>().value, | ||
supportedLocales: AppLocalizations.supportedLocales, | ||
localizationsDelegates: AppLocalizations.localizationsDelegates, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters