添加家政服务卡片

hmxc
张萌 3 years ago
parent 8aea4295a5
commit fafa1623a4

@ -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<String, dynamic> 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<Object?> get props {
return [

@ -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 [];
}
}
}

@ -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<HouseKeepingView> {
class _HouseKeepingViewState extends State<HouseKeepingView>
with AutomaticKeepAliveClientMixin {
late EasyRefreshController _controller;
@override
void initState() {
@ -28,6 +32,7 @@ class _HouseKeepingViewState extends State<HouseKeepingView> {
@override
Widget build(BuildContext context) {
super.build(context);
return BeeListView(
path: API.manager.houseKeepingList,
controller: _controller,
@ -35,14 +40,22 @@ class _HouseKeepingViewState extends State<HouseKeepingView> {
"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;
}

@ -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)),
),
);
}
}
Loading…
Cancel
Save