rewrite convenient phone page

hmxc
张萌 4 years ago
parent e55fb2a1eb
commit 2887f61a66

@ -45,5 +45,8 @@ class _User {
} }
class _Manager { class _Manager {
///
String get commiteeStaff => '/ownersCommittee/findAll'; String get commiteeStaff => '/ownersCommittee/findAll';
///便
String get convenientPhone => '/convenientTelephone/list';
} }

@ -0,0 +1,21 @@
class ConvenientPhoneModel {
int id;
String name;
String tel;
ConvenientPhoneModel({this.id, this.name, this.tel});
ConvenientPhoneModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
tel = json['tel'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['tel'] = this.tel;
return data;
}
}

@ -1,11 +1,14 @@
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/user/convenient_phone_model.dart';
import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_icons/flutter_icons.dart'; import 'package:flutter/material.dart';
import 'package:akuCommunity/utils/headers.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:akuCommunity/widget/sliver_app_bar_delegate.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:akuCommunity/widget/search_bar_delegate.dart'; import 'package:multi_image_picker/multi_image_picker.dart';
import 'widget/phone_list.dart'; import 'package:velocity_x/velocity_x.dart';
import 'package:akuCommunity/const/resource.dart';
class ConvenientPhonePage extends StatefulWidget { class ConvenientPhonePage extends StatefulWidget {
ConvenientPhonePage({Key key}) : super(key: key); ConvenientPhonePage({Key key}) : super(key: key);
@ -15,91 +18,132 @@ class ConvenientPhonePage extends StatefulWidget {
} }
class _ConvenientPhonePageState extends State<ConvenientPhonePage> { class _ConvenientPhonePageState extends State<ConvenientPhonePage> {
Container _containerSearch() { EasyRefreshController _easyRefreshController;
return Container( TextEditingController _textEditingController;
color: Colors.white,
child: InkWell( @override
onTap: () { void initState() {
showSearch(context: context, delegate: SearchBarDelegate()); super.initState();
}, _easyRefreshController = EasyRefreshController();
child: Container( _textEditingController = TextEditingController();
margin: EdgeInsets.only( }
left: 32.w,
right: 32.w, @override
top: 12.w, void dispose() {
bottom: 20.w, _easyRefreshController?.dispose();
), _textEditingController?.dispose();
padding: EdgeInsets.symmetric( super.dispose();
horizontal: 32.w, }
vertical: 16.w,
), Widget _buildTile(ConvenientPhoneModel model) {
decoration: BoxDecoration( return Material(
color: Color(0xfff9f9f9), child: Column(
borderRadius: BorderRadius.all(Radius.circular(36)), children: [
), Row(
child: InkWell( crossAxisAlignment: CrossAxisAlignment.center,
onTap: () {}, children: [
child: Container( Column(
child: Row(children: [ crossAxisAlignment: CrossAxisAlignment.start,
Icon(AntDesign.search1), children: [
SizedBox(width: 5), model.name.text.black.size(32.sp).make(),
Text('搜索机构') 12.heightBox,
]), model.tel.text.color(Color(0xFF999999)).size(28.sp).make(),
), ],
).expand(),
IconButton(
icon: Image.asset(
R.ASSETS_ICONS_PHONE_PNG,
width: 40.w,
height: 40.w,
),
onPressed: () {})
],
), ),
), ],
), ),
); );
} }
List<Widget> _silverBuilder(BuildContext context, bool innerBoxIsScrolled) { // Widget _buildCard(String title, List tableList) {
double statusBarHeight = MediaQuery.of(context).padding.top; // return Material(
double _swiperHeight = 122.w; // child: Padding(
double _spikeHeight = 25; // padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 40.w),
double _appBarHeight = _swiperHeight - _spikeHeight - statusBarHeight; // child: Column(
return <Widget>[ // children: [
SliverAppBar( // title.text.black.size(32.sp).make(),
backgroundColor: Colors.white, // 45.heightBox,
automaticallyImplyLeading: false, // ],
bottom: PreferredSize( // ),
child: Container(), // ),
preferredSize: Size.fromHeight((_appBarHeight).h)), // );
flexibleSpace: Column( // }
children: <Widget>[
_containerSearch(),
],
),
),
SliverPersistentHeader(
pinned: true,
delegate: SliverAppBarDelegate(
minHeight: 45, //
maxHeight: 45,
child: Container(
color: Colors.white,
alignment: Alignment.centerLeft,
padding: EdgeInsets.symmetric(horizontal: 32.w),
child: Text(
'小区服务电话',
style: TextStyle(
fontSize: 32.sp,
),
),
)),
),
];
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BeeScaffold( return BeeScaffold(
title: '便民电话', title: '便民电话',
body: Container( body: Column(
color: Colors.white, children: [
child: NestedScrollView( Container(
headerSliverBuilder: _silverBuilder, width: double.infinity,
body: PhoneList(), constraints: BoxConstraints(minHeight: 72.w + 16.w),
), color: Colors.white,
alignment: Alignment.center,
child: Container(
width: 686.w,
height: 72.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(36.w),
color: Color(0xFFF9F9F9),
),
child: TextField(
controller: _textEditingController,
decoration: InputDecoration(
border: InputBorder.none,
prefixIcon: Icon(
CupertinoIcons.search,
size: 42.w,
),
contentPadding: EdgeInsets.only(top: 14.w),
// isDense: true,
hintText: '搜索机构',
hintStyle:
TextStyle(color: Color(0xFF999999), fontSize: 28.sp),
),
),
),
),
Expanded(
child: BeeListView(
controller: _easyRefreshController,
path: API.manager.convenientPhone,
convert: (model) {
return model.tableList
.map((e) => ConvenientPhoneModel.fromJson(e))
.toList();
},
builder: (items) {
return ListView.separated(
padding:
EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w),
itemBuilder: (context, index) {
return _buildTile(items[index]);
},
separatorBuilder: (context, index) {
return Padding(
padding: EdgeInsets.symmetric(vertical: 20.w),
child: Divider(
thickness: 1.w,
height: 0,
color: Color(0xFFD8D8D8),
),
);
},
itemCount: items.length);
},
),
),
],
), ),
); );
} }

