页面返回自动刷新

hmxc
张萌 4 years ago
parent 68da371190
commit f9d4911149

@ -47,7 +47,8 @@ class _BussinessViewState extends State<BussinessView>
controller: _refreshController,
header: MaterialHeader(),
onRefresh: () async {
var dataList = await BussinessFunc.getBussinessModelList(widget.backlogStatus);
var dataList =
await BussinessFunc.getBussinessModelList(widget.backlogStatus);
_modelList = dataList.map((e) => ToDoModel.fromJson(e)).toList();
setState(() {});
},
@ -58,10 +59,18 @@ class _BussinessViewState extends State<BussinessView>
children: [
..._modelList.map((e) {
if (e.dynamicModel.runtimeType == BussinessAndFixModel) {
return BusinessFixCard(model: e.dynamicModel);
return BusinessFixCard(
model: e.dynamicModel,
callRefresh: () {
_refreshController.callRefresh();
},
);
} else if (e.dynamicModel.runtimeType == ToDoOutDoorModel) {
return ToDoOutDoorCard(
model: e.dynamicModel,
callRefresh: () {
_refreshController.callRefresh();
},
);
}
}).toList()
@ -74,8 +83,6 @@ class _BussinessViewState extends State<BussinessView>
return SizedBox();
}
@override
bool get wantKeepAlive => true;
}

