feat:更新颜色模块
This commit is contained in:
@@ -123,7 +123,7 @@ class StatsPageState extends State<StatsPage> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
buildFlispStatsCard(allFlisps),
|
||||
buildFlispStatsCard(context, allFlisps),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ class StatsPageState extends State<StatsPage> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Expanded(child: buildTodoStatsCard(allTodos)),
|
||||
Expanded(child: buildTodoStatsCard(context, allTodos)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ class TodoPageState extends State<TodoPage> {
|
||||
children: [
|
||||
_buildTodoTabs(),
|
||||
_buildTodoSegment(),
|
||||
SizedBox(height: 6),
|
||||
Expanded(child: _buildActiveTodoList(context)),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -24,18 +24,16 @@ class CalendarForm extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CalendarFormState extends State<CalendarForm> {
|
||||
final int maxTitleCount = 10;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final int maxTitleCount = 10;
|
||||
final provider = Provider.of<CalendarProvider>(context);
|
||||
Widget buildTitle() {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
Widget buildTitle() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
@@ -67,7 +65,9 @@ class _CalendarFormState extends State<CalendarForm> {
|
||||
return null;
|
||||
}
|
||||
|
||||
FormBuilderTextField buildTitleField() {
|
||||
FormBuilderTextField buildTitleField(CalendarProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return FormBuilderTextField(
|
||||
name: 'title',
|
||||
initialValue: provider.formItem.title,
|
||||
@@ -110,7 +110,7 @@ class _CalendarFormState extends State<CalendarForm> {
|
||||
);
|
||||
}
|
||||
|
||||
String? startTimeFieldValidator(value) {
|
||||
String? startTimeFieldValidator(CalendarProvider provider, value) {
|
||||
if (value == null) {
|
||||
return '请选择开始时间';
|
||||
}
|
||||
@@ -129,7 +129,8 @@ class _CalendarFormState extends State<CalendarForm> {
|
||||
return null;
|
||||
}
|
||||
|
||||
FormBuilderDateTimePicker buildStartTimeField() {
|
||||
FormBuilderDateTimePicker buildStartTimeField(CalendarProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
var startTime = provider.formItem.startTime;
|
||||
|
||||
return FormBuilderDateTimePicker(
|
||||
@@ -156,11 +157,11 @@ class _CalendarFormState extends State<CalendarForm> {
|
||||
fillColor: colors.surface,
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
),
|
||||
validator: (value) => startTimeFieldValidator(value),
|
||||
validator: (value) => startTimeFieldValidator(provider, value),
|
||||
);
|
||||
}
|
||||
|
||||
String? endTimeFieldValidator(value) {
|
||||
String? endTimeFieldValidator(CalendarProvider provider, value) {
|
||||
if (value == null) {
|
||||
return '请选择结束时间';
|
||||
}
|
||||
@@ -179,7 +180,8 @@ class _CalendarFormState extends State<CalendarForm> {
|
||||
return null;
|
||||
}
|
||||
|
||||
FormBuilderDateTimePicker buildEndTimeField() {
|
||||
FormBuilderDateTimePicker buildEndTimeField(CalendarProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
var endTime = provider.formItem.endTime;
|
||||
|
||||
return FormBuilderDateTimePicker(
|
||||
@@ -193,8 +195,7 @@ class _CalendarFormState extends State<CalendarForm> {
|
||||
});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
labelText:
|
||||
endTime == null ? '选择结束时间' : '结束时间: ${formatTime(endTime)}',
|
||||
labelText: endTime == null ? '选择结束时间' : '结束时间: ${formatTime(endTime)}',
|
||||
labelStyle: TextStyle(
|
||||
color: endTime == null ? Colors.grey : Colors.black87,
|
||||
),
|
||||
@@ -206,11 +207,11 @@ class _CalendarFormState extends State<CalendarForm> {
|
||||
fillColor: colors.surface,
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
),
|
||||
validator: (value) => endTimeFieldValidator(value),
|
||||
validator: (value) => endTimeFieldValidator(provider, value),
|
||||
);
|
||||
}
|
||||
|
||||
IconButton buildClearScheduled() {
|
||||
IconButton buildClearScheduled(CalendarProvider provider) {
|
||||
return IconButton(
|
||||
icon: Icon(Icons.clear, size: 18),
|
||||
onPressed: () {
|
||||
@@ -229,7 +230,8 @@ class _CalendarFormState extends State<CalendarForm> {
|
||||
return null;
|
||||
}
|
||||
|
||||
FormBuilderDateTimePicker buildScheduledTimeField() {
|
||||
FormBuilderDateTimePicker buildScheduledTimeField(CalendarProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
var scheduledTime = provider.formItem.scheduledTime;
|
||||
|
||||
return FormBuilderDateTimePicker(
|
||||
@@ -257,35 +259,40 @@ class _CalendarFormState extends State<CalendarForm> {
|
||||
filled: true,
|
||||
fillColor: colors.surface,
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
suffixIcon: scheduledTime != null ? buildClearScheduled() : null,
|
||||
suffixIcon:
|
||||
scheduledTime != null ? buildClearScheduled(provider) : null,
|
||||
),
|
||||
validator: (value) => scheduledTimeFieldValidator(value),
|
||||
);
|
||||
}
|
||||
|
||||
FormBuilder buildForm() {
|
||||
FormBuilder buildForm(CalendarProvider provider) {
|
||||
return FormBuilder(
|
||||
key: widget.formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
buildTitleField(),
|
||||
buildTitleField(provider),
|
||||
SizedBox(height: 12),
|
||||
buildStartTimeField(),
|
||||
buildStartTimeField(provider),
|
||||
SizedBox(height: 12),
|
||||
buildEndTimeField(),
|
||||
buildEndTimeField(provider),
|
||||
SizedBox(height: 12),
|
||||
buildScheduledTimeField(),
|
||||
buildScheduledTimeField(provider),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<CalendarProvider>(context);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 10),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [buildTitle(), SizedBox(height: 20), buildForm()],
|
||||
children: [buildTitle(), SizedBox(height: 20), buildForm(provider)],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -193,16 +193,18 @@ Widget buildToggleSwitch<T extends Enum>({
|
||||
required List<String> labels,
|
||||
required ValueChanged<T> onTabChanged,
|
||||
}) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return ToggleSwitch(
|
||||
minWidth: 90.0,
|
||||
minHeight: 40.0,
|
||||
initialLabelIndex: tabValues.indexOf(currentTab),
|
||||
totalSwitches: tabValues.length,
|
||||
labels: labels,
|
||||
activeBgColor: [Theme.of(context).colorScheme.primary],
|
||||
activeBgColor: [colors.primary],
|
||||
activeFgColor: Colors.white,
|
||||
inactiveBgColor: Colors.grey.shade200,
|
||||
inactiveFgColor: Colors.grey.shade700,
|
||||
inactiveBgColor: colors.surfaceContainer,
|
||||
inactiveFgColor: colors.onSurface,
|
||||
cornerRadius: 12.0,
|
||||
customTextStyles: [TextStyle(fontSize: 12, fontWeight: FontWeight.w500)],
|
||||
onToggle: (index) {
|
||||
@@ -216,7 +218,7 @@ Widget buildToggleSwitch<T extends Enum>({
|
||||
ButtonStyle buildSegmentStyle(ColorScheme colors) {
|
||||
return ButtonStyle(
|
||||
side: WidgetStateProperty.all<BorderSide>(
|
||||
const BorderSide(color: Colors.transparent, width: 0),
|
||||
BorderSide(color: colors.surface, width: 0),
|
||||
),
|
||||
iconColor: WidgetStateProperty.resolveWith<Color>(
|
||||
(Set<WidgetState> states) {
|
||||
@@ -232,7 +234,7 @@ ButtonStyle buildSegmentStyle(ColorScheme colors) {
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return colors.primary;
|
||||
}
|
||||
return Colors.grey.shade200;
|
||||
return colors.surfaceContainer;
|
||||
}),
|
||||
foregroundColor: WidgetStateProperty.resolveWith<Color>((
|
||||
Set<WidgetState> states,
|
||||
|
||||
@@ -27,6 +27,7 @@ class FlispForm extends StatefulWidget {
|
||||
|
||||
class _FlispFormState extends State<FlispForm> {
|
||||
bool _showTagOptions = false;
|
||||
final int maxContentCount = 100;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -62,13 +63,9 @@ class _FlispFormState extends State<FlispForm> {
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final int maxContentCount = 100;
|
||||
final provider = Provider.of<FlispProvider>(context);
|
||||
Widget buildContentField(FlispProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
Widget buildContentField() {
|
||||
return FormBuilderTextField(
|
||||
name: 'content',
|
||||
initialValue: provider.formItem.content,
|
||||
@@ -114,15 +111,15 @@ class _FlispFormState extends State<FlispForm> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildFormBody() {
|
||||
Widget buildFormBody(FlispProvider provider) {
|
||||
return Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
buildContentField(),
|
||||
buildContentField(provider),
|
||||
SizedBox(height: 8),
|
||||
buildFlispTag(provider.formItem),
|
||||
buildFlispTag(context, provider.formItem),
|
||||
SizedBox(height: 12),
|
||||
if (provider.formItem.imageUrl.isNotEmpty)
|
||||
buildFlispImage(
|
||||
@@ -161,11 +158,7 @@ class _FlispFormState extends State<FlispForm> {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.blue.withAlpha(80), width: 1),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.photo_library_rounded,
|
||||
size: 20,
|
||||
color: Colors.blue,
|
||||
),
|
||||
child: Icon(Icons.photo_library_rounded, size: 20, color: Colors.blue),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -181,11 +174,7 @@ class _FlispFormState extends State<FlispForm> {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.orange.withAlpha(80), width: 1),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.local_offer_rounded,
|
||||
size: 20,
|
||||
color: Colors.orange,
|
||||
),
|
||||
child: Icon(Icons.local_offer_rounded, size: 20, color: Colors.orange),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -195,7 +184,7 @@ class _FlispFormState extends State<FlispForm> {
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
color: colors.primary,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
child: IconButton(
|
||||
@@ -243,11 +232,7 @@ class _FlispFormState extends State<FlispForm> {
|
||||
color: tag.color,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
tag.icon,
|
||||
size: 12,
|
||||
color: Colors.white,
|
||||
),
|
||||
child: Icon(tag.icon, size: 12, color: Colors.white),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(tag.label, style: TextStyle(fontSize: 12)),
|
||||
@@ -280,6 +265,10 @@ class _FlispFormState extends State<FlispForm> {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<FlispProvider>(context);
|
||||
|
||||
// 整体使用Stack布局分离事件层级
|
||||
return Stack(
|
||||
children: [
|
||||
@@ -300,7 +289,9 @@ class _FlispFormState extends State<FlispForm> {
|
||||
// 主表单内容
|
||||
FormBuilder(
|
||||
key: widget.formKey,
|
||||
child: Column(children: [buildFormBody(), buildBottomButton()]),
|
||||
child: Column(
|
||||
children: [buildFormBody(provider), buildBottomButton()],
|
||||
),
|
||||
),
|
||||
|
||||
// 标签弹窗(放在最上层,确保事件优先响应)
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:flisp_app/widgets/common.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
Widget buildFlispStatsCard(List<Flisp> flisps) {
|
||||
Widget buildFlispStatsCard(BuildContext context, List<Flisp> flisps) {
|
||||
int totalCount = flisps.length;
|
||||
|
||||
int lifeCount = flisps.where((flisp) => flisp.tag == FlispTag.life).length;
|
||||
@@ -15,16 +15,16 @@ Widget buildFlispStatsCard(List<Flisp> flisps) {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
_buildStatItem('总计', totalCount, Colors.orange),
|
||||
_buildStatItem('生活', lifeCount, FlispTag.life.color),
|
||||
_buildStatItem('工作', workCount, FlispTag.work.color),
|
||||
_buildStatItem('学习', studyCount, FlispTag.study.color),
|
||||
_buildStatItem(context, '总计', totalCount),
|
||||
_buildStatItem(context, '生活', lifeCount),
|
||||
_buildStatItem(context, '工作', workCount),
|
||||
_buildStatItem(context, '学习', studyCount),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatItem(String label, int count, Color color) {
|
||||
Widget _buildStatItem(BuildContext context, String label, int count) {
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
@@ -32,7 +32,7 @@ Widget _buildStatItem(String label, int count, Color color) {
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
@@ -209,13 +209,15 @@ Widget _buildFlispVideo(Flisp flisp) {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildFlispTag(Flisp flisp) {
|
||||
Widget buildFlispTag(BuildContext context, Flisp flisp) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: flisp.tag.color.withAlpha(30),
|
||||
color: colors.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: flisp.tag.color.withAlpha(60)),
|
||||
// border: Border.all(color: flisp.tag.color.withAlpha(60)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -224,7 +226,7 @@ Widget buildFlispTag(Flisp flisp) {
|
||||
width: 14,
|
||||
height: 14,
|
||||
decoration: BoxDecoration(
|
||||
color: flisp.tag.color,
|
||||
color: colors.secondary,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(flisp.tag.icon, size: 8, color: Colors.white),
|
||||
@@ -234,7 +236,7 @@ Widget buildFlispTag(Flisp flisp) {
|
||||
flisp.tag.label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: flisp.tag.color,
|
||||
color: colors.secondary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
@@ -250,9 +252,13 @@ Widget buildFlispTime(Flisp flisp) {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFlispSuffix(Flisp flisp) {
|
||||
Widget _buildFlispSuffix(BuildContext context, Flisp flisp) {
|
||||
return Row(
|
||||
children: [buildFlispTag(flisp), const Spacer(), buildFlispTime(flisp)],
|
||||
children: [
|
||||
buildFlispTag(context, flisp),
|
||||
const Spacer(),
|
||||
buildFlispTime(flisp),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -281,7 +287,7 @@ Widget _buildFlispItem({
|
||||
const SizedBox(height: 4),
|
||||
if (hasVideo) _buildFlispVideo(flisp),
|
||||
const SizedBox(height: 4),
|
||||
_buildFlispSuffix(flisp),
|
||||
_buildFlispSuffix(context, flisp),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -22,25 +22,21 @@ class TodoForm extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _TodoFormState extends State<TodoForm> {
|
||||
final int maxTitleCount = 10;
|
||||
final int maxContentCount = 20;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final int maxTitleCount = 10;
|
||||
final int maxContentCount = 20;
|
||||
final provider = Provider.of<TodoProvider>(context);
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
Widget buildTitle() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
widget.isEditing ? Icons.edit_note : Icons.add_task,
|
||||
color: colors.primary,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
size: 24,
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
@@ -49,14 +45,16 @@ class _TodoFormState extends State<TodoForm> {
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: colors.primary,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
FormBuilderTextField buildTitleField() {
|
||||
FormBuilderTextField buildTitleField(TodoProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return FormBuilderTextField(
|
||||
name: 'title',
|
||||
initialValue: provider.formItem.title,
|
||||
@@ -116,7 +114,9 @@ class _TodoFormState extends State<TodoForm> {
|
||||
);
|
||||
}
|
||||
|
||||
FormBuilderTextField buildContentField() {
|
||||
FormBuilderTextField buildContentField(TodoProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return FormBuilderTextField(
|
||||
name: 'content',
|
||||
initialValue: provider.formItem.content,
|
||||
@@ -159,7 +159,7 @@ class _TodoFormState extends State<TodoForm> {
|
||||
);
|
||||
}
|
||||
|
||||
IconButton buildClearDueDateSuffixIcon() {
|
||||
IconButton buildClearDueDateSuffixIcon(TodoProvider provider) {
|
||||
return IconButton(
|
||||
icon: Icon(Icons.clear, size: 18),
|
||||
onPressed: () {
|
||||
@@ -171,7 +171,9 @@ class _TodoFormState extends State<TodoForm> {
|
||||
);
|
||||
}
|
||||
|
||||
FormBuilderDateTimePicker buildDueDateField() {
|
||||
FormBuilderDateTimePicker buildDueDateField(TodoProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return FormBuilderDateTimePicker(
|
||||
name: 'dueDate',
|
||||
format: DateFormat('yyyy-MM-dd'),
|
||||
@@ -189,9 +191,7 @@ class _TodoFormState extends State<TodoForm> {
|
||||
: '截止: ${DateFormat('yyyy-MM-dd').format(provider.formItem.dueDate!)}',
|
||||
labelStyle: TextStyle(
|
||||
color:
|
||||
provider.formItem.dueDate == null
|
||||
? Colors.grey
|
||||
: Colors.black87,
|
||||
provider.formItem.dueDate == null ? Colors.grey : Colors.black87,
|
||||
),
|
||||
prefixIcon: Icon(Icons.calendar_month, color: Colors.purple),
|
||||
border: OutlineInputBorder(
|
||||
@@ -211,7 +211,7 @@ class _TodoFormState extends State<TodoForm> {
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
suffixIcon:
|
||||
provider.formItem.dueDate != null
|
||||
? buildClearDueDateSuffixIcon()
|
||||
? buildClearDueDateSuffixIcon(provider)
|
||||
: null,
|
||||
),
|
||||
validator: (value) {
|
||||
@@ -224,7 +224,7 @@ class _TodoFormState extends State<TodoForm> {
|
||||
);
|
||||
}
|
||||
|
||||
IconButton buildClearScheduledTimeSuffixIcon() {
|
||||
IconButton buildClearScheduledTimeSuffixIcon(TodoProvider provider) {
|
||||
return IconButton(
|
||||
icon: Icon(Icons.clear, size: 18),
|
||||
onPressed: () {
|
||||
@@ -236,7 +236,9 @@ class _TodoFormState extends State<TodoForm> {
|
||||
);
|
||||
}
|
||||
|
||||
FormBuilderDateTimePicker buildScheduledTimeField() {
|
||||
FormBuilderDateTimePicker buildScheduledTimeField(TodoProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return FormBuilderDateTimePicker(
|
||||
name: 'scheduledTime',
|
||||
format: DateFormat('yyyy-MM-dd HH:mm:ss'),
|
||||
@@ -276,7 +278,7 @@ class _TodoFormState extends State<TodoForm> {
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
suffixIcon:
|
||||
provider.formItem.scheduledTime != null
|
||||
? buildClearScheduledTimeSuffixIcon()
|
||||
? buildClearScheduledTimeSuffixIcon(provider)
|
||||
: null,
|
||||
),
|
||||
validator: (value) {
|
||||
@@ -288,7 +290,7 @@ class _TodoFormState extends State<TodoForm> {
|
||||
);
|
||||
}
|
||||
|
||||
FormBuilderRadioGroup builderRadioGroup() {
|
||||
FormBuilderRadioGroup builderRadioGroup(TodoProvider provider) {
|
||||
return FormBuilderRadioGroup<TodoPriority>(
|
||||
name: 'priority',
|
||||
initialValue: provider.formItem.priority,
|
||||
@@ -318,10 +320,10 @@ class _TodoFormState extends State<TodoForm> {
|
||||
);
|
||||
}
|
||||
|
||||
Container buildPriorityField() {
|
||||
Container buildPriorityField(TodoProvider provider) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surface,
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
padding: EdgeInsets.all(12),
|
||||
@@ -335,37 +337,41 @@ class _TodoFormState extends State<TodoForm> {
|
||||
Text('优先级'),
|
||||
],
|
||||
),
|
||||
builderRadioGroup(),
|
||||
builderRadioGroup(provider),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
FormBuilder buildForm() {
|
||||
FormBuilder buildForm(TodoProvider provider) {
|
||||
return FormBuilder(
|
||||
key: widget.formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
buildTitleField(),
|
||||
buildTitleField(provider),
|
||||
SizedBox(height: 12),
|
||||
buildContentField(),
|
||||
buildContentField(provider),
|
||||
SizedBox(height: 12),
|
||||
buildDueDateField(),
|
||||
buildDueDateField(provider),
|
||||
SizedBox(height: 12),
|
||||
buildScheduledTimeField(),
|
||||
buildScheduledTimeField(provider),
|
||||
SizedBox(height: 12),
|
||||
buildPriorityField(),
|
||||
buildPriorityField(provider),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<TodoProvider>(context);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 10),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [buildTitle(), SizedBox(height: 20), buildForm()],
|
||||
children: [buildTitle(), SizedBox(height: 20), buildForm(provider)],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
// 统计卡片
|
||||
Widget buildTodoStatsCard(List<Todo> todos) {
|
||||
Widget buildTodoStatsCard(BuildContext context, List<Todo> todos) {
|
||||
int totalCount = todos.length;
|
||||
|
||||
int activeCount = todos.where((todo) => !todo.isCompleted).length;
|
||||
@@ -17,15 +17,15 @@ Widget buildTodoStatsCard(List<Todo> todos) {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
_buildStatItem('总计', totalCount, Colors.blue),
|
||||
_buildStatItem('待完成', activeCount, Colors.orange),
|
||||
_buildStatItem('已完成', completedCount, Colors.green),
|
||||
_buildStatItem(context, '总计', totalCount),
|
||||
_buildStatItem(context, '待完成', activeCount),
|
||||
_buildStatItem(context, '已完成', completedCount),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatItem(String label, int count, Color color) {
|
||||
Widget _buildStatItem(BuildContext context, String label, int count) {
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
@@ -33,7 +33,7 @@ Widget _buildStatItem(String label, int count, Color color) {
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
|
||||
@@ -104,7 +104,7 @@ class _YearSelectorState extends State<YearSelector>
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).primaryColor,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user