@ -3,8 +3,6 @@ import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/user/committee_item_model.dart'; import 'package:akuCommunity/model/user/committee_item_model.dart';
import 'package:akuCommunity/pages/industry_committee/committee_mailbox/committee_mailbox_page.dart'; import 'package:akuCommunity/pages/industry_committee/committee_mailbox/committee_mailbox_page.dart';
import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart';
import 'package:akuCommunity/utils/network/base_list_model.dart';
import 'package:akuCommunity/utils/network/net_util.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@ -23,36 +21,6 @@ class IndustryCommitteePage extends StatefulWidget {
class _IndustryCommitteePageState extends State<IndustryCommitteePage> { class _IndustryCommitteePageState extends State<IndustryCommitteePage> {
EasyRefreshController _refreshController = EasyRefreshController(); EasyRefreshController _refreshController = EasyRefreshController();
BaseListModel _listModel = BaseListModel.zero();
List<CommitteeItemModel> _committeeModels = [];
int _page = 0;
Future<List<CommitteeItemModel>> _getCommitteeList() async {
_listModel = await NetUtil().getList(API.manager.commiteeStaff, params: {
'pageNum': _page,
'size': 10,
});
return _listModel.tableList
.map((e) => CommitteeItemModel.fromJson(e))
.toList();
}
Future<void> refresh() async {
_page = 0;
_listModel = BaseListModel.zero();
_committeeModels.clear();
_committeeModels = await _getCommitteeList();
setState(() {});
}
Future addPage() async {
_page++;
if (_page >= _listModel.pageCount)
_refreshController.finishLoad(noMore: true);
else
_committeeModels.addAll(await _getCommitteeList());
setState(() {});
}
Widget _buildBottomNavi() { Widget _buildBottomNavi() {
return [ return [
@ -82,7 +50,7 @@ class _IndustryCommitteePageState extends State<IndustryCommitteePage> {
) )
.box .box
.color(Color(0xFF2A2A2A)) .color(Color(0xFF2A2A2A))
.margin(EdgeInsets.only( .padding(EdgeInsets.only(
bottom: MediaQuery.of(context).viewPadding.bottom, bottom: MediaQuery.of(context).viewPadding.bottom,
)) ))
.make() .make()
@ -95,7 +63,7 @@ class _IndustryCommitteePageState extends State<IndustryCommitteePage> {
) )
.box .box
.color(kPrimaryColor) .color(kPrimaryColor)
.margin(EdgeInsets.only( .padding(EdgeInsets.only(
bottom: MediaQuery.of(context).viewPadding.bottom, bottom: MediaQuery.of(context).viewPadding.bottom,
)) ))
.make() .make()
@ -178,20 +146,6 @@ class _IndustryCommitteePageState extends State<IndustryCommitteePage> {
); );
}, },
), ),
// body: EasyRefresh(
// firstRefresh: true,
// header: MaterialHeader(),
// controller: _refreshController,
// onRefresh: refresh,
// child: ListView.separated(
// padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w),
// itemBuilder: (context, index) {
// return _buildCard(_committeeModels[index]);
// },
// separatorBuilder: (context, index) => 20.hb,
// itemCount: _committeeModels.length,
// ),
// ),
bottomNavi: _buildBottomNavi(), bottomNavi: _buildBottomNavi(),
); );
} }

Loading…
Cancel
Save