From 826f66f765cef4fabe8ed7d21079c0fdb91fcc1d Mon Sep 17 00:00:00 2001 From: tanlongsheng <252620078@qq.com> Date: Wed, 19 Nov 2025 21:24:34 +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 --- .../views/widgets/row_input_widget.dart | 161 +---------------- .../widgets/select_equalizer_widget.dart | 66 ++++--- .../views/widgets/settings_input_widget.dart | 162 ++++++++++++++++++ 3 files changed, 208 insertions(+), 181 deletions(-) create mode 100644 lib/modules/eq_settings/views/widgets/settings_input_widget.dart diff --git a/lib/modules/eq_settings/views/widgets/row_input_widget.dart b/lib/modules/eq_settings/views/widgets/row_input_widget.dart index 2409e644e..339b79ce8 100644 --- a/lib/modules/eq_settings/views/widgets/row_input_widget.dart +++ b/lib/modules/eq_settings/views/widgets/row_input_widget.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'settings_input_widget.dart'; + class RowInputWidget extends StatefulWidget { final Map templateData; @@ -54,7 +56,7 @@ class _RowInputWidgetState extends State { void _inputBottomSheet(bool isDarkMode) { Get.bottomSheet( - InputBox(_templateData['name'], _templateData['value']), + SettingsInputWidget(_templateData['name'], _templateData['value']), isScrollControlled: true, backgroundColor: isDarkMode ? Colors.grey[800] : Colors.grey[100], shape: RoundedRectangleBorder( @@ -72,160 +74,3 @@ class _RowInputWidgetState extends State { }); } } - -class InputBox extends StatefulWidget { - final String title; - final String inputText; - - const InputBox(this.title, this.inputText, {super.key}); - - @override - State createState() => _InputBoxState(); -} - -class _InputBoxState extends State { - final TextEditingController _inputController = TextEditingController(); - - @override - void initState() { - super.initState(); - _inputController.text = widget.inputText; - } - - @override - void dispose() { - _inputController.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Padding( - padding: EdgeInsets.symmetric(horizontal: 12.w), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - padding: EdgeInsets.symmetric(vertical: 10.w), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - widget.title, - style: TextStyle( - fontSize: 16.sp, - color: Colors.black87, - fontWeight: FontWeight.bold, - ), - ), - GestureDetector( - onTap: () => Get.back(), - child: Container( - width: 26.w, - height: 26.w, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(26.r), - ), - child: Icon( - Icons.close, - size: 18.w, - color: Colors.grey[400], - ), - ), - ) - ], - ), - ), - Divider( - height: 1, - color: Colors.grey[300], - ), - Container( - margin: EdgeInsets.symmetric(vertical: 20.w), - alignment: Alignment.center, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(12.w), - boxShadow: [ - BoxShadow( - color: Colors.black.withValues(alpha: 0.05), - blurRadius: 10, - offset: const Offset(0, 2), - ), - ], - ), - child: TextField( - controller: _inputController, - style: TextStyle( - color: Colors.black87, - fontSize: 16.sp, - ), - decoration: InputDecoration( - hintText: 'maxCharacters'.tr, - hintStyle: TextStyle( - color: Colors.black54, - fontSize: 16.sp, - ), - isDense: true, - fillColor: Colors.transparent, - border: InputBorder.none, - contentPadding: EdgeInsets.all(10.w), - ), - ), - ), - Padding( - padding: EdgeInsets.only(bottom: 20.w), - child: Row( - children: [ - Expanded( - child: GestureDetector( - onTap: () => Get.back(), - child: Container( - height: 48.w, - alignment: Alignment.center, - decoration: BoxDecoration( - color: Colors.grey[300], - borderRadius: BorderRadius.circular(12.r), - ), - child: Text( - 'cancel'.tr, // 取消 - style: TextStyle( - fontSize: 16.sp, - color: Colors.black, - ), - ), - ), - ), - ), - 10.horizontalSpace, - Expanded( - child: GestureDetector( - onTap: () { - Get.back(result: _inputController.text); - }, - child: Container( - height: 48.w, - alignment: Alignment.center, - decoration: BoxDecoration( - color: Colors.black, - borderRadius: BorderRadius.circular(12.r), - ), - child: Text( - 'confirm'.tr, // 确认 - style: TextStyle( - fontSize: 16.sp, - color: Colors.white, - ), - ), - ), - ), - ), - ], - ), - ), - ], - ), - ); - } -} 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 1c62abde0..427c643d2 100644 --- a/lib/modules/eq_settings/views/widgets/select_equalizer_widget.dart +++ b/lib/modules/eq_settings/views/widgets/select_equalizer_widget.dart @@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'settings_input_widget.dart'; + class SelectEqualizerWidget extends StatefulWidget { final Map templateData; @@ -80,29 +82,32 @@ class _SelectEqualizerWidgetState extends State { return _item(isDarkMode, option, isSelected); }).toList(), if (isAdd) - Container( - width: 110.w, - height: 110.w, - alignment: Alignment.center, - decoration: BoxDecoration( - color: 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: Icon( - Icons.add, - size: 40.sp, - color: Colors.green, + GestureDetector( + onTap: () => _inputBottomSheet(isDarkMode), + child: Container( + width: 110.w, + height: 110.w, + alignment: Alignment.center, + decoration: BoxDecoration( + color: 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: Icon( + Icons.add, + size: 40.sp, + color: Colors.green, + ), ), ), ], @@ -205,4 +210,19 @@ class _SelectEqualizerWidgetState extends State { ), ); } + + void _inputBottomSheet(bool isDarkMode) { + Get.bottomSheet( + const SettingsInputWidget('添加均衡器', ''), + isScrollControlled: true, + backgroundColor: isDarkMode ? Colors.grey[800] : Colors.grey[100], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.vertical( + top: Radius.circular(12.r), + ), + ), + ).then((value) { + if (value != null) {} + }); + } } diff --git a/lib/modules/eq_settings/views/widgets/settings_input_widget.dart b/lib/modules/eq_settings/views/widgets/settings_input_widget.dart new file mode 100644 index 000000000..ea41dd49c --- /dev/null +++ b/lib/modules/eq_settings/views/widgets/settings_input_widget.dart @@ -0,0 +1,162 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; + +class SettingsInputWidget extends StatefulWidget { + final String title; + final String inputText; + + const SettingsInputWidget(this.title, this.inputText, {super.key}); + + @override + State createState() => _SettingsInputWidgetState(); +} + +class _SettingsInputWidgetState extends State { + final TextEditingController _inputController = TextEditingController(); + + @override + void initState() { + super.initState(); + _inputController.text = widget.inputText; + } + + @override + void dispose() { + _inputController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.symmetric(horizontal: 12.w), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + padding: EdgeInsets.symmetric(vertical: 10.w), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + widget.title, + style: TextStyle( + fontSize: 16.sp, + color: Colors.black87, + fontWeight: FontWeight.bold, + ), + ), + GestureDetector( + onTap: () => Get.back(), + child: Container( + width: 26.w, + height: 26.w, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(26.r), + ), + child: Icon( + Icons.close, + size: 18.w, + color: Colors.grey[400], + ), + ), + ) + ], + ), + ), + Divider( + height: 1, + color: Colors.grey[300], + ), + Container( + margin: EdgeInsets.symmetric(vertical: 20.w), + alignment: Alignment.center, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12.w), + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: 0.05), + blurRadius: 10, + offset: const Offset(0, 2), + ), + ], + ), + child: TextField( + controller: _inputController, + style: TextStyle( + color: Colors.black87, + fontSize: 16.sp, + ), + decoration: InputDecoration( + hintText: 'maxCharacters'.tr, + hintStyle: TextStyle( + color: Colors.black54, + fontSize: 16.sp, + ), + isDense: true, + fillColor: Colors.transparent, + border: InputBorder.none, + contentPadding: EdgeInsets.all(10.w), + ), + ), + ), + Padding( + padding: EdgeInsets.only(bottom: 20.w), + child: Row( + children: [ + Expanded( + child: GestureDetector( + onTap: () => Get.back(), + child: Container( + height: 48.w, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Colors.grey[300], + borderRadius: BorderRadius.circular(12.r), + ), + child: Text( + 'cancel'.tr, // 取消 + style: TextStyle( + fontSize: 16.sp, + color: Colors.black, + ), + ), + ), + ), + ), + 10.horizontalSpace, + Expanded( + child: GestureDetector( + onTap: () { + if (_inputController.text.isNotEmpty) { + Get.back(result: _inputController.text); + } + }, + child: Container( + height: 48.w, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Colors.black, + borderRadius: BorderRadius.circular(12.r), + ), + child: Text( + 'confirm'.tr, // 确认 + style: TextStyle( + fontSize: 16.sp, + color: Colors.white, + ), + ), + ), + ), + ), + ], + ), + ), + ], + ), + ); + } +}