diff --git a/lib/models/house_keeping/house_keeping_list_model.dart b/lib/models/house_keeping/house_keeping_list_model.dart index 9321b0e4..553c3209 100644 --- a/lib/models/house_keeping/house_keeping_list_model.dart +++ b/lib/models/house_keeping/house_keeping_list_model.dart @@ -1,6 +1,7 @@ import 'package:equatable/equatable.dart'; import 'package:aku_community/model/common/img_model.dart'; +import 'package:flutter/material.dart'; import 'package:json_annotation/json_annotation.dart'; part 'house_keeping_list_model.g.dart'; @@ -42,6 +43,59 @@ class HouseKeepingListModel extends Equatable { }); factory HouseKeepingListModel.fromJson(Map json) => _$HouseKeepingListModelFromJson(json); + String get typeString { + switch (this.type) { + case 1: + return '室内清洁'; + case 2: + return '洗涤护理'; + default: + return '未知'; + } + } + + String get statusString { + switch (this.status) { + case 1: + return '待派单'; + case 2: + return '已派单'; + case 3: + return '处理中'; + case 4: + return '待支付'; + case 5: + return '待评价'; + case 6: + return '已完成'; + case 9: + return '已取消'; + default: + return '未知'; + } + } + + Color get statusColor { + switch (this.status) { + case 1: + return Color(0xFFFF4501); + case 2: + return Color(0xFFFF4501); + case 3: + return Color(0xFFFF4501); + case 4: + return Color(0xFFFF4501); + case 5: + return Color(0xFFFF4501); + case 6: + return Color(0xFFFF4501); + case 9: + return Color(0xFFFF4501); + default: + return Color(0xFFFF4501); + } + } + @override List get props { return [ diff --git a/lib/ui/manager/house_keeping/house_keeping_card.dart b/lib/ui/manager/house_keeping/house_keeping_card.dart new file mode 100644 index 00000000..3b020d96 --- /dev/null +++ b/lib/ui/manager/house_keeping/house_keeping_card.dart @@ -0,0 +1,145 @@ +import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/const/resource.dart'; +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/models/house_keeping/house_keeping_list_model.dart'; +import 'package:aku_community/widget/buttons/card_bottom_button.dart'; +import 'package:aku_community/widget/others/aku_chip_box.dart'; +import 'package:flustars/flustars.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class HouseKeepingCard extends StatelessWidget { + final HouseKeepingListModel model; + const HouseKeepingCard({Key? key, required this.model}) : super(key: key); + String get dateStart => + DateUtil.formatDateStr(model.createDate, format: 'yyyy-MM-dd HH:mm:ss'); + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () async {}, + child: Container( + padding: EdgeInsets.all(24.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Row( + children: [ + AkuChipBox(title: model.typeString), + 16.w.widthBox, + Expanded( + child: Text( + dateStart, + style: TextStyle( + color: ktextSubColor, + fontSize: 22.sp, + ), + ), + ), + Text( + model.statusString, + style: TextStyle( + color: + model.statusColor), + ), + ], + ), + 24.w.heightBox, + Text( + model.content, + overflow: TextOverflow.visible, + style: TextStyle( + color: ktextPrimary, + fontSize: 28.sp, + fontWeight: FontWeight.bold, + ), + ), + 16.w.heightBox, + _buildImgs(), + _getBottomCard(), + ], + ), + margin: EdgeInsets.only(top: 16.w), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8.w), + ), + ), + ); + } + + _buildImgs() { + return Container( + height: 168.w, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemBuilder: (context, index) { + var imgObj = model.submitImgList[index].url; + return Container( + margin: EdgeInsets.symmetric(horizontal: 8.w), + height: 168.w, + width: 168.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4.w), + ), + clipBehavior: Clip.antiAlias, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(imgObj ?? '')), + ); + }, + itemCount: model.submitImgList.length, + ), + ); + } + + _getBottomCard() { + return Column( + children: [ + Divider(height: 48.w), + Align( + alignment: Alignment.centerRight, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: _getButtons())), + ], + ); + } + + _getButtons() { + switch (model.status) { + case 1: + return [ + CardBottomButton.white(onPressed: () async {}, text: ('取消服务')), + ]; + case 2: + return [ + CardBottomButton.white(onPressed: () async {}, text: ('取消服务')), + ]; + case 3: + return [ + CardBottomButton.white(onPressed: () async {}, text: ('查看详情')), + ]; + case 4: + return [ + CardBottomButton.white(onPressed: () async {}, text: ('查看账单')), + ]; + case 5: + return [ + CardBottomButton.white(onPressed: () async {}, text: ('查看详情')), + ]; + case 6: + return [ + CardBottomButton.white(onPressed: () async {}, text: ('查看详情')), + ]; + case 9: + return [ + CardBottomButton.white(onPressed: () async {}, text: ('查看详情')), + ]; + default: + return []; + } + } +} diff --git a/lib/ui/manager/house_keeping/house_keeping_view.dart b/lib/ui/manager/house_keeping/house_keeping_view.dart index a87e83e5..ae7bf580 100644 --- a/lib/ui/manager/house_keeping/house_keeping_view.dart +++ b/lib/ui/manager/house_keeping/house_keeping_view.dart @@ -1,8 +1,11 @@ import 'package:aku_community/constants/api.dart'; import 'package:aku_community/models/house_keeping/house_keeping_list_model.dart'; import 'package:aku_community/pages/things_page/widget/bee_list_view.dart'; +import 'package:aku_community/ui/manager/house_keeping/house_keeping_card.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; class HouseKeepingView extends StatefulWidget { final int index; @@ -12,7 +15,8 @@ class HouseKeepingView extends StatefulWidget { _HouseKeepingViewState createState() => _HouseKeepingViewState(); } -class _HouseKeepingViewState extends State { +class _HouseKeepingViewState extends State + with AutomaticKeepAliveClientMixin { late EasyRefreshController _controller; @override void initState() { @@ -28,6 +32,7 @@ class _HouseKeepingViewState extends State { @override Widget build(BuildContext context) { + super.build(context); return BeeListView( path: API.manager.houseKeepingList, controller: _controller, @@ -35,14 +40,22 @@ class _HouseKeepingViewState extends State { "housekeepingStatus": widget.index == 0 ? null : widget.index }, convert: (models) { - return models.tableList!.map((e) => HouseKeepingListModel.fromJson(e)).toList(); + return models.tableList! + .map((e) => HouseKeepingListModel.fromJson(e)) + .toList(); }, builder: (items) { - return ListView( - children: [ - - ], - ); + return ListView.separated( + padding: EdgeInsets.symmetric(horizontal: 24.w), + itemBuilder: (context, index) { + return HouseKeepingCard(model: items[index]); + }, + separatorBuilder: (_, __) { + return 24.w.heightBox; + }, + itemCount: items.length); }); } + @override + bool get wantKeepAlive => true; } diff --git a/lib/widget/others/aku_chip_box.dart b/lib/widget/others/aku_chip_box.dart new file mode 100644 index 00000000..d62dee7d --- /dev/null +++ b/lib/widget/others/aku_chip_box.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class AkuChipBox extends StatelessWidget { + final String title; + final Color? borderClor; + final Color? textColor; + const AkuChipBox( + {Key? key, required this.title, this.borderClor, this.textColor}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + child: Text( + title, + style: TextStyle( + color: textColor ?? Color(0xFF3F8FFE), + fontSize: 20.sp, + fontWeight: FontWeight.bold, + ), + ), + padding: EdgeInsets.symmetric(vertical: 6.w, horizontal: 16.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2.w), + border: Border.all(width: 2.w, color: borderClor ?? Color(0xFF3F8FFE)), + ), + ); + } +}