main.dart 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:taskservice/Common/JXColors.dart';
  4. import 'package:taskservice/Model/JXMemberModel.dart';
  5. import 'package:taskservice/src/crtacc/page_crtacc.dart';
  6. void main() {
  7. runApp(MyApp());
  8. }
  9. class MyApp extends StatelessWidget {
  10. // This widget is the root of your application.
  11. @override
  12. Widget build(BuildContext context) {
  13. return MaterialApp(
  14. title: 'JXZS',
  15. theme: ThemeData(
  16. // This is the theme of your application.
  17. //
  18. // Try running your application with "flutter run". You'll see the
  19. // application has a blue toolbar. Then, without quitting the app, try
  20. // changing the primarySwatch below to Colors.green and then invoke
  21. // "hot reload" (press "r" in the console where you ran "flutter run",
  22. // or simply save your changes to "hot reload" in a Flutter IDE).
  23. // Notice that the counter didn't reset back to zero; the application
  24. // is not restarted.
  25. primarySwatch: Colors.blue,
  26. // This makes the visual density adapt to the platform that you ru
  27. // the app on. For desktop platforms, the controls will be smaller and
  28. // closer together (more dense) than on mobile platforms.
  29. visualDensity: VisualDensity.adaptivePlatformDensity,
  30. ),
  31. home: CreateAccPage(),
  32. );
  33. }
  34. }
  35. class MyHomePage extends StatefulWidget {
  36. MyHomePage({Key key, this.title}) : super(key: key);
  37. final String title;
  38. @override
  39. _MyHomePageState createState() => _MyHomePageState();
  40. }
  41. class _MyHomePageState extends State<MyHomePage> {
  42. // 参数
  43. /*空白区域键盘消失控制*/
  44. FocusNode blankNode = FocusNode();
  45. /*搜索值*/
  46. String _searchText;
  47. /*tableView*/
  48. List<JXMemberModel> _datasource = List();
  49. List<JXMemberModel> _basesource = List();
  50. @override
  51. void initState() {
  52. // TODO: implement initState
  53. super.initState();
  54. _basesource = [
  55. JXMemberModel()
  56. ..name = 'Jack'
  57. ..tel = '156000'
  58. ..addr = '广州',
  59. JXMemberModel()
  60. ..name = 'Ros'
  61. ..tel = '1523'
  62. ..addr = '广州12',
  63. JXMemberModel()
  64. ..name = 'Rose'
  65. ..tel = '156186'
  66. ..addr = '广州12',
  67. JXMemberModel()
  68. ..name = 'Base'
  69. ..tel = '186'
  70. ..addr = '广州12',
  71. ];
  72. _datasource = List.from(_basesource);
  73. }
  74. /*筛选列表数据*/
  75. void filterMember() {
  76. String text = _searchText;
  77. List tmpItems = [];
  78. _datasource.clear();
  79. print('筛选:$_searchText');
  80. if (text.isEmpty) {
  81. tmpItems.addAll(_basesource);
  82. } else {
  83. for (JXMemberModel member in _basesource) {
  84. bool has = false;
  85. /*filter name*/
  86. if (member.name.toLowerCase().contains(text.toLowerCase())) {
  87. tmpItems.add(member);
  88. has = true;
  89. }
  90. /*filter tel*/
  91. if (!has && (member.tel.contains(text))) {
  92. tmpItems.add(member);
  93. }
  94. }
  95. }
  96. _datasource = tmpItems;
  97. setState(() {});
  98. }
  99. /*cell*/
  100. Widget theCellBuilder(BuildContext context, int row) {
  101. if (row >= _datasource.length) {
  102. return null;
  103. }
  104. JXMemberModel model = _datasource[row];
  105. return GestureDetector(
  106. onTap: () {
  107. print('click cell, row:$row');
  108. },
  109. child: Container(
  110. height: 92.0,
  111. alignment: Alignment.topCenter,
  112. child: Container(
  113. height: 80.0,
  114. alignment: Alignment.center,
  115. decoration: BoxDecoration(
  116. color: JXColors.kFFFFFF,
  117. borderRadius: BorderRadius.all(Radius.circular(8.0)),
  118. border: Border.all(
  119. color: JXColors.kE6E6E6,
  120. ),
  121. ),
  122. child: Column(
  123. mainAxisAlignment: MainAxisAlignment.start,
  124. children: <Widget>[
  125. Row(
  126. mainAxisAlignment: MainAxisAlignment.start,
  127. children: <Widget>[
  128. Container(
  129. padding: EdgeInsets.only(left: 12.0,top: 12.0),
  130. width: 120.0,
  131. child: Text(
  132. model.name,
  133. style: TextStyle(
  134. fontSize: 16,
  135. color: JXColors.k2E3032,
  136. ),
  137. ),
  138. ),
  139. Expanded(
  140. child: Container(
  141. padding: EdgeInsets.only(top: 12.0, right: 12.0),
  142. child: Text(
  143. model.tel,
  144. textAlign: TextAlign.right,
  145. style: TextStyle(
  146. fontSize: 16,
  147. color: JXColors.k2E3032,
  148. ),
  149. ),
  150. )
  151. )
  152. ],
  153. ),
  154. Row (
  155. mainAxisAlignment: MainAxisAlignment.start,
  156. children: [
  157. Expanded(
  158. child: Container(
  159. padding: EdgeInsets.only(left: 18, top: 12, right: 18),
  160. child: Text(
  161. '任务:${model.addr}',
  162. overflow: TextOverflow.ellipsis,
  163. style: TextStyle(
  164. fontSize: 16,
  165. color: JXColors.k2E3032,
  166. ),
  167. ),
  168. ),
  169. )
  170. ],
  171. )
  172. ],
  173. ),
  174. ),
  175. ));
  176. }
  177. @override
  178. Widget build(BuildContext context) {
  179. return GestureDetector(
  180. onTap: () {
  181. FocusScope.of(context).requestFocus(blankNode);
  182. },
  183. child: Scaffold(
  184. appBar: AppBar(
  185. title: Text(widget.title),
  186. ),
  187. body: SafeArea(
  188. child: Column(
  189. mainAxisAlignment: MainAxisAlignment.start,
  190. children: <Widget>[
  191. Container(
  192. color: JXColors.kF0F0F0,
  193. alignment: Alignment.center,
  194. padding: EdgeInsets.fromLTRB(12.0, 4.0, 12.0, 4.0),
  195. height: 50.0,
  196. child: Row(children: <Widget>[
  197. Container(
  198. width: 44.0,
  199. child: Icon(
  200. Icons.search,
  201. size: 24.0,
  202. )),
  203. Expanded(
  204. child: TextField(
  205. focusNode: blankNode,
  206. obscureText: false,
  207. cursorColor: JXColors.k1F2529,
  208. decoration: InputDecoration(
  209. border: InputBorder.none,
  210. hintText: '快速筛选',
  211. labelStyle: TextStyle(
  212. color: JXColors.k2E3032,
  213. fontSize: 18,
  214. ),
  215. ),
  216. onSubmitted: (value) {
  217. _searchText = value;
  218. filterMember();
  219. },
  220. ),
  221. ),
  222. ])),
  223. Expanded(
  224. child: Container(
  225. color: JXColors.kF0F0F0,
  226. child: ListView.builder(
  227. padding: EdgeInsets.only(left: 12.0, right: 12.0),
  228. itemCount: _datasource.length,
  229. itemExtent: 92.0,
  230. itemBuilder: (BuildContext context, int row) {
  231. return theCellBuilder(context, row);
  232. },
  233. ),
  234. )),
  235. Row (
  236. mainAxisAlignment: MainAxisAlignment.start,
  237. children: <Widget>[
  238. Expanded(
  239. child: FlatButton(
  240. onPressed: () {
  241. print('新建会员');
  242. setState(() {
  243. for (int i = 0; i < 2; i++) {
  244. JXMemberModel model = JXMemberModel();
  245. model.name = 'Poto';
  246. model.tel = '1560000';
  247. model.addr = '详细地址';
  248. _datasource.add(model);
  249. }
  250. });
  251. },
  252. padding: EdgeInsets.all(0),
  253. color: JXColors.kF0F0F0,
  254. textColor: JXColors.k1F2529,
  255. child: Text('新建会员',
  256. style: TextStyle(fontSize: 14)),
  257. )
  258. ),
  259. Expanded(
  260. child: FlatButton(
  261. onPressed: () {
  262. print('会员列表');
  263. },
  264. padding: EdgeInsets.all(0),
  265. color: JXColors.k1F2529,
  266. textColor: JXColors.kFFFFFF,
  267. child: const Text('会员列表',
  268. style: TextStyle(fontSize: 14)),
  269. ),
  270. ),
  271. ],
  272. )
  273. ],
  274. ),
  275. ),
  276. ));
  277. }
  278. }