Commit 4fd0bd2c923e2eaee5da6e4b6ec2cc5ecd1fbec4

Authored by wdn127929
1 parent 8495b7e6

日历、农历节日

Showing 1 changed file with 243 additions and 211 deletions
@@ -1115,226 +1115,258 @@ class DialogUtil { @@ -1115,226 +1115,258 @@ class DialogUtil {
1115 builder: (BuildContext context) { 1115 builder: (BuildContext context) {
1116 BuildContext dialogContext = context; 1116 BuildContext dialogContext = context;
1117 Widget widget = StatefulBuilder(builder: (context, _setState) { 1117 Widget widget = StatefulBuilder(builder: (context, _setState) {
1118 - return Stack(  
1119 - children: <Widget>[  
1120 - Container(  
1121 - color: MyColours.color_ffffff,  
1122 - child: Column(  
1123 - children: <Widget>[  
1124 - TableCalendar(  
1125 - calendarController: _calendarController,  
1126 - initialSelectedDay: selectDateTime,  
1127 - onDaySelected: (day, events, holidays) {  
1128 - Navigator.of(dialogContext).pop(day); 1118 + return Container(
  1119 + color: MyColours.color_ffffff,
  1120 + child: Column(
  1121 + children: <Widget>[
  1122 + TableCalendar(
  1123 + calendarController: _calendarController,
  1124 + initialSelectedDay: selectDateTime,
  1125 + onDaySelected: (day, events, holidays) {
  1126 + Navigator.of(dialogContext).pop(day);
  1127 + },
  1128 + // holidays: _holidays,
  1129 + availableGestures: AvailableGestures.none,
  1130 + events: _events,
  1131 + locale: "zh_CN",
  1132 + initialCalendarFormat: CalendarFormat.month,
  1133 + headerStyle: HeaderStyle(
  1134 + decoration:
  1135 + BoxDecoration(color: MyColours.color_2bb5b7),
  1136 + headerPadding: EdgeInsets.zero,
  1137 + formatButtonVisible: false,
  1138 + centerHeaderTitle: false,
  1139 + titleTextBuilder: (dateTime, _) {
  1140 + return dateTime.year.toString() +
  1141 + "年-" +
  1142 + Utils.addZeroNumber(dateTime.month) +
  1143 + "月";
1129 }, 1144 },
1130 - // holidays: _holidays,  
1131 - availableGestures: AvailableGestures.none,  
1132 - events: _events,  
1133 - locale: "zh_CN",  
1134 - initialCalendarFormat: CalendarFormat.month,  
1135 - headerStyle: HeaderStyle(  
1136 - decoration:  
1137 - BoxDecoration(color: MyColours.color_2bb5b7),  
1138 - headerPadding: EdgeInsets.zero,  
1139 - formatButtonVisible: false,  
1140 - centerHeaderTitle: false,  
1141 - titleTextBuilder: (dateTime, _) {  
1142 - return dateTime.year.toString() +  
1143 - "年-" +  
1144 - Utils.addZeroNumber(dateTime.month) +  
1145 - "月";  
1146 - },  
1147 - titleTextStyle: TextStyle(  
1148 - color: MyColours.color_ffffff,  
1149 - fontSize: ScreenUtil().setSp(30)),  
1150 - leftChevronIcon: const Icon(Icons.chevron_left,  
1151 - color: Colors.white),  
1152 - rightChevronIcon: const Icon(Icons.chevron_right,  
1153 - color: Colors.white),  
1154 - ),  
1155 - calendarStyle: CalendarStyle(  
1156 - contentPadding:  
1157 - EdgeInsets.only(bottom: ScreenUtil().setWidth(8)),  
1158 - weekdayStyle: TextStyle(  
1159 - color: MyColours.color_2bb5b7,  
1160 - fontSize: ScreenUtil().setSp(32)),  
1161 - weekendStyle: TextStyle(  
1162 - color: MyColours.color_f49a5e,  
1163 - fontSize: ScreenUtil().setSp(32)),  
1164 - selectedColor: MyColours.color_2bb5b7,  
1165 - outsideDaysVisible: false,  
1166 - ),  
1167 - builders: CalendarBuilders(  
1168 - dowWeekdayBuilder: (context, weekday) {  
1169 - return Container(  
1170 - color: MyColours.color_2bb5b7,  
1171 - alignment: Alignment.center,  
1172 - margin: EdgeInsets.only(  
1173 - bottom: ScreenUtil().setWidth(40)),  
1174 - padding: EdgeInsets.symmetric(  
1175 - vertical: ScreenUtil().setHeight(25)),  
1176 - child: Text(  
1177 - weekday,  
1178 - style: TextStyle(  
1179 - color: MyColours.color_97e9ea,  
1180 - fontSize: ScreenUtil().setSp(32)),  
1181 - ),  
1182 - );  
1183 - },  
1184 - dayBuilder: (context, date, _) {  
1185 - return Container(  
1186 - height: ScreenUtil().setWidth(200),  
1187 - decoration: BoxDecoration( 1145 + titleTextStyle: TextStyle(
  1146 + color: MyColours.color_ffffff,
  1147 + fontSize: ScreenUtil().setSp(30)),
  1148 + leftChevronIcon:
  1149 + const Icon(Icons.chevron_left, color: Colors.white),
  1150 + rightChevronIcon: const Icon(Icons.chevron_right,
  1151 + color: Colors.white),
  1152 + ),
  1153 + calendarStyle: CalendarStyle(
  1154 + contentPadding:
  1155 + EdgeInsets.only(bottom: ScreenUtil().setWidth(8)),
  1156 + weekdayStyle: TextStyle(
  1157 + color: MyColours.color_2bb5b7,
  1158 + fontSize: ScreenUtil().setSp(32)),
  1159 + weekendStyle: TextStyle(
  1160 + color: MyColours.color_f49a5e,
  1161 + fontSize: ScreenUtil().setSp(32)),
  1162 + selectedColor: MyColours.color_2bb5b7,
  1163 + outsideDaysVisible: false,
  1164 + ),
  1165 + builders: CalendarBuilders(
  1166 + dowWeekdayBuilder: (context, weekday) {
  1167 + return Container(
  1168 + color: MyColours.color_2bb5b7,
  1169 + alignment: Alignment.center,
  1170 + margin: EdgeInsets.only(
  1171 + bottom: ScreenUtil().setWidth(40)),
  1172 + padding: EdgeInsets.symmetric(
  1173 + vertical: ScreenUtil().setHeight(25)),
  1174 + child: Text(
  1175 + weekday,
  1176 + style: TextStyle(
  1177 + color: MyColours.color_97e9ea,
  1178 + fontSize: ScreenUtil().setSp(32)),
  1179 + ),
  1180 + );
  1181 + },
  1182 + dayBuilder: (context, date, _) {
  1183 + return Container(
  1184 + height: ScreenUtil().setWidth(200),
  1185 + decoration: BoxDecoration(
  1186 + shape: BoxShape.circle,
  1187 + // color: Colors.blue,
  1188 + ),
  1189 + alignment: Alignment.center,
  1190 + margin: EdgeInsets.fromLTRB(
  1191 + ScreenUtil().setWidth(12),
  1192 + ScreenUtil().setWidth(12),
  1193 + ScreenUtil().setWidth(12),
  1194 + ScreenUtil().setWidth(32)),
  1195 + padding: EdgeInsets.only(
  1196 + bottom: ScreenUtil().setWidth(8),
  1197 + left: ScreenUtil().setWidth(16),
  1198 + right: ScreenUtil().setWidth(16),
  1199 + top: ScreenUtil().setWidth(8)),
  1200 + child: Text(
  1201 + // "${_parseDateDay(date)}",
  1202 + '${date.day}',
  1203 + style: TextStyle().copyWith(
  1204 + fontSize: ScreenUtil().setSp(32),
  1205 + color: MyColours.color_353535),
  1206 + ),
  1207 + );
  1208 + },
  1209 + selectedDayBuilder: (context, date, _) {
  1210 + return Container(
  1211 + decoration: BoxDecoration(
1188 shape: BoxShape.circle, 1212 shape: BoxShape.circle,
1189 - // color: Colors.blue,  
1190 - ),  
1191 - alignment: Alignment.center,  
1192 - margin: EdgeInsets.fromLTRB(  
1193 - ScreenUtil().setWidth(12),  
1194 - ScreenUtil().setWidth(12),  
1195 - ScreenUtil().setWidth(12),  
1196 - ScreenUtil().setWidth(32)),  
1197 - padding: EdgeInsets.only(  
1198 - bottom: ScreenUtil().setWidth(8),  
1199 - left: ScreenUtil().setWidth(16),  
1200 - right: ScreenUtil().setWidth(16),  
1201 - top: ScreenUtil().setWidth(8)),  
1202 - child: Text(  
1203 - // "${_parseDateDay(date)}",  
1204 - '${date.day}',  
1205 - style: TextStyle().copyWith(  
1206 - fontSize: ScreenUtil().setSp(32),  
1207 - color: MyColours.color_353535),  
1208 - ),  
1209 - );  
1210 - },  
1211 - selectedDayBuilder: (context, date, _) {  
1212 - return Container(  
1213 - decoration: BoxDecoration(  
1214 - shape: BoxShape.circle, 1213 + color: MyColours.color_2bb5b7),
  1214 + alignment: Alignment.center,
  1215 + margin: EdgeInsets.fromLTRB(
  1216 + ScreenUtil().setWidth(12),
  1217 + ScreenUtil().setWidth(12),
  1218 + ScreenUtil().setWidth(12),
  1219 + ScreenUtil().setWidth(32)),
  1220 + padding: EdgeInsets.only(
  1221 + bottom: ScreenUtil().setWidth(8),
  1222 + left: ScreenUtil().setWidth(16),
  1223 + right: ScreenUtil().setWidth(16),
  1224 + top: ScreenUtil().setWidth(8)),
  1225 + child: Text(
  1226 + // "${_parseDateDay(date)}",
  1227 + '${date.day}',
  1228 + style: TextStyle().copyWith(
  1229 + fontSize: ScreenUtil().setSp(32),
  1230 + color: MyColours.color_ffffff),
  1231 + ),
  1232 + );
  1233 + },
  1234 + todayDayBuilder: (context, date, _) {
  1235 + return Container(
  1236 + decoration: BoxDecoration(
  1237 + shape: BoxShape.circle,
  1238 + border: Border.all(
  1239 + color: MyColours.color_2bb5b7,
  1240 + width: ScreenUtil().setWidth(2))),
  1241 + alignment: Alignment.center,
  1242 + margin: EdgeInsets.fromLTRB(
  1243 + ScreenUtil().setWidth(12),
  1244 + ScreenUtil().setWidth(12),
  1245 + ScreenUtil().setWidth(12),
  1246 + ScreenUtil().setWidth(32)),
  1247 + padding: EdgeInsets.only(
  1248 + bottom: ScreenUtil().setWidth(8),
  1249 + left: ScreenUtil().setWidth(16),
  1250 + right: ScreenUtil().setWidth(16),
  1251 + top: ScreenUtil().setWidth(8)),
  1252 + child: Text(
  1253 + // '今',
  1254 + '${date.day}',
  1255 + style: TextStyle().copyWith(
  1256 + fontSize: ScreenUtil().setSp(32),
1215 color: MyColours.color_2bb5b7), 1257 color: MyColours.color_2bb5b7),
1216 - alignment: Alignment.center,  
1217 - margin: EdgeInsets.fromLTRB(  
1218 - ScreenUtil().setWidth(12),  
1219 - ScreenUtil().setWidth(12),  
1220 - ScreenUtil().setWidth(12),  
1221 - ScreenUtil().setWidth(32)),  
1222 - padding: EdgeInsets.only(  
1223 - bottom: ScreenUtil().setWidth(8),  
1224 - left: ScreenUtil().setWidth(16),  
1225 - right: ScreenUtil().setWidth(16),  
1226 - top: ScreenUtil().setWidth(8)),  
1227 - child: Text(  
1228 - // "${_parseDateDay(date)}",  
1229 - '${date.day}',  
1230 - style: TextStyle().copyWith(  
1231 - fontSize: ScreenUtil().setSp(32),  
1232 - color: MyColours.color_ffffff),  
1233 - ),  
1234 - );  
1235 - },  
1236 - todayDayBuilder: (context, date, _) {  
1237 - return Container(  
1238 - decoration: BoxDecoration(  
1239 - shape: BoxShape.circle,  
1240 - border: Border.all(  
1241 - color: MyColours.color_2bb5b7,  
1242 - width: ScreenUtil().setWidth(2))),  
1243 - alignment: Alignment.center,  
1244 - margin: EdgeInsets.fromLTRB(  
1245 - ScreenUtil().setWidth(12),  
1246 - ScreenUtil().setWidth(12),  
1247 - ScreenUtil().setWidth(12),  
1248 - ScreenUtil().setWidth(32)),  
1249 - padding: EdgeInsets.only(  
1250 - bottom: ScreenUtil().setWidth(8),  
1251 - left: ScreenUtil().setWidth(16),  
1252 - right: ScreenUtil().setWidth(16),  
1253 - top: ScreenUtil().setWidth(8)),  
1254 - child: Text(  
1255 - // '今',  
1256 - '${date.day}',  
1257 - style: TextStyle().copyWith(  
1258 - fontSize: ScreenUtil().setSp(32),  
1259 - color: MyColours.color_2bb5b7),  
1260 - ),  
1261 - );  
1262 - },  
1263 - markersBuilder: (context, date, events, holidays) {  
1264 - final children = <Widget>[];  
1265 -  
1266 - // if (events.isNotEmpty) {  
1267 - // children.add(  
1268 - // Positioned(  
1269 - // right: 1,  
1270 - // bottom: 1,  
1271 - // child: _buildEventsMarker(date, events),  
1272 - // ),  
1273 - // );  
1274 - // }  
1275 -  
1276 - // if (holidays.isNotEmpty) {  
1277 - children.add(  
1278 - Positioned(  
1279 - right: ScreenUtil().setWidth(27),  
1280 - bottom: 0,  
1281 - top: ScreenUtil().setWidth(30),  
1282 - child: buildMarker(date)),  
1283 - // Align(  
1284 - // alignment: Alignment.bottomCenter,  
1285 - // child: buildMarker(date),  
1286 - // )  
1287 - );  
1288 - // } 1258 + ),
  1259 + );
  1260 + },
  1261 + markersBuilder: (context, date, events, holidays) {
  1262 + final children = <Widget>[];
1289 1263
1290 - return children;  
1291 - },  
1292 - // singleMarkerBuilder: (context, dateTime, event) {  
1293 - // return Container(  
1294 - // width: ScreenUtil().setWidth(6),  
1295 - // height: ScreenUtil().setWidth(6),  
1296 - // margin:  
1297 - // const EdgeInsets.symmetric(horizontal: 0.3),  
1298 - // decoration: BoxDecoration(  
1299 - // shape: BoxShape.circle,  
1300 - // color: MyColours.color_ff0000, 1264 + // if (events.isNotEmpty) {
  1265 + // children.add(
  1266 + // Positioned(
  1267 + // right: 1,
  1268 + // bottom: 1,
  1269 + // child: _buildEventsMarker(date, events),
1301 // ), 1270 // ),
1302 // ); 1271 // );
1303 - // },  
1304 - ),  
1305 - ),  
1306 - ],  
1307 - ),  
1308 - ),  
1309 - Positioned(  
1310 - right: ScreenUtil().setWidth(62),  
1311 - bottom: ScreenUtil().setHeight(20),  
1312 - child: Container(  
1313 - child: GestureDetector(  
1314 - onTap: () {  
1315 - _calendarController.setSelectedDay(DateTime.now());  
1316 - _setState(() {});  
1317 - },  
1318 - child: Container(  
1319 - child: ClipOval(  
1320 - child: Container(  
1321 - width: ScreenUtil().setWidth(100),  
1322 - height: ScreenUtil().setWidth(100),  
1323 - alignment: Alignment.center,  
1324 - color: MyColours.color_2bb5b7,  
1325 - child: Text(  
1326 - "回到\n今天",  
1327 - style: TextStyle(  
1328 - color: MyColours.color_ffffff,  
1329 - fontSize: ScreenUtil().setSp(26)),  
1330 - ),  
1331 - )), 1272 + // }
  1273 +
  1274 + // if (holidays.isNotEmpty) {
  1275 + children.add(
  1276 + Positioned(
  1277 + right: ScreenUtil().setWidth(27),
  1278 + bottom: 0,
  1279 + top: ScreenUtil().setWidth(30),
  1280 + child: buildMarker(date)),
  1281 + // Align(
  1282 + // alignment: Alignment.bottomCenter,
  1283 + // child: buildMarker(date),
  1284 + // )
  1285 + );
  1286 + // }
  1287 +
  1288 + return children;
  1289 + },
  1290 + // singleMarkerBuilder: (context, dateTime, event) {
  1291 + // return Container(
  1292 + // width: ScreenUtil().setWidth(6),
  1293 + // height: ScreenUtil().setWidth(6),
  1294 + // margin:
  1295 + // const EdgeInsets.symmetric(horizontal: 0.3),
  1296 + // decoration: BoxDecoration(
  1297 + // shape: BoxShape.circle,
  1298 + // color: MyColours.color_ff0000,
  1299 + // ),
  1300 + // );
  1301 + // },
1332 ), 1302 ),
1333 ), 1303 ),
1334 - ), 1304 + Row(
  1305 + mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  1306 + children: [
  1307 + RoundButton(
  1308 + onPressed: () async {
  1309 + _calendarController.setSelectedDay(DateTime.now());
  1310 + _setState(() {});
  1311 + },
  1312 + text: '回到今天',
  1313 + fontSize: 28,
  1314 + isBold: false,
  1315 + height: ScreenUtil().setWidth(70),
  1316 + width: ScreenUtil().setWidth(220),
  1317 + gradientStart: MyColours.color_2bb5b7,
  1318 + gradientEnd: MyColours.color_2bb5b7,
  1319 + radius: ScreenUtil().setWidth(10),
  1320 + ),
  1321 + RoundButton(
  1322 + onPressed: () async {
  1323 + Navigator.pop(context);
  1324 + },
  1325 + text: '取消',
  1326 + fontSize: 28,
  1327 + isBold: false,
  1328 + textColor: MyColours.color_333333,
  1329 + borderColor: Color.fromRGBO(119, 119, 119, 1),
  1330 + height: ScreenUtil().setWidth(70),
  1331 + width: ScreenUtil().setWidth(220),
  1332 + gradientStart: MyColours.color_ffffff,
  1333 + gradientEnd: MyColours.color_ffffff,
  1334 + radius: ScreenUtil().setWidth(10),
  1335 + )
  1336 + ],
  1337 + )
  1338 + ],
1335 ) 1339 )
1336 - ],  
1337 - ); 1340 +
  1341 + // Positioned(
  1342 + // right: ScreenUtil().setWidth(62),
  1343 + // bottom: ScreenUtil().setHeight(20),
  1344 + // child: Container(
  1345 + // child: GestureDetector(
  1346 + // onTap: () {
  1347 + // _calendarController.setSelectedDay(DateTime.now());
  1348 + // _setState(() {});
  1349 + // },
  1350 + // child: Container(
  1351 + // child: ClipOval(
  1352 + // child: Container(
  1353 + // width: ScreenUtil().setWidth(100),
  1354 + // height: ScreenUtil().setWidth(100),
  1355 + // alignment: Alignment.center,
  1356 + // color: MyColours.color_2bb5b7,
  1357 + // child: Text(
  1358 + // "回到\n今天",
  1359 + // style: TextStyle(
  1360 + // color: MyColours.color_ffffff,
  1361 + // fontSize: ScreenUtil().setSp(26)),
  1362 + // ),
  1363 + // )),
  1364 + // ),
  1365 + // ),
  1366 + // ),
  1367 + // )
  1368 + // ],
  1369 + );
1338 }); 1370 });
1339 return SizedBox( 1371 return SizedBox(
1340 width: double.infinity, 1372 width: double.infinity,