From bbbdaf55bfc906ef38f099db38eff4844772118c Mon Sep 17 00:00:00 2001 From: tanlongsheng <252620078@qq.com> Date: Thu, 20 Nov 2025 11:11:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=BE=E5=A4=87=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widgets/select_equalizer_widget.dart | 124 +++++++++++++----- 1 file changed, 93 insertions(+), 31 deletions(-) diff --git a/lib/modules/eq_settings/views/widgets/select_equalizer_widget.dart b/lib/modules/eq_settings/views/widgets/select_equalizer_widget.dart index 427c643d2..6fcf6429a 100644 --- a/lib/modules/eq_settings/views/widgets/select_equalizer_widget.dart +++ b/lib/modules/eq_settings/views/widgets/select_equalizer_widget.dart @@ -19,6 +19,8 @@ class _SelectEqualizerWidgetState extends State { List _values = []; + bool isEdit = false; + @override void initState() { super.initState(); @@ -59,6 +61,28 @@ class _SelectEqualizerWidgetState extends State { ), ), centerTitle: true, + actions: [ + GestureDetector( + onTap: () { + setState(() { + isEdit = !isEdit; + }); + }, + child: Padding( + padding: EdgeInsets.symmetric( + horizontal: 12.w, + vertical: 6.w, + ), + child: Text( + isEdit ? 'cancel'.tr : 'edit'.tr, + style: TextStyle( + color: isDarkMode ? Colors.white : Colors.black87, + fontSize: 16.sp, + ), + ), + ), + ), + ], ); } @@ -174,39 +198,69 @@ class _SelectEqualizerWidgetState extends State { 'value': option['value'], }); }, - child: Container( - width: 110.w, - height: 110.w, - alignment: Alignment.center, - decoration: BoxDecoration( - color: isSelected - ? Colors.green - : isDarkMode - ? Colors.white.withValues(alpha: 0.05) - : Colors.white, - borderRadius: BorderRadius.circular(8.w), - boxShadow: [ - BoxShadow( - color: isDarkMode - ? Colors.black.withValues(alpha: 0.2) - : Colors.black.withValues(alpha: 0.05), - blurRadius: 10, - offset: const Offset(0, 4), + child: Stack( + children: [ + Container( + width: 110.w, + height: 110.w, + alignment: Alignment.center, + decoration: BoxDecoration( + color: isSelected + ? Colors.green + : isDarkMode + ? Colors.white.withValues(alpha: 0.05) + : Colors.white, + borderRadius: BorderRadius.circular(8.w), + boxShadow: [ + BoxShadow( + color: isDarkMode + ? Colors.black.withValues(alpha: 0.2) + : Colors.black.withValues(alpha: 0.05), + blurRadius: 10, + offset: const Offset(0, 4), + ), + ], ), - ], - ), - child: Text( - option['label'], - style: TextStyle( - fontSize: 16.sp, - fontWeight: FontWeight.w600, - color: isSelected - ? Colors.white - : isDarkMode + child: Text( + option['label'], + style: TextStyle( + fontSize: 16.sp, + fontWeight: FontWeight.w600, + color: isSelected ? Colors.white - : Colors.black, + : isDarkMode + ? Colors.white + : Colors.black, + ), + ), ), - ), + if (isEdit && !option['default']) + Positioned( + top: 4.w, + right: 4.w, + child: GestureDetector( + onTap: () { + setState(() { + _templateData['options'].remove(option); + }); + }, + child: Container( + width: 24.w, + height: 24.w, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(12.w), + ), + child: Icon( + Icons.close, + size: 16.sp, + color: Colors.white, + ), + ), + ), + ), + ], ), ); } @@ -222,7 +276,15 @@ class _SelectEqualizerWidgetState extends State { ), ), ).then((value) { - if (value != null) {} + if (value != null) { + setState(() { + _templateData['options'].add({ + 'label': value, + 'value': List.from(_values), + 'default': false, + }); + }); + } }); } }