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

@@ -3,10 +3,15 @@ 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';
class AppDrawer extends StatelessWidget { class AppDrawer extends StatefulWidget {
const AppDrawer({super.key}); const AppDrawer({super.key});
DrawerHeader _buildDrawerHeader(BuildContext context) { @override
State<AppDrawer> createState() => AppDrawerState();
}
class AppDrawerState extends State<AppDrawer> {
DrawerHeader _buildDrawerHeader() {
return DrawerHeader( return DrawerHeader(
decoration: BoxDecoration(color: Theme.of(context).colorScheme.primary), decoration: BoxDecoration(color: Theme.of(context).colorScheme.primary),
child: Column( child: Column(
@@ -39,7 +44,7 @@ class AppDrawer extends StatelessWidget {
); );
} }
Widget _buildDarkModeSection(BuildContext context, AppProvider appProvider) { Widget _buildDarkModeSection(AppProvider appProvider) {
return ListTile( return ListTile(
leading: Icon( leading: Icon(
appProvider.isDarkMode ? Icons.dark_mode : Icons.light_mode, appProvider.isDarkMode ? Icons.dark_mode : Icons.light_mode,
@@ -58,7 +63,7 @@ class AppDrawer extends StatelessWidget {
); );
} }
Widget _buildThemeSection(BuildContext context, AppProvider appProvider) { Widget _buildThemeSection(AppProvider appProvider) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@@ -66,7 +71,7 @@ class AppDrawer extends StatelessWidget {
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8), padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
child: Text('主题颜色', style: Theme.of(context).textTheme.titleMedium), child: Text('主题颜色', style: Theme.of(context).textTheme.titleMedium),
), ),
_buildDarkModeSection(context, appProvider), _buildDarkModeSection(appProvider),
buildThemeColorList(context, appProvider), buildThemeColorList(context, appProvider),
], ],
); );
@@ -74,7 +79,6 @@ class AppDrawer extends StatelessWidget {
// 构建抽屉菜单项 // 构建抽屉菜单项
Widget _buildDrawerItem({ Widget _buildDrawerItem({
required BuildContext context,
required IconData icon, required IconData icon,
required String title, required String title,
required VoidCallback onTap, required VoidCallback onTap,
@@ -118,11 +122,10 @@ class AppDrawer extends StatelessWidget {
child: ListView( child: ListView(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
children: [ children: [
_buildDrawerHeader(context), _buildDrawerHeader(),
_buildThemeSection(context, appProvider), _buildThemeSection(appProvider),
const Divider(), const Divider(),
_buildDrawerItem( _buildDrawerItem(
context: context,
icon: Icons.help, icon: Icons.help,
title: '帮助与反馈', title: '帮助与反馈',
onTap: () { onTap: () {
@@ -136,7 +139,7 @@ class AppDrawer extends StatelessWidget {
_buildVersionInfo( _buildVersionInfo(
context: context, context: context,
fullVersion: appProvider.fullVersion, fullVersion: appProvider.fullVersion,
) ),
], ],
), ),
); );

View File

@@ -42,7 +42,11 @@ class _MainScreenState extends State<MainScreen> {
TodoSortMode.priority, TodoSortMode.priority,
); );
final List<Todo> todayTodos = final List<Todo> todayTodos =
todoResult.where((todo) => isToday(todo.scheduledTime)).toList(); todoResult
.where(
(todo) => !todo.isCompleted && isAfterToday(todo.scheduledTime),
)
.toList();
for (Todo todo in todayTodos) { for (Todo todo in todayTodos) {
await notifyService.scheduleNotification( await notifyService.scheduleNotification(
@@ -57,7 +61,7 @@ class _MainScreenState extends State<MainScreen> {
final List<Calendar> calendarResult = calendarService.getAllCalendars(); final List<Calendar> calendarResult = calendarService.getAllCalendars();
final List<Calendar> todayCalendars = final List<Calendar> todayCalendars =
calendarResult calendarResult
.where((calendar) => isToday(calendar.scheduledTime)) .where((item) => isAfterToday(item.scheduledTime))
.toList(); .toList();
for (Calendar calendar in todayCalendars) { for (Calendar calendar in todayCalendars) {

View File

@@ -86,7 +86,7 @@ class TodoPageState extends State<TodoPage> {
), ),
ButtonSegment<TodoSortMode>( ButtonSegment<TodoSortMode>(
value: TodoSortMode.priority, value: TodoSortMode.priority,
icon: Icon(Icons.flag_outlined, size: 16,), icon: Icon(Icons.flag_outlined, size: 16),
label: const Text('优先级', style: TextStyle(fontSize: 12)), label: const Text('优先级', style: TextStyle(fontSize: 12)),
), ),
], ],
@@ -123,6 +123,8 @@ class TodoPageState extends State<TodoPage> {
// 切换待办事项完成状态 // 切换待办事项完成状态
void _toggleTodo(Todo todo) async { void _toggleTodo(Todo todo) async {
final bool? result = await showConfirmDialog(context, '确定已完成该待办吗?');
if (result == true) {
await notifyService.cancelNotification(todo.id); await notifyService.cancelNotification(todo.id);
setState(() { setState(() {
@@ -131,6 +133,7 @@ class TodoPageState extends State<TodoPage> {
todoService.updateTodo(todo); todoService.updateTodo(todo);
}); });
} }
}
// 显示对话框 // 显示对话框
void _showDialog(bool isEditing, Todo? todo) { void _showDialog(bool isEditing, Todo? todo) {

View File

@@ -16,3 +16,9 @@ bool isToday(DateTime? date) {
date.month == now.month && date.month == now.month &&
date.day == now.day; date.day == now.day;
} }
bool isAfterToday(DateTime? date) {
if (date == null) return false;
return date.isAfter(DateTime.now());
}

View File

@@ -25,16 +25,23 @@ List<Todo> getActiveTodos(TodoTab currentTab, List<Todo> todos) {
// 格式化截止日期 // 格式化截止日期
String formatDueDate(DateTime dueDate, bool isToday, bool isTomorrow) { String formatDueDate(DateTime dueDate, bool isToday, bool isTomorrow) {
if (isToday) return '今天截止';
if (isTomorrow) return '明天截止';
final now = DateTime.now(); final now = DateTime.now();
final difference = dueDate.difference(DateTime(now.year, now.month, now.day)); final today = DateTime(now.year, now.month, now.day);
final dueDateStart = DateTime(dueDate.year, dueDate.month, dueDate.day);
final difference = dueDateStart.difference(today);
if (difference.inDays < 7) { // 处理过期情况
return '${difference.inDays}天后截止'; if (difference.inDays < 0) {
final daysPast = -difference.inDays;
return '已过期$daysPast天';
} }
// 处理未来日期
if (difference.inDays == 0) return '今天截止';
if (difference.inDays == 1) return '明天截止';
if (difference.inDays == 2) return '后天截止';
if (difference.inDays < 7) return '${difference.inDays}天后截止';
return DateFormat("MM-dd").format(dueDate); return DateFormat("MM-dd").format(dueDate);
} }

View File

@@ -80,7 +80,11 @@ class _CalendarFormState extends State<CalendarForm> {
label: RichText( label: RichText(
text: TextSpan( text: TextSpan(
text: '内容', text: '内容',
style: TextStyle(color: Colors.grey.shade700, fontSize: 16), style: TextStyle(
color: Colors.grey,
fontSize: 16,
fontFamily: 'CustomFont',
),
children: const [ children: const [
TextSpan( TextSpan(
text: '*', text: '*',
@@ -146,9 +150,7 @@ class _CalendarFormState extends State<CalendarForm> {
decoration: InputDecoration( decoration: InputDecoration(
labelText: labelText:
startTime == null ? '选择开始时间' : '开始时间: ${formatTime(startTime)}', startTime == null ? '选择开始时间' : '开始时间: ${formatTime(startTime)}',
labelStyle: TextStyle( labelStyle: TextStyle(color: Colors.grey),
color: startTime == null ? Colors.grey : Colors.black87,
),
prefixIcon: Icon(Icons.calendar_month, color: Colors.purple), prefixIcon: Icon(Icons.calendar_month, color: Colors.purple),
border: buildFormBoard(), border: buildFormBoard(),
enabledBorder: buildFormEnabledBoard(), enabledBorder: buildFormEnabledBoard(),
@@ -196,9 +198,7 @@ class _CalendarFormState extends State<CalendarForm> {
}, },
decoration: InputDecoration( decoration: InputDecoration(
labelText: endTime == null ? '选择结束时间' : '结束时间: ${formatTime(endTime)}', labelText: endTime == null ? '选择结束时间' : '结束时间: ${formatTime(endTime)}',
labelStyle: TextStyle( labelStyle: TextStyle(color: Colors.grey),
color: endTime == null ? Colors.grey : Colors.black87,
),
prefixIcon: Icon(Icons.calendar_month, color: Colors.purple), prefixIcon: Icon(Icons.calendar_month, color: Colors.purple),
border: buildFormBoard(), border: buildFormBoard(),
enabledBorder: buildFormEnabledBoard(), enabledBorder: buildFormEnabledBoard(),
@@ -247,11 +247,9 @@ class _CalendarFormState extends State<CalendarForm> {
decoration: InputDecoration( decoration: InputDecoration(
labelText: labelText:
scheduledTime == null scheduledTime == null
? '选择提醒日期' ? '选择提醒时间'
: '提醒: ${formatTime(scheduledTime)}', : '提醒时间: ${formatTime(scheduledTime)}',
labelStyle: TextStyle( labelStyle: TextStyle(color: Colors.grey),
color: scheduledTime == null ? Colors.grey : Colors.black87,
),
prefixIcon: Icon(Icons.calendar_month, color: Colors.purple), prefixIcon: Icon(Icons.calendar_month, color: Colors.purple),
border: buildFormBoard(), border: buildFormBoard(),
enabledBorder: buildFormEnabledBoard(), enabledBorder: buildFormEnabledBoard(),

View File

@@ -107,7 +107,7 @@ Widget buildCalendar({
onLongPress: (CalendarLongPressDetails details) async { onLongPress: (CalendarLongPressDetails details) async {
if (details.targetElement == CalendarElement.appointment) { if (details.targetElement == CalendarElement.appointment) {
if (details.appointments?.length == 1) { if (details.appointments?.length == 1) {
final bool? result = await showDeleteConfirmationDialog(context); final bool? result = await showConfirmDialog(context, '确定要删除这个项目吗?');
if (result == true) { if (result == true) {
onDelete(details.appointments!.first); onDelete(details.appointments!.first);
} }

View File

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

View File

@@ -77,8 +77,6 @@ class _FlispFormState extends State<FlispForm> {
decoration: InputDecoration( decoration: InputDecoration(
hintText: '记录你的灵感瞬间...', hintText: '记录你的灵感瞬间...',
hintStyle: TextStyle(color: Colors.grey), hintStyle: TextStyle(color: Colors.grey),
counterText: '',
suffixText: '${provider.formItem.content.length}/$maxContentCount',
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.grey.shade200), borderSide: BorderSide(color: Colors.grey.shade200),
@@ -98,6 +96,22 @@ class _FlispFormState extends State<FlispForm> {
minLines: 4, minLines: 4,
maxLines: 8, maxLines: 8,
maxLength: maxContentCount, maxLength: maxContentCount,
buildCounter: (
context, {
required currentLength,
required isFocused,
maxLength,
}) {
return Text(
'$currentLength/$maxContentCount',
style: TextStyle(
color:
currentLength > maxLength!
? Colors.red
: Theme.of(context).colorScheme.primary,
),
);
},
validator: (value) { validator: (value) {
if (value != null && value.isEmpty) { if (value != null && value.isEmpty) {
return '请输入内容'; return '请输入内容';
@@ -204,7 +218,7 @@ class _FlispFormState extends State<FlispForm> {
width: 90, width: 90,
padding: EdgeInsets.all(8), padding: EdgeInsets.all(8),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(

View File

@@ -67,7 +67,11 @@ class _TodoFormState extends State<TodoForm> {
label: RichText( label: RichText(
text: TextSpan( text: TextSpan(
text: '标题', text: '标题',
style: TextStyle(color: Colors.grey.shade700, fontSize: 16), style: TextStyle(
color: Colors.grey,
fontSize: 16,
fontFamily: 'CustomFont',
),
children: const [ children: const [
TextSpan( TextSpan(
text: '*', text: '*',
@@ -127,6 +131,7 @@ class _TodoFormState extends State<TodoForm> {
}, },
decoration: InputDecoration( decoration: InputDecoration(
labelText: '内容', labelText: '内容',
labelStyle: TextStyle(color: Colors.grey),
hintText: '请输入待办事项内容...', hintText: '请输入待办事项内容...',
hintStyle: TextStyle(color: Colors.grey), hintStyle: TextStyle(color: Colors.grey),
counterText: '', counterText: '',
@@ -188,11 +193,8 @@ class _TodoFormState extends State<TodoForm> {
labelText: labelText:
provider.formItem.dueDate == null provider.formItem.dueDate == null
? '选择截止日期' ? '选择截止日期'
: '截止: ${DateFormat('yyyy-MM-dd').format(provider.formItem.dueDate!)}', : '截止日期: ${DateFormat('yyyy-MM-dd').format(provider.formItem.dueDate!)}',
labelStyle: TextStyle( labelStyle: TextStyle(color: Colors.grey),
color:
provider.formItem.dueDate == null ? Colors.grey : Colors.black87,
),
prefixIcon: Icon(Icons.calendar_month, color: Colors.purple), prefixIcon: Icon(Icons.calendar_month, color: Colors.purple),
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
@@ -252,14 +254,9 @@ class _TodoFormState extends State<TodoForm> {
decoration: InputDecoration( decoration: InputDecoration(
labelText: labelText:
provider.formItem.scheduledTime == null provider.formItem.scheduledTime == null
? '选择提醒日期' ? '选择提醒时间'
: '提醒: ${DateFormat('yyyy-MM-dd HH:mm:ss').format(provider.formItem.scheduledTime!)}', : '提醒时间: ${DateFormat('yyyy-MM-dd HH:mm:ss').format(provider.formItem.scheduledTime!)}',
labelStyle: TextStyle( labelStyle: TextStyle(color: Colors.grey),
color:
provider.formItem.scheduledTime == null
? Colors.grey
: Colors.black87,
),
prefixIcon: Icon(Icons.calendar_month, color: Colors.purple), prefixIcon: Icon(Icons.calendar_month, color: Colors.purple),
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),

View File

@@ -2,7 +2,7 @@ name: flisp_app
description: "闪灵" description: "闪灵"
publish_to: 'none' # Remove this line if you wish to publish to pub.dev publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1 version: 1.0.0+2
environment: environment:
sdk: ^3.7.0 sdk: ^3.7.0