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

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

View File

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

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;
}

View File

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

View File

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