pull/1/head
戴余标 3 years ago
parent 0850044c82
commit 989f9072a0

@ -25,25 +25,16 @@ class FacilityPreorderDatePicker extends StatefulWidget {
_FacilityPreorderDatePickerState(); _FacilityPreorderDatePickerState();
} }
class _FacilityPreorderDatePickerState extends State<FacilityPreorderDatePicker> { class _FacilityPreorderDatePickerState
extends State<FacilityPreorderDatePicker> {
List<int> get _num => List.generate( List<int> get _num => List.generate(
getNum(widget.typeModel.openEndDT!) - getNum(widget.typeModel.openEndDT!) -
getNum(widget.typeModel.openStartDT!), getNum(widget.typeModel.openStartDT!),
(index) => index + 1); (index) => index + 1);
DateTime? start; DateTime? start;
List<int> models=[]; List<int> models = [];
static Future<List<int>> getPreorderData(int id) async { List<int> _selectIndex = [];
BaseModel model =
await NetUtil().get(SAASAPI.facilities.allAppointmentPeriod, params: {
'facilitiesManageId': id,
'todayDate': DateTime.now(),
});
if (model.success) {
return (model.data as List<int>).toList();
}
return [];
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -62,7 +53,10 @@ class _FacilityPreorderDatePickerState extends State<FacilityPreorderDatePicker>
children: [ children: [
_datesList(index), _datesList(index),
20.hb, 20.hb,
Divider(height: 1.0,color: Colors.black12,), Divider(
height: 1.0,
color: Colors.black12,
),
], ],
); );
}, },
@ -74,52 +68,81 @@ class _FacilityPreorderDatePickerState extends State<FacilityPreorderDatePicker>
} }
Widget _datesList(int index) { Widget _datesList(int index) {
DateTime start=widget.typeModel.openStartDT!; DateTime start = widget.typeModel.openStartDT!;
()async{ () async {
BaseModel model = BaseModel model =
await NetUtil().get(SAASAPI.facilities.allAppointmentPeriod, params: { await NetUtil().get(SAASAPI.facilities.allAppointmentPeriod, params: {
'facilitiesManageId': widget.typeModel.id, 'facilitiesManageId': widget.typeModel.id,
'todayDate': DateTime.now(), 'todayDate': DateTime.now(),
}); });
if (model.success) { if (model.success) {
models=(model.data as List<int>).toList(); models = (model.data as List<int>).toList();
} }
}; };
return GestureDetector( return GestureDetector(
onTap: (){ onTap: () {
print(getNum(start)+index);
if(!models.contains(getNum(start)+index)||start.add(Duration(minutes: 30 * index)).isAfter(DateTime.now())){
if (_selectIndex.contains(index)) {
_selectIndex.remove(index);
} else {
_selectIndex.add(index);
}
}
setState(() {});
}, },
child:Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
BeeCheckRadio( BeeCheckRadio(
value: getNum(start)+index, value: index,
groupValue: models, groupValue: _selectIndex,
backColor: start.isAfter(DateTime.now())?Colors.grey:Colors.white, canCheck: models.contains(getNum(start)+index),
), ),
30.wb, 30.wb,
Text( Text(
'${DateUtil.formatDate(start.add(Duration(minutes: 30*index)),format: 'HH:mm')}' '${DateUtil.formatDate(start.add(Duration(minutes: 30 * index)), format: 'HH:mm')}'
'~${DateUtil.formatDate(start.add(Duration(minutes: 30*(index+1))),format: 'HH:mm')}', '~${DateUtil.formatDate(start.add(Duration(minutes: 30 * (index + 1))), format: 'HH:mm')}',
style: TextStyle( style: TextStyle(
fontSize: 30.sp, fontSize: 30.sp,
), ),
), ),
Spacer(), Spacer(),
start.isAfter(DateTime.now())?'已过期'.text.size(30.sp).color(Colors.black.withOpacity(0.45)).make(): isPass(start.add(Duration(minutes: 30 * index)))
models.contains(getNum(start))?'已被他人预约'.text.size(30.sp).color(Colors.black.withOpacity(0.45)).make():SizedBox(), ? '已过期'
], .text
), .size(30.sp)
.color(Colors.black.withOpacity(0.45))
.make()
: models.contains(getNum(start)+index)
? '已被他人预约'
.text
.size(30.sp)
.color(Colors.black.withOpacity(0.45))
.make()
: SizedBox(),
],
),
); );
} }
} }
bool isPass(DateTime date){
if(date.hour<DateTime.now().hour||(date.minute<DateTime.now().minute&&date.hour==DateTime.now().hour)){
return true;
}
else{
return false;
}
}
int getNum(DateTime dateTime) { int getNum(DateTime dateTime) {
int hour, minute; int hour, minute;
hour = dateTime.hour; hour = dateTime.hour;
minute = dateTime.minute; minute = dateTime.minute;
if (minute > 0) { if (minute > 0) {
return hour * 2 + 1; return hour * 2;
} }
return hour * 2; return hour * 2 + 1;
} }

@ -1,3 +1,4 @@
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';

@ -10,6 +10,7 @@ class BeeCheckRadio<T> extends StatefulWidget {
final Widget? indent; final Widget? indent;
final Color? backColor; final Color? backColor;
final double? size; final double? size;
final bool? canCheck;
BeeCheckRadio( BeeCheckRadio(
{Key? key, {Key? key,
@ -17,7 +18,8 @@ class BeeCheckRadio<T> extends StatefulWidget {
this.groupValue, this.groupValue,
this.indent, this.indent,
this.backColor, this.backColor,
this.size}) this.size,
this.canCheck,})
: super(key: key); : super(key: key);
@override @override
@ -35,6 +37,35 @@ class _BeeCheckRadioState extends State<BeeCheckRadio> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if(widget.canCheck!=null&&widget.canCheck!){
return AnimatedContainer(
height: widget.size ?? 40.w,
width: widget.size ?? 40.w,
decoration: BoxDecoration(
color: Color(0xFF979797),
border: Border.all(
color: Color(0xFF979797),
width: 3.w,
),
borderRadius: BorderRadius.circular((widget.size??40.w)/2),
),
duration: Duration(milliseconds: 300),
curve: Curves.easeInOutCubic,
alignment: Alignment.center,
child: AnimatedOpacity(
duration: Duration(milliseconds: 500),
curve: Curves.easeInOutCubic,
opacity: 1,
child:
Icon(
CupertinoIcons.checkmark,
color: Colors.white,
size: 28.w,
),
),
);
}
else
return AnimatedContainer( return AnimatedContainer(
height: widget.size ?? 40.w, height: widget.size ?? 40.w,
width: widget.size ?? 40.w, width: widget.size ?? 40.w,

Loading…
Cancel
Save