|
@@ -1,8 +1,7 @@
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
-import 'package:taskservice/Common/JXColors.dart';
|
|
|
-import 'package:taskservice/Model/JXMemberModel.dart';
|
|
|
import 'package:taskservice/src/crtacc/page_crtacc.dart';
|
|
|
+import 'package:taskservice/src/home/home.dart';
|
|
|
|
|
|
void main() {
|
|
|
runApp(MyApp());
|
|
@@ -13,279 +12,20 @@ class MyApp extends StatelessWidget {
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return MaterialApp(
|
|
|
- title: 'JXZS',
|
|
|
+ onGenerateRoute: (RouteSettings settings){
|
|
|
+ var name = settings.name;
|
|
|
+ if(name == '$CreateAccPage') {
|
|
|
+ return CupertinoPageRoute(builder: (context)=> CreateAccPage());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ },
|
|
|
theme: ThemeData(
|
|
|
- // This is the theme of your application.
|
|
|
- //
|
|
|
- // Try running your application with "flutter run". You'll see the
|
|
|
- // application has a blue toolbar. Then, without quitting the app, try
|
|
|
- // changing the primarySwatch below to Colors.green and then invoke
|
|
|
- // "hot reload" (press "r" in the console where you ran "flutter run",
|
|
|
- // or simply save your changes to "hot reload" in a Flutter IDE).
|
|
|
- // Notice that the counter didn't reset back to zero; the application
|
|
|
- // is not restarted.
|
|
|
primarySwatch: Colors.blue,
|
|
|
- // This makes the visual density adapt to the platform that you ru
|
|
|
- // the app on. For desktop platforms, the controls will be smaller and
|
|
|
- // closer together (more dense) than on mobile platforms.
|
|
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
|
),
|
|
|
- home: CreateAccPage(),
|
|
|
+ home: MyHomePage(title: 'JXZS',),
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class MyHomePage extends StatefulWidget {
|
|
|
- MyHomePage({Key key, this.title}) : super(key: key);
|
|
|
-
|
|
|
- final String title;
|
|
|
-
|
|
|
- @override
|
|
|
- _MyHomePageState createState() => _MyHomePageState();
|
|
|
-}
|
|
|
-
|
|
|
-class _MyHomePageState extends State<MyHomePage> {
|
|
|
- // 参数
|
|
|
- /*空白区域键盘消失控制*/
|
|
|
- FocusNode blankNode = FocusNode();
|
|
|
-
|
|
|
- /*搜索值*/
|
|
|
- String _searchText;
|
|
|
-
|
|
|
- /*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 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,
|
|
|
- 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>[
|
|
|
- Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.start,
|
|
|
- children: <Widget>[
|
|
|
- Container(
|
|
|
- padding: EdgeInsets.only(left: 12.0,top: 12.0),
|
|
|
- width: 120.0,
|
|
|
- child: Text(
|
|
|
- model.name,
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 16,
|
|
|
- color: JXColors.k2E3032,
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- Expanded(
|
|
|
- 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,
|
|
|
- ),
|
|
|
- ),
|
|
|
- )
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
- 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) {
|
|
|
- return GestureDetector(
|
|
|
- onTap: () {
|
|
|
- FocusScope.of(context).requestFocus(blankNode);
|
|
|
- },
|
|
|
- child: Scaffold(
|
|
|
- appBar: AppBar(
|
|
|
- title: Text(widget.title),
|
|
|
- ),
|
|
|
- body: SafeArea(
|
|
|
- child: Column(
|
|
|
- mainAxisAlignment: MainAxisAlignment.start,
|
|
|
- children: <Widget>[
|
|
|
- Container(
|
|
|
- color: JXColors.kF0F0F0,
|
|
|
- alignment: Alignment.center,
|
|
|
- padding: EdgeInsets.fromLTRB(12.0, 4.0, 12.0, 4.0),
|
|
|
- height: 50.0,
|
|
|
- child: Row(children: <Widget>[
|
|
|
- Container(
|
|
|
- width: 44.0,
|
|
|
- child: Icon(
|
|
|
- Icons.search,
|
|
|
- size: 24.0,
|
|
|
- )),
|
|
|
- Expanded(
|
|
|
- child: TextField(
|
|
|
- focusNode: blankNode,
|
|
|
- obscureText: false,
|
|
|
- cursorColor: JXColors.k1F2529,
|
|
|
- decoration: InputDecoration(
|
|
|
- border: InputBorder.none,
|
|
|
- hintText: '快速筛选',
|
|
|
- labelStyle: TextStyle(
|
|
|
- color: JXColors.k2E3032,
|
|
|
- fontSize: 18,
|
|
|
- ),
|
|
|
- ),
|
|
|
- onSubmitted: (value) {
|
|
|
- _searchText = value;
|
|
|
- filterMember();
|
|
|
- },
|
|
|
- ),
|
|
|
- ),
|
|
|
- ])),
|
|
|
- Expanded(
|
|
|
- child: Container(
|
|
|
- color: JXColors.kF0F0F0,
|
|
|
- child: ListView.builder(
|
|
|
- padding: EdgeInsets.only(left: 12.0, right: 12.0),
|
|
|
- itemCount: _datasource.length,
|
|
|
- itemExtent: 92.0,
|
|
|
- itemBuilder: (BuildContext context, int row) {
|
|
|
- return theCellBuilder(context, row);
|
|
|
- },
|
|
|
- ),
|
|
|
- )),
|
|
|
- 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)),
|
|
|
- ),
|
|
|
- ),
|
|
|
- ],
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- ));
|
|
|
- }
|
|
|
-}
|