3 changed files with 203 additions and 8 deletions
@ -0,0 +1,164 @@ |
|||
import 'package:flutter/material.dart'; |
|||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|||
import 'package:get/get.dart'; |
|||
|
|||
class SecondLevelBottomSheet extends StatefulWidget { |
|||
final String title; |
|||
final String subtitle; |
|||
final Function(int index) onTap; |
|||
final List children; |
|||
|
|||
const SecondLevelBottomSheet( |
|||
this.title, this.subtitle, this.onTap, this.children, |
|||
{super.key}); |
|||
|
|||
@override |
|||
State<SecondLevelBottomSheet> createState() => _SecondLevelBottomSheetState(); |
|||
} |
|||
|
|||
class _SecondLevelBottomSheetState extends State<SecondLevelBottomSheet> { |
|||
int _selectedIndex = 0; |
|||
|
|||
@override |
|||
Widget build(BuildContext context) { |
|||
return Padding( |
|||
padding: EdgeInsets.symmetric(horizontal: 12.w), |
|||
child: Column( |
|||
mainAxisSize: MainAxisSize.min, |
|||
crossAxisAlignment: CrossAxisAlignment.start, |
|||
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], |
|||
), |
|||
Padding( |
|||
padding: EdgeInsetsGeometry.only( |
|||
top: 20.w, |
|||
bottom: 10.w, |
|||
left: 12.w, |
|||
), |
|||
child: Text( |
|||
widget.subtitle, |
|||
style: TextStyle( |
|||
fontSize: 14.sp, |
|||
color: Colors.grey[600], |
|||
), |
|||
), |
|||
), |
|||
Container( |
|||
clipBehavior: Clip.hardEdge, |
|||
decoration: BoxDecoration( |
|||
color: Colors.white, |
|||
borderRadius: BorderRadius.circular(12.r), |
|||
), |
|||
child: Column( |
|||
children: List.generate(widget.children.length, (int index) { |
|||
Map item = widget.children[index]; |
|||
return InkWell( |
|||
onTap: () { |
|||
setState(() { |
|||
_selectedIndex = index; |
|||
}); |
|||
}, |
|||
child: Container( |
|||
padding: |
|||
EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.w), |
|||
decoration: BoxDecoration( |
|||
border: item['isBorder'] |
|||
? Border( |
|||
bottom: BorderSide( |
|||
width: 0.5, |
|||
color: Colors.grey[300]!, |
|||
), |
|||
) |
|||
: null, |
|||
), |
|||
child: Row( |
|||
children: [ |
|||
Icon( |
|||
item['icon'], |
|||
color: Colors.black87, |
|||
), |
|||
10.horizontalSpace, |
|||
Expanded( |
|||
child: Text( |
|||
item['title'], |
|||
style: TextStyle( |
|||
fontSize: 14.sp, |
|||
color: Colors.black87, |
|||
), |
|||
), |
|||
), |
|||
if (_selectedIndex == index) |
|||
const Icon( |
|||
Icons.check, |
|||
color: Colors.black87, |
|||
), |
|||
], |
|||
), |
|||
), |
|||
); |
|||
}), |
|||
), |
|||
), |
|||
Padding( |
|||
padding: EdgeInsets.symmetric(vertical: 20.w), |
|||
child: GestureDetector( |
|||
onTap: () { |
|||
Get.back(); |
|||
widget.onTap(_selectedIndex); |
|||
}, |
|||
child: Container( |
|||
height: 48.w, |
|||
alignment: Alignment.center, |
|||
decoration: BoxDecoration( |
|||
color: Colors.black, |
|||
borderRadius: BorderRadius.circular(12.r), |
|||
), |
|||
child: Text( |
|||
'导出', |
|||
style: TextStyle( |
|||
fontSize: 16.sp, |
|||
color: Colors.white, |
|||
), |
|||
), |
|||
), |
|||
), |
|||
), |
|||
], |
|||
), |
|||
); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue