123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- import 'package:flutter/material.dart';
- import 'package:liftmanager/internal/heavy/provider/heavy_lift_list_provider.dart';
- import 'package:liftmanager/internal/lift/model/lift_list_entity.dart';
- import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
- import 'package:liftmanager/mvp/base_page_state.dart';
- import 'package:liftmanager/res/resources.dart';
- import 'package:liftmanager/widgets/app_bar.dart';
- import 'package:liftmanager/widgets/my_refresh_list.dart';
- import 'package:liftmanager/widgets/search_bar.dart';
- import 'package:liftmanager/widgets/state_layout.dart';
- import 'package:provider/provider.dart' as p;
- class HeavyLiftListPage extends StatefulWidget {
- HeavyLiftListPage(this.projectId);
- final String projectId;
- @override
- HeavyLiftListPageState createState() => HeavyLiftListPageState();
- }
- class HeavyLiftListPageState extends BasePageState<HeavyLiftListPage, HeavyLiftListPresenter> {
- BaseListProvider<LiftListItem> provider = BaseListProvider<LiftListItem>();
- String _keyword = "";
- int _page = 1;
- @override
- void initState() {
- /// 默认为加载中状态,本页面场景默认为空
- provider.setStateTypeNotNotify(StateType.loading);
- super.initState();
- _onRefresh();
- }
- @override
- Widget build(BuildContext context) {
- return p.ChangeNotifierProvider<BaseListProvider<LiftListItem>>(
- create: (_) => provider,
- child: Scaffold(
- appBar: MyAppBar(
- centerTitle: "大修电梯列表",
- ),
- body: Container(
- color: Color(0xFFF1F4FC),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Container(
- color: Colors.white,
- padding:
- EdgeInsets.only(top: 10, bottom: 10, left: 15, right: 15),
- child: SearchBar(
- autofocus: false,
- hintText: "搜索电梯",
- onPressed: (text) {
- print(widget.projectId);
- _keyword = text;
- provider.setStateType(StateType.loading);
- _page = 1;
- presenter.searchLift(context,
- widget.projectId, _keyword, _page, true);
- },
- ),
- ),
- Expanded(
- flex: 1,
- child: p.Consumer<BaseListProvider<LiftListItem>>(
- builder: (_, provider, __) {
- return MyListView(
- key: Key('lift_list'),
- itemCount: provider.list.length,
- stateType: provider.stateType,
- onRefresh: _onRefresh,
- loadMore: _loadMore,
- // itemExtent: 67.0,
- hasMore: provider.hasMore,
- itemBuilder: (_, index) {
- return Container(
- margin: EdgeInsets.fromLTRB(15, 5, 15, 5),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(6.0),
- ),
- padding: const EdgeInsets.only(bottom: 10),
- child: Column(
- children: <Widget>[
- Container(
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 0.5, color: Colours.text_gray_c),
- )),
- padding: EdgeInsets.only(left: 12),
- child: Row(
- children: <Widget>[
- Expanded(
- flex: 1,
- child: Text(
- provider.list[index].useCompanyCode,
- style: TextStyles.text15,
- overflow: TextOverflow.ellipsis,
- softWrap: false, //单行显示
- )),
- // MyButton(
- // key: const Key('lift_list'),
- // onPressed: () {
- //// _liftList(provider.list[index].id);
- // NavigatorUtils.push(context, "${LiftRouter.liftDetailPage}?project_id="+widget.projectId+"&id="+provider.list[index].id);
- // },
- // height: 25,
- // fontSize: 11,
- // colors: [
- // Colours.app_main,
- // Colours.app_main
- // ],
- // borderWidth: 0.5,
- // borderColor: Colours.app_main,
- // text: "查看详情",
- // )
- ],
- ),
- ),
- lineTxt("注册代码",
- "${provider.list[index].registrationCode}"),
- lineTxt(
- "电梯型号", "${provider.list[index].liftCode}"),
- lineTxt(
- "电梯类型", "${provider.list[index].liftTypeName}"),
- lineTxt(
- "电梯品牌", "${provider.list[index].liftBrand}")
- ],
- ),
- );
- },
- );
- }))
- ],
- ),
- ),
- ));
- }
- Widget lineTxt(title, value) {
- return Container(
- padding: EdgeInsets.only(left: 12, top: 5, right: 12),
- child: Row(
- children: <Widget>[
- Text("${title}",
- style: TextStyle(fontSize: 13, color: Colours.dark_text_gray)),
- Expanded(
- flex: 1,
- child: Text(
- "${value}",
- textAlign: TextAlign.right,
- style: TextStyle(fontSize: 13, color: Colours.dark_text_gray),
- ),
- )
- ],
- ),
- );
- }
- Future _onRefresh() async {
- _page = 1;
- await presenter.searchLift(context,widget.projectId, _keyword, _page, false);
- }
- Future _loadMore() async {
- _page++;
- await presenter.searchLift(context,widget.projectId, _keyword, _page, false);
- }
- @override
- HeavyLiftListPresenter createPresenter() {
- return HeavyLiftListPresenter();
- }
- }
|