Files
PiliPlus/lib/common/widgets/appbar/appbar.dart
bggRGjQaUbCoE 422b413778 opt ui
opt req

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
2025-08-15 11:18:10 +08:00

60 lines
1.6 KiB
Dart

import 'package:PiliPlus/pages/common/multi_select/base.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class MultiSelectAppBarWidget extends StatelessWidget
implements PreferredSizeWidget {
final MultiSelectBase ctr;
final bool? visible;
final AppBar child;
final List<Widget>? children;
const MultiSelectAppBarWidget({
super.key,
required this.ctr,
this.visible,
this.children,
required this.child,
});
@override
Widget build(BuildContext context) {
if (visible ?? ctr.enableMultiSelect.value) {
return AppBar(
bottom: child.bottom,
leading: IconButton(
tooltip: '取消',
onPressed: ctr.handleSelect,
icon: const Icon(Icons.close_outlined),
),
title: Obx(() => Text('已选: ${ctr.checkedCount}')),
actions: [
TextButton(
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
),
onPressed: () => ctr.handleSelect(checked: true),
child: const Text('全选'),
),
...?children,
TextButton(
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
),
onPressed: ctr.onRemove,
child: Text(
'移除',
style: TextStyle(color: Get.theme.colorScheme.error),
),
),
const SizedBox(width: 6),
],
);
}
return child;
}
@override
Size get preferredSize => child.preferredSize;
}