diff --git a/lib/new_ui/work_order/distributor/work_order_distributor_page.dart b/lib/new_ui/work_order/distributor/work_order_distributor_page.dart index 561bbf0..8908afe 100644 --- a/lib/new_ui/work_order/distributor/work_order_distributor_page.dart +++ b/lib/new_ui/work_order/distributor/work_order_distributor_page.dart @@ -1,5 +1,6 @@ import 'package:aku_new_community_manager/const/saas_api.dart'; import 'package:aku_new_community_manager/new_ui/work_order/distributor/distributor_card.dart'; +import 'package:aku_new_community_manager/new_ui/work_order/distributor/work_order_distributor_view.dart'; import 'package:aku_new_community_manager/saas_models/work_order/work_order_list_model.dart'; import 'package:aku_new_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_new_community_manager/ui/widgets/inner/aku_tab_bar.dart'; @@ -32,20 +33,20 @@ class _WorkOrderDistributorPageState extends State '已取消' ]; late TabController _tabController; - EasyRefreshController _refreshController = EasyRefreshController(); - int _page = 1; - int _size = 10; - List _models = []; + List _refreshControllers = []; @override void initState() { + _refreshControllers = List.filled(_tabs.length, EasyRefreshController()); _tabController = TabController(length: _tabs.length, vsync: this); super.initState(); } @override void dispose() { - _refreshController.dispose(); + _refreshControllers.forEach((element) { + element.dispose(); + }); _tabController.dispose(); super.dispose(); } @@ -73,51 +74,8 @@ class _WorkOrderDistributorPageState extends State body: TabBarView( controller: _tabController, children: - _tabs.mapIndexed((e, index) => _getOrderView(index)).toList()), + _tabs.mapIndexed((e, index) => WorkOrderDistributorView(refreshController: _refreshControllers[index], index: index, + )).toList()), ); } - - Widget _getOrderView(int index) { - return EasyRefresh( - firstRefresh: true, - header: MaterialHeader(), - onRefresh: () async { - _page = 1; - var base = await NetUtil().getList(SAASAPI.workOrder.list, params: { - 'pageNum': _page, - 'size': _size, - 'status': index == 0 ? null : index, - }); - _models = - base.rows.map((e) => WorkOrderListModel.fromJson(e)).toList(); - setState(() {}); - }, - onLoad: () async { - _page++; - var base = await NetUtil().getList(SAASAPI.workOrder.list, params: { - 'pageNum': _page, - 'size': _size, - 'status': index == 0 ? null : index, - }); - if (_models.length < base.total) { - _models.addAll( - base.rows.map((e) => WorkOrderListModel.fromJson(e)).toList()); - setState(() {}); - } else { - _refreshController.finishLoad(); - } - }, - child: ListView.separated( - padding: EdgeInsets.all(24.w), - itemBuilder: (context, index) { - return DistributorCard( - model: _models[index], - refresh: _refreshController.callRefresh, - ); - }, - separatorBuilder: (context, index) { - return 24.w.heightBox; - }, - itemCount: _models.length)); - } } diff --git a/lib/new_ui/work_order/distributor/work_order_distributor_view.dart b/lib/new_ui/work_order/distributor/work_order_distributor_view.dart new file mode 100644 index 0000000..e77c27e --- /dev/null +++ b/lib/new_ui/work_order/distributor/work_order_distributor_view.dart @@ -0,0 +1,69 @@ +import 'package:aku_new_community_manager/style/app_style.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:velocity_x/velocity_x.dart'; + +import '../../../const/saas_api.dart'; +import '../../../saas_models/work_order/work_order_list_model.dart'; +import '../../../utils/network/net_util.dart'; +import 'distributor_card.dart'; + +class WorkOrderDistributorView extends StatefulWidget { + final EasyRefreshController refreshController; + final int index; + const WorkOrderDistributorView({Key? key, required this.refreshController, required this.index}) : super(key: key); + + @override + _WorkOrderDistributorViewState createState() => _WorkOrderDistributorViewState(); +} + +class _WorkOrderDistributorViewState extends State { + int _page = 1; + int _size = 10; + List _models = []; + + @override + Widget build(BuildContext context) { + return EasyRefresh( + firstRefresh: true, + header: MaterialHeader(), + onRefresh: () async { + _page = 1; + var base = await NetUtil().getList(SAASAPI.workOrder.list, params: { + 'pageNum': _page, + 'size': _size, + 'status': widget.index == 0 ? null : widget.index, + }); + _models = + base.rows.map((e) => WorkOrderListModel.fromJson(e)).toList(); + setState(() {}); + }, + onLoad: () async { + _page++; + var base = await NetUtil().getList(SAASAPI.workOrder.list, params: { + 'pageNum': _page, + 'size': _size, + 'status': widget.index == 0 ? null : widget.index, + }); + if (_models.length < base.total) { + _models.addAll( + base.rows.map((e) => WorkOrderListModel.fromJson(e)).toList()); + setState(() {}); + } else { + widget.refreshController.finishLoad(); + } + }, + child: ListView.separated( + padding: EdgeInsets.all(24.w), + itemBuilder: (context, index) { + return DistributorCard( + model: _models[index], + refresh: widget.refreshController.callRefresh, + ); + }, + separatorBuilder: (context, index) { + return 24.w.heightBox; + }, + itemCount: _models.length)); + } +} diff --git a/lib/ui/home/messages/announce_card.dart b/lib/ui/home/messages/announce_card.dart index b61c5a4..6b0fa82 100644 --- a/lib/ui/home/messages/announce_card.dart +++ b/lib/ui/home/messages/announce_card.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; import '../../../models/message/notice_model.dart'; import 'announce_view.dart';