feat:更新主题色兼容

This commit is contained in:
2025-11-21 14:58:11 +08:00
parent 3ea162f33e
commit f133e5ce13
11 changed files with 112 additions and 75 deletions

View File

@@ -143,7 +143,7 @@ Widget buildDismissible({
background: _buildDismissBackground(),
confirmDismiss: (direction) async {
// 这里实现二次确认
return await showDeleteConfirmationDialog(context);
return await showConfirmDialog(context, '确定要删除这个项目吗?');
},
onDismissed: (direction) {
onDelete();
@@ -153,22 +153,27 @@ Widget buildDismissible({
}
// 确认对话框
Future<bool?> showDeleteConfirmationDialog(BuildContext context) async {
Future<bool?> showConfirmDialog(BuildContext context, String text) async {
final colors = Theme.of(context).colorScheme;
return showDialog<bool>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('确认删除'),
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
content: const Text('确定要删除这个项目吗?'),
title: const Text('确认'),
backgroundColor: colors.surfaceContainer,
content: Text(text),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text('取消'),
child: Text(
'取消',
style: TextStyle(color: colors.secondary.withAlpha(150)),
),
),
TextButton(
onPressed: () => Navigator.of(context).pop(true),
child: const Text('删除', style: TextStyle(color: Colors.red)),
child: Text('确认', style: TextStyle(color: colors.primary)),
),
],
);
@@ -220,25 +225,25 @@ ButtonStyle buildSegmentStyle(ColorScheme colors) {
side: WidgetStateProperty.all<BorderSide>(
BorderSide(color: colors.surface, width: 0),
),
iconColor: WidgetStateProperty.resolveWith<Color>(
(Set<WidgetState> states) {
if (states.contains(WidgetState.selected)) {
return colors.onPrimary;
}
return Colors.grey;
},
),
iconColor: WidgetStateProperty.resolveWith<Color>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.selected)) {
return colors.onPrimary;
}
return Colors.grey;
}),
backgroundColor: WidgetStateProperty.resolveWith<Color>((
Set<WidgetState> states,
) {
Set<WidgetState> states,
) {
if (states.contains(WidgetState.selected)) {
return colors.primary;
}
return colors.surfaceContainer;
}),
foregroundColor: WidgetStateProperty.resolveWith<Color>((
Set<WidgetState> states,
) {
Set<WidgetState> states,
) {
if (states.contains(WidgetState.selected)) {
return colors.onPrimary;
}