From 06803c68966c3fac2c0175ecf780cf2ff3507783 Mon Sep 17 00:00:00 2001 From: lxm <1274844347@qq.com> Date: Mon, 2 Mar 2026 15:18:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(theme):=20=E6=94=AF=E6=8C=81=E6=9A=97?= =?UTF-8?q?=E8=89=B2=E6=A8=A1=E5=BC=8F=E4=B8=BB=E9=A2=98=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在模板列表视图中增加暗色模式颜色支持 - 调整模板详情页面文本与背景颜色的暗色模式兼容 - 修正模板编辑页面输入框及按钮颜色以适配暗色模式 - 更新模板视图组件颜色,根据当前主题动态切换 - 按钮、标签、边框等UI元素颜色增强暗色和明色模式区分 - 移除暗色模式下不必要的阴影效果,提升视觉一致性 --- .../views/template/template_all_view.dart | 34 ++++++++++++------- .../views/template/template_details_view.dart | 20 ++++++++--- .../views/template/template_edit_view.dart | 32 ++++++++++------- .../meeting/views/template/template_view.dart | 33 +++++++++++------- 4 files changed, 77 insertions(+), 42 deletions(-) diff --git a/lib/modules/meeting/views/template/template_all_view.dart b/lib/modules/meeting/views/template/template_all_view.dart index 7da711ba8..676c5f80f 100644 --- a/lib/modules/meeting/views/template/template_all_view.dart +++ b/lib/modules/meeting/views/template/template_all_view.dart @@ -124,7 +124,7 @@ class _TemplateAllViewState extends State { padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 20.w), itemBuilder: (BuildContext context, int index) { Map data = _templateList[index]; - return _item(data); + return _item(data, isDarkMode); }, ), ), @@ -141,14 +141,18 @@ class _TemplateAllViewState extends State { height: 48.w, alignment: Alignment.center, decoration: BoxDecoration( - color: _templateData.isNotEmpty ? Colors.black : Colors.grey, + color: _templateData.isNotEmpty + ? (isDarkMode ? Colors.white : Colors.black) + : Colors.grey, borderRadius: BorderRadius.circular(12.r), ), child: Text( '就用这个模版', style: TextStyle( fontSize: 16.sp, - color: Colors.white, + color: _templateData.isNotEmpty + ? (isDarkMode ? Colors.black : Colors.white) + : Colors.white, ), ), ), @@ -158,11 +162,11 @@ class _TemplateAllViewState extends State { ); } - Widget _item(Map template) { + Widget _item(Map template, bool isDarkMode) { return Container( clipBehavior: Clip.hardEdge, decoration: BoxDecoration( - color: Colors.white, + color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white, borderRadius: BorderRadius.circular(14.w), ), child: GestureDetector( @@ -176,7 +180,7 @@ class _TemplateAllViewState extends State { Container( padding: EdgeInsets.all(5.w), decoration: BoxDecoration( - color: Colors.white, + color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white, gradient: _templateData['id'] == template['id'] ? const LinearGradient( colors: [Colors.blue, Colors.pinkAccent], @@ -190,7 +194,7 @@ class _TemplateAllViewState extends State { padding: EdgeInsets.all(10.w), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.w), - color: Colors.white, + color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -209,7 +213,7 @@ class _TemplateAllViewState extends State { template['name'], style: TextStyle( fontSize: 16.sp, - color: Colors.black87, + color: isDarkMode ? Colors.white : Colors.black87, fontWeight: FontWeight.bold, ), ), @@ -224,14 +228,18 @@ class _TemplateAllViewState extends State { padding: EdgeInsets.symmetric( horizontal: 5.w, vertical: 2.w), decoration: BoxDecoration( - color: Colors.grey[200], + color: isDarkMode + ? Colors.grey[700] + : Colors.grey[200], borderRadius: BorderRadius.circular(4.r), ), child: Text( template['tag'][idx], style: TextStyle( fontSize: 10.sp, - color: Colors.grey[600], + color: isDarkMode + ? Colors.grey[300] + : Colors.grey[600], ), ), ); @@ -243,7 +251,9 @@ class _TemplateAllViewState extends State { overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 12.sp, - color: Colors.grey[600], + color: isDarkMode + ? Colors.grey[400] + : Colors.grey[600], ), ), ], @@ -277,7 +287,7 @@ class _TemplateAllViewState extends State { padding: EdgeInsets.all(10.w), child: Icon( Icons.fullscreen, - color: Colors.grey[600], + color: isDarkMode ? Colors.grey[400] : Colors.grey[600], size: 26.w, ), ), diff --git a/lib/modules/meeting/views/template/template_details_view.dart b/lib/modules/meeting/views/template/template_details_view.dart index fc517e280..43fbd907a 100644 --- a/lib/modules/meeting/views/template/template_details_view.dart +++ b/lib/modules/meeting/views/template/template_details_view.dart @@ -80,6 +80,7 @@ class _TemplateDetailsViewState extends State { style: TextStyle( fontSize: 20.sp, fontWeight: FontWeight.bold, + color: isDarkMode ? Colors.white : Colors.black87, ), ), ), @@ -90,6 +91,7 @@ class _TemplateDetailsViewState extends State { style: TextStyle( fontSize: 12.sp, fontWeight: FontWeight.bold, + color: isDarkMode ? Colors.white70 : Colors.black87, ), ), ), @@ -102,14 +104,15 @@ class _TemplateDetailsViewState extends State { padding: EdgeInsets.symmetric(horizontal: 5.w, vertical: 2.w), decoration: BoxDecoration( - color: Colors.grey[200], + color: isDarkMode ? Colors.grey[700] : Colors.grey[200], borderRadius: BorderRadius.circular(4.r), ), child: Text( _templateData['tag'][idx], style: TextStyle( fontSize: 10.sp, - color: Colors.grey[600], + color: + isDarkMode ? Colors.grey[300] : Colors.grey[600], ), ), ); @@ -123,6 +126,7 @@ class _TemplateDetailsViewState extends State { style: TextStyle( fontSize: 12.sp, fontWeight: FontWeight.bold, + color: isDarkMode ? Colors.white70 : Colors.black87, ), ), ), @@ -130,7 +134,7 @@ class _TemplateDetailsViewState extends State { _templateData['desc'], style: TextStyle( fontSize: 14.sp, - color: Colors.grey[600], + color: isDarkMode ? Colors.grey[400] : Colors.grey[600], ), ), Padding( @@ -140,11 +144,17 @@ class _TemplateDetailsViewState extends State { style: TextStyle( fontSize: 12.sp, fontWeight: FontWeight.bold, + color: isDarkMode ? Colors.white70 : Colors.black87, ), ), ), MarkdownBody( data: _templateData['prompt'], + styleSheet: MarkdownStyleSheet( + p: TextStyle( + color: isDarkMode ? Colors.grey[300] : Colors.black87, + ), + ), ), ], ), @@ -173,14 +183,14 @@ class _TemplateDetailsViewState extends State { decoration: BoxDecoration( borderRadius: BorderRadius.circular(12.r), border: Border.all( - color: Colors.black, + color: isDarkMode ? Colors.white : Colors.black, ), ), child: Text( '修改', style: TextStyle( fontSize: 16.sp, - color: Colors.black, + color: isDarkMode ? Colors.white : Colors.black, ), ), ), diff --git a/lib/modules/meeting/views/template/template_edit_view.dart b/lib/modules/meeting/views/template/template_edit_view.dart index 27dc4fb5c..133e660de 100644 --- a/lib/modules/meeting/views/template/template_edit_view.dart +++ b/lib/modules/meeting/views/template/template_edit_view.dart @@ -130,7 +130,7 @@ class _TemplateEditViewState extends State { color: _nameController.text.isNotEmpty && _descController.text.isNotEmpty && _promptController.text.isNotEmpty - ? Colors.black + ? (isDarkMode ? Colors.white : Colors.black) : Colors.grey, borderRadius: BorderRadius.circular(12.r), ), @@ -138,7 +138,11 @@ class _TemplateEditViewState extends State { '提交', style: TextStyle( fontSize: 16.sp, - color: Colors.white, + color: _nameController.text.isNotEmpty && + _descController.text.isNotEmpty && + _promptController.text.isNotEmpty + ? (isDarkMode ? Colors.black : Colors.white) + : Colors.white, ), ), ), @@ -168,7 +172,7 @@ class _TemplateEditViewState extends State { title, style: TextStyle( fontSize: 14.sp, - color: isDarkMode ? Colors.white60 : Colors.black87, + color: isDarkMode ? Colors.white70 : Colors.black87, ), ), ), @@ -200,28 +204,30 @@ class _TemplateEditViewState extends State { margin: EdgeInsets.only(top: 10.w, bottom: 20.w), alignment: Alignment.center, decoration: BoxDecoration( - color: Colors.white, + color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white, borderRadius: BorderRadius.circular(12.w), - boxShadow: [ - BoxShadow( - color: Colors.black.withValues(alpha: 0.05), - blurRadius: 10, - offset: const Offset(0, 2), - ), - ], + boxShadow: isDarkMode + ? null + : [ + BoxShadow( + color: Colors.black.withValues(alpha: 0.05), + blurRadius: 10, + offset: const Offset(0, 2), + ), + ], ), child: TextField( controller: controller, minLines: minLines, maxLines: maxLines, style: TextStyle( - color: Colors.black87, + color: isDarkMode ? Colors.white : Colors.black87, fontSize: 14.sp, ), decoration: InputDecoration( hintText: hintText ?? '请输入$title', hintStyle: TextStyle( - color: Colors.black54, + color: isDarkMode ? Colors.grey[500] : Colors.black54, fontSize: 14.sp, ), isDense: true, diff --git a/lib/modules/meeting/views/template/template_view.dart b/lib/modules/meeting/views/template/template_view.dart index 3efcd1716..f6b156be5 100644 --- a/lib/modules/meeting/views/template/template_view.dart +++ b/lib/modules/meeting/views/template/template_view.dart @@ -179,6 +179,7 @@ class _TemplateViewState extends State { } Widget _item(Map data, bool isLast) { + final isDarkMode = Theme.of(context).brightness == Brightness.dark; return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -200,13 +201,13 @@ class _TemplateViewState extends State { data['name'], style: TextStyle( fontSize: 18.sp, - color: Colors.black87, + color: isDarkMode ? Colors.white : Colors.black87, fontWeight: FontWeight.bold, ), ), - const Icon( + Icon( Icons.keyboard_arrow_right, - color: Colors.grey, + color: isDarkMode ? Colors.grey[400] : Colors.grey, ) ], ), @@ -242,6 +243,7 @@ class _TemplateViewState extends State { } Widget _template(Map template, bool isEdit) { + final isDarkMode = Theme.of(context).brightness == Brightness.dark; return Container( width: 200.w, margin: EdgeInsets.symmetric(horizontal: 4.w), @@ -260,7 +262,7 @@ class _TemplateViewState extends State { Container( padding: EdgeInsets.all(5.w), decoration: BoxDecoration( - color: Colors.white, + color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white, gradient: _templateData['id'] == template['id'] ? const LinearGradient( colors: [Colors.blue, Colors.pinkAccent], @@ -274,7 +276,7 @@ class _TemplateViewState extends State { padding: EdgeInsets.all(10.w), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.w), - color: Colors.white, + color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -293,7 +295,7 @@ class _TemplateViewState extends State { template['name'], style: TextStyle( fontSize: 16.sp, - color: Colors.black87, + color: isDarkMode ? Colors.white : Colors.black87, fontWeight: FontWeight.bold, ), ), @@ -308,14 +310,18 @@ class _TemplateViewState extends State { padding: EdgeInsets.symmetric( horizontal: 5.w, vertical: 2.w), decoration: BoxDecoration( - color: Colors.grey[200], + color: isDarkMode + ? Colors.grey[700] + : Colors.grey[200], borderRadius: BorderRadius.circular(4.r), ), child: Text( template['tag'][idx], style: TextStyle( fontSize: 10.sp, - color: Colors.grey[600], + color: isDarkMode + ? Colors.grey[300] + : Colors.grey[600], ), ), ); @@ -327,7 +333,9 @@ class _TemplateViewState extends State { overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 12.sp, - color: Colors.grey[600], + color: isDarkMode + ? Colors.grey[400] + : Colors.grey[600], ), ), ], @@ -347,7 +355,7 @@ class _TemplateViewState extends State { padding: EdgeInsets.all(10.w), child: Icon( Icons.fullscreen, - color: Colors.grey[600], + color: isDarkMode ? Colors.grey[400] : Colors.grey[600], size: 26.w, ), ), @@ -403,6 +411,7 @@ class _TemplateViewState extends State { } Widget _createTemplate(int categoryid) { + final isDarkMode = Theme.of(context).brightness == Brightness.dark; return GestureDetector( onTap: () async { await Get.to(() => TemplateEditView(categoryid: categoryid)); @@ -418,7 +427,7 @@ class _TemplateViewState extends State { borderRadius: BorderRadius.circular(14.w), ), child: Container( - color: Colors.white, + color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -436,7 +445,7 @@ class _TemplateViewState extends State { '创建', style: TextStyle( fontSize: 16.sp, - color: Colors.black87, + color: isDarkMode ? Colors.white : Colors.black87, fontWeight: FontWeight.bold, ), ),