@ -9,7 +9,8 @@ import 'package:velocity_x/velocity_x.dart';
class ToDoOutDoorCard extends StatefulWidget {
final ToDoOutDoorModel model;
ToDoOutDoorCard({Key key, this.model}) : super(key: key);
final VoidCallback callRefresh;
ToDoOutDoorCard({Key key, this.model, this.callRefresh}) : super(key: key);
@override
_ToDoOutDoorCardState createState() => _ToDoOutDoorCardState();
@ -191,8 +192,11 @@ class _ToDoOutDoorCardState extends State<ToDoOutDoorCard> {
height: 112.w,
alignment: Alignment.centerRight,
child: AkuButton(
onPressed: () {
Get.to(ItemsOutdoorDetailsPage(id: widget.model.id));
onPressed: () async {
await Get.to(ItemsOutdoorDetailsPage(id: widget.model.id));
if (widget.callRefresh != null) {
widget.callRefresh();
}
},
child: Container(
alignment: Alignment.center,

@ -560,8 +560,9 @@ class _HomePageState extends State<HomePage> {
!userProvider.isLogin
? SizedBox()
: Container(
height: 480.w,
height: 500.w,
child: ListView.separated(
padding: EdgeInsets.zero,
separatorBuilder: (context, index) {
return AkuBox.w(16);
},
@ -576,6 +577,10 @@ class _HomePageState extends State<HomePage> {
.runtimeType ==
BussinessAndFixModel) {
return BusinessFixCard(
callRefresh: () {
_refreshController
.callRefresh();
},
model: _todoModelList[index]
.dynamicModel);
} else if (_todoModelList[index]

@ -25,11 +25,16 @@ class BusinessFixCard extends StatefulWidget {
final BussinessAndFixModel model;
final bool homeDisplay;
final bool canSeeBottomButton;
final VoidCallback callRefresh;
//
final bool hasFinished;
BusinessFixCard(
{Key key,
@required this.model,
this.homeDisplay = false,
this.canSeeBottomButton = true})
this.canSeeBottomButton = true,
this.callRefresh,
this.hasFinished = false})
: super(key: key);
@override
@ -70,8 +75,11 @@ class _BusinessFixCardState extends State<BusinessFixCard> {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
Get.to(() => BusinessAndFixDetailPage(model: widget.model));
onTap: () async {
await Get.to(() => BusinessAndFixDetailPage(model: widget.model));
if (widget.callRefresh != null) {
widget.callRefresh();
}
},
child: Container(
padding: EdgeInsets.all(24.w),
@ -93,9 +101,13 @@ class _BusinessFixCardState extends State<BusinessFixCard> {
),
),
Text(
AkuMap.fixStatus(userInfoModel.canSendTicket,
widget.hasFinished
? '已处理'
: AkuMap.fixStatus(userInfoModel.canSendTicket,
userInfoModel.canPickUpTicket, widget.model.status),
style: TextStyle(
style: widget.hasFinished
? TextStyle(color: AppStyle.minorTextColor)
: TextStyle(
color: widget.model.status < 4
? Color(0XFFFF4501)
: AppStyle.minorTextColor,
@ -194,8 +206,8 @@ class _BusinessFixCardState extends State<BusinessFixCard> {
widget.model.status == 3 ? AkuBox.w(24) : SizedBox(),
widget.model.status == 3
? AkuMaterialButton(
onPressed: () {
Get.to(() => BusinessAndFixDetailPage(
onPressed: () async {
await Get.to(() => BusinessAndFixDetailPage(
model: widget.model,
));
},
@ -214,7 +226,7 @@ class _BusinessFixCardState extends State<BusinessFixCard> {
: SizedBox(),
(widget.model.status == 2) && (userInfoModel.canPickUpTicket)
? AkuMaterialButton(
onPressed: () {
onPressed: () async {
// final userProvider =
// Provider.of<UserProvider>(context, listen: false);
// widget.model.detail.fixStatuses.add(FixStatus(
@ -223,9 +235,12 @@ class _BusinessFixCardState extends State<BusinessFixCard> {
// ));
// widget.model.type = FIX_ENUM.PROCESSING;
// Get.back();
Get.to(() => BusinessAndFixDetailPage(
await Get.to(() => BusinessAndFixDetailPage(
model: widget.model,
));
if (widget.callRefresh != null) {
widget.callRefresh();
}
},
radius: 4.w,
color: AppStyle.primaryColor,
@ -252,8 +267,11 @@ class _BusinessFixCardState extends State<BusinessFixCard> {
alignment: Alignment.centerRight,
child: AkuMaterialButton(
height: 64.w,
onPressed: () {
onPressed: () async {
Get.to(() => BusinessAndFixDetailPage(model: widget.model));
if (widget.callRefresh != null) {
widget.callRefresh();
}
},
radius: 4,
color: AppStyle.primaryColor,

@ -47,7 +47,11 @@ class _BussinessAndFixViewState extends State<BussinessAndFixView>
builder: (items) {
return ListView.separated(
itemBuilder: (context, index) {
return BusinessFixCard(model: items[index]);
return BusinessFixCard(
model: items[index],
callRefresh: () {
_easyRefreshController.callRefresh();
});
},
separatorBuilder: (_, __) {
return 16.w.heightBox;

@ -23,6 +23,7 @@ class FixSubmitFinishPage extends StatelessWidget {
'您已处理完成该报修'.text.black.size(40.sp).bold.make(),
120.w.heightBox,
BusinessFixCard(
hasFinished: true,
model: this.model,
canSeeBottomButton: false,
),

@ -289,10 +289,15 @@ class _FixWorkFinishPageState extends State<FixWorkFinishPage> {
title: '费用明细',
spacing: 16,
children: [
Row(
SizedBox(
height: 96.w,
child: Row(
children: [
AkuBox.h(96),
Text('人工费'),
Text(
'人工费',
style:
TextStyle(color: Colors.black, fontSize: 28.sp),
),
Expanded(
child: TextField(
controller: _humanController,
@ -312,11 +317,17 @@ class _FixWorkFinishPageState extends State<FixWorkFinishPage> {
),
],
),
),
Divider(height: 1.w),
Row(
SizedBox(
height: 96.w,
child: Row(
children: [
AkuBox.h(96),
Text('材料费'),
Text(
'材料费',
style:
TextStyle(color: Colors.black, fontSize: 28.sp),
),
Expanded(
child: TextField(
onChanged: (_) => setState(() {}),
@ -336,11 +347,17 @@ class _FixWorkFinishPageState extends State<FixWorkFinishPage> {
),
],
),
),
Divider(height: 1.w),
Row(
SizedBox(
height: 96.w,
child: Row(
children: [
AkuBox.h(96),
Text('总计费用'),
Text(
'总计费用',
style:
TextStyle(color: Colors.black, fontSize: 28.sp),
),
Spacer(),
Builder(
builder: (context) {
@ -355,11 +372,15 @@ class _FixWorkFinishPageState extends State<FixWorkFinishPage> {
_materialPriceController.text);
}
return Text(
'¥${(humanPrice + materialPrice).toStringAsFixed(2)}');
'¥${(humanPrice + materialPrice).toStringAsFixed(2)}',
style: TextStyle(
color: Colors.black, fontSize: 28.sp),
);
},
),
],
),
),
],
),
],
@ -409,6 +430,7 @@ class _FixWorkFinishPageState extends State<FixWorkFinishPage> {
if (baseModel.status) {
FixSubmitFinishPage(
model: widget.fixModel,
).to();
} else {
BotToast.showText(text: baseModel.message);

@ -241,6 +241,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.0.1"
extended_list_library:
dependency: transitive
description:
name: extended_list_library
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.0"
extended_text:
dependency: "direct main"
description:
@ -800,6 +807,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.0"
waterfall_flow:
dependency: "direct main"
description:
name: waterfall_flow
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.1"
yaml:
dependency: transitive
description:

@ -55,6 +55,8 @@ dependencies:
firebase_crashlytics: ^2.0.0
#json序列化
json_serializable: ^4.1.1
#瀑布流
waterfall_flow: ^3.0.1
power_logger: ^1.0.1-nullsafety.1
logger: ^1.0.0

Loading…
Cancel
Save