main.dart 8.0 KB

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