mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-07-08 01:30:28 +08:00
Add reorder button
This commit is contained in:
@@ -5,8 +5,9 @@ import '../api/task.dart';
|
|||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
|
|
||||||
class TaskView extends StatefulWidget {
|
class TaskView extends StatefulWidget {
|
||||||
const TaskView(this.task, {super.key});
|
const TaskView(this.task, this.index, {super.key});
|
||||||
final TaskDetail task;
|
final TaskDetail task;
|
||||||
|
final int index;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _TaskView();
|
State<StatefulWidget> createState() => _TaskView();
|
||||||
@@ -82,20 +83,27 @@ class _TaskView extends State<TaskView> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Column(children: [
|
child: GestureDetector(
|
||||||
_buildText(context),
|
onTap: () {},
|
||||||
LinearPercentIndicator(
|
child: Row(children: [
|
||||||
animation: true,
|
Expanded(
|
||||||
animateFromLastPercent: true,
|
child: Column(children: [
|
||||||
progressColor: Colors.green,
|
_buildText(context),
|
||||||
lineHeight: 20.0,
|
LinearPercentIndicator(
|
||||||
barRadius: const Radius.circular(10),
|
animation: true,
|
||||||
padding: EdgeInsets.zero,
|
animateFromLastPercent: true,
|
||||||
center:
|
progressColor: Colors.green,
|
||||||
Text(percentText, style: const TextStyle(color: Colors.black)),
|
lineHeight: 20.0,
|
||||||
percent: percent,
|
barRadius: const Radius.circular(10),
|
||||||
),
|
padding: EdgeInsets.zero,
|
||||||
]),
|
center: Text(percentText,
|
||||||
|
style: const TextStyle(color: Colors.black)),
|
||||||
|
percent: percent,
|
||||||
|
),
|
||||||
|
])),
|
||||||
|
ReorderableDragStartListener(
|
||||||
|
index: widget.index, child: const Icon(Icons.reorder)),
|
||||||
|
])),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class _TaskManagerPage extends State<TaskManagerPage>
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
key: ValueKey("task_${task.base.id}"),
|
key: ValueKey("task_${task.base.id}"),
|
||||||
child: TaskView(task));
|
child: TaskView(task, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _proxyDecorator(Widget child, int index, Animation<double> animation) {
|
Widget _proxyDecorator(Widget child, int index, Animation<double> animation) {
|
||||||
@@ -117,7 +117,15 @@ class _TaskManagerPage extends State<TaskManagerPage>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onReorder(int oldIndex, int newIndex) {}
|
void _onReorder(int oldIndex, int newIndex) {
|
||||||
|
setState(() {
|
||||||
|
if (oldIndex < newIndex) {
|
||||||
|
newIndex -= 1;
|
||||||
|
}
|
||||||
|
final task = tasks.tasksList.removeAt(oldIndex);
|
||||||
|
tasks.tasksList.insert(newIndex, task);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildList(BuildContext context) {
|
Widget _buildList(BuildContext context) {
|
||||||
return SliverReorderableList(
|
return SliverReorderableList(
|
||||||
|
|||||||
Reference in New Issue
Block a user