diff --git a/lib/ui/community/facility/facility_preorder_page.dart b/lib/ui/community/facility/facility_preorder_page.dart index d4e58609..904c0865 100644 --- a/lib/ui/community/facility/facility_preorder_page.dart +++ b/lib/ui/community/facility/facility_preorder_page.dart @@ -63,12 +63,12 @@ class _FacilityPreorderPageState extends State { ), onTap: () => Get.to(() => AdviceHousePage()), title: Text( - UserTool.userProvider.userInfoModel!.name!, + UserTool.userProvider.userInfoModel!.name??'请先选择房屋', style: TextStyle( fontSize: 30.sp, ), ), - subtitle: Text( + subtitle: userProvider.defaultHouse!=null?Text( '租户 ' + userProvider.defaultHouse!.communityName + userProvider.defaultHouseString, @@ -76,7 +76,7 @@ class _FacilityPreorderPageState extends State { color: Colors.black.withOpacity(0.45), fontSize: 26.sp, ), - ), + ):SizedBox(), trailing: Icon( CupertinoIcons.chevron_forward, size: 35.w, @@ -252,7 +252,7 @@ class _FacilityPreorderPageState extends State { DateTime getDate(int dateNum) { DateTime startDate = DateTime( DateTime.now().year, DateTime.now().month, DateTime.now().day, 0, 0, 0); - return startDate.add(Duration(minutes: 30 * (dateNum - 1))); + return startDate.add(Duration(minutes: 30 * (dateNum))); } String dateString(List dates){ diff --git a/lib/ui/community/facility/facility_type_detail_card.dart b/lib/ui/community/facility/facility_type_detail_card.dart index f051b160..2d785045 100644 --- a/lib/ui/community/facility/facility_type_detail_card.dart +++ b/lib/ui/community/facility/facility_type_detail_card.dart @@ -1,5 +1,6 @@ import 'dart:ui'; +import 'package:aku_new_community/ui/community/facility/facility_preorder_date_picker.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter/material.dart'; @@ -7,19 +8,52 @@ import 'package:get/get.dart'; import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/utils/headers.dart'; +import '../../../constants/saas_api.dart'; import '../../../models/facility/facility_type_detail_model.dart'; import '../../../models/facility/facility_type_model.dart'; +import '../../../utils/network/base_model.dart'; +import '../../../utils/network/net_util.dart'; import '../../../widget/bee_image_network.dart'; import 'facility_preorder_page.dart'; -class FacilityTypeDetailCard extends StatelessWidget { +class FacilityTypeDetailCard extends StatefulWidget { final FacilityTypeDetailModel model; final FacilityTypeModel facilityModel; - const FacilityTypeDetailCard( + FacilityTypeDetailCard( {Key? key, required this.model, required this.facilityModel}) : super(key: key); + @override + _FacilityTypeDetailCardState createState() => _FacilityTypeDetailCardState(); +} + +class _FacilityTypeDetailCardState extends State { + List datesNum = []; + + @override + void initState() { + Future.delayed( + Duration.zero, + () => setState(() { + _load(); + })); + super.initState(); + } + + _load() async { + BaseModel model = + await NetUtil().get(SAASAPI.facilities.allAppointmentPeriod, params: { + 'facilitiesManageId': widget.model.id, + 'todayDate': DateTime.now(), + }); + if (model.success) { + datesNum = (model.data as List); + print(datesNum); + } + setState(() {}); + } + @override Widget build(BuildContext context) { return MaterialButton( @@ -38,7 +72,7 @@ class FacilityTypeDetailCard extends StatelessWidget { borderRadius: BorderRadius.circular(10.w), clipBehavior: Clip.antiAliasWithSaveLayer, child: BeeImageNetwork( - imgs: model.imgList ?? [], + imgs: widget.model.imgList ?? [], height: 150.h, width: 200.w, fit: BoxFit.cover, @@ -56,19 +90,19 @@ class FacilityTypeDetailCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - model.name, + widget.model.name, style: TextStyle( fontSize: 28.sp, fontWeight: FontWeight.bold, ), ), 15.hb, - '${DateUtil.formatDate(model.openStartDT, format: 'HH:mm')}-${DateUtil.formatDate(model.openEndDT, format: 'HH:mm')} 开放' + '${DateUtil.formatDate(widget.model.openStartDT, format: 'HH:mm')}-${DateUtil.formatDate(widget.model.openEndDT, format: 'HH:mm')} 开放' .text .size(20.sp) .make(), 12.hb, - '${model.address}' + '${widget.model.address}' .text .size(20.sp) .color(BaseStyle.color474747) @@ -78,47 +112,88 @@ class FacilityTypeDetailCard extends StatelessWidget { ], ), 30.hb, - // Container( - // height: 30.h, - // width: double.infinity, - // decoration: BoxDecoration( - // border: Border.all( - // color: Color(0xFF979797), - // width: 3.w, - // ), - // ), - // child: CustomPaint( - // painter: MyPainter(), - // ), - // ) + Wrap( + spacing: 7.5.sp, + children: [ + for (int i = 0; i < 25; i++) + Text( + '${i}', + style: TextStyle( + fontSize: 19.sp, + ), + ), + ], + ), + 10.hb, + Container( + padding: EdgeInsets.only(left: 2.w, right: 2.w), + alignment: Alignment.centerLeft, + width: 615.w, + height: 40.h, + decoration: BoxDecoration( + border: Border.all( + width: 1, + color: Colors.black12, + ), + ), + child: CustomPaint( + foregroundPainter: MyPainter(datesNum, widget.model), + ), + ), ], ), onPressed: () { - Get.off(() => FacilityPreorderPage( - facilityModel: facilityModel, - typeModel: model, - )); + Get.off( + () => FacilityPreorderPage( + facilityModel: widget.facilityModel, + typeModel: widget.model, + ), + ); }, ); } } class MyPainter extends CustomPainter { + Path path = new Path(); + List? dates; + FacilityTypeDetailModel? model; + DateTime? start; + DateTime? end; + + MyPainter(List dates, FacilityTypeDetailModel model) { + this.dates = dates; + this.model = model; + start = model.openStartDT!; + end = model.openEndDT!; + } + @override void paint(Canvas canvas, Size size) { - Paint _paint = Paint() - ..color = Colors.redAccent - ..strokeWidth = 20; - - //平移之前 - canvas.drawPoints(PointMode.points, [Offset(0, 0)], _paint); - canvas.translate(200, 200); - //平移之后 - canvas.drawPoints(PointMode.points, [Offset(0, 0)], _paint); + for (int i = 0; i < 48; i++) { + Paint _paint = Paint() + ..color = dates!.contains(i) + ? kPrimaryColor + : i < getNum(start!) || + i > getNum(end!) || + i < getNum(DateTime.now()) + ? ktextThirdColor + : Colors.transparent + ..strokeWidth = 40.h; + if (dates!.contains(i) || + i <= getNum(start!) || + i >= getNum(end!) || + i <= getNum(DateTime.now())) { + canvas.translate(0, 0); + canvas.drawLine( + Offset(12.7.w * i - 1, 0), Offset(12.7.w * (i + 1), 0), _paint); + } + } + print(getNum(start!)); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) { - throw UnimplementedError(); + return true; } }