Commit ba0c3a5b7c68596867d37cc04427dfc81f5d3db1

Authored by “gaiyaguang”
1 parent 6b776015

日期显示

Showing 1 changed file with 279 additions and 186 deletions
... ... @@ -15,13 +15,12 @@ import 'package:provider/provider.dart';
import 'package:table_calendar/table_calendar.dart';
class DialogUtil {
//显示消息弹框
static showMessageDialog(BuildContext context) async {
MessageDialogModel messageModel =
Provider.of<MessageDialogModel>(context, listen: false);
Provider.of<MessageDialogModel>(context, listen: false);
if (messageModel.messages.isEmpty) return null;
messageModel.showMessageDialog=true;
messageModel.showMessageDialog = true;
await showModalBottomSheet<int>(
context: context,
isScrollControlled: true,
... ... @@ -33,12 +32,14 @@ class DialogUtil {
children: <Widget>[
Consumer<MessageDialogModel>(builder: (BuildContext context,
MessageDialogModel model, Widget child) {
if(messageModel.messages.isEmpty)return Container();
if (messageModel.messages.isEmpty) return Container();
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
margin: EdgeInsets.only(top: ScreenUtil().setWidth(21),bottom: ScreenUtil().setWidth(12)),
margin: EdgeInsets.only(
top: ScreenUtil().setWidth(21),
bottom: ScreenUtil().setWidth(12)),
width: double.infinity,
child: Stack(
alignment: Alignment.center,
... ... @@ -56,8 +57,8 @@ class DialogUtil {
Navigator.of(dialogContext).pop();
},
child: Padding(
padding:
EdgeInsets.all(ScreenUtil().setWidth(12)),
padding: EdgeInsets.all(
ScreenUtil().setWidth(12)),
child: Image.asset(
"assets/icon_close.png",
width: ScreenUtil().setWidth(28),
... ... @@ -67,70 +68,78 @@ class DialogUtil {
))
],
)),
model.messages.length>3?Container(
margin: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(22),vertical: ScreenUtil().setWidth(11)),
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(16),
ScreenUtil().setWidth(76),
ScreenUtil().setWidth(16),
ScreenUtil().setWidth(41)),
decoration: BoxDecoration(
color: MyColours.color_fefefe,
borderRadius:
BorderRadius.all(Radius.circular(ScreenUtil().setWidth(8)))),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
"在线预订",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(32)),
),
Spacer(),
Text(
"刚刚",
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(22)),
),
],
),
VEmptyView(20),
Text(
"在线预订:${model.messages.length}个",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(32)),
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Spacer(),
CommonButton(
width: 160,
height: 48,
fontSize: 32,
content: "立即处理",
state: 1,
onPress: () {
NavigatorUtil.goHomePage(context,initialIndex: 0);
},
)
],
model.messages.length > 3
? Container(
margin: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(22),
vertical: ScreenUtil().setWidth(11)),
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(16),
ScreenUtil().setWidth(76),
ScreenUtil().setWidth(16),
ScreenUtil().setWidth(41)),
decoration: BoxDecoration(
color: MyColours.color_fefefe,
borderRadius: BorderRadius.all(
Radius.circular(
ScreenUtil().setWidth(8)))),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Text(
"在线预订",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(32)),
),
Spacer(),
Text(
"刚刚",
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(22)),
),
],
),
VEmptyView(20),
Text(
"在线预订:${model.messages.length}个",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(32)),
),
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Spacer(),
CommonButton(
width: 160,
height: 48,
fontSize: 32,
content: "立即处理",
state: 1,
onPress: () {
NavigatorUtil.goHomePage(context,
initialIndex: 0);
},
)
],
)
],
),
)
],
),
):ListView.builder(
itemBuilder: (context, index) {
return MessageDialogItem(model.messages[index]);
},
itemCount: model.messages.length,
shrinkWrap: true)
: ListView.builder(
itemBuilder: (context, index) {
return MessageDialogItem(model.messages[index]);
},
itemCount: model.messages.length,
shrinkWrap: true)
],
);
})
... ... @@ -139,30 +148,42 @@ class DialogUtil {
);
return widget;
});
messageModel.showMessageDialog=false;
messageModel.showMessageDialog = false;
}
//解析返回显示的日期
static String _parseDateDay(DateTime dateTime){
DateTime now=DateTime.now();
if(Utils.isOneDay(dateTime,now)){
static String _parseDateDay(DateTime dateTime) {
DateTime now = DateTime.now();
if (Utils.isOneDay(dateTime, now)) {
return "今";
}else if(Utils.isOneDay(dateTime,now.add(Duration(days: 1)))){
} else if (Utils.isOneDay(dateTime, now.add(Duration(days: 1)))) {
return "明";
}else if(Utils.isOneDay(dateTime,now.add(Duration(days: 2)))){
} else if (Utils.isOneDay(dateTime, now.add(Duration(days: 2)))) {
return "后";
}else{
} else {
return dateTime.day.toString();
}
}
//显示日历弹框
static Future<DateTime> showCalendarDialog(BuildContext context,DateTime selectDateTime) {
static Future<DateTime> showCalendarDialog(
BuildContext context, DateTime selectDateTime) {
CalendarController _calendarController = CalendarController();
Map<DateTime, List> _events = {};
final _selectedDay = DateTime.now();
Map<DateTime, List> _events = {
_selectedDay: ['Event A7', 'Event B7', 'Event C7', 'Event D7'],
_selectedDay.add(Duration(days: 1)): [
'Event A8',
'Event B8',
'Event C8',
'Event D8'
],
_selectedDay.add(Duration(days: 2)):
Set.from(['Event A9', 'Event A9', 'Event B9']).toList(),
};
return showModalBottomSheet<DateTime>(
context: context,
isScrollControlled:true,
isScrollControlled: true,
builder: (BuildContext context) {
BuildContext dialogContext = context;
Widget widget = StatefulBuilder(builder: (context, _setState) {
... ... @@ -183,8 +204,8 @@ class DialogUtil {
locale: "zh_CN",
initialCalendarFormat: CalendarFormat.month,
headerStyle: HeaderStyle(
decoration: BoxDecoration(
color: MyColours.color_2bb5b7),
decoration:
BoxDecoration(color: MyColours.color_2bb5b7),
headerPadding: EdgeInsets.zero,
formatButtonVisible: false,
centerHeaderTitle: false,
... ... @@ -197,10 +218,10 @@ class DialogUtil {
titleTextStyle: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(30)),
leftChevronIcon:
const Icon(Icons.chevron_left, color: Colors.white),
rightChevronIcon:
const Icon(Icons.chevron_right, color: Colors.white),
leftChevronIcon: const Icon(Icons.chevron_left,
color: Colors.white),
rightChevronIcon: const Icon(Icons.chevron_right,
color: Colors.white),
),
calendarStyle: CalendarStyle(
contentPadding: const EdgeInsets.only(bottom: 4.0),
... ... @@ -218,6 +239,7 @@ class DialogUtil {
return Container(
color: MyColours.color_2bb5b7,
alignment: Alignment.center,
margin: EdgeInsets.only(bottom: 20),
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setHeight(25)),
child: Text(
... ... @@ -228,17 +250,20 @@ class DialogUtil {
),
);
},
dayBuilder: (context,date,_){
dayBuilder: (context, date, _) {
return Container(
height: 100,
decoration: BoxDecoration(
shape: BoxShape.circle,
shape: BoxShape.circle,
// color: Colors.blue,
),
alignment: Alignment.center,
margin: const EdgeInsets.all(6.0),
margin: const EdgeInsets.fromLTRB(6, 6, 6, 16),
padding: const EdgeInsets.only(
bottom: 4.0, left: 8.0, right: 8.0, top: 4.0),
child: Text(
"${_parseDateDay(date)}",
// "${_parseDateDay(date)}",
'${date.day}',
style: TextStyle().copyWith(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_353535),
... ... @@ -249,14 +274,14 @@ class DialogUtil {
return Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: MyColours.color_2bb5b7
),
color: MyColours.color_2bb5b7),
alignment: Alignment.center,
margin: const EdgeInsets.all(6.0),
margin: const EdgeInsets.fromLTRB(6, 6, 6, 16),
padding: const EdgeInsets.only(
bottom: 4.0, left: 8.0, right: 8.0, top: 4.0),
child: Text(
"${_parseDateDay(date)}",
// "${_parseDateDay(date)}",
'${date.day}',
style: TextStyle().copyWith(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_ffffff),
... ... @@ -270,29 +295,59 @@ class DialogUtil {
border: Border.all(
color: MyColours.color_2bb5b7, width: 1)),
alignment: Alignment.center,
margin: const EdgeInsets.all(6.0),
margin: const EdgeInsets.fromLTRB(6, 6, 6, 16),
padding: const EdgeInsets.only(
bottom: 4.0, left: 8.0, right: 8.0, top: 4.0),
child: Text(
'今',
// '今',
'${date.day}',
style: TextStyle().copyWith(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_2bb5b7),
),
);
},
singleMarkerBuilder: (context, dateTime, event) {
return Container(
width: ScreenUtil().setWidth(6),
height: ScreenUtil().setWidth(6),
margin: const EdgeInsets.symmetric(
horizontal: 0.3),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: MyColours.color_ff0000,
),
markersBuilder: (context, date, events, holidays) {
final children = <Widget>[];
// if (events.isNotEmpty) {
// children.add(
// Positioned(
// right: 1,
// bottom: 1,
// child: _buildEventsMarker(date, events),
// ),
// );
// }
// if (holidays.isNotEmpty) {
children.add(
Positioned(
right: ScreenUtil().setWidth(27),
bottom: 0,
top: 5,
child: buildMarker(date)),
// Align(
// alignment: Alignment.bottomCenter,
// child: buildMarker(date),
// )
);
// }
return children;
},
// singleMarkerBuilder: (context, dateTime, event) {
// return Container(
// width: ScreenUtil().setWidth(6),
// height: ScreenUtil().setWidth(6),
// margin:
// const EdgeInsets.symmetric(horizontal: 0.3),
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// color: MyColours.color_ff0000,
// ),
// );
// },
),
),
],
... ... @@ -310,17 +365,17 @@ class DialogUtil {
child: Container(
child: ClipOval(
child: Container(
width: ScreenUtil().setWidth(100),
height: ScreenUtil().setWidth(100),
alignment: Alignment.center,
color: MyColours.color_2bb5b7,
child: Text(
"今天",
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(32)),
),
)),
width: ScreenUtil().setWidth(100),
height: ScreenUtil().setWidth(100),
alignment: Alignment.center,
color: MyColours.color_2bb5b7,
child: Text(
"回到\n今天",
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(26)),
),
)),
),
),
),
... ... @@ -336,93 +391,131 @@ class DialogUtil {
});
}
static Widget buildMarker(date) {
return Container(
height: ScreenUtil().setWidth(30),
// color: Colors.red,
// decoration:
// BoxDecoration(shape: BoxShape.circle, color: MyColours.color_2bb5b7),
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.fromLTRB(6, 6, 6, 0),
padding: const EdgeInsets.only(top: 10.0),
child: Text(
"${_parseDateDay(date)}",
style: TextStyle().copyWith(
fontSize: ScreenUtil().setSp(28), color: MyColours.color_2bb5b7),
),
);
}
//显示分享弹框
static showShareDialog(BuildContext context) {
return showModalBottomSheet(context: context, builder: (context) {
Widget widget = Container(
width: double.infinity,
height: ScreenUtil().setHeight(233),
color: MyColours.color_f1f1f1,
child: Row(
children: <Widget>[
Expanded(
child: GestureDetector(
onTap: (){
Navigator.of(context).pop(1);
},
behavior: HitTestBehavior.opaque,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Image.asset(
"assets/icon_wechat.png", width: ScreenUtil().setWidth(140),
height: ScreenUtil().setWidth(140),),
Text("微信", style: TextStyle(color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(32)),)
],
return showModalBottomSheet(
context: context,
builder: (context) {
Widget widget = Container(
width: double.infinity,
height: ScreenUtil().setHeight(233),
color: MyColours.color_f1f1f1,
child: Row(
children: <Widget>[
Expanded(
child: GestureDetector(
onTap: () {
Navigator.of(context).pop(1);
},
behavior: HitTestBehavior.opaque,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Image.asset(
"assets/icon_wechat.png",
width: ScreenUtil().setWidth(140),
height: ScreenUtil().setWidth(140),
),
Text(
"微信",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(32)),
)
],
),
),
),
),
),
Expanded(
child: GestureDetector(
onTap: (){
Navigator.of(context).pop(2);
},
behavior: HitTestBehavior.opaque,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Image.asset(
"assets/icon_sms.png", width: ScreenUtil().setWidth(140),
height: ScreenUtil().setWidth(140),),
Text("短信", style: TextStyle(color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(32)),)
],
Expanded(
child: GestureDetector(
onTap: () {
Navigator.of(context).pop(2);
},
behavior: HitTestBehavior.opaque,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Image.asset(
"assets/icon_sms.png",
width: ScreenUtil().setWidth(140),
height: ScreenUtil().setWidth(140),
),
Text(
"短信",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(32)),
)
],
),
),
),
),
Expanded(
child: GestureDetector(
onTap: () {
Navigator.of(context).pop(3);
},
behavior: HitTestBehavior.opaque,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Image.asset(
"assets/icon_phone.png",
width: ScreenUtil().setWidth(140),
height: ScreenUtil().setWidth(140),
),
Text(
"电话",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(32)),
)
],
),
),
)
],
),
Expanded(
child: GestureDetector(
onTap: (){
Navigator.of(context).pop(3);
},
behavior: HitTestBehavior.opaque,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Image.asset(
"assets/icon_phone.png", width: ScreenUtil().setWidth(140),
height: ScreenUtil().setWidth(140),),
Text("电话", style: TextStyle(color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(32)),)
],
),
),
)
],
),
);
return widget;
});
);
return widget;
});
}
//显示选择客户经理弹框
static Future<List<int>> showSelectCusmanDialog(BuildContext context,List<String> data,ValueChanged valueChanged){
static Future<List<int>> showSelectCusmanDialog(
BuildContext context, List<String> data, ValueChanged valueChanged) {
return Picker(
adapter: PickerDataAdapter<String>(pickerdata: data),
hideHeader: false,
cancelText: "取消",
cancelTextStyle: TextStyle(color: MyColours.color_828282,fontSize: 20),
cancelTextStyle: TextStyle(color: MyColours.color_828282, fontSize: 20),
confirmText: "确定",
confirmTextStyle: TextStyle(color: MyColours.color_2bb5b7,fontSize: 20),
confirmTextStyle:
TextStyle(color: MyColours.color_2bb5b7, fontSize: 20),
selectedTextStyle: TextStyle(color: Colors.blue),
onConfirm: (Picker picker, List value) {
print(value.toString());
if(valueChanged!=null){
if (valueChanged != null) {
valueChanged(value);
}
}
).showModal<List<int>>(context).then((value){
}).showModal<List<int>>(context).then((value) {
LogUtil.v("value:${value.toString()}");
return value;
});
... ...