feat:增加主题色存储本地的功能
This commit is contained in:
@@ -48,23 +48,12 @@ Widget buildTabs({
|
||||
}) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: ToggleSwitch(
|
||||
minWidth: 90.0,
|
||||
minHeight: 40.0,
|
||||
initialLabelIndex: FlispTab.values.indexOf(currentTab),
|
||||
totalSwitches: FlispTab.values.length,
|
||||
child: buildToggleSwitch(
|
||||
context: context,
|
||||
currentTab: currentTab,
|
||||
tabValues: FlispTab.values,
|
||||
labels: FlispTab.values.map((e) => e.label).toList(),
|
||||
activeBgColor: [Theme.of(context).colorScheme.primary],
|
||||
activeFgColor: Colors.white,
|
||||
inactiveBgColor: Colors.grey.shade200,
|
||||
inactiveFgColor: Colors.grey.shade700,
|
||||
cornerRadius: 12.0,
|
||||
customTextStyles: [TextStyle(fontSize: 12, fontWeight: FontWeight.w500)],
|
||||
onToggle: (index) {
|
||||
if (index != null) {
|
||||
onTabChanged(FlispTab.values[index]);
|
||||
}
|
||||
},
|
||||
onTabChanged: onTabChanged,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -275,17 +264,10 @@ Widget _buildFlispItem({
|
||||
final hasImage = flisp.imageUrl.isNotEmpty;
|
||||
final hasVideo = flisp.videoUrl.isNotEmpty;
|
||||
|
||||
return Dismissible(
|
||||
key: ValueKey(flisp.id),
|
||||
direction: DismissDirection.endToStart,
|
||||
background: _buildDismissBackground(),
|
||||
confirmDismiss: (direction) async {
|
||||
// 这里实现二次确认
|
||||
return await _showDeleteConfirmationDialog(context);
|
||||
},
|
||||
onDismissed: (direction) {
|
||||
onDelete(flisp);
|
||||
},
|
||||
return buildDismissible(
|
||||
context: context,
|
||||
id: flisp.id,
|
||||
onDelete: () => onDelete(flisp),
|
||||
child: BuildCard(
|
||||
child: InkWell(
|
||||
onTap: () => onEdit(flisp),
|
||||
@@ -306,39 +288,6 @@ Widget _buildFlispItem({
|
||||
);
|
||||
}
|
||||
|
||||
// 确认对话框
|
||||
Future<bool?> _showDeleteConfirmationDialog(BuildContext context) async {
|
||||
return showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('确认删除'),
|
||||
backgroundColor: Colors.white,
|
||||
content: const Text('确定要删除这个项目吗?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: const Text('删除', style: TextStyle(color: Colors.red)),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDismissBackground() {
|
||||
return Container(
|
||||
color: Colors.red,
|
||||
alignment: Alignment.centerRight,
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
child: const Icon(Icons.delete, color: Colors.white, size: 24),
|
||||
);
|
||||
}
|
||||
|
||||
// 空状态
|
||||
Widget buildEmptyState(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
Reference in New Issue
Block a user