You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
4.9 KiB
139 lines
4.9 KiB
import 'package:flutter/material.dart'; |
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
import 'package:huixiang/utils/font_weight.dart'; |
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
import 'package:huixiang/view_widget/round_button.dart'; |
|
|
|
class PeopleNumView extends StatefulWidget { |
|
final String tableName; |
|
|
|
// final Function(int peopleNum) callback; |
|
|
|
PeopleNumView(this.tableName); |
|
|
|
@override |
|
State<StatefulWidget> createState() { |
|
return _PeopleNumView(); |
|
} |
|
} |
|
|
|
class _PeopleNumView extends State<PeopleNumView> { |
|
int peopleNum = 1; |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
return SimpleDialog( |
|
titlePadding: EdgeInsets.all(10), |
|
backgroundColor: Colors.transparent, |
|
elevation: 0, |
|
shape: RoundedRectangleBorder( |
|
borderRadius: BorderRadius.circular(6), |
|
), |
|
children: [ |
|
Stack( |
|
alignment: Alignment.bottomCenter, |
|
children: [ |
|
Container( |
|
width: 295, |
|
height: 247, |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.circular(8), |
|
), |
|
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 20), |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Text( |
|
"桌位:${widget.tableName}", |
|
style: TextStyle( |
|
fontSize: 16.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF171717), |
|
), |
|
), |
|
Text( |
|
"请选择用餐人数:$peopleNum人", |
|
style: TextStyle( |
|
fontSize: 16.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF171717), |
|
), |
|
), |
|
SizedBox( |
|
height: 10, |
|
), |
|
Container( |
|
child: GridView.builder( |
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
|
crossAxisCount: 5, |
|
crossAxisSpacing: 24, |
|
mainAxisSpacing: 18, |
|
childAspectRatio: 1, |
|
), |
|
shrinkWrap: true, |
|
itemCount: 10, |
|
padding: EdgeInsets.zero, |
|
physics: NeverScrollableScrollPhysics(), |
|
itemBuilder: (context, position) { |
|
return InkWell( |
|
onTap: () { |
|
setState(() { |
|
peopleNum = position + 1; |
|
}); |
|
}, |
|
child: Container( |
|
decoration: BoxDecoration( |
|
color: peopleNum == (position + 1) |
|
? Color(0xFF32A060) |
|
: Colors.transparent, |
|
border: Border.all( |
|
color: Color(0xFF32A060), |
|
width: 1, |
|
), |
|
borderRadius: BorderRadius.circular(3), |
|
), |
|
alignment: Alignment.center, |
|
child: Text( |
|
"${position + 1}", |
|
style: TextStyle( |
|
color: peopleNum == (position + 1) |
|
? Colors.white |
|
: Color(0xFF32A060), |
|
fontWeight: MyFontWeight.regular, |
|
fontSize: 16.sp, |
|
), |
|
), |
|
), |
|
); |
|
}, |
|
), |
|
), |
|
SizedBox( |
|
height: 10, |
|
), |
|
RoundButton( |
|
text: "确定", |
|
width: 130.w, |
|
height: 34.h, |
|
textColor: Colors.white, |
|
fontSize: 16.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
backgroup: Color(0xFF32A060), |
|
radius: 4.w, |
|
callback: () { |
|
// widget.callback(peopleNum); |
|
// SmartDialog.dismiss(); |
|
Navigator.of(context).pop(peopleNum); |
|
}, |
|
), |
|
], |
|
), |
|
), |
|
], |
|
), |
|
], |
|
); |
|
} |
|
}
|
|
|