mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-05-10 15:40:38 +00:00
Update custom_navigation_settings.dart
No need for SingleChildScrollView, because ReorderableListView already is scrollable
This commit is contained in:
parent
c799c3451c
commit
b6ff9fe141
1 changed files with 59 additions and 62 deletions
|
|
@ -21,70 +21,67 @@ class _CustomNavigationSettingsState
|
|||
final hideItems = ref.watch(hideItemsStateProvider);
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(l10n.reorder_navigation)),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
child: ReorderableListView.builder(
|
||||
buildDefaultDragHandles: false,
|
||||
shrinkWrap: true,
|
||||
itemCount: navigationOrder.length,
|
||||
itemBuilder: (context, index) {
|
||||
final navigation = navigationOrder[index];
|
||||
return Row(
|
||||
key: Key('navigation_$navigation'),
|
||||
children: [
|
||||
ReorderableDragStartListener(
|
||||
index: index,
|
||||
child: const Icon(Icons.drag_handle),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
child: ReorderableListView.builder(
|
||||
buildDefaultDragHandles: false,
|
||||
itemCount: navigationOrder.length,
|
||||
itemBuilder: (context, index) {
|
||||
final navigation = navigationOrder[index];
|
||||
return Row(
|
||||
key: Key('navigation_$navigation'),
|
||||
children: [
|
||||
ReorderableDragStartListener(
|
||||
index: index,
|
||||
child: const Icon(Icons.drag_handle),
|
||||
),
|
||||
Expanded(
|
||||
child: SwitchListTile(
|
||||
key: Key(navigation),
|
||||
dense: true,
|
||||
value: !hideItems.contains(navigation),
|
||||
onChanged:
|
||||
[
|
||||
"/more",
|
||||
"/browse",
|
||||
"/history",
|
||||
].any((element) => element == navigation)
|
||||
? null
|
||||
: (value) {
|
||||
final temp = hideItems.toList();
|
||||
if (!value && !hideItems.contains(navigation)) {
|
||||
temp.add(navigation);
|
||||
} else if (value) {
|
||||
temp.remove(navigation);
|
||||
}
|
||||
ref
|
||||
.read(hideItemsStateProvider.notifier)
|
||||
.set(temp);
|
||||
},
|
||||
title: Text(navigationItems[navigation]!),
|
||||
),
|
||||
Expanded(
|
||||
child: SwitchListTile(
|
||||
key: Key(navigation),
|
||||
dense: true,
|
||||
value: !hideItems.contains(navigation),
|
||||
onChanged:
|
||||
[
|
||||
"/more",
|
||||
"/browse",
|
||||
"/history",
|
||||
].any((element) => element == navigation)
|
||||
? null
|
||||
: (value) {
|
||||
final temp = hideItems.toList();
|
||||
if (!value && !hideItems.contains(navigation)) {
|
||||
temp.add(navigation);
|
||||
} else if (value) {
|
||||
temp.remove(navigation);
|
||||
}
|
||||
ref
|
||||
.read(hideItemsStateProvider.notifier)
|
||||
.set(temp);
|
||||
},
|
||||
title: Text(navigationItems[navigation]!),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
onReorder: (oldIndex, newIndex) {
|
||||
if (oldIndex < newIndex) {
|
||||
final draggedItem = navigationOrder[oldIndex];
|
||||
for (var i = oldIndex; i < newIndex - 1; i++) {
|
||||
navigationOrder[i] = navigationOrder[i + 1];
|
||||
}
|
||||
navigationOrder[newIndex - 1] = draggedItem;
|
||||
} else {
|
||||
final draggedItem = navigationOrder[oldIndex];
|
||||
for (var i = oldIndex; i > newIndex; i--) {
|
||||
navigationOrder[i] = navigationOrder[i - 1];
|
||||
}
|
||||
navigationOrder[newIndex] = draggedItem;
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
onReorder: (oldIndex, newIndex) {
|
||||
if (oldIndex < newIndex) {
|
||||
final draggedItem = navigationOrder[oldIndex];
|
||||
for (var i = oldIndex; i < newIndex - 1; i++) {
|
||||
navigationOrder[i] = navigationOrder[i + 1];
|
||||
}
|
||||
ref
|
||||
.read(navigationOrderStateProvider.notifier)
|
||||
.set(navigationOrder);
|
||||
},
|
||||
),
|
||||
navigationOrder[newIndex - 1] = draggedItem;
|
||||
} else {
|
||||
final draggedItem = navigationOrder[oldIndex];
|
||||
for (var i = oldIndex; i > newIndex; i--) {
|
||||
navigationOrder[i] = navigationOrder[i - 1];
|
||||
}
|
||||
navigationOrder[newIndex] = draggedItem;
|
||||
}
|
||||
ref
|
||||
.read(navigationOrderStateProvider.notifier)
|
||||
.set(navigationOrder);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue