From daefd362ee7b3f8dc6b3325522db26fe5821a1a7 Mon Sep 17 00:00:00 2001 From: datang Date: Thu, 19 May 2022 17:46:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=B7=B2=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E6=9D=A1=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../facility/facility_preorder_page.dart | 8 +- .../facility/facility_type_detail_card.dart | 124 +++++++++++++----- 2 files changed, 95 insertions(+), 37 deletions(-) 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..31d0c794 100644 --- a/lib/ui/community/facility/facility_type_detail_card.dart +++ b/lib/ui/community/facility/facility_type_detail_card.dart @@ -7,19 +7,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 +71,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 +89,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 +111,72 @@ 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), + ), + ), ], ), 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; + + MyPainter(List dates) { + this.dates = dates; + } + @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 : ktextThirdColor + ..strokeWidth = 40.h; + if (dates!.contains(i)) { + canvas.translate(0, 0); + canvas.drawLine( + Offset(12.7.w * i - 1, 0), Offset(12.7.w * (i + 1), 0), _paint); + } + } } @override bool shouldRepaint(covariant CustomPainter oldDelegate) { - throw UnimplementedError(); + return true; } }