index.dart 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. import 'package:flutter/material.dart';
  2. import 'package:fun_selfie_app/pages/home/setting.dart';
  3. import 'package:fun_selfie_app/pages/home/search_bar.dart';
  4. import 'package:fun_selfie_app/utils/api.dart';
  5. import 'package:fun_selfie_app/widgets/my_refresh_list.dart';
  6. class HomePage extends StatefulWidget {
  7. const HomePage({Key? key}) : super(key: key);
  8. @override
  9. State<StatefulWidget> createState() => _HomePageState();
  10. }
  11. class _HomePageState extends State<HomePage> {
  12. bool isUp = false;
  13. int currentPage = 1;
  14. int totalPage = 0;
  15. final ScrollController _controller = ScrollController();
  16. // List listData = [];
  17. @override
  18. void initState() {
  19. super.initState();
  20. // 初始化的时候开启倒计时
  21. getList();
  22. }
  23. @override
  24. Widget build(BuildContext context) {
  25. return Scaffold(
  26. appBar: AppBar(title: const Text('趣味自拍'), actions: <Widget>[
  27. TextButton.icon(
  28. icon: Icon(
  29. isUp ? Icons.vertical_align_top : Icons.vertical_align_bottom,
  30. color: Colors.white,
  31. size: 32,
  32. ),
  33. label: const Text(
  34. '排序 活动时间',
  35. style: TextStyle(color: Colors.white, fontSize: 20),
  36. ),
  37. onPressed: () {
  38. setState(() {
  39. isUp = !isUp;
  40. });
  41. },
  42. ),
  43. Padding(
  44. padding: const EdgeInsets.only(left: 30, right: 30),
  45. child: TextButton(
  46. child: const Text(
  47. '创建',
  48. style: TextStyle(color: Colors.white, fontSize: 20),
  49. ),
  50. onPressed: () {
  51. Navigator.pushNamed(context, "/addNews");
  52. })),
  53. Padding(
  54. padding: const EdgeInsets.only(right: 30),
  55. child: IconButton(
  56. icon: const Icon(Icons.search),
  57. onPressed: () {
  58. showSearch(context: context, delegate: SeachBarDelegate());
  59. },
  60. )),
  61. ]),
  62. body: Scrollbar(
  63. // thumbVisibility: true,
  64. controller: _controller,
  65. child: DeerListView(
  66. controller: _controller,
  67. onRefresh: onRefresh,
  68. hasMore: currentPage < totalPage,
  69. loadMore: onRefresh,
  70. itemCount: listData.length, //条目个数:获取数据的个数
  71. itemBuilder: (context, index) {
  72. return GestureDetector(
  73. onTap: () {
  74. Navigator.pushNamed(
  75. context, "/newsDetail/${listData[index]["id"]}");
  76. },
  77. child: Column(
  78. crossAxisAlignment: CrossAxisAlignment.start,
  79. children: [
  80. Container(
  81. padding:
  82. const EdgeInsets.only(left: 12, right: 12, top: 10),
  83. child: Text(listData[index]["createTime"],
  84. style: const TextStyle(
  85. fontSize: 16,
  86. overflow: TextOverflow.ellipsis,
  87. ))),
  88. ListTile(
  89. title: Text(listData[index]["title"]),
  90. subtitle: Column(
  91. crossAxisAlignment: CrossAxisAlignment.start,
  92. children: [
  93. const SizedBox(height: 12),
  94. Text(listData[index]["subtitle"],
  95. style: const TextStyle(
  96. fontSize: 12, color: Colors.grey)),
  97. ],
  98. ), //小标题
  99. // trailing: Image.network(listData[index]["image"],
  100. // fit: BoxFit.fill, width: 110, height: 90),
  101. // visualDensity:
  102. // const VisualDensity(vertical: 4), //增加item高度,优化布局,便于图片展示
  103. minVerticalPadding: 8,
  104. )
  105. ]),
  106. );
  107. },
  108. ),
  109. ),
  110. drawer: const SizedBox(
  111. width: 500,
  112. child: Drawer(
  113. child: DrawerModalPage(),
  114. )),
  115. );
  116. }
  117. List listData = [
  118. {
  119. 'id': '0001',
  120. "title": "斗门希尔顿「林俭华&魏映雪」婚礼直播",
  121. "subtitle": "珠海",
  122. "image":
  123. "https://img-blog.csdnimg.cn/c6dfd375abf1433fa3a42951cc186a2b.jpeg",
  124. 'createTime': '2023年6月02日',
  125. },
  126. {
  127. 'id': '0002',
  128. "title": "嘉德诺家庭日",
  129. "subtitle": "上海",
  130. "image":
  131. "https://img-blog.csdnimg.cn/678c0686dc694b65ad6b20693dbc35f1.jpeg",
  132. 'createTime': '2023年5月16日',
  133. },
  134. {
  135. 'id': '0003',
  136. "title": "祥琪酒店「梁培安&丘凤」婚礼直播",
  137. "subtitle": "上海",
  138. "image":
  139. "https://img-blog.csdnimg.cn/63efe7acbac74e7ebce85e3801f948e3.jpeg",
  140. 'createTime': '2023年5月02日',
  141. },
  142. {
  143. 'id': '0004',
  144. "title": "黄府寿宴--广州华南理工大学西湖苑宾馆",
  145. "subtitle": "广州",
  146. "image":
  147. "https://img-blog.csdnimg.cn/c6dfd375abf1433fa3a42951cc186a2b.jpeg",
  148. 'createTime': '2023年4月30日',
  149. },
  150. {
  151. 'id': '0005',
  152. "title": "西卡德高广州总部大厦乔迁庆典",
  153. "subtitle": "广州",
  154. "image":
  155. "https://img-blog.csdnimg.cn/678c0686dc694b65ad6b20693dbc35f1.jpeg",
  156. 'createTime': '2023年4月15日',
  157. },
  158. {
  159. 'id': '0006',
  160. "title": "郭鹏&欧阳思昐 新婚之喜",
  161. "subtitle": "广州",
  162. "image":
  163. "https://img-blog.csdnimg.cn/63efe7acbac74e7ebce85e3801f948e3.jpeg",
  164. 'createTime': '2023年4月02日',
  165. },
  166. {
  167. 'id': '0007',
  168. "title": "深圳宝安格兰云天",
  169. "subtitle": "广州",
  170. "image":
  171. "https://img-blog.csdnimg.cn/c6dfd375abf1433fa3a42951cc186a2b.jpeg",
  172. 'createTime': '20201232',
  173. },
  174. {
  175. 'id': '0008',
  176. "title": "祥琪酒店「梁培安&丘凤」婚礼直播",
  177. "subtitle": "上海",
  178. "image":
  179. "https://img-blog.csdnimg.cn/c6dfd375abf1433fa3a42951cc186a2b.jpeg",
  180. 'createTime': '2023年5月24日',
  181. },
  182. {
  183. 'id': '0009',
  184. "title": "西卡德高广州总部大厦乔迁庆典",
  185. "subtitle": "上海",
  186. "image":
  187. "https://img-blog.csdnimg.cn/c6dfd375abf1433fa3a42951cc186a2b.jpeg",
  188. 'createTime': '2023年5月12日',
  189. },
  190. ];
  191. Future<dynamic> getList() async {
  192. try {
  193. // var params = {
  194. // "pageNo": currentPage,
  195. // "pageSize": 20,
  196. // "status": 'DONE', //READY
  197. // "saleOrderNo": ''
  198. // };
  199. // var res = await UtilHelper.updateList(params);
  200. var params = {
  201. "pageNo": currentPage,
  202. "pageSize": 30,
  203. "department": 'PACKING',
  204. "worklineId": 'workline-1-packing',
  205. "end": false
  206. };
  207. var res = await UtilHelper.updatePackingList(params);
  208. setState(() {
  209. // if (currentPage > 1) {
  210. // listData.addAll(res['records']);
  211. // } else {
  212. // listData = res['records'];
  213. // }
  214. // totalPage = res['pages'];
  215. });
  216. } catch (err) {
  217. debugPrint(err.toString());
  218. }
  219. }
  220. /// 处理刷新操作
  221. Future onRefresh() async {
  222. await Future.delayed(const Duration(seconds: 1), () {
  223. ++currentPage;
  224. getList();
  225. });
  226. }
  227. }