notebook_detail_change_page.dart
7.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/app_bar.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/round_button.dart';
class NoteBookChangePage extends StatefulWidget {
@override
_NoteBookChangePageState createState() => _NoteBookChangePageState();
}
class _NoteBookChangePageState extends State<NoteBookChangePage> {
String dateText = ""; //当前显示日期时间
int currTimeIndex = 1; //当前选中时间段
String morning; //早市时间段
String noon; //午市时间段
String night; //晚市时间段
DateTime dateTime; //当前日期
//生成日期文本
_createDateText(DateTime day) {
if (Utils.isOneDay(day, dateTime)) return; //日期没变
setState(() {
DateTime dateNow = DateTime.now();
if (Utils.isOneDay(day, dateNow)) {
dateText = Utils.addZeroNumber(dateNow.month) +
"-" +
Utils.addZeroNumber(dateNow.day) +
" 今天";
} else {
dateText =
Utils.addZeroNumber(day.month) + "-" + Utils.addZeroNumber(day.day);
}
dateTime = day;
});
// _getReserveList();
// _reserveCountDay();
}
//初始化时间
_initTime() {
dateTime = DateTime.now();
dateText = Utils.addZeroNumber(dateTime.month) +
"-" +
Utils.addZeroNumber(dateTime.day);
// morning =
// userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning;
// noon = userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon;
// night = userModel.user.night.isEmpty ? "00:00-00:00" : userModel.user.night;
// if (dateTime.isBefore(DateTime.parse(dateTime.year.toString() +
// "-" +
// Utils.addZeroNumber(dateTime.month) +
// "-" +
// Utils.addZeroNumber(dateTime.day) +
// " " +
// morning.split("-")[1] +
// ":00"))) {
// //未过早市
// currTimeIndex = 1;
// } else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() +
// "-" +
// Utils.addZeroNumber(dateTime.month) +
// "-" +
// Utils.addZeroNumber(dateTime.day) +
// " " +
// morning.split("-")[1] +
// ":00")) &&
// dateTime.isBefore(DateTime.parse(dateTime.year.toString() +
// "-" +
// Utils.addZeroNumber(dateTime.month) +
// "-" +
// Utils.addZeroNumber(dateTime.day) +
// " " +
// noon.split("-")[1] +
// ":00"))) {
// //过了早市,未过午市
// currTimeIndex = 2;
// } else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() +
// "-" +
// Utils.addZeroNumber(dateTime.month) +
// "-" +
// Utils.addZeroNumber(dateTime.day) +
// " " +
// noon.split("-")[1] +
// ":00")) &&
// dateTime.isBefore(DateTime.parse(dateTime.year.toString() +
// "-" +
// Utils.addZeroNumber(dateTime.month) +
// "-" +
// Utils.addZeroNumber(dateTime.day) +
// " " +
// night.split("-")[1] +
// ":00"))) {
// //过了午市,未过晚市
// currTimeIndex = 3;
// } else {
// //过了晚市
// currTimeIndex = 3;
// }
}
@override
void initState() {
super.initState();
_initTime();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Column(children: <Widget>[
SizedBox(height: ScreenUtil.statusBarHeight),
MyAppBar(
"在线预订详情",
showBack: true,
),
//第一行
Container(
padding: EdgeInsets.all(ScreenUtil().setWidth(40)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CustomButton(
dateText: dateText,
dayText: ' 今天',
isSelect: true,
),
CustomButton(
dateText: dateText,
dayText: ' 明天',
isSelect: false,
),
CustomButton(
dateText: '其他',
fontSize: 30,
dayText: '',
isImage: true,
isSelect: false,
)
],
),
),
//第二行
Container(
padding: EdgeInsets.all(ScreenUtil().setWidth(40)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CustomButton(
dateText: '早市',
dayText: '',
isSelect: true,
),
CustomButton(
dateText: '午市',
dayText: '',
isSelect: false,
),
CustomButton(
dateText: '晚市',
dayText: '',
isSelect: false,
)
],
),
),
]),
),
);
}
}
class CustomButton extends StatefulWidget {
final String dateText;
final String dayText;
final bool isSelect;
final double fontSize;
final bool isImage;
const CustomButton(
{Key key,
this.dateText,
this.dayText,
this.isSelect,
this.fontSize = 34,
this.isImage = false})
: super(key: key);
@override
_ButtonState createState() => _ButtonState();
}
class _ButtonState extends State<CustomButton> {
@override
Widget build(BuildContext context) {
return Container(
width: ScreenUtil().setWidth(105 * 2),
height: ScreenUtil().setWidth(25 * 2),
decoration: BoxDecoration(
color: widget.isSelect ? MyColours.color_199095 : Colors.white,
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
border: Border.all(
color: MyColours.color_199095, width: ScreenUtil().setWidth(2))),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(widget.dateText,
style: TextStyle(
fontWeight: FontWeight.bold,
color: widget.isSelect
? MyColours.color_fefefe
: MyColours.color_199095,
fontSize: ScreenUtil().setSp(widget.fontSize))),
widget.isImage ? HEmptyView(20) : Container(),
widget.isImage
? Image.asset(
widget.isSelect
? 'assets/message_selected.png'
: 'assets/message_default.png',
width: ScreenUtil().setWidth(36))
: Text(widget.dayText,
style: TextStyle(
fontWeight: FontWeight.bold,
color: widget.isSelect
? MyColours.color_fefefe
: MyColours.color_199095,
fontSize: ScreenUtil().setSp(30)))
],
),
);
}
}