|
|
@@ -2,6 +2,7 @@ import 'package:app_business/service/api.dart';
|
|
|
import 'package:app_business/view/home/dialog_event_register.dart';
|
|
|
import 'package:pretty_qr_code/pretty_qr_code.dart';
|
|
|
import 'package:track_common/model/event_state.dart';
|
|
|
+import 'package:track_common/utils.dart';
|
|
|
import 'package:track_common/widget.dart';
|
|
|
import 'package:track_common/widget/prelude.dart';
|
|
|
|
|
|
@@ -41,36 +42,49 @@ class EventManage extends GetView<EventManagerController> {
|
|
|
Widget wTopButtons(BuildContext context) {
|
|
|
return Obx(() {
|
|
|
final enable = controller.selected?.state == EventState.start;
|
|
|
+ final buttons = [
|
|
|
+ (Colors.orange, '一键重赛', controller.userRestartAll),
|
|
|
+ (Colors.blue, '一键分发', controller.routeAllocAll),
|
|
|
+ (Colors.green, '一键开始', controller.userStartAll),
|
|
|
+ (Colors.red, '一键删除', controller.userDelAll),
|
|
|
+ ];
|
|
|
+
|
|
|
+ final List<Widget> children = buttons.map((e) {
|
|
|
+ return AppButton.outlined(
|
|
|
+ color: e.$1,
|
|
|
+ onPressed: onDoAll(context, enable, e.$2, e.$3),
|
|
|
+ child: Text(e.$2),
|
|
|
+ );
|
|
|
+ }).toList();
|
|
|
|
|
|
return Row(
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
- children: [
|
|
|
- AppButton.outlined(
|
|
|
- color: Colors.orange,
|
|
|
- onPressed: enable ? controller.userRestartAll : null,
|
|
|
- child: const Text('一键重赛'),
|
|
|
- ),
|
|
|
- AppButton.outlined(
|
|
|
- color: Colors.blue,
|
|
|
- onPressed: enable ? controller.routeAllocAll : null,
|
|
|
- child: const Text('一键分发'),
|
|
|
- ),
|
|
|
- AppButton.outlined(
|
|
|
- color: Colors.green,
|
|
|
- onPressed: enable ? controller.userStartAll : null,
|
|
|
- child: const Text('一键开始'),
|
|
|
- ),
|
|
|
- AppButton.outlined(
|
|
|
- color: Colors.red,
|
|
|
- onPressed: enable ? controller.userDelAll : null,
|
|
|
- child: const Text('一键删除'),
|
|
|
- )
|
|
|
- ],
|
|
|
+ children: children,
|
|
|
);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ void Function()? onDoAll(BuildContext context, bool enable, String title,
|
|
|
+ Future<void> Function() then) {
|
|
|
+ return enable ? () => doAll(context, title, then) : null;
|
|
|
+ }
|
|
|
+
|
|
|
+ Future<void> doAll(
|
|
|
+ BuildContext context, String title, Future<void> Function() then) async {
|
|
|
+ Get.dialog(AppDialog(
|
|
|
+ title: Text('确认$title?'),
|
|
|
+ onCancelText: '取消',
|
|
|
+ onConfirmText: '确认',
|
|
|
+ onConfirm: () => context.doCall(() async {
|
|
|
+ await then();
|
|
|
+ if (context.mounted) {
|
|
|
+ ScaffoldMessenger.of(context)
|
|
|
+ .showSnackBar(const SnackBar(content: Text('操作成功')));
|
|
|
+ }
|
|
|
+ }, onFinally: () => Get.back())));
|
|
|
+ }
|
|
|
+
|
|
|
Widget wDate(BuildContext context) {
|
|
|
return GestureDetector(
|
|
|
onTap: () => _onTapDate(context),
|