Add settings page #46
1 changed files with 38 additions and 15 deletions
fully working search on desktop
commit
b6a722a935
|
|
@ -14,6 +14,7 @@ import "package:nexus/models/setting.dart";
|
||||||
import "package:nexus/models/settings.dart";
|
import "package:nexus/models/settings.dart";
|
||||||
import "package:nexus/models/settings_category.dart";
|
import "package:nexus/models/settings_category.dart";
|
||||||
import "package:nexus/widgets/divider_text.dart";
|
import "package:nexus/widgets/divider_text.dart";
|
||||||
|
import "package:nexus/widgets/highlight_wrapper.dart";
|
||||||
import "package:nexus/widgets/settings/dialog_list_tile.dart";
|
import "package:nexus/widgets/settings/dialog_list_tile.dart";
|
||||||
import "package:super_sliver_list/super_sliver_list.dart";
|
import "package:super_sliver_list/super_sliver_list.dart";
|
||||||
import "package:nexus/main.dart";
|
import "package:nexus/main.dart";
|
||||||
|
|
@ -108,6 +109,10 @@ class SettingsPage extends ConsumerWidget {
|
||||||
|
|
||||||
final selected = useState(0);
|
final selected = useState(0);
|
||||||
|
|
||||||
|
final highlightedMatch = useState<(int, int)?>(null);
|
||||||
|
final listController = useRef(ListController());
|
||||||
|
final scrollController = useScrollController();
|
||||||
|
|
||||||
final searchBar = SearchAnchor.bar(
|
final searchBar = SearchAnchor.bar(
|
||||||
barHintText: "Search...",
|
barHintText: "Search...",
|
||||||
suggestionsBuilder: (context, controller) {
|
suggestionsBuilder: (context, controller) {
|
||||||
|
|
@ -140,15 +145,26 @@ class SettingsPage extends ConsumerWidget {
|
||||||
|
|
||||||
return matches.map(
|
return matches.map(
|
||||||
(match) => ListTile(
|
(match) => ListTile(
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
// TODO: Do something
|
if (context.mounted) Navigator.of(context).pop();
|
||||||
// if (categoriesArePages) {
|
if (categoriesArePages) {
|
||||||
// // Navigator.of(context).push(route);
|
// Navigator.of(context).push(route);
|
||||||
// } else {
|
} else {
|
||||||
// selected.value = match.$1.$1;
|
selected.value = match.$1.$1;
|
||||||
// }
|
listController.value.animateToItem(
|
||||||
|
index: match.$1.$2,
|
||||||
Navigator.of(context).pop();
|
scrollController: scrollController,
|
||||||
|
alignment: 0.5,
|
||||||
|
duration: (_) => .new(milliseconds: 700),
|
||||||
|
curve: (_) => Curves.easeInOut,
|
||||||
|
);
|
||||||
|
highlightedMatch.value = match.$1;
|
||||||
|
await Future.delayed(.new(seconds: 1), () {
|
||||||
|
if (highlightedMatch.value == match.$1) {
|
||||||
|
highlightedMatch.value = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
leading: Icon(match.$2.icon),
|
leading: Icon(match.$2.icon),
|
||||||
title: Text(match.$2.title),
|
title: Text(match.$2.title),
|
||||||
|
|
@ -286,18 +302,25 @@ class SettingsPage extends ConsumerWidget {
|
||||||
VerticalDivider(),
|
VerticalDivider(),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SuperListView(
|
child: SuperListView(
|
||||||
|
listController: listController.value,
|
||||||
|
controller: scrollController,
|
||||||
padding: .symmetric(vertical: 12),
|
padding: .symmetric(vertical: 12),
|
||||||
children: buildCategories(settings)
|
children: buildCategories(settings)
|
||||||
.values
|
.values
|
||||||
.flattenedToList[selected.value]
|
.flattenedToList[selected.value]
|
||||||
.settings
|
.settings
|
||||||
.map(
|
.mapIndexed(
|
||||||
(setting) => Padding(
|
(index, setting) => Padding(
|
||||||
padding: .only(bottom: 4),
|
padding: .only(bottom: 4),
|
||||||
child: setting.builder(
|
child: HighlightWrapper(
|
||||||
setting.title,
|
setting.builder(
|
||||||
setting.description,
|
setting.title,
|
||||||
setting.icon,
|
setting.description,
|
||||||
|
setting.icon,
|
||||||
|
),
|
||||||
|
isHighlighted:
|
||||||
|
highlightedMatch.value ==
|
||||||
|
(selected.value, index),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue