3 changed files with 178 additions and 1 deletions
@ -0,0 +1,76 @@ |
|||||
|
import 'package:flutter/material.dart'; |
||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
|
import 'package:get/get.dart'; |
||||
|
|
||||
|
import 'select_equalizer_widget.dart'; |
||||
|
|
||||
|
class RowEqualizerWidget extends StatefulWidget { |
||||
|
final Map templateData; |
||||
|
|
||||
|
const RowEqualizerWidget(this.templateData, {super.key}); |
||||
|
|
||||
|
@override |
||||
|
State<RowEqualizerWidget> createState() => _RowEqualizerWidgetState(); |
||||
|
} |
||||
|
|
||||
|
class _RowEqualizerWidgetState extends State<RowEqualizerWidget> { |
||||
|
Map get _templateData => widget.templateData; |
||||
|
|
||||
|
String _label = ''; |
||||
|
|
||||
|
@override |
||||
|
void initState() { |
||||
|
super.initState(); |
||||
|
_label = _templateData['options'].firstWhere( |
||||
|
(option) => option['value'] == _templateData['value'], |
||||
|
orElse: () => {'label': ''}, |
||||
|
)['label']; |
||||
|
} |
||||
|
|
||||
|
@override |
||||
|
Widget build(BuildContext context) { |
||||
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark; |
||||
|
|
||||
|
return GestureDetector( |
||||
|
onTap: () async { |
||||
|
var result = await Get.to(() => SelectEqualizerWidget(_templateData)); |
||||
|
if (result != null) { |
||||
|
setState(() { |
||||
|
_label = result['label']; |
||||
|
}); |
||||
|
_templateData['value'] = result['value']; |
||||
|
_templateData['onCallback'](result['value']); |
||||
|
} |
||||
|
}, |
||||
|
behavior: HitTestBehavior.translucent, |
||||
|
child: Padding( |
||||
|
padding: EdgeInsets.fromLTRB(10.w, 10.w, 0, 10.w), |
||||
|
child: Row( |
||||
|
children: [ |
||||
|
Expanded( |
||||
|
child: Text( |
||||
|
_templateData['name'], |
||||
|
style: TextStyle( |
||||
|
fontSize: 14.sp, |
||||
|
color: isDarkMode ? Colors.white : Colors.black, |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
Text( |
||||
|
_label, |
||||
|
style: TextStyle( |
||||
|
fontSize: 12.sp, |
||||
|
color: isDarkMode ? Colors.white : Colors.grey, |
||||
|
), |
||||
|
), |
||||
|
Icon( |
||||
|
Icons.chevron_right, |
||||
|
size: 26.w, |
||||
|
color: Colors.blue, |
||||
|
), |
||||
|
], |
||||
|
), |
||||
|
), |
||||
|
); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,58 @@ |
|||||
|
import 'package:flutter/material.dart'; |
||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
|
import 'package:get/get.dart'; |
||||
|
|
||||
|
class SelectEqualizerWidget extends StatefulWidget { |
||||
|
final Map templateData; |
||||
|
|
||||
|
const SelectEqualizerWidget(this.templateData, {super.key}); |
||||
|
|
||||
|
@override |
||||
|
State<SelectEqualizerWidget> createState() => _SelectEqualizerWidgetState(); |
||||
|
} |
||||
|
|
||||
|
class _SelectEqualizerWidgetState extends State<SelectEqualizerWidget> { |
||||
|
Map get _templateData => widget.templateData; |
||||
|
|
||||
|
@override |
||||
|
Widget build(BuildContext context) { |
||||
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark; |
||||
|
|
||||
|
return Scaffold( |
||||
|
backgroundColor: isDarkMode ? Colors.black : Colors.grey[50], |
||||
|
appBar: _buildAppBar(isDarkMode), |
||||
|
body: _buildBody(isDarkMode), |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
// 构建应用栏 |
||||
|
PreferredSizeWidget _buildAppBar(bool isDarkMode) { |
||||
|
return AppBar( |
||||
|
backgroundColor: isDarkMode ? Colors.black : Colors.white, |
||||
|
surfaceTintColor: Colors.transparent, |
||||
|
elevation: 0.5, |
||||
|
leading: IconButton( |
||||
|
icon: Icon( |
||||
|
Icons.arrow_back_ios, |
||||
|
color: isDarkMode ? Colors.white : Colors.black, |
||||
|
size: 20.sp, |
||||
|
), |
||||
|
onPressed: () => Get.back(), |
||||
|
), |
||||
|
title: Text( |
||||
|
_templateData['name'], |
||||
|
style: TextStyle( |
||||
|
fontSize: 17.sp, |
||||
|
fontWeight: FontWeight.w600, |
||||
|
color: isDarkMode ? Colors.white : Colors.black, |
||||
|
), |
||||
|
), |
||||
|
centerTitle: true, |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
// 构建主体内容 |
||||
|
Widget _buildBody(bool isDarkMode) { |
||||
|
return Container(); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue