页面返回自动刷新

hmxc
张萌 4 years ago
parent 68da371190
commit f9d4911149

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

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

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

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

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

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

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

@ -241,6 +241,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.0.1" 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: extended_text:
dependency: "direct main" dependency: "direct main"
description: description:
@ -800,6 +807,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.0" 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: yaml:
dependency: transitive dependency: transitive
description: description:

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

Loading…
Cancel
Save