Browse Source

feat(theme): 支持暗色模式主题适配

- 在模板列表视图中增加暗色模式颜色支持
- 调整模板详情页面文本与背景颜色的暗色模式兼容
- 修正模板编辑页面输入框及按钮颜色以适配暗色模式
- 更新模板视图组件颜色,根据当前主题动态切换
- 按钮、标签、边框等UI元素颜色增强暗色和明色模式区分
- 移除暗色模式下不必要的阴影效果,提升视觉一致性
newdev_shunjiawei
lxm 7 months ago
parent
commit
06803c6896
  1. 34
      lib/modules/meeting/views/template/template_all_view.dart
  2. 20
      lib/modules/meeting/views/template/template_details_view.dart
  3. 32
      lib/modules/meeting/views/template/template_edit_view.dart
  4. 33
      lib/modules/meeting/views/template/template_view.dart

34
lib/modules/meeting/views/template/template_all_view.dart

@ -124,7 +124,7 @@ class _TemplateAllViewState extends State<TemplateAllView> {
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 20.w), padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 20.w),
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
Map data = _templateList[index]; Map data = _templateList[index];
return _item(data); return _item(data, isDarkMode);
}, },
), ),
), ),
@ -141,14 +141,18 @@ class _TemplateAllViewState extends State<TemplateAllView> {
height: 48.w, height: 48.w,
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
color: _templateData.isNotEmpty ? Colors.black : Colors.grey, color: _templateData.isNotEmpty
? (isDarkMode ? Colors.white : Colors.black)
: Colors.grey,
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
), ),
child: Text( child: Text(
'就用这个模版', '就用这个模版',
style: TextStyle( style: TextStyle(
fontSize: 16.sp, fontSize: 16.sp,
color: Colors.white, color: _templateData.isNotEmpty
? (isDarkMode ? Colors.black : Colors.white)
: Colors.white,
), ),
), ),
), ),
@ -158,11 +162,11 @@ class _TemplateAllViewState extends State<TemplateAllView> {
); );
} }
Widget _item(Map template) { Widget _item(Map template, bool isDarkMode) {
return Container( return Container(
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white,
borderRadius: BorderRadius.circular(14.w), borderRadius: BorderRadius.circular(14.w),
), ),
child: GestureDetector( child: GestureDetector(
@ -176,7 +180,7 @@ class _TemplateAllViewState extends State<TemplateAllView> {
Container( Container(
padding: EdgeInsets.all(5.w), padding: EdgeInsets.all(5.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white,
gradient: _templateData['id'] == template['id'] gradient: _templateData['id'] == template['id']
? const LinearGradient( ? const LinearGradient(
colors: [Colors.blue, Colors.pinkAccent], colors: [Colors.blue, Colors.pinkAccent],
@ -190,7 +194,7 @@ class _TemplateAllViewState extends State<TemplateAllView> {
padding: EdgeInsets.all(10.w), padding: EdgeInsets.all(10.w),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.w), borderRadius: BorderRadius.circular(10.w),
color: Colors.white, color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white,
), ),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -209,7 +213,7 @@ class _TemplateAllViewState extends State<TemplateAllView> {
template['name'], template['name'],
style: TextStyle( style: TextStyle(
fontSize: 16.sp, fontSize: 16.sp,
color: Colors.black87, color: isDarkMode ? Colors.white : Colors.black87,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
@ -224,14 +228,18 @@ class _TemplateAllViewState extends State<TemplateAllView> {
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: 5.w, vertical: 2.w), horizontal: 5.w, vertical: 2.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.grey[200], color: isDarkMode
? Colors.grey[700]
: Colors.grey[200],
borderRadius: BorderRadius.circular(4.r), borderRadius: BorderRadius.circular(4.r),
), ),
child: Text( child: Text(
template['tag'][idx], template['tag'][idx],
style: TextStyle( style: TextStyle(
fontSize: 10.sp, fontSize: 10.sp,
color: Colors.grey[600], color: isDarkMode
? Colors.grey[300]
: Colors.grey[600],
), ),
), ),
); );
@ -243,7 +251,9 @@ class _TemplateAllViewState extends State<TemplateAllView> {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
color: Colors.grey[600], color: isDarkMode
? Colors.grey[400]
: Colors.grey[600],
), ),
), ),
], ],
@ -277,7 +287,7 @@ class _TemplateAllViewState extends State<TemplateAllView> {
padding: EdgeInsets.all(10.w), padding: EdgeInsets.all(10.w),
child: Icon( child: Icon(
Icons.fullscreen, Icons.fullscreen,
color: Colors.grey[600], color: isDarkMode ? Colors.grey[400] : Colors.grey[600],
size: 26.w, size: 26.w,
), ),
), ),

20
lib/modules/meeting/views/template/template_details_view.dart

@ -80,6 +80,7 @@ class _TemplateDetailsViewState extends State<TemplateDetailsView> {
style: TextStyle( style: TextStyle(
fontSize: 20.sp, fontSize: 20.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: isDarkMode ? Colors.white : Colors.black87,
), ),
), ),
), ),
@ -90,6 +91,7 @@ class _TemplateDetailsViewState extends State<TemplateDetailsView> {
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: isDarkMode ? Colors.white70 : Colors.black87,
), ),
), ),
), ),
@ -102,14 +104,15 @@ class _TemplateDetailsViewState extends State<TemplateDetailsView> {
padding: padding:
EdgeInsets.symmetric(horizontal: 5.w, vertical: 2.w), EdgeInsets.symmetric(horizontal: 5.w, vertical: 2.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.grey[200], color: isDarkMode ? Colors.grey[700] : Colors.grey[200],
borderRadius: BorderRadius.circular(4.r), borderRadius: BorderRadius.circular(4.r),
), ),
child: Text( child: Text(
_templateData['tag'][idx], _templateData['tag'][idx],
style: TextStyle( style: TextStyle(
fontSize: 10.sp, fontSize: 10.sp,
color: Colors.grey[600], color:
isDarkMode ? Colors.grey[300] : Colors.grey[600],
), ),
), ),
); );
@ -123,6 +126,7 @@ class _TemplateDetailsViewState extends State<TemplateDetailsView> {
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: isDarkMode ? Colors.white70 : Colors.black87,
), ),
), ),
), ),
@ -130,7 +134,7 @@ class _TemplateDetailsViewState extends State<TemplateDetailsView> {
_templateData['desc'], _templateData['desc'],
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
color: Colors.grey[600], color: isDarkMode ? Colors.grey[400] : Colors.grey[600],
), ),
), ),
Padding( Padding(
@ -140,11 +144,17 @@ class _TemplateDetailsViewState extends State<TemplateDetailsView> {
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: isDarkMode ? Colors.white70 : Colors.black87,
), ),
), ),
), ),
MarkdownBody( MarkdownBody(
data: _templateData['prompt'], data: _templateData['prompt'],
styleSheet: MarkdownStyleSheet(
p: TextStyle(
color: isDarkMode ? Colors.grey[300] : Colors.black87,
),
),
), ),
], ],
), ),
@ -173,14 +183,14 @@ class _TemplateDetailsViewState extends State<TemplateDetailsView> {
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
border: Border.all( border: Border.all(
color: Colors.black, color: isDarkMode ? Colors.white : Colors.black,
), ),
), ),
child: Text( child: Text(
'修改', '修改',
style: TextStyle( style: TextStyle(
fontSize: 16.sp, fontSize: 16.sp,
color: Colors.black, color: isDarkMode ? Colors.white : Colors.black,
), ),
), ),
), ),

