|
@@ -1,3 +1,4 @@
|
|
|
+import 'package:flutter/cupertino.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:taskservice/Common/JXColors.dart';
|
|
|
import 'package:taskservice/Model/JXMemberModel.dart';
|
|
@@ -53,96 +54,141 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
|
/*tableView*/
|
|
|
List<JXMemberModel> _datasource = List();
|
|
|
+ List<JXMemberModel> _basesource = List();
|
|
|
+
|
|
|
+ @override
|
|
|
+ void initState() {
|
|
|
+ // TODO: implement initState
|
|
|
+ super.initState();
|
|
|
+ _basesource = [
|
|
|
+ JXMemberModel()
|
|
|
+ ..name = 'Jack'
|
|
|
+ ..tel = '156000'
|
|
|
+ ..addr = '广州',
|
|
|
+ JXMemberModel()
|
|
|
+ ..name = 'Ros'
|
|
|
+ ..tel = '1523'
|
|
|
+ ..addr = '广州12',
|
|
|
+ JXMemberModel()
|
|
|
+ ..name = 'Rose'
|
|
|
+ ..tel = '156186'
|
|
|
+ ..addr = '广州12',
|
|
|
+ JXMemberModel()
|
|
|
+ ..name = 'Base'
|
|
|
+ ..tel = '186'
|
|
|
+ ..addr = '广州12',
|
|
|
+ ];
|
|
|
+ _datasource = List.from(_basesource);
|
|
|
+ }
|
|
|
|
|
|
/*筛选列表数据*/
|
|
|
- void filterListView() {
|
|
|
- print('筛选:$_searchText');
|
|
|
+ void filterMember() {
|
|
|
String text = _searchText;
|
|
|
+
|
|
|
+ List tmpItems = [];
|
|
|
+ _datasource.clear();
|
|
|
+ print('筛选:$_searchText');
|
|
|
+ if (text.isEmpty) {
|
|
|
+ tmpItems.addAll(_basesource);
|
|
|
+ } else {
|
|
|
+ for (JXMemberModel member in _basesource) {
|
|
|
+ bool has = false;
|
|
|
+ /*filter name*/
|
|
|
+ if (member.name.toLowerCase().contains(text.toLowerCase())) {
|
|
|
+ tmpItems.add(member);
|
|
|
+ has = true;
|
|
|
+ }
|
|
|
+ /*filter tel*/
|
|
|
+ if (!has && (member.tel.contains(text))) {
|
|
|
+ tmpItems.add(member);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _datasource = tmpItems;
|
|
|
+ setState(() {});
|
|
|
}
|
|
|
|
|
|
/*cell*/
|
|
|
Widget theCellBuilder(BuildContext context, int row) {
|
|
|
+ if (row >= _datasource.length) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JXMemberModel model = _datasource[row];
|
|
|
return GestureDetector(
|
|
|
- onTap: () {
|
|
|
- print('click cell, row:$row');
|
|
|
- },
|
|
|
- child: Container(
|
|
|
- height: 92.0,
|
|
|
- alignment: Alignment.topCenter,
|
|
|
+ onTap: () {
|
|
|
+ print('click cell, row:$row');
|
|
|
+ },
|
|
|
child: Container(
|
|
|
- height: 80.0,
|
|
|
- alignment: Alignment.center,
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: JXColors.kFFFFFF,
|
|
|
- borderRadius: BorderRadius.all(Radius.circular(8.0)),
|
|
|
- border: Border(
|
|
|
- bottom: BorderSide(
|
|
|
+ height: 92.0,
|
|
|
+ alignment: Alignment.topCenter,
|
|
|
+ child: Container(
|
|
|
+ height: 80.0,
|
|
|
+ alignment: Alignment.center,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: JXColors.kFFFFFF,
|
|
|
+ borderRadius: BorderRadius.all(Radius.circular(8.0)),
|
|
|
+ border: Border.all(
|
|
|
color: JXColors.kE6E6E6,
|
|
|
),
|
|
|
),
|
|
|
- ),
|
|
|
- child: Column(
|
|
|
- mainAxisAlignment: MainAxisAlignment.start,
|
|
|
- children: <Widget>[
|
|
|
- Container(
|
|
|
- padding: EdgeInsets.only(left: 12.0, right: 12.0),
|
|
|
- height: 30.0,
|
|
|
- alignment: Alignment.center,
|
|
|
- color: Colors.blue,
|
|
|
- child: Row (
|
|
|
+ child: Column(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
+ children: <Widget>[
|
|
|
+ Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
children: <Widget>[
|
|
|
Container(
|
|
|
- padding: EdgeInsets.only(left: 12.0),
|
|
|
- width: 80.0,
|
|
|
+ padding: EdgeInsets.only(left: 12.0,top: 12.0),
|
|
|
+ width: 120.0,
|
|
|
child: Text(
|
|
|
- 'Poto',
|
|
|
+ model.name,
|
|
|
style: TextStyle(
|
|
|
fontSize: 16,
|
|
|
color: JXColors.k2E3032,
|
|
|
- backgroundColor: JXColors.kE6E6E6,
|
|
|
),
|
|
|
),
|
|
|
),
|
|
|
Expanded(
|
|
|
- child: Text(
|
|
|
- 'Right',
|
|
|
- textAlign: TextAlign.right,
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 16,
|
|
|
- color: JXColors.k2E3032,
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.only(top: 12.0, right: 12.0),
|
|
|
+ child: Text(
|
|
|
+ model.tel,
|
|
|
+ textAlign: TextAlign.right,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 16,
|
|
|
+ color: JXColors.k2E3032,
|
|
|
+ ),
|
|
|
),
|
|
|
- ),
|
|
|
+ )
|
|
|
)
|
|
|
],
|
|
|
),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- padding: EdgeInsets.only(left: 24, right: 12),
|
|
|
- child: Text(
|
|
|
- '任务',
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 16,
|
|
|
- color: JXColors.k2E3032,
|
|
|
- ),
|
|
|
- ),
|
|
|
- )
|
|
|
- ],
|
|
|
+ Row (
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Expanded(
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.only(left: 18, top: 12, right: 18),
|
|
|
+ child: Text(
|
|
|
+ '任务:${model.addr}',
|
|
|
+ overflow: TextOverflow.ellipsis,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 16,
|
|
|
+ color: JXColors.k2E3032,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
),
|
|
|
- ),
|
|
|
- )
|
|
|
- );
|
|
|
+ ));
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- for (int i = 0; i < 10; i++) {
|
|
|
- JXMemberModel model = JXMemberModel();
|
|
|
- model.name = 'Poto';
|
|
|
- model.tel = '1560000';
|
|
|
- model.addr = '详细地址';
|
|
|
- _datasource.add(model);
|
|
|
- }
|
|
|
return GestureDetector(
|
|
|
onTap: () {
|
|
|
FocusScope.of(context).requestFocus(blankNode);
|
|
@@ -181,16 +227,13 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
),
|
|
|
),
|
|
|
onSubmitted: (value) {
|
|
|
- setState(() {
|
|
|
- _searchText = value;
|
|
|
- });
|
|
|
- filterListView();
|
|
|
+ _searchText = value;
|
|
|
+ filterMember();
|
|
|
},
|
|
|
),
|
|
|
),
|
|
|
])),
|
|
|
Expanded(
|
|
|
- flex: 1,
|
|
|
child: Container(
|
|
|
color: JXColors.kF0F0F0,
|
|
|
child: ListView.builder(
|
|
@@ -202,38 +245,44 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
},
|
|
|
),
|
|
|
)),
|
|
|
- Container(
|
|
|
- color: JXColors.kF0F0F0,
|
|
|
- height: 44.0,
|
|
|
- child: Row(
|
|
|
- children: <Widget>[
|
|
|
- Expanded(
|
|
|
- child: FlatButton(
|
|
|
- onPressed: () {
|
|
|
- print('新建会员');
|
|
|
- },
|
|
|
- padding: EdgeInsets.all(0),
|
|
|
- color: JXColors.kFFFFFF,
|
|
|
- textColor: JXColors.k1F2529,
|
|
|
- child: const Text('新建会员',
|
|
|
- style: TextStyle(fontSize: 14)),
|
|
|
- ),
|
|
|
- ),
|
|
|
- Expanded(
|
|
|
- child: FlatButton(
|
|
|
- onPressed: () {
|
|
|
- print('会员列表');
|
|
|
- },
|
|
|
- padding: EdgeInsets.all(0),
|
|
|
- color: JXColors.k1F2529,
|
|
|
- textColor: JXColors.kFFFFFF,
|
|
|
- child: const Text('会员列表',
|
|
|
- style: TextStyle(fontSize: 14)),
|
|
|
- ),
|
|
|
+ Row (
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
+ children: <Widget>[
|
|
|
+ Expanded(
|
|
|
+ child: FlatButton(
|
|
|
+ onPressed: () {
|
|
|
+ print('新建会员');
|
|
|
+ setState(() {
|
|
|
+ for (int i = 0; i < 2; i++) {
|
|
|
+ JXMemberModel model = JXMemberModel();
|
|
|
+ model.name = 'Poto';
|
|
|
+ model.tel = '1560000';
|
|
|
+ model.addr = '详细地址';
|
|
|
+ _datasource.add(model);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ padding: EdgeInsets.all(0),
|
|
|
+ color: JXColors.kF0F0F0,
|
|
|
+ textColor: JXColors.k1F2529,
|
|
|
+ child: Text('新建会员',
|
|
|
+ style: TextStyle(fontSize: 14)),
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: FlatButton(
|
|
|
+ onPressed: () {
|
|
|
+ print('会员列表');
|
|
|
+ },
|
|
|
+ padding: EdgeInsets.all(0),
|
|
|
+ color: JXColors.k1F2529,
|
|
|
+ textColor: JXColors.kFFFFFF,
|
|
|
+ child: const Text('会员列表',
|
|
|
+ style: TextStyle(fontSize: 14)),
|
|
|
),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ )
|
|
|
],
|
|
|
),
|
|
|
),
|