mirror of
https://github.com/simon-ding/polaris.git
synced 2026-05-27 13:07:47 +08:00
refactor: activity list
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:percent_indicator/circular_percent_indicator.dart';
|
|||||||
import 'package:ui/providers/activity.dart';
|
import 'package:ui/providers/activity.dart';
|
||||||
import 'package:ui/widgets/progress_indicator.dart';
|
import 'package:ui/widgets/progress_indicator.dart';
|
||||||
import 'package:ui/widgets/widgets.dart';
|
import 'package:ui/widgets/widgets.dart';
|
||||||
|
import 'package:timeago/timeago.dart' as timeago;
|
||||||
|
|
||||||
class ActivityPage extends ConsumerStatefulWidget {
|
class ActivityPage extends ConsumerStatefulWidget {
|
||||||
const ActivityPage({super.key});
|
const ActivityPage({super.key});
|
||||||
@@ -60,21 +61,63 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
|
|||||||
|
|
||||||
return activitiesWatcher.when(
|
return activitiesWatcher.when(
|
||||||
data: (activities) {
|
data: (activities) {
|
||||||
return SingleChildScrollView(
|
return Flexible(
|
||||||
child: PaginatedDataTable(
|
child: ListView.builder(
|
||||||
rowsPerPage: 10,
|
itemCount: activities.length,
|
||||||
columns: const [
|
itemBuilder: (context, index) {
|
||||||
DataColumn(label: Text("#"), numeric: true),
|
final ac = activities[index];
|
||||||
DataColumn(label: Text("名称")),
|
return Column(
|
||||||
DataColumn(label: Text("开始时间")),
|
children: [
|
||||||
DataColumn(label: Text("状态")),
|
ListTile(
|
||||||
DataColumn(label: Text("操作"))
|
dense: true,
|
||||||
],
|
leading: () {
|
||||||
source: ActivityDataSource(
|
if (ac.status == "uploading") {
|
||||||
activities: activities,
|
return const SizedBox(
|
||||||
onDelete: selectedTab == 0 ? onDelete() : null),
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
child: Tooltip(
|
||||||
|
message: "正在上传到指定存储",
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
));
|
||||||
|
} else if (ac.status == "fail") {
|
||||||
|
return const Tooltip(
|
||||||
|
message: "下载失败",
|
||||||
|
child: Icon(
|
||||||
|
Icons.close,
|
||||||
|
color: Colors.red,
|
||||||
|
));
|
||||||
|
} else if (ac.status == "success") {
|
||||||
|
return const Tooltip(
|
||||||
|
message: "下载成功",
|
||||||
|
child: Icon(
|
||||||
|
Icons.check,
|
||||||
|
color: Colors.green,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
double p = ac.progress == null
|
||||||
|
? 0
|
||||||
|
: ac.progress!.toDouble() / 100;
|
||||||
|
return Tooltip(message: "${ac.progress}%",child: CircularProgressIndicator(
|
||||||
|
backgroundColor: Colors.black26,
|
||||||
|
value: p,
|
||||||
|
),);
|
||||||
|
}(),
|
||||||
|
title: Text("$index " + (ac.sourceTitle ?? "")),
|
||||||
|
subtitle: Text("开始时间:${timeago.format(ac.date!)}"),
|
||||||
|
trailing: selectedTab == 0
|
||||||
|
? IconButton(
|
||||||
|
tooltip: "删除任务",
|
||||||
|
onPressed: () => onDelete()(ac.id!),
|
||||||
|
icon: const Icon(Icons.delete))
|
||||||
|
: const Text("-"),
|
||||||
|
),
|
||||||
|
Divider(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
));
|
||||||
},
|
},
|
||||||
error: (err, trace) => Text("$err"),
|
error: (err, trace) => Text("$err"),
|
||||||
loading: () => const MyProgressIndicator());
|
loading: () => const MyProgressIndicator());
|
||||||
|
|||||||
@@ -434,6 +434,14 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.2"
|
version: "0.7.2"
|
||||||
|
timeago:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: timeago
|
||||||
|
sha256: "054cedf68706bb142839ba0ae6b135f6b68039f0b8301cbe8784ae653d5ff8de"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "3.7.0"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ dependencies:
|
|||||||
flutter_form_builder: ^9.3.0
|
flutter_form_builder: ^9.3.0
|
||||||
form_builder_validators: ^11.0.0
|
form_builder_validators: ^11.0.0
|
||||||
url_launcher: ^6.3.0
|
url_launcher: ^6.3.0
|
||||||
|
timeago: ^3.7.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user