Commit 47f54a42bb94a1654c3a523d08dbcc1c5b94f451

Authored by wdn127929
1 parent e18fde02

添加桌位布局和其他UI

... ... @@ -31,17 +31,22 @@ class AreaItemTableState extends State<AreaItemTable> {
}
},
child: Stack(
overflow: Overflow.visible,
alignment: Alignment.topLeft,
children: <Widget>[
Container(
// width: ScreenUtil().setWidth(189),
height: ScreenUtil().setWidth(50),
margin: EdgeInsets.only(right: ScreenUtil().setWidth(40)),
padding:
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(40)),
width: ScreenUtil().setWidth(104 * 2),
height: ScreenUtil().setWidth(80),
margin: EdgeInsets.only(
right: ScreenUtil().setWidth(20),
top: ScreenUtil().setWidth(20),
),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(10)),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(30)),
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
color: isSelected
? MyColours.color_199095
: MyColours.color_ffffff,
... ... @@ -54,38 +59,38 @@ class AreaItemTableState extends State<AreaItemTable> {
color: isSelected
? MyColours.color_ffffff
: MyColours.color_199095,
fontSize: ScreenUtil().setSp(32),
fontSize: ScreenUtil().setSp(28),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal),
),
),
Positioned(
left: 0,
top: 0,
child: Container(
width: ScreenUtil().setWidth(73),
height: ScreenUtil().setHeight(37),
alignment: Alignment.center,
decoration: BoxDecoration(
color: area.count <= 0
? MyColours.color_999999
: MyColours.color_63a6d1,
borderRadius: BorderRadius.only(
topRight: Radius.circular(ScreenUtil().setWidth(8)),
bottomRight: Radius.circular(ScreenUtil().setWidth(8)))),
child: Text(
area.count == 0
? "满座"
: area.count == -1
? '无'
: "余${area.count}",
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(26),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal)),
),
),
area.count == -1
? Container()
: Positioned(
left: 0,
top: 0,
child: Container(
width: ScreenUtil().setWidth(78),
height: ScreenUtil().setWidth(30),
alignment: Alignment.center,
decoration: BoxDecoration(
color: area.count <= 0
? MyColours.color_999999
: MyColours.color_63a6d1,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(ScreenUtil().setWidth(10)),
topRight:
Radius.circular(ScreenUtil().setWidth(15)),
bottomRight:
Radius.circular(ScreenUtil().setWidth(15)))),
child: Text(area.count == 0 ? "满座" : "余${area.count}",
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(26),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal)),
),
),
],
),
);
... ...
... ... @@ -75,143 +75,206 @@ class TableManagerPageState extends State<TableManagerPage> {
scrollDirection: Axis.vertical,
);
void scrollTo(int index) => itemScrollController.scrollTo(
index: index,
duration: scrollDuration,
curve: Curves.easeInOutCubic,
alignment: 0);
void scrollTo(int index) => itemScrollController
.scrollTo(
index: index,
duration: scrollDuration,
curve: Curves.easeInOutCubic,
alignment: 0)
.then((value) {
// print(_selectIndex);
// this.setState(() {});
});
void jumpTo(int index) =>
itemScrollController.jumpTo(index: index, alignment: 0);
/// Generate item number [i].
Widget item(int i) {
int heightSum;
int length =
tableManagerModel.areaTableMap[tableManagerModel.areas[i].name].length;
if (length % 4 == 0) {
heightSum = (length / 4).floor();
} else {
heightSum = (length / 4).floor() + 1;
}
return Container(
height: ScreenUtil().setWidth(185) * heightSum +
heightSum * 10 +
ScreenUtil().setWidth(60 * 2),
return SingleChildScrollView(
child: Column(
children: [
Container(
alignment: Alignment.center,
height: ScreenUtil().setWidth(30 * 2),
child: Text(tableManagerModel.areas[i].name,
style: TextStyle(
fontSize: ScreenUtil().setWidth(30),
color: MyColours.color_666666)),
),
Container(
constraints: BoxConstraints(
minHeight: ScreenUtil().setWidth(185) * heightSum),
height: ScreenUtil().setWidth(200) * heightSum + heightSum * 10,
child: GridView.builder(
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
childAspectRatio: 8 / 9,
),
itemBuilder: (context, index) {
return Selector<TableManagerModel, t.Table>(
shouldRebuild: (pre, next) => true,
selector: (context, model) => model.currentTables[index],
builder: (context, table, _) {
return TableItem(table, onSelected: (table) {
if ((table as t.Table).selected) {
tableManagerModel.selectTables.add(table);
} else {
tableManagerModel.selectTables
.removeWhere((t) => t.id == table.id);
}
DialogUtil.showTableManagerDialog(context, table)
.then((value) {
if (value != null) {
switch (value) {
case 1: //查看详情
NavigatorUtil.goNotebookDetailPage(context,
tableManagerModel.tableMap[table.id].id);
break;
case 2: //订座
NavigatorUtil.goNoteBookChangePage(
context,
NotebookDetail.fromTableManager(
tableManagerModel.getCurrDdateStr(),
tableManagerModel.currTimeIndex
.toString(),
table),
"");
break;
case 3: //停用,启用桌位
Map<String, String> params = {
"id": (table as t.Table).id,
"status": (table as t.Table).enable == "1"
? "0"
: "1"
};
tableManagerModel
.setSwitchStatus(context, params)
.then((value) {
if (value != null) {
(table as t.Table).enable = ((int.parse(
(table as t.Table)
.enable) +
1) %
2)
.toString();
if ((table as t.Table).enable == "1") {
for (Area area
in tableManagerModel.areas) {
if (area.name ==
tableManagerModel.currentArea) {
if (table.sign != '5' &&
table.sign != '1') {
//已预订
area.count++;
}
break;
}
}
} else {
for (Area area
in tableManagerModel.areas) {
if (area.name ==
tableManagerModel.currentArea) {
if (table.sign != '5' &&
table.sign != '1') {
//已预订
area.count--;
}
break;
}
}
children: [
VEmptyView(40),
Container(
alignment: Alignment.center,
height: ScreenUtil().setWidth(21 * 2),
child: Text(tableManagerModel.areas[i].name,
style: TextStyle(
fontSize: ScreenUtil().setWidth(30),
color: MyColours.color_199095)),
),
VEmptyView(30),
GridView.builder(
// controller: _areaController,
physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.only(top: 0),
shrinkWrap: true,
itemCount: tableManagerModel
.areaTableMap[tableManagerModel.areas[i].name].length +
1,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
childAspectRatio: 8 / 9,
),
// mainAxisSpacing: ScreenUtil().setWidth(15 * 2),
// crossAxisSpacing: ScreenUtil().setWidth(38 * 2)),
itemBuilder: (BuildContext context, int index) {
if (index ==
tableManagerModel
.areaTableMap[tableManagerModel.areas[i].name].length ||
tableManagerModel
.areaTableMap[tableManagerModel.areas[i].name].length ==
0) {
return InkWell(
onTap: () async {
List<String> areas = [];
for (int i = 0; i < tableManagerModel.areas.length; i++) {
areas.add(tableManagerModel.areas[i].name);
}
//添加桌位弹框
await DialogUtil.openCreateTableDialog(
context, areas, i, ['1', '2', '3'],
onTap: (value) async {
print(value);
//添加桌位 接口参数带整合???
// 以下是旧的不去,明天添加桌位接口
bool success =
await tableManagerModel.addTableAreas(context, value);
print(success);
if (success) {
Utils.showToast('添加成功!');
TableOuter tableOuter = TableOuter();
tableOuter.name = value;
tableOuter.list = [];
tableManagerModel.tableOuterList.add(tableOuter);
tableManagerModel.initData();
Timer(
Duration(milliseconds: 500),
() => _areaController.jumpTo(
_areaController.position.maxScrollExtent));
// await tableManagerModel
// .getTableList(context);
// await tableManagerModel
// .initData();
}
});
},
child: Container(
margin: EdgeInsets.all(ScreenUtil().setWidth(9)),
child: DottedBorder(
dashPattern: [5, 5, 5, 5],
borderType: BorderType.RRect,
radius: Radius.circular(ScreenUtil().setWidth(10)),
// padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
color: MyColours.color_199095,
strokeWidth: ScreenUtil().setWidth(2),
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(10))),
child: Container(
height: ScreenUtil().setWidth(90 * 2),
width: ScreenUtil().setWidth(80 * 2),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(Utils.getImgPath('add_area'),
width: ScreenUtil().setWidth(32)),
],
),
),
),
)));
} else {
return Selector<TableManagerModel, t.Table>(
shouldRebuild: (pre, next) => true,
selector: (context, model) => tableManagerModel
.areaTableMap[tableManagerModel.areas[i].name][index],
builder: (context, table, _) {
return TableItem(table, onSelected: (table) {
if ((table as t.Table).selected) {
tableManagerModel.selectTables.add(table);
} else {
tableManagerModel.selectTables
.removeWhere((t) => t.id == table.id);
}
DialogUtil.showTableManagerDialog(context, table)
.then((value) {
if (value != null) {
switch (value) {
case 1: //查看详情
NavigatorUtil.goNotebookDetailPage(context,
tableManagerModel.tableMap[table.id].id);
break;
case 2: //订座
NavigatorUtil.goNoteBookChangePage(
context,
NotebookDetail.fromTableManager(
tableManagerModel.getCurrDdateStr(),
tableManagerModel.currTimeIndex.toString(),
table),
"");
break;
case 3: //停用,启用桌位
Map<String, String> params = {
"id": (table as t.Table).id,
"status":
(table as t.Table).enable == "1" ? "0" : "1"
};
tableManagerModel
.setSwitchStatus(context, params)
.then((value) {
if (value != null) {
(table as t.Table).enable =
((int.parse((table as t.Table).enable) +
1) %
2)
.toString();
if ((table as t.Table).enable == "1") {
for (Area area in tableManagerModel.areas) {
if (area.name ==
tableManagerModel.currentArea) {
if (table.sign != '5' &&
table.sign != '1') {
//已预订
area.count++;
}
break;
}
}
} else {
for (Area area in tableManagerModel.areas) {
if (area.name ==
tableManagerModel.currentArea) {
if (table.sign != '5' &&
table.sign != '1') {
//已预订
area.count--;
}
tableManagerModel.notifyListeners();
break;
}
});
break;
}
}
tableManagerModel.notifyListeners();
}
}
});
},
canSelected: false,
fromPage: 'table_manage',
tableMap: tableManagerModel.tableMap,
rid: "");
},
);
});
break;
}
}
});
},
itemCount: tableManagerModel
.areaTableMap[tableManagerModel.areas[i].name].length,
)),
],
));
canSelected: false,
fromPage: 'table_manage',
tableMap: tableManagerModel.tableMap,
rid: "");
},
);
}
},
),
],
));
}
@override
... ... @@ -360,7 +423,7 @@ class TableManagerPageState extends State<TableManagerPage> {
return Container(
color: MyColours.color_ffffff,
child: Column(children: <Widget>[
VEmptyView(20),
// VEmptyView(20),
ValueListenableBuilder<Iterable<ItemPosition>>(
valueListenable:
itemPositionsListener.itemPositions,
... ... @@ -376,6 +439,7 @@ class TableManagerPageState extends State<TableManagerPage> {
// ? position
// : max)
// .index;
min = positions
.where((ItemPosition position) =>
position.itemTrailingEdge > 0)
... ... @@ -399,13 +463,20 @@ class TableManagerPageState extends State<TableManagerPage> {
}
tableManagerModel.currentArea =
tableManagerModel.areas[_selectIndex].name;
_areaController.animateTo(
_selectIndex *
ScreenUtil().setWidth(104 * 2),
duration: new Duration(milliseconds: 500),
curve: Curves.ease);
}
return Container(
height: ScreenUtil().setWidth(50),
height: ScreenUtil().setWidth(80),
color: MyColours.color_ffffff,
margin: EdgeInsets.only(
bottom: ScreenUtil().setWidth(20)),
child: ListView.builder(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
controller: _areaController,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
... ... @@ -448,37 +519,44 @@ class TableManagerPageState extends State<TableManagerPage> {
}
});
},
child: DottedBorder(
dashPattern: [5, 5, 5, 5],
borderType: BorderType.RRect,
radius: Radius.circular(
ScreenUtil().setWidth(30)),
// padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
color: MyColours.color_199095,
strokeWidth:
ScreenUtil().setWidth(2),
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil()
.setWidth(30))),
child: Container(
height: ScreenUtil()
.setWidth(50 * 2),
width: ScreenUtil()
.setWidth(60 * 2),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Image.asset(
Utils.getImgPath(
'add_store'),
width: ScreenUtil()
.setWidth(22)),
],
child: Column(
children: [
VEmptyView(20),
DottedBorder(
dashPattern: [5, 5, 5, 5],
borderType: BorderType.RRect,
radius: Radius.circular(
ScreenUtil().setWidth(10)),
// padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
color: MyColours.color_199095,
strokeWidth:
ScreenUtil().setWidth(2),
child: ClipRRect(
borderRadius: BorderRadius
.all(Radius.circular(
ScreenUtil()
.setWidth(10))),
child: Container(
height: ScreenUtil()
.setWidth(25 * 2),
width: ScreenUtil()
.setWidth(104 * 2),
child: Column(
mainAxisAlignment:
MainAxisAlignment
.center,
children: [
Image.asset(
Utils.getImgPath(
'add_area'),
width: ScreenUtil()
.setWidth(24)),
],
),
),
),
),
),
)
],
));
} else {
return Selector<TableManagerModel, Area>(
... ... @@ -489,6 +567,7 @@ class TableManagerPageState extends State<TableManagerPage> {
tableManagerModel.currentArea,
(area) {
isTap = true;
_selectIndex = index;
scrollTo(index);
// setState(() {
tableManagerModel.currentArea =
... ... @@ -498,7 +577,16 @@ class TableManagerPageState extends State<TableManagerPage> {
tableManagerModel.areaTableMap[
tableManagerModel
.currentArea];
_selectIndex = index;
// if (position.value.first.itemLeadingEdge ==
// itemPositionsListener
// .itemPositions.value.first.itemLeadingEdge) {
// setState(() {
// _selectIndex = index;
// });
// }
// setState(() {});
// });
// setState(() {
// tableManagerModel.currentArea =
... ... @@ -513,162 +601,19 @@ class TableManagerPageState extends State<TableManagerPage> {
);
}
},
// itemExtent: ScreenUtil().setHeight(207),
itemExtent: ScreenUtil().setWidth(104 * 2),
itemCount: tableManagerModel.areas.length + 1,
),
);
}),
Expanded(
child: Container(
color: MyColours.color_ffffff,
color: MyColours.color_f5f5f5,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
horizontal: ScreenUtil().setWidth(24)),
width: double.infinity,
child: list(tableManagerModel.areas)),
),
// Expanded(
// child: Container(
// color: MyColours.color_e5e5e5,
// padding: EdgeInsets.symmetric(
// vertical: ScreenUtil().setHeight(10),
// horizontal: ScreenUtil().setWidth(9)),
// child: Column(
// children: [
// Expanded(
// child: GridView.builder(
// gridDelegate:
// SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: 3,
// childAspectRatio: 8 / 9),
// itemBuilder: (context, index) {
// return Selector<TableManagerModel,
// t.Table>(
// shouldRebuild: (pre, next) => true,
// selector: (context, model) =>
// model.currentTables[index],
// builder: (context, table, _) {
// return TableItem(table,
// onSelected: (table) {
// if ((table as t.Table).selected) {
// tableManagerModel.selectTables
// .add(table);
// } else {
// tableManagerModel.selectTables
// .removeWhere((t) =>
// t.id == table.id);
// }
// DialogUtil.showTableManagerDialog(
// context, table)
// .then((value) {
// if (value != null) {
// switch (value) {
// case 1: //查看详情
// NavigatorUtil
// .goNotebookDetailPage(
// context,
// tableManagerModel
// .tableMap[
// table.id]
// .id);
// break;
// case 2: //订座
// NavigatorUtil.goNoteBookChangePage(
// context,
// NotebookDetail.fromTableManager(
// tableManagerModel
// .getCurrDdateStr(),
// tableManagerModel
// .currTimeIndex
// .toString(),
// table),
// "");
// break;
// case 3: //停用,启用桌位
// Map<String, String>
// params = {
// "id": (table as t.Table)
// .id,
// "status": (table as t
// .Table)
// .enable ==
// "1"
// ? "0"
// : "1"
// };
// tableManagerModel
// .setSwitchStatus(
// context, params)
// .then((value) {
// if (value != null) {
// (table as t.Table)
// .enable =
// ((int.parse((table as t.Table)
// .enable) +
// 1) %
// 2)
// .toString();
// if ((table as t.Table)
// .enable ==
// "1") {
// for (Area area
// in tableManagerModel
// .areas) {
// if (area.name ==
// tableManagerModel
// .currentArea) {
// if (table.sign !=
// '5' &&
// table.sign !=
// '1') {
// //已预订
// area.count++;
// }
// break;
// }
// }
// } else {
// for (Area area
// in tableManagerModel
// .areas) {
// if (area.name ==
// tableManagerModel
// .currentArea) {
// if (table.sign !=
// '5' &&
// table.sign !=
// '1') {
// //已预订
// area.count--;
// }
// break;
// }
// }
// }
// tableManagerModel
// .notifyListeners();
// }
// });
// break;
// }
// }
// });
// },
// canSelected: false,
// fromPage: 'table_manage',
// tableMap:
// tableManagerModel.tableMap,
// rid: "");
// },
// );
// },
// itemCount: tableManagerModel
// .currentTables.length,
// )),
// ],
// )),
// )
// ],
]),
);
}
... ...
... ... @@ -122,7 +122,8 @@ class TableManagerModel with ChangeNotifier {
if (temp.length > 0) {
getReserveList(context);
} else {
pageState = PageState.Empty;
// pageState = PageState.Empty;
pageState = PageState.Success;
notifyListeners();
}
}
... ... @@ -261,7 +262,7 @@ class TableManagerModel with ChangeNotifier {
notifyListeners();
}
if ((baseResp.data[0] as List).isEmpty) {
pageState = PageState.Empty;
pageState = PageState.Success;
notifyListeners();
return [];
}
... ... @@ -420,7 +421,7 @@ class TableManagerModel with ChangeNotifier {
areaTableMap["${outer.name}"] = outer.list;
Area area = Area();
area.name = outer.name;
area.count = outer.list.length == 0 ? -1 : count;
area.count = outer.list.length == 0 ? -1 : count;
areas.add(area);
}
if (areaTableMap.isNotEmpty) {
... ... @@ -428,7 +429,8 @@ class TableManagerModel with ChangeNotifier {
currentTables = areaTableMap[currentArea];
pageState = PageState.Success;
} else {
pageState = PageState.Empty;
// pageState = PageState.Empty;
pageState = PageState.Success;
}
notifyListeners();
... ...
import 'dart:convert';
import 'dart:ui';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
... ... @@ -6,8 +7,10 @@ import 'package:flutter_picker/flutter_picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/models/remark.dart';
import 'package:one_key/pages/home_enter_order/home_enter_order.dart';
import 'package:one_key/pages/message/message_dialog_item.dart';
import 'package:one_key/provider/message_dialog_model.dart';
import 'package:one_key/provider/table_manager_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/misc.dart';
import 'package:one_key/route/navigator_util.dart';
... ... @@ -36,112 +39,128 @@ class DialogUtil {
return Center(
child: Container(
padding:
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(72)),
height: ScreenUtil().setWidth(380),
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(50)),
height: ScreenUtil().setWidth(207 * 2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(30))),
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(30)))), //设置圆角
child: Column(
Radius.circular(ScreenUtil().setWidth(10)))), //设置圆角
child: Stack(
children: [
VEmptyView(40),
Container(
// height: ScreenUtil().setWidth(48),
alignment: Alignment.center,
child: Text('新建区域',
style: TextStyle(
fontSize: ScreenUtil().setSp(36),
color: MyColours.color_199095)),
),
Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
padding: EdgeInsets.all(ScreenUtil().setWidth(40)),
child: Column(
children: [
Text(
'区域名称',
style: TextStyle(
fontSize: ScreenUtil().setSp(30),
color: MyColours.color_199095),
Container(
// height: ScreenUtil().setWidth(48),
alignment: Alignment.center,
child: Text('新建区域',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_333333)),
),
HEmptyView(10),
Expanded(
child: TextField(
controller: controller,
maxLines: 1,
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
//输入文本的样式
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
),
decoration: InputDecoration(
contentPadding: EdgeInsets.only(
top: 15, bottom: -15), //设置文字内容与边框距离
enabledBorder: UnderlineInputBorder(
borderSide:
BorderSide(color: MyColours.color_d8d8d8),
),
focusedBorder: UnderlineInputBorder(
borderSide:
BorderSide(color: MyColours.color_d8d8d8),
VEmptyView(60),
Container(
height: ScreenUtil().setWidth(28 * 2),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'*',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_E95750),
),
hintText: '点击输入区域名称',
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(26),
Text(
'区域名称',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_333333),
),
),
onChanged: (value) {},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.text,
HEmptyView(40),
Expanded(
child: TextField(
controller: controller,
maxLines: 1,
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
//输入文本的样式
style: TextStyle(
fontSize: ScreenUtil().setSp(30),
color: MyColours.color_333333),
decoration: InputDecoration(
contentPadding: EdgeInsets.only(
bottom: ScreenUtil()
.setWidth(40)), //设置文字内容与边框距离
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: MyColours.color_efefef),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: MyColours.color_efefef,
width: ScreenUtil().setWidth(2)),
),
hintText: '请输入区域名称',
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(30),
),
),
onChanged: (value) {},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.text,
),
)
],
),
)
),
VEmptyView(80),
RoundButton(
text: '保存',
width: ScreenUtil().setWidth(300),
height: ScreenUtil().setWidth(80),
radius: ScreenUtil().setWidth(10),
fontSize: 34,
onPressed: () {
if (controller.text.trim() == '') {
Utils.showToast('请输入区域名称!');
return;
}
onTap(controller.text);
Navigator.pop(context, controller.text);
})
],
),
),
VEmptyView(60),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
RoundButton(
text: '取消',
width: ScreenUtil().setWidth(120),
height: ScreenUtil().setWidth(84),
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
textColor: MyColours.color_199095,
borderColor: MyColours.color_199095,
isBold: false,
radius: ScreenUtil().setWidth(20),
onPressed: () {
Positioned(
top: 0,
right: 0,
child: InkWell(
onTap: () {
Navigator.pop(context);
},
),
HEmptyView(40),
RoundButton(
text: '保存',
width: ScreenUtil().setWidth(120),
height: ScreenUtil().setWidth(84),
isBold: false,
radius: ScreenUtil().setWidth(20),
onPressed: () {
if (controller.text.trim() == '') {
Utils.showToast('请输入区域名称!');
return;
}
onTap(controller.text);
Navigator.pop(context, controller.text);
})
],
child: Container(
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(30),
right: ScreenUtil().setWidth(40),
left: ScreenUtil().setWidth(40),
bottom: ScreenUtil().setWidth(40),
),
child: Image.asset(
Utils.getImgPath('close'),
width: ScreenUtil().setWidth(28),
height: ScreenUtil().setWidth(28),
),
)),
)
],
),
... ... @@ -152,6 +171,417 @@ class DialogUtil {
);
}
static btnChoose(String title, double width, ClickCallback callback) {
return InkWell(
onTap: () {
callback(title);
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(10)),
height: ScreenUtil().setWidth(60),
width: width,
decoration: BoxDecoration(
border: Border.all(
width: ScreenUtil().setWidth(2),
color: MyColours.color_199095),
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Row(
children: [
Expanded(
child: Text(
title,
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setWidth(28)),
)),
HEmptyView(10),
Image.asset(
Utils.getImgPath('enter_order_arrow'),
width: ScreenUtil().setWidth(20),
height: ScreenUtil().setWidth(10),
)
],
)));
}
static selectWidget(List<String> data, CustomCallBack onTap) {
return Container(
decoration: BoxDecoration(
color: MyColours.color_ffffff,
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
border: Border.all(
color: MyColours.color_cccccc,
width: ScreenUtil().setWidth(2))),
width: ScreenUtil().setWidth(120 * 2),
constraints: BoxConstraints(
maxHeight: ScreenUtil().setWidth(140 * 2),
),
child: ListView.builder(
padding:
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(20)),
itemCount: data.length,
itemBuilder: (context, index) {
return InkWell(
onTap: () {
onTap(index);
},
child: Container(
padding: EdgeInsets.all(ScreenUtil().setWidth(20)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: MyColours.color_efefef,
width: ScreenUtil().setWidth(2)))),
child: Text(data[index],
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(28))),
),
);
}));
}
static Future openCreateTableDialog(BuildContext context, List<String> areas,
int currentAreaIndex, List<String> pnum,
{CustomCallBack onTap}) async {
TextEditingController controller = TextEditingController();
FocusNode focusNode = FocusNode();
bool showArea = true;
bool showPnumMin = true;
bool showPnumMax = true;
String pnumMin = '';
String pnumMax = '';
StateSetter globalState;
// //输入框焦点
// focusNode.addListener(() {
// if (!focusNode.hasFocus) {
// // print('失去焦点');
// } else {
// // print('得到焦点');
// globalState(() {
// showPnumMin = true;
// showPnumMax = true;
// showArea = true;
// });
// }
// });
final action = await showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return StatefulBuilder(builder: (context, state) {
globalState = state;
return Center(
child: Container(
padding:
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(50)),
height: ScreenUtil().setWidth(326 * 2),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(10)))), //设置圆角
child: Stack(
overflow: Overflow.visible,
children: [
Container(
padding: EdgeInsets.all(ScreenUtil().setWidth(40)),
child: Column(
children: [
Container(
// height: ScreenUtil().setWidth(48),
alignment: Alignment.center,
child: Text('新建桌位',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_333333)),
),
VEmptyView(60),
Container(
height: ScreenUtil().setWidth(30 * 2),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'*',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_E95750),
),
Text(
'选择区域',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_333333),
),
HEmptyView(40),
// Stack(
// overflow: Overflow.visible,
// children: [
btnChoose(areas[currentAreaIndex],
ScreenUtil().setWidth(120 * 2), (value) {
state(() {
showPnumMin = true;
showPnumMax = true;
showArea = !showArea;
});
}),
],
),
),
VEmptyView(60),
Container(
height: ScreenUtil().setWidth(28 * 2),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'*',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_E95750),
),
Text(
'桌位名称',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_333333),
),
HEmptyView(40),
Expanded(
child: TextField(
controller: controller,
maxLines: 1,
focusNode: focusNode,
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
//输入文本的样式
style: TextStyle(
fontSize: ScreenUtil().setSp(30),
color: MyColours.color_333333),
decoration: InputDecoration(
contentPadding: EdgeInsets.only(
bottom: ScreenUtil()
.setWidth(40)), //设置文字内容与边框距离
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: MyColours.color_efefef),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: MyColours.color_efefef,
width: ScreenUtil().setWidth(2)),
),
hintText: '请输入桌位名称',
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(30),
),
),
onChanged: (value) {},
onEditingComplete: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.text,
),
)
],
),
),
VEmptyView(60),
Container(
height: ScreenUtil().setWidth(30 * 2),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'*',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_E95750),
),
Text(
'人数(选填)',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_333333),
),
HEmptyView(40),
// Stack(
// overflow: Overflow.visible,
// children: [
btnChoose(
pnumMin, ScreenUtil().setWidth(52 * 2),
(value) {
state(() {
showArea = true;
showPnumMax = true;
showPnumMin = !showPnumMin;
});
}),
HEmptyView(20),
Text(
'至',
style: TextStyle(
fontSize: ScreenUtil().setSp(30),
color: MyColours.color_199095),
),
HEmptyView(20),
btnChoose(
pnumMax, ScreenUtil().setWidth(52 * 2),
(value) {
state(() {
showArea = true;
showPnumMin = true;
showPnumMax = !showPnumMax;
});
}),
],
),
),
VEmptyView(80),
RoundButton(
text: '保存',
width: ScreenUtil().setWidth(300),
height: ScreenUtil().setWidth(80),
radius: ScreenUtil().setWidth(10),
fontSize: 34,
onPressed: () {
if (controller.text.trim() == '') {
Utils.showToast('请输入桌位名称!');
return;
}
// 当前选中区域
// areas[currentAreaIndex]
//最低人数
// pnumMin
//最高人数
// pnumMax
onTap(controller.text);
Navigator.pop(context, controller.text);
})
],
),
),
Positioned(
left: ScreenUtil().setWidth(113 * 2),
top: ScreenUtil().setWidth(105 * 2),
child: Offstage(
offstage: showArea,
child: selectWidget(areas, (index) {
state(() {
showArea = !showArea;
currentAreaIndex = index;
});
}),
// child: Container(
// decoration: BoxDecoration(
// color: MyColours.color_ffffff,
// borderRadius: BorderRadius.circular(
// ScreenUtil().setWidth(10)),
// border: Border.all(
// color: MyColours.color_cccccc,
// width: ScreenUtil().setWidth(2))),
// width: ScreenUtil().setWidth(120 * 2),
// height: ScreenUtil().setWidth(140 * 2),
// child: ListView.builder(
// padding: EdgeInsets.symmetric(
// horizontal:
// ScreenUtil().setWidth(20)),
// itemCount: areas.length,
// itemBuilder: (context, index) {
// return InkWell(
// onTap: () {
// state(() {
// showArea = !showArea;
// currentAreaIndex = index;
// });
// },
// child: Container(
// padding: EdgeInsets.all(
// ScreenUtil().setWidth(20)),
// decoration: BoxDecoration(
// border: Border(
// bottom: BorderSide(
// color: MyColours
// .color_efefef,
// width: ScreenUtil()
// .setWidth(2)))),
// child: Text(areas[index],
// style: TextStyle(
// color:
// MyColours.color_199095,
// fontSize: ScreenUtil()
// .setSp(28))),
// ),
// );
// }))
)),
Positioned(
left: ScreenUtil().setWidth(136 * 2),
top: ScreenUtil().setWidth(221 * 2),
child: Offstage(
offstage: showPnumMin,
child: selectWidget(pnum, (index) {
state(() {
showPnumMin = !showPnumMin;
pnumMin = pnum[index];
});
}),
)),
Positioned(
left: ScreenUtil().setWidth(223 * 2),
top: ScreenUtil().setWidth(221 * 2),
child: Offstage(
offstage: showPnumMax,
child: selectWidget(pnum, (index) {
state(() {
showPnumMax = !showPnumMax;
pnumMax = pnum[index];
});
}),
)),
Positioned(
top: 0,
right: 0,
child: InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(30),
right: ScreenUtil().setWidth(40),
left: ScreenUtil().setWidth(40),
bottom: ScreenUtil().setWidth(40),
),
child: Image.asset(
Utils.getImgPath('close'),
width: ScreenUtil().setWidth(28),
height: ScreenUtil().setWidth(28),
),
)),
)
],
),
),
),
);
});
});
}
//跳转拨打电话页面
static goPhone(String phoneNum) async {
String url = "tel:$phoneNum";
... ...