feat:增加主题色存储本地的功能
This commit is contained in:
@@ -19,7 +19,7 @@ if (keystorePropertiesFile.exists()) {
|
|||||||
android {
|
android {
|
||||||
namespace = "com.cxx.flisp_app"
|
namespace = "com.cxx.flisp_app"
|
||||||
compileSdk = flutter.compileSdkVersion
|
compileSdk = flutter.compileSdkVersion
|
||||||
ndkVersion = flutter.ndkVersion
|
ndkVersion = "27.0.12077973"
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
@@ -46,7 +46,7 @@ android {
|
|||||||
|
|
||||||
// 签名配置
|
// 签名配置
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
create("release") {
|
create("sigin") {
|
||||||
if (keystorePropertiesFile.exists()) {
|
if (keystorePropertiesFile.exists()) {
|
||||||
keyAlias = keystoreProperties.getProperty("keyAlias")
|
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||||
keyPassword = keystoreProperties.getProperty("keyPassword")
|
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||||
@@ -57,10 +57,18 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
debug {
|
||||||
// 修改这里:使用发布签名配置
|
|
||||||
signingConfig = if (keystorePropertiesFile.exists()) {
|
signingConfig = if (keystorePropertiesFile.exists()) {
|
||||||
signingConfigs.getByName("release")
|
signingConfigs.getByName("sigin")
|
||||||
|
} else {
|
||||||
|
signingConfigs.getByName("debug")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
release {
|
||||||
|
// 使用发布签名配置
|
||||||
|
signingConfig = if (keystorePropertiesFile.exists()) {
|
||||||
|
signingConfigs.getByName("sigin")
|
||||||
} else {
|
} else {
|
||||||
signingConfigs.getByName("debug")
|
signingConfigs.getByName("debug")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flisp_app/provider/app_provider.dart';
|
import 'package:flisp_app/provider/app_provider.dart';
|
||||||
|
import 'package:flisp_app/utils/theme_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
@@ -57,88 +58,6 @@ class AppDrawer extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildThemeColorList(BuildContext context, AppProvider appProvider) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
|
||||||
child: GridView.builder(
|
|
||||||
shrinkWrap: true,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
||||||
crossAxisCount: 4,
|
|
||||||
crossAxisSpacing: 8,
|
|
||||||
mainAxisSpacing: 8,
|
|
||||||
childAspectRatio: 1.2,
|
|
||||||
),
|
|
||||||
itemCount: appProvider.availableThemes.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final themeColor = appProvider.availableThemes[index];
|
|
||||||
final isSelected = appProvider.currentTheme == themeColor;
|
|
||||||
|
|
||||||
return _buildThemeColorItem(
|
|
||||||
themeColor: themeColor,
|
|
||||||
isSelected: isSelected,
|
|
||||||
onTap: () => appProvider.changeTheme(themeColor),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildThemeColorItem({
|
|
||||||
required ThemeColor themeColor,
|
|
||||||
required bool isSelected,
|
|
||||||
required VoidCallback onTap,
|
|
||||||
}) {
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: onTap,
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color:
|
|
||||||
isSelected
|
|
||||||
? themeColor.primaryColor.withAlpha(50)
|
|
||||||
: Colors.transparent,
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
border: Border.all(
|
|
||||||
color: isSelected ? themeColor.primaryColor : Colors.grey.shade300,
|
|
||||||
width: isSelected ? 2 : 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
// 颜色圆点
|
|
||||||
Container(
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: themeColor.primaryColor,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
border: Border.all(color: Colors.white, width: 2),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black.withAlpha(10),
|
|
||||||
blurRadius: 2,
|
|
||||||
offset: const Offset(0, 1),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
themeColor.name,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 10,
|
|
||||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
|
||||||
color:
|
|
||||||
isSelected ? themeColor.primaryColor : Colors.grey.shade600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildThemeSection(BuildContext context, AppProvider appProvider) {
|
Widget _buildThemeSection(BuildContext context, AppProvider appProvider) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -148,7 +67,7 @@ class AppDrawer extends StatelessWidget {
|
|||||||
child: Text('主题颜色', style: Theme.of(context).textTheme.titleMedium),
|
child: Text('主题颜色', style: Theme.of(context).textTheme.titleMedium),
|
||||||
),
|
),
|
||||||
_buildDarkModeSection(context, appProvider),
|
_buildDarkModeSection(context, appProvider),
|
||||||
_buildThemeColorList(context, appProvider),
|
buildThemeColorList(context, appProvider),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -178,49 +97,6 @@ class AppDrawer extends StatelessWidget {
|
|||||||
// 抽屉头部
|
// 抽屉头部
|
||||||
buildDrawerHeader(context),
|
buildDrawerHeader(context),
|
||||||
|
|
||||||
// 菜单项
|
|
||||||
_buildDrawerItem(
|
|
||||||
context: context,
|
|
||||||
icon: Icons.flash_on,
|
|
||||||
title: '闪灵',
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
appProvider.changeTab(0);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
_buildDrawerItem(
|
|
||||||
context: context,
|
|
||||||
icon: Icons.checklist,
|
|
||||||
title: '待办事项',
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
appProvider.changeTab(1);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
const Divider(),
|
|
||||||
|
|
||||||
_buildDrawerItem(
|
|
||||||
context: context,
|
|
||||||
icon: Icons.analytics,
|
|
||||||
title: '统计',
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
// 这里可以导航到统计页面
|
|
||||||
},
|
|
||||||
),
|
|
||||||
_buildDrawerItem(
|
|
||||||
context: context,
|
|
||||||
icon: Icons.archive,
|
|
||||||
title: '归档',
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
// 这里可以导航到归档页面
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
const Divider(),
|
|
||||||
|
|
||||||
_buildThemeSection(context, appProvider),
|
_buildThemeSection(context, appProvider),
|
||||||
|
|
||||||
const Divider(),
|
const Divider(),
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ class FlispPageState extends State<FlispPage> {
|
|||||||
padding: EdgeInsets.all(10),
|
padding: EdgeInsets.all(10),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
buildStatsCard(_activeFlisps),
|
|
||||||
buildTabs(
|
buildTabs(
|
||||||
context: context,
|
context: context,
|
||||||
currentTab: _currentTab,
|
currentTab: _currentTab,
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ class TodoPageState extends State<TodoPage> {
|
|||||||
padding: EdgeInsets.all(10),
|
padding: EdgeInsets.all(10),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
buildStatsCard(_todos),
|
|
||||||
buildTabs(
|
buildTabs(
|
||||||
context: context,
|
context: context,
|
||||||
currentTab: _currentTab,
|
currentTab: _currentTab,
|
||||||
@@ -67,6 +66,7 @@ class TodoPageState extends State<TodoPage> {
|
|||||||
return _activeTodos.isEmpty
|
return _activeTodos.isEmpty
|
||||||
? buildEmptyState(context, _currentTab)
|
? buildEmptyState(context, _currentTab)
|
||||||
: buildTodoList(
|
: buildTodoList(
|
||||||
|
context: context,
|
||||||
todos: _activeTodos,
|
todos: _activeTodos,
|
||||||
onToggleTodo: (todo) {
|
onToggleTodo: (todo) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -76,6 +76,9 @@ class TodoPageState extends State<TodoPage> {
|
|||||||
onEditTodo: (todo) {
|
onEditTodo: (todo) {
|
||||||
_showDialog(true, todo);
|
_showDialog(true, todo);
|
||||||
},
|
},
|
||||||
|
onDelete: (todo) {
|
||||||
|
_deleteTodo(todo);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,4 +152,19 @@ class TodoPageState extends State<TodoPage> {
|
|||||||
showErrorDialog(context, isEditing ? '更新失败' : '添加失败');
|
showErrorDialog(context, isEditing ? '更新失败' : '添加失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _deleteTodo(Todo todo) async {
|
||||||
|
await notifyService.cancelNotification(todo.id);
|
||||||
|
bool isSuccess = await todoService.deleteTodo(todo);
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_todos = todoService.getAllTodos();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isSuccess) {
|
||||||
|
showSuccessDialog(context, '删除成功');
|
||||||
|
} else {
|
||||||
|
showErrorDialog(context, '删除失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,153 +1,54 @@
|
|||||||
|
import 'package:flisp_app/utils/theme_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
class ThemeColor {
|
|
||||||
final String name;
|
|
||||||
final Color primaryColor;
|
|
||||||
final MaterialColor materialColor;
|
|
||||||
|
|
||||||
ThemeColor({
|
|
||||||
required this.name,
|
|
||||||
required this.primaryColor,
|
|
||||||
required this.materialColor,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
class AppProvider with ChangeNotifier {
|
class AppProvider with ChangeNotifier {
|
||||||
|
static const String _themeKey = 'selected_theme';
|
||||||
|
static const String _darkModeKey = 'is_dark_mode';
|
||||||
|
|
||||||
int _currentTab = 0;
|
int _currentTab = 0;
|
||||||
bool _isDarkMode = false;
|
bool _isDarkMode = false;
|
||||||
ThemeColor _currentTheme = _defaultThemes[0];
|
ThemeColor _currentTheme = defaultThemes[0];
|
||||||
|
late SharedPreferences _prefs;
|
||||||
|
bool _isInitialized = false;
|
||||||
|
|
||||||
// 预定义主题色
|
AppProvider() {
|
||||||
static final List<ThemeColor> _defaultThemes = [
|
_initPreferences();
|
||||||
ThemeColor(
|
}
|
||||||
name: '科技蓝',
|
|
||||||
primaryColor: Color(0xFF2563EB),
|
// 初始化 SharedPreferences
|
||||||
materialColor: MaterialColor(0xFF2563EB, {
|
Future<void> _initPreferences() async {
|
||||||
50: Color(0xFFDBEAFE),
|
_prefs = await SharedPreferences.getInstance();
|
||||||
100: Color(0xFFBFDBFE),
|
_loadPreferences();
|
||||||
200: Color(0xFF93C5FD),
|
_isInitialized = true;
|
||||||
300: Color(0xFF60A5FA),
|
notifyListeners();
|
||||||
400: Color(0xFF3B82F6),
|
}
|
||||||
500: Color(0xFF2563EB),
|
|
||||||
600: Color(0xFF1D4ED8),
|
// 加载存储的设置
|
||||||
700: Color(0xFF1E40AF),
|
void _loadPreferences() {
|
||||||
800: Color(0xFF1E3A8A),
|
_isDarkMode = _prefs.getBool(_darkModeKey) ?? false;
|
||||||
900: Color(0xFF1E3A8A),
|
|
||||||
}),
|
// 加载主题色
|
||||||
),
|
final themeName = _prefs.getString(_themeKey);
|
||||||
ThemeColor(
|
if (themeName != null) {
|
||||||
name: '翡翠绿',
|
// 根据主题名称查找对应的主题
|
||||||
primaryColor: Color(0xFF10B981),
|
final savedTheme = defaultThemes.firstWhere(
|
||||||
materialColor: MaterialColor(0xFF10B981, {
|
(theme) => theme.name == themeName,
|
||||||
50: Color(0xFFECFDF5),
|
orElse: () => defaultThemes[0],
|
||||||
100: Color(0xFFD1FAE5),
|
);
|
||||||
200: Color(0xFFA7F3D0),
|
_currentTheme = savedTheme;
|
||||||
300: Color(0xFF6EE7B7),
|
}
|
||||||
400: Color(0xFF34D399),
|
}
|
||||||
500: Color(0xFF10B981),
|
|
||||||
600: Color(0xFF059669),
|
// 保存主题色
|
||||||
700: Color(0xFF047857),
|
Future<void> _saveTheme() async {
|
||||||
800: Color(0xFF065F46),
|
await _prefs.setString(_themeKey, _currentTheme.name);
|
||||||
900: Color(0xFF064E3B),
|
}
|
||||||
}),
|
|
||||||
),
|
// 保存暗黑模式
|
||||||
ThemeColor(
|
Future<void> _saveDarkMode() async {
|
||||||
name: '活力橙',
|
await _prefs.setBool(_darkModeKey, _isDarkMode);
|
||||||
primaryColor: Color(0xFFF59E0B),
|
}
|
||||||
materialColor: MaterialColor(0xFFF59E0B, {
|
|
||||||
50: Color(0xFFFFFBEB),
|
|
||||||
100: Color(0xFFFEF3C7),
|
|
||||||
200: Color(0xFFFDE68A),
|
|
||||||
300: Color(0xFFFCD34D),
|
|
||||||
400: Color(0xFFFBBF24),
|
|
||||||
500: Color(0xFFF59E0B),
|
|
||||||
600: Color(0xFFD97706),
|
|
||||||
700: Color(0xFFB45309),
|
|
||||||
800: Color(0xFF92400E),
|
|
||||||
900: Color(0xFF78350F),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
ThemeColor(
|
|
||||||
name: '梦幻紫',
|
|
||||||
primaryColor: Color(0xFF8B5CF6),
|
|
||||||
materialColor: MaterialColor(0xFF8B5CF6, {
|
|
||||||
50: Color(0xFFF5F3FF),
|
|
||||||
100: Color(0xFFEDE9FE),
|
|
||||||
200: Color(0xFFDDD6FE),
|
|
||||||
300: Color(0xFFC4B5FD),
|
|
||||||
400: Color(0xFFA78BFA),
|
|
||||||
500: Color(0xFF8B5CF6),
|
|
||||||
600: Color(0xFF7C3AED),
|
|
||||||
700: Color(0xFF6D28D9),
|
|
||||||
800: Color(0xFF5B21B6),
|
|
||||||
900: Color(0xFF4C1D95),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
ThemeColor(
|
|
||||||
name: '浪漫粉',
|
|
||||||
primaryColor: Color(0xFFEC4899),
|
|
||||||
materialColor: MaterialColor(0xFFEC4899, {
|
|
||||||
50: Color(0xFFFDF2F8),
|
|
||||||
100: Color(0xFFFCE7F3),
|
|
||||||
200: Color(0xFFFBCFE8),
|
|
||||||
300: Color(0xFFF9A8D4),
|
|
||||||
400: Color(0xFFF472B6),
|
|
||||||
500: Color(0xFFEC4899),
|
|
||||||
600: Color(0xFFDB2777),
|
|
||||||
700: Color(0xFFBE185D),
|
|
||||||
800: Color(0xFF9D174D),
|
|
||||||
900: Color(0xFF831843),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
ThemeColor(
|
|
||||||
name: '清新青',
|
|
||||||
primaryColor: Color(0xFF06B6D4),
|
|
||||||
materialColor: MaterialColor(0xFF06B6D4, {
|
|
||||||
50: Color(0xFFF0FDFA),
|
|
||||||
100: Color(0xFFCCFBF1),
|
|
||||||
200: Color(0xFF99F6E4),
|
|
||||||
300: Color(0xFF5EEAD4),
|
|
||||||
400: Color(0xFF2DD4BF),
|
|
||||||
500: Color(0xFF06B6D4),
|
|
||||||
600: Color(0xFF0891B2),
|
|
||||||
700: Color(0xFF0E7490),
|
|
||||||
800: Color(0xFF155E75),
|
|
||||||
900: Color(0xFF164E63),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
ThemeColor(
|
|
||||||
name: '深空蓝',
|
|
||||||
primaryColor: Color(0xFF1E40AF),
|
|
||||||
materialColor: MaterialColor(0xFF1E40AF, {
|
|
||||||
50: Color(0xFFEFF6FF),
|
|
||||||
100: Color(0xFFDBEAFE),
|
|
||||||
200: Color(0xFFBFDBFE),
|
|
||||||
300: Color(0xFF93C5FD),
|
|
||||||
400: Color(0xFF60A5FA),
|
|
||||||
500: Color(0xFF3B82F6),
|
|
||||||
600: Color(0xFF2563EB),
|
|
||||||
700: Color(0xFF1D4ED8),
|
|
||||||
800: Color(0xFF1E40AF),
|
|
||||||
900: Color(0xFF1E3A8A),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
ThemeColor(
|
|
||||||
name: '落日红',
|
|
||||||
primaryColor: Color(0xFFEF4444),
|
|
||||||
materialColor: MaterialColor(0xFFEF4444, {
|
|
||||||
50: Color(0xFFFEF2F2),
|
|
||||||
100: Color(0xFFFEE2E2),
|
|
||||||
200: Color(0xFFFECACA),
|
|
||||||
300: Color(0xFFFCA5A5),
|
|
||||||
400: Color(0xFFF87171),
|
|
||||||
500: Color(0xFFEF4444),
|
|
||||||
600: Color(0xFFDC2626),
|
|
||||||
700: Color(0xFFB91C1C),
|
|
||||||
800: Color(0xFF991B1B),
|
|
||||||
900: Color(0xFF7F1D1D),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
int get currentTab => _currentTab;
|
int get currentTab => _currentTab;
|
||||||
|
|
||||||
@@ -155,7 +56,9 @@ class AppProvider with ChangeNotifier {
|
|||||||
|
|
||||||
ThemeColor get currentTheme => _currentTheme;
|
ThemeColor get currentTheme => _currentTheme;
|
||||||
|
|
||||||
List<ThemeColor> get availableThemes => _defaultThemes;
|
List<ThemeColor> get availableThemes => defaultThemes;
|
||||||
|
|
||||||
|
bool get isInitialized => _isInitialized;
|
||||||
|
|
||||||
void changeTab(int index) {
|
void changeTab(int index) {
|
||||||
_currentTab = index;
|
_currentTab = index;
|
||||||
@@ -165,12 +68,14 @@ class AppProvider with ChangeNotifier {
|
|||||||
// 切换明暗模式
|
// 切换明暗模式
|
||||||
void toggleDarkMode(bool value) {
|
void toggleDarkMode(bool value) {
|
||||||
_isDarkMode = value;
|
_isDarkMode = value;
|
||||||
|
_saveDarkMode();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改主题色
|
// 更改主题色
|
||||||
void changeTheme(ThemeColor theme) {
|
void changeTheme(ThemeColor theme) {
|
||||||
_currentTheme = theme;
|
_currentTheme = theme;
|
||||||
|
_saveTheme();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
229
lib/utils/theme_utils.dart
Normal file
229
lib/utils/theme_utils.dart
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:flisp_app/provider/app_provider.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class ThemeColor {
|
||||||
|
final String name;
|
||||||
|
final Color primaryColor;
|
||||||
|
final MaterialColor materialColor;
|
||||||
|
|
||||||
|
ThemeColor({
|
||||||
|
required this.name,
|
||||||
|
required this.primaryColor,
|
||||||
|
required this.materialColor,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<ThemeColor> defaultThemes = [
|
||||||
|
ThemeColor(
|
||||||
|
name: '科技蓝',
|
||||||
|
primaryColor: Color(0xFF2563EB),
|
||||||
|
materialColor: MaterialColor(0xFF2563EB, {
|
||||||
|
50: Color(0xFFDBEAFE),
|
||||||
|
100: Color(0xFFBFDBFE),
|
||||||
|
200: Color(0xFF93C5FD),
|
||||||
|
300: Color(0xFF60A5FA),
|
||||||
|
400: Color(0xFF3B82F6),
|
||||||
|
500: Color(0xFF2563EB),
|
||||||
|
600: Color(0xFF1D4ED8),
|
||||||
|
700: Color(0xFF1E40AF),
|
||||||
|
800: Color(0xFF1E3A8A),
|
||||||
|
900: Color(0xFF1E3A8A),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
ThemeColor(
|
||||||
|
name: '翡翠绿',
|
||||||
|
primaryColor: Color(0xFF10B981),
|
||||||
|
materialColor: MaterialColor(0xFF10B981, {
|
||||||
|
50: Color(0xFFECFDF5),
|
||||||
|
100: Color(0xFFD1FAE5),
|
||||||
|
200: Color(0xFFA7F3D0),
|
||||||
|
300: Color(0xFF6EE7B7),
|
||||||
|
400: Color(0xFF34D399),
|
||||||
|
500: Color(0xFF10B981),
|
||||||
|
600: Color(0xFF059669),
|
||||||
|
700: Color(0xFF047857),
|
||||||
|
800: Color(0xFF065F46),
|
||||||
|
900: Color(0xFF064E3B),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
ThemeColor(
|
||||||
|
name: '活力橙',
|
||||||
|
primaryColor: Color(0xFFF59E0B),
|
||||||
|
materialColor: MaterialColor(0xFFF59E0B, {
|
||||||
|
50: Color(0xFFFFFBEB),
|
||||||
|
100: Color(0xFFFEF3C7),
|
||||||
|
200: Color(0xFFFDE68A),
|
||||||
|
300: Color(0xFFFCD34D),
|
||||||
|
400: Color(0xFFFBBF24),
|
||||||
|
500: Color(0xFFF59E0B),
|
||||||
|
600: Color(0xFFD97706),
|
||||||
|
700: Color(0xFFB45309),
|
||||||
|
800: Color(0xFF92400E),
|
||||||
|
900: Color(0xFF78350F),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
ThemeColor(
|
||||||
|
name: '梦幻紫',
|
||||||
|
primaryColor: Color(0xFF8B5CF6),
|
||||||
|
materialColor: MaterialColor(0xFF8B5CF6, {
|
||||||
|
50: Color(0xFFF5F3FF),
|
||||||
|
100: Color(0xFFEDE9FE),
|
||||||
|
200: Color(0xFFDDD6FE),
|
||||||
|
300: Color(0xFFC4B5FD),
|
||||||
|
400: Color(0xFFA78BFA),
|
||||||
|
500: Color(0xFF8B5CF6),
|
||||||
|
600: Color(0xFF7C3AED),
|
||||||
|
700: Color(0xFF6D28D9),
|
||||||
|
800: Color(0xFF5B21B6),
|
||||||
|
900: Color(0xFF4C1D95),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
ThemeColor(
|
||||||
|
name: '浪漫粉',
|
||||||
|
primaryColor: Color(0xFFEC4899),
|
||||||
|
materialColor: MaterialColor(0xFFEC4899, {
|
||||||
|
50: Color(0xFFFDF2F8),
|
||||||
|
100: Color(0xFFFCE7F3),
|
||||||
|
200: Color(0xFFFBCFE8),
|
||||||
|
300: Color(0xFFF9A8D4),
|
||||||
|
400: Color(0xFFF472B6),
|
||||||
|
500: Color(0xFFEC4899),
|
||||||
|
600: Color(0xFFDB2777),
|
||||||
|
700: Color(0xFFBE185D),
|
||||||
|
800: Color(0xFF9D174D),
|
||||||
|
900: Color(0xFF831843),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
ThemeColor(
|
||||||
|
name: '清新青',
|
||||||
|
primaryColor: Color(0xFF06B6D4),
|
||||||
|
materialColor: MaterialColor(0xFF06B6D4, {
|
||||||
|
50: Color(0xFFF0FDFA),
|
||||||
|
100: Color(0xFFCCFBF1),
|
||||||
|
200: Color(0xFF99F6E4),
|
||||||
|
300: Color(0xFF5EEAD4),
|
||||||
|
400: Color(0xFF2DD4BF),
|
||||||
|
500: Color(0xFF06B6D4),
|
||||||
|
600: Color(0xFF0891B2),
|
||||||
|
700: Color(0xFF0E7490),
|
||||||
|
800: Color(0xFF155E75),
|
||||||
|
900: Color(0xFF164E63),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
ThemeColor(
|
||||||
|
name: '深空蓝',
|
||||||
|
primaryColor: Color(0xFF1E40AF),
|
||||||
|
materialColor: MaterialColor(0xFF1E40AF, {
|
||||||
|
50: Color(0xFFEFF6FF),
|
||||||
|
100: Color(0xFFDBEAFE),
|
||||||
|
200: Color(0xFFBFDBFE),
|
||||||
|
300: Color(0xFF93C5FD),
|
||||||
|
400: Color(0xFF60A5FA),
|
||||||
|
500: Color(0xFF3B82F6),
|
||||||
|
600: Color(0xFF2563EB),
|
||||||
|
700: Color(0xFF1D4ED8),
|
||||||
|
800: Color(0xFF1E40AF),
|
||||||
|
900: Color(0xFF1E3A8A),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
ThemeColor(
|
||||||
|
name: '落日红',
|
||||||
|
primaryColor: Color(0xFFEF4444),
|
||||||
|
materialColor: MaterialColor(0xFFEF4444, {
|
||||||
|
50: Color(0xFFFEF2F2),
|
||||||
|
100: Color(0xFFFEE2E2),
|
||||||
|
200: Color(0xFFFECACA),
|
||||||
|
300: Color(0xFFFCA5A5),
|
||||||
|
400: Color(0xFFF87171),
|
||||||
|
500: Color(0xFFEF4444),
|
||||||
|
600: Color(0xFFDC2626),
|
||||||
|
700: Color(0xFFB91C1C),
|
||||||
|
800: Color(0xFF991B1B),
|
||||||
|
900: Color(0xFF7F1D1D),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
Widget buildThemeColorList(BuildContext context, AppProvider appProvider) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||||
|
child: GridView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: 4,
|
||||||
|
crossAxisSpacing: 8,
|
||||||
|
mainAxisSpacing: 8,
|
||||||
|
childAspectRatio: 1.2,
|
||||||
|
),
|
||||||
|
itemCount: appProvider.availableThemes.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final themeColor = appProvider.availableThemes[index];
|
||||||
|
final isSelected = appProvider.currentTheme == themeColor;
|
||||||
|
|
||||||
|
return _buildThemeColorItem(
|
||||||
|
themeColor: themeColor,
|
||||||
|
isSelected: isSelected,
|
||||||
|
onTap: () => appProvider.changeTheme(themeColor),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildThemeColorItem({
|
||||||
|
required ThemeColor themeColor,
|
||||||
|
required bool isSelected,
|
||||||
|
required VoidCallback onTap,
|
||||||
|
}) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: onTap,
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color:
|
||||||
|
isSelected
|
||||||
|
? themeColor.primaryColor.withAlpha(50)
|
||||||
|
: Colors.transparent,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(
|
||||||
|
color: isSelected ? themeColor.primaryColor : Colors.grey.shade300,
|
||||||
|
width: isSelected ? 2 : 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
// 颜色圆点
|
||||||
|
Container(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: themeColor.primaryColor,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
border: Border.all(color: Colors.white, width: 2),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withAlpha(10),
|
||||||
|
blurRadius: 2,
|
||||||
|
offset: const Offset(0, 1),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
themeColor.name,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 10,
|
||||||
|
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||||
|
color:
|
||||||
|
isSelected ? themeColor.primaryColor : Colors.grey.shade600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:toggle_switch/toggle_switch.dart';
|
||||||
|
|
||||||
BoxDecoration buildBoxDecoration() {
|
BoxDecoration buildBoxDecoration() {
|
||||||
return BoxDecoration(
|
return BoxDecoration(
|
||||||
@@ -8,6 +9,7 @@ BoxDecoration buildBoxDecoration() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 卡片
|
||||||
class BuildCard extends StatelessWidget {
|
class BuildCard extends StatelessWidget {
|
||||||
final Widget? child;
|
final Widget? child;
|
||||||
|
|
||||||
@@ -29,6 +31,7 @@ class BuildCard extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 底部弹出
|
||||||
void buildModalBottom({
|
void buildModalBottom({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required String title,
|
required String title,
|
||||||
@@ -113,3 +116,86 @@ Widget buildModalBottomBody(BuildContext context, String title, Widget body) {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 滑动删除
|
||||||
|
Widget buildDismissible({
|
||||||
|
required BuildContext context,
|
||||||
|
required Object id,
|
||||||
|
required Widget child,
|
||||||
|
required VoidCallback onDelete,
|
||||||
|
}) {
|
||||||
|
return Dismissible(
|
||||||
|
key: ValueKey(id),
|
||||||
|
direction: DismissDirection.endToStart,
|
||||||
|
background: _buildDismissBackground(),
|
||||||
|
confirmDismiss: (direction) async {
|
||||||
|
// 这里实现二次确认
|
||||||
|
return await _showDeleteConfirmationDialog(context);
|
||||||
|
},
|
||||||
|
onDismissed: (direction) {
|
||||||
|
onDelete();
|
||||||
|
},
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认对话框
|
||||||
|
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),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// toggle切换
|
||||||
|
Widget buildToggleSwitch<T extends Enum>({
|
||||||
|
required BuildContext context,
|
||||||
|
required T currentTab,
|
||||||
|
required List<T> tabValues,
|
||||||
|
required List<String> labels,
|
||||||
|
required ValueChanged<T> onTabChanged,
|
||||||
|
}) {
|
||||||
|
return ToggleSwitch(
|
||||||
|
minWidth: 90.0,
|
||||||
|
minHeight: 40.0,
|
||||||
|
initialLabelIndex: tabValues.indexOf(currentTab),
|
||||||
|
totalSwitches: tabValues.length,
|
||||||
|
labels: labels,
|
||||||
|
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 && index < tabValues.length) {
|
||||||
|
onTabChanged(tabValues[index]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ class _FlispFormState extends State<FlispForm> {
|
|||||||
},
|
},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: '记录你的灵感瞬间...',
|
hintText: '记录你的灵感瞬间...',
|
||||||
|
hintStyle: TextStyle(color: Colors.grey),
|
||||||
counterText: '',
|
counterText: '',
|
||||||
suffixText: '${provider.formItem.content.length}/$maxContentCount',
|
suffixText: '${provider.formItem.content.length}/$maxContentCount',
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
|
|||||||
@@ -48,23 +48,12 @@ Widget buildTabs({
|
|||||||
}) {
|
}) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
child: ToggleSwitch(
|
child: buildToggleSwitch(
|
||||||
minWidth: 90.0,
|
context: context,
|
||||||
minHeight: 40.0,
|
currentTab: currentTab,
|
||||||
initialLabelIndex: FlispTab.values.indexOf(currentTab),
|
tabValues: FlispTab.values,
|
||||||
totalSwitches: FlispTab.values.length,
|
|
||||||
labels: FlispTab.values.map((e) => e.label).toList(),
|
labels: FlispTab.values.map((e) => e.label).toList(),
|
||||||
activeBgColor: [Theme.of(context).colorScheme.primary],
|
onTabChanged: onTabChanged,
|
||||||
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]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -275,17 +264,10 @@ Widget _buildFlispItem({
|
|||||||
final hasImage = flisp.imageUrl.isNotEmpty;
|
final hasImage = flisp.imageUrl.isNotEmpty;
|
||||||
final hasVideo = flisp.videoUrl.isNotEmpty;
|
final hasVideo = flisp.videoUrl.isNotEmpty;
|
||||||
|
|
||||||
return Dismissible(
|
return buildDismissible(
|
||||||
key: ValueKey(flisp.id),
|
context: context,
|
||||||
direction: DismissDirection.endToStart,
|
id: flisp.id,
|
||||||
background: _buildDismissBackground(),
|
onDelete: () => onDelete(flisp),
|
||||||
confirmDismiss: (direction) async {
|
|
||||||
// 这里实现二次确认
|
|
||||||
return await _showDeleteConfirmationDialog(context);
|
|
||||||
},
|
|
||||||
onDismissed: (direction) {
|
|
||||||
onDelete(flisp);
|
|
||||||
},
|
|
||||||
child: BuildCard(
|
child: BuildCard(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => onEdit(flisp),
|
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) {
|
Widget buildEmptyState(BuildContext context) {
|
||||||
final colors = Theme.of(context).colorScheme;
|
final colors = Theme.of(context).colorScheme;
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ class _TodoFormState extends State<TodoForm> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
hintText: '请输入待办事项标题...',
|
hintText: '请输入待办事项标题...',
|
||||||
|
hintStyle: TextStyle(color: Colors.grey),
|
||||||
counterText: '',
|
counterText: '',
|
||||||
suffixText: '${provider.formItem.title.length}/$maxTitleCount',
|
suffixText: '${provider.formItem.title.length}/$maxTitleCount',
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
@@ -126,6 +127,7 @@ class _TodoFormState extends State<TodoForm> {
|
|||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: '内容',
|
labelText: '内容',
|
||||||
hintText: '请输入待办事项内容...',
|
hintText: '请输入待办事项内容...',
|
||||||
|
hintStyle: TextStyle(color: Colors.grey),
|
||||||
counterText: '',
|
counterText: '',
|
||||||
suffixText: '${provider.formItem.content.length}/$maxContentCount',
|
suffixText: '${provider.formItem.content.length}/$maxContentCount',
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
|
|||||||
@@ -50,31 +50,22 @@ Widget buildTabs({
|
|||||||
}) {
|
}) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
child: ToggleSwitch(
|
child: buildToggleSwitch(
|
||||||
minWidth: 90.0,
|
context: context,
|
||||||
minHeight: 40.0,
|
currentTab: currentTab,
|
||||||
initialLabelIndex: TodoTab.values.indexOf(currentTab),
|
tabValues: TodoTab.values,
|
||||||
totalSwitches: TodoTab.values.length,
|
|
||||||
labels: TodoTab.values.map((e) => e.label).toList(),
|
labels: TodoTab.values.map((e) => e.label).toList(),
|
||||||
activeBgColor: [Theme.of(context).colorScheme.primary],
|
onTabChanged: onTabChanged,
|
||||||
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(TodoTab.values[index]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildTodoList({
|
Widget buildTodoList({
|
||||||
|
required BuildContext context,
|
||||||
required List<Todo> todos,
|
required List<Todo> todos,
|
||||||
required ValueChanged<Todo> onToggleTodo,
|
required ValueChanged<Todo> onToggleTodo,
|
||||||
required ValueChanged<Todo> onEditTodo,
|
required ValueChanged<Todo> onEditTodo,
|
||||||
|
required ValueChanged<Todo> onDelete,
|
||||||
}) {
|
}) {
|
||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
itemCount: todos.length,
|
itemCount: todos.length,
|
||||||
@@ -82,35 +73,44 @@ Widget buildTodoList({
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final todo = todos[index];
|
final todo = todos[index];
|
||||||
return _buildTodoItem(
|
return _buildTodoItem(
|
||||||
|
context: context,
|
||||||
todo: todo,
|
todo: todo,
|
||||||
onToggle: onToggleTodo,
|
onToggle: onToggleTodo,
|
||||||
onEdit: onEditTodo,
|
onEdit: onEditTodo,
|
||||||
|
onDelete: onDelete,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTodoItem({
|
Widget _buildTodoItem({
|
||||||
|
required BuildContext context,
|
||||||
required Todo todo,
|
required Todo todo,
|
||||||
required ValueChanged<Todo> onToggle,
|
required ValueChanged<Todo> onToggle,
|
||||||
required ValueChanged<Todo> onEdit,
|
required ValueChanged<Todo> onEdit,
|
||||||
|
required ValueChanged<Todo> onDelete,
|
||||||
}) {
|
}) {
|
||||||
return BuildCard(
|
return buildDismissible(
|
||||||
child: ListTile(
|
context: context,
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 0),
|
id: todo.id,
|
||||||
leading: SizedBox(
|
onDelete: () => onDelete(todo),
|
||||||
width: 24,
|
child: BuildCard(
|
||||||
child: Checkbox(
|
child: ListTile(
|
||||||
value: todo.isCompleted,
|
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 0),
|
||||||
onChanged: (value) => onToggle(todo),
|
leading: SizedBox(
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
width: 24,
|
||||||
|
child: Checkbox(
|
||||||
|
value: todo.isCompleted,
|
||||||
|
onChanged: (value) => onToggle(todo),
|
||||||
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
title: _buildTodoTitle(todo),
|
||||||
|
subtitle: _buildTodoSubtitle(todo),
|
||||||
|
trailing: _buildPriorityBadge(todo.priority),
|
||||||
|
onTap: () => onEdit(todo),
|
||||||
|
// onLongPress: () => onShowOptions(todo),
|
||||||
),
|
),
|
||||||
title: _buildTodoTitle(todo),
|
|
||||||
subtitle: _buildTodoSubtitle(todo),
|
|
||||||
trailing: _buildPriorityBadge(todo.priority),
|
|
||||||
onTap: () => onEdit(todo),
|
|
||||||
// onLongPress: () => onShowOptions(todo),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user