feat:更新主题色有些失效的场景

This commit is contained in:
2025-11-11 21:40:07 +08:00
parent 741d6842b8
commit 4960158dcc
5 changed files with 47 additions and 38 deletions

View File

@@ -7,7 +7,7 @@ class AppDrawer extends StatelessWidget {
DrawerHeader buildDrawerHeader(BuildContext context) {
return DrawerHeader(
decoration: BoxDecoration(color: Theme.of(context).primaryColor),
decoration: BoxDecoration(color: Theme.of(context).colorScheme.primary),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [

View File

@@ -12,7 +12,7 @@ void showAwesomeDialog({
dialogType: DialogType.noHeader,
animType: AnimType.scale,
body: body,
dialogBackgroundColor: Colors.white,
dialogBackgroundColor: Theme.of(context).colorScheme.surface,
btnOkText: "确认",
btnCancelText: "取消",
btnOkColor: Colors.orange,
@@ -25,7 +25,7 @@ void showAwesomeDialog({
onPressed: onOk,
style: ElevatedButton.styleFrom(
elevation: 0,
backgroundColor: Theme.of(context).primaryColor,
backgroundColor: Theme.of(context).colorScheme.primary,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),

View File

@@ -34,6 +34,8 @@ void buildModalBottom({
required String title,
required Widget body,
}) {
final colors = Theme.of(context).colorScheme;
showModalBottomSheet(
context: context,
isScrollControlled: true,
@@ -52,7 +54,11 @@ void buildModalBottom({
builder: (_, controller) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
color: colors.surface,
border: Border.all(
color: colors.outline.withAlpha(50),
width: 1,
),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(24),
topRight: Radius.circular(24),
@@ -69,6 +75,25 @@ void buildModalBottom({
);
}
Widget buildModalBottomTitle(BuildContext context, String title) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
title,
style: TextStyle(
fontSize: 20,
color: Theme.of(context).colorScheme.primary,
fontWeight: FontWeight.w700,
),
),
],
),
);
}
Widget buildModalBottomBody(BuildContext context, String title, Widget body) {
return Column(
children: [
@@ -82,23 +107,8 @@ Widget buildModalBottomBody(BuildContext context, String title, Widget body) {
borderRadius: BorderRadius.circular(2),
),
),
// 标题栏
Padding(
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
title,
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w700),
),
],
),
),
buildModalBottomTitle(context, title),
Divider(height: 1, thickness: 1),
Expanded(child: Padding(padding: EdgeInsets.all(12), child: body)),
],
);

View File

@@ -66,6 +66,7 @@ class _FlispFormState extends State<FlispForm> {
Widget build(BuildContext context) {
final int maxContentCount = 100;
final provider = Provider.of<FlispProvider>(context);
final colors = Theme.of(context).colorScheme;
Widget buildContentField() {
return FormBuilderTextField(
@@ -90,10 +91,10 @@ class _FlispFormState extends State<FlispForm> {
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.orange),
borderSide: BorderSide(color: colors.primary),
),
filled: true,
fillColor: Colors.white,
fillColor: colors.surface,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
),
minLines: 4,
@@ -193,7 +194,7 @@ class _FlispFormState extends State<FlispForm> {
width: 48,
height: 48,
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
color: colors.primary,
borderRadius: BorderRadius.circular(24),
),
child: IconButton(

View File

@@ -32,13 +32,14 @@ class _TodoFormState extends State<TodoForm> {
final int maxTitleCount = 10;
final int maxContentCount = 20;
final provider = Provider.of<TodoProvider>(context);
final colors = Theme.of(context).colorScheme;
Widget buildTitle() {
return Row(
children: [
Icon(
widget.isEditing ? Icons.edit_note : Icons.add_task,
color: Theme.of(context).primaryColor,
color: colors.primary,
size: 24,
),
SizedBox(width: 8),
@@ -47,7 +48,7 @@ class _TodoFormState extends State<TodoForm> {
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Theme.of(context).primaryColor,
color: colors.primary,
),
),
],
@@ -67,10 +68,7 @@ class _TodoFormState extends State<TodoForm> {
label: RichText(
text: TextSpan(
text: '标题',
style: TextStyle(
color: Colors.grey.shade700,
fontSize: 16,
),
style: TextStyle(color: Colors.grey.shade700, fontSize: 16),
children: const [
TextSpan(
text: '*',
@@ -96,10 +94,10 @@ class _TodoFormState extends State<TodoForm> {
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.orange),
borderSide: BorderSide(color: colors.primary),
),
filled: true,
fillColor: Colors.white,
fillColor: colors.surface,
prefixIcon: Icon(Icons.title, color: Colors.blue),
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
),
@@ -140,10 +138,10 @@ class _TodoFormState extends State<TodoForm> {
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.orange),
borderSide: BorderSide(color: colors.primary),
),
filled: true,
fillColor: Colors.white,
fillColor: colors.surface,
prefixIcon: Icon(Icons.description, color: Colors.green),
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
),
@@ -203,10 +201,10 @@ class _TodoFormState extends State<TodoForm> {
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.orange),
borderSide: BorderSide(color: colors.primary),
),
filled: true,
fillColor: Colors.white,
fillColor: colors.surface,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
suffixIcon:
provider.formItem.dueDate != null
@@ -268,10 +266,10 @@ class _TodoFormState extends State<TodoForm> {
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.orange),
borderSide: BorderSide(color: colors.primary),
),
filled: true,
fillColor: Colors.white,
fillColor: colors.surface,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
suffixIcon:
provider.formItem.scheduledTime != null
@@ -320,7 +318,7 @@ class _TodoFormState extends State<TodoForm> {
Container buildPriorityField() {
return Container(
decoration: BoxDecoration(
color: Colors.white,
color: colors.surface,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey.shade300, width: 1),
),