页面返回自动刷新

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;
} }

@ -8,8 +8,9 @@ import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart'; 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,13 +101,17 @@ class _BusinessFixCardState extends State<BusinessFixCard> {
), ),
), ),
Text( Text(
AkuMap.fixStatus(userInfoModel.canSendTicket, widget.hasFinished
userInfoModel.canPickUpTicket, widget.model.status), ? '已处理'
style: TextStyle( : AkuMap.fixStatus(userInfoModel.canSendTicket,
color: widget.model.status < 4 userInfoModel.canPickUpTicket, widget.model.status),
? Color(0XFFFF4501) style: widget.hasFinished
: AppStyle.minorTextColor, ? 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 ? 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,76 +289,97 @@ class _FixWorkFinishPageState extends State<FixWorkFinishPage> {
title: '费用明细', title: '费用明细',
spacing: 16, spacing: 16,
children: [ children: [
Row( SizedBox(
children: [ height: 96.w,
AkuBox.h(96), child: Row(
Text('人工费'), children: [
Expanded( Text(
child: TextField( '人工费',
controller: _humanController, style:
onChanged: (_) => setState(() {}), TextStyle(color: Colors.black, fontSize: 28.sp),
keyboardType: TextInputType.number, ),
textAlign: TextAlign.end, Expanded(
decoration: InputDecoration( child: TextField(
border: InputBorder.none, controller: _humanController,
hintText: '请输入', onChanged: (_) => setState(() {}),
hintStyle: TextStyle( keyboardType: TextInputType.number,
fontWeight: FontWeight.bold, textAlign: TextAlign.end,
fontSize: 28.sp, decoration: InputDecoration(
color: AppStyle.minorTextColor, border: InputBorder.none,
hintText: '请输入',
hintStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 28.sp,
color: AppStyle.minorTextColor,
),
), ),
), ),
), ),
), ],
], ),
), ),
Divider(height: 1.w), Divider(height: 1.w),
Row( SizedBox(
children: [ height: 96.w,
AkuBox.h(96), child: Row(
Text('材料费'), children: [
Expanded( Text(
child: TextField( '材料费',
onChanged: (_) => setState(() {}), style:
controller: _materialPriceController, TextStyle(color: Colors.black, fontSize: 28.sp),
textAlign: TextAlign.end, ),
keyboardType: TextInputType.number, Expanded(
decoration: InputDecoration( child: TextField(
border: InputBorder.none, onChanged: (_) => setState(() {}),
hintText: '请输入', controller: _materialPriceController,
hintStyle: TextStyle( textAlign: TextAlign.end,
fontWeight: FontWeight.bold, keyboardType: TextInputType.number,
fontSize: 28.sp, decoration: InputDecoration(
color: AppStyle.minorTextColor, border: InputBorder.none,
hintText: '请输入',
hintStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 28.sp,
color: AppStyle.minorTextColor,
),
), ),
), ),
), ),
), ],
], ),
), ),
Divider(height: 1.w), Divider(height: 1.w),
Row( SizedBox(
children: [ height: 96.w,
AkuBox.h(96), child: Row(
Text('总计费用'), children: [
Spacer(), Text(
Builder( '总计费用',
builder: (context) { style:
if (TextUtil.isEmpty(_humanController.text) || TextStyle(color: Colors.black, fontSize: 28.sp),
TextUtil.isEmpty( ),
_materialPriceController.text)) { Spacer(),
return Text('人工费或材料费不能为空'); Builder(
} else { builder: (context) {
humanPrice = if (TextUtil.isEmpty(_humanController.text) ||
double.tryParse(_humanController.text); TextUtil.isEmpty(
materialPrice = double.tryParse( _materialPriceController.text)) {
_materialPriceController.text); return Text('人工费或材料费不能为空');
} } else {
return Text( humanPrice =
'¥${(humanPrice + materialPrice).toStringAsFixed(2)}'); double.tryParse(_humanController.text);
}, materialPrice = double.tryParse(
), _materialPriceController.text);
], }
return Text(
'¥${(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