32
lib/modules/meeting/views/template/template_edit_view.dart

@ -130,7 +130,7 @@ class _TemplateEditViewState extends State<TemplateEditView> {
color: _nameController.text.isNotEmpty && color: _nameController.text.isNotEmpty &&
_descController.text.isNotEmpty && _descController.text.isNotEmpty &&
_promptController.text.isNotEmpty _promptController.text.isNotEmpty
? Colors.black ? (isDarkMode ? Colors.white : Colors.black)
: Colors.grey, : Colors.grey,
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
), ),
@ -138,7 +138,11 @@ class _TemplateEditViewState extends State<TemplateEditView> {
'提交', '提交',
style: TextStyle( style: TextStyle(
fontSize: 16.sp, 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<TemplateEditView> {
title, title,
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
color: isDarkMode ? Colors.white60 : Colors.black87, color: isDarkMode ? Colors.white70 : Colors.black87,
), ),
), ),
), ),
@ -200,28 +204,30 @@ class _TemplateEditViewState extends State<TemplateEditView> {
margin: EdgeInsets.only(top: 10.w, bottom: 20.w), margin: EdgeInsets.only(top: 10.w, bottom: 20.w),
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white,
borderRadius: BorderRadius.circular(12.w), borderRadius: BorderRadius.circular(12.w),
boxShadow: [ boxShadow: isDarkMode
BoxShadow( ? null
color: Colors.black.withValues(alpha: 0.05), : [
blurRadius: 10, BoxShadow(
offset: const Offset(0, 2), color: Colors.black.withValues(alpha: 0.05),
), blurRadius: 10,
], offset: const Offset(0, 2),
),
],
), ),
child: TextField( child: TextField(
controller: controller, controller: controller,
minLines: minLines, minLines: minLines,
maxLines: maxLines, maxLines: maxLines,
style: TextStyle( style: TextStyle(
color: Colors.black87, color: isDarkMode ? Colors.white : Colors.black87,
fontSize: 14.sp, fontSize: 14.sp,
), ),
decoration: InputDecoration( decoration: InputDecoration(
hintText: hintText ?? '请输入$title', hintText: hintText ?? '请输入$title',
hintStyle: TextStyle( hintStyle: TextStyle(
color: Colors.black54, color: isDarkMode ? Colors.grey[500] : Colors.black54,
fontSize: 14.sp, fontSize: 14.sp,
), ),
isDense: true, isDense: true,

33
lib/modules/meeting/views/template/template_view.dart

@ -179,6 +179,7 @@ class _TemplateViewState extends State<TemplateView> {
} }
Widget _item(Map data, bool isLast) { Widget _item(Map data, bool isLast) {
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -200,13 +201,13 @@ class _TemplateViewState extends State<TemplateView> {
data['name'], data['name'],
style: TextStyle( style: TextStyle(
fontSize: 18.sp, fontSize: 18.sp,
color: Colors.black87, color: isDarkMode ? Colors.white : Colors.black87,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
const Icon( Icon(
Icons.keyboard_arrow_right, Icons.keyboard_arrow_right,
color: Colors.grey, color: isDarkMode ? Colors.grey[400] : Colors.grey,
) )
], ],
), ),
@ -242,6 +243,7 @@ class _TemplateViewState extends State<TemplateView> {
} }
Widget _template(Map template, bool isEdit) { Widget _template(Map template, bool isEdit) {
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
return Container( return Container(
width: 200.w, width: 200.w,
margin: EdgeInsets.symmetric(horizontal: 4.w), margin: EdgeInsets.symmetric(horizontal: 4.w),
@ -260,7 +262,7 @@ class _TemplateViewState extends State<TemplateView> {
Container( Container(
padding: EdgeInsets.all(5.w), padding: EdgeInsets.all(5.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white,
gradient: _templateData['id'] == template['id'] gradient: _templateData['id'] == template['id']
? const LinearGradient( ? const LinearGradient(
colors: [Colors.blue, Colors.pinkAccent], colors: [Colors.blue, Colors.pinkAccent],
@ -274,7 +276,7 @@ class _TemplateViewState extends State<TemplateView> {
padding: EdgeInsets.all(10.w), padding: EdgeInsets.all(10.w),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.w), borderRadius: BorderRadius.circular(10.w),
color: Colors.white, color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white,
), ),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -293,7 +295,7 @@ class _TemplateViewState extends State<TemplateView> {
template['name'], template['name'],
style: TextStyle( style: TextStyle(
fontSize: 16.sp, fontSize: 16.sp,
color: Colors.black87, color: isDarkMode ? Colors.white : Colors.black87,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
@ -308,14 +310,18 @@ class _TemplateViewState extends State<TemplateView> {
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: 5.w, vertical: 2.w), horizontal: 5.w, vertical: 2.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.grey[200], color: isDarkMode
? Colors.grey[700]
: Colors.grey[200],
borderRadius: BorderRadius.circular(4.r), borderRadius: BorderRadius.circular(4.r),
), ),
child: Text( child: Text(
template['tag'][idx], template['tag'][idx],
style: TextStyle( style: TextStyle(
fontSize: 10.sp, fontSize: 10.sp,
color: Colors.grey[600], color: isDarkMode
? Colors.grey[300]
: Colors.grey[600],
), ),
), ),
); );
@ -327,7 +333,9 @@ class _TemplateViewState extends State<TemplateView> {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
color: Colors.grey[600], color: isDarkMode
? Colors.grey[400]
: Colors.grey[600],
), ),
), ),
], ],
@ -347,7 +355,7 @@ class _TemplateViewState extends State<TemplateView> {
padding: EdgeInsets.all(10.w), padding: EdgeInsets.all(10.w),
child: Icon( child: Icon(
Icons.fullscreen, Icons.fullscreen,
color: Colors.grey[600], color: isDarkMode ? Colors.grey[400] : Colors.grey[600],
size: 26.w, size: 26.w,
), ),
), ),
@ -403,6 +411,7 @@ class _TemplateViewState extends State<TemplateView> {
} }
Widget _createTemplate(int categoryid) { Widget _createTemplate(int categoryid) {
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
return GestureDetector( return GestureDetector(
onTap: () async { onTap: () async {
await Get.to(() => TemplateEditView(categoryid: categoryid)); await Get.to(() => TemplateEditView(categoryid: categoryid));
@ -418,7 +427,7 @@ class _TemplateViewState extends State<TemplateView> {
borderRadius: BorderRadius.circular(14.w), borderRadius: BorderRadius.circular(14.w),
), ),
child: Container( child: Container(
color: Colors.white, color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
@ -436,7 +445,7 @@ class _TemplateViewState extends State<TemplateView> {
'创建', '创建',
style: TextStyle( style: TextStyle(
fontSize: 16.sp, fontSize: 16.sp,
color: Colors.black87, color: isDarkMode ? Colors.white : Colors.black87,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),

Loading…
Cancel
Save