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