| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- import 'package:flutter/material.dart';
- import 'package:fun_selfie_app/pages/home/setting.dart';
- import 'package:fun_selfie_app/pages/home/search_bar.dart';
- import 'package:fun_selfie_app/utils/api.dart';
- import 'package:fun_selfie_app/widgets/my_refresh_list.dart';
- class HomePage extends StatefulWidget {
- const HomePage({Key? key}) : super(key: key);
- @override
- State<StatefulWidget> createState() => _HomePageState();
- }
- class _HomePageState extends State<HomePage> {
- bool isUp = false;
- int currentPage = 1;
- int totalPage = 0;
- final ScrollController _controller = ScrollController();
- // List listData = [];
- @override
- void initState() {
- super.initState();
- // 初始化的时候开启倒计时
- getList();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(title: const Text('趣味自拍'), actions: <Widget>[
- TextButton.icon(
- icon: Icon(
- isUp ? Icons.vertical_align_top : Icons.vertical_align_bottom,
- color: Colors.white,
- size: 32,
- ),
- label: const Text(
- '排序 活动时间',
- style: TextStyle(color: Colors.white, fontSize: 20),
- ),
- onPressed: () {
- setState(() {
- isUp = !isUp;
- });
- },
- ),
- Padding(
- padding: const EdgeInsets.only(left: 30, right: 30),
- child: TextButton(
- child: const Text(
- '创建',
- style: TextStyle(color: Colors.white, fontSize: 20),
- ),
- onPressed: () {
- Navigator.pushNamed(context, "/addNews");
- })),
- Padding(
- padding: const EdgeInsets.only(right: 30),
- child: IconButton(
- icon: const Icon(Icons.search),
- onPressed: () {
- showSearch(context: context, delegate: SeachBarDelegate());
- },
- )),
- ]),
- body: Scrollbar(
- // thumbVisibility: true,
- controller: _controller,
- child: DeerListView(
- controller: _controller,
- onRefresh: onRefresh,
- hasMore: currentPage < totalPage,
- loadMore: onRefresh,
- itemCount: listData.length, //条目个数:获取数据的个数
- itemBuilder: (context, index) {
- return GestureDetector(
- onTap: () {
- Navigator.pushNamed(
- context, "/newsDetail/${listData[index]["id"]}");
- },
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- padding:
- const EdgeInsets.only(left: 12, right: 12, top: 10),
- child: Text(listData[index]["createTime"],
- style: const TextStyle(
- fontSize: 16,
- overflow: TextOverflow.ellipsis,
- ))),
- ListTile(
- title: Text(listData[index]["title"]),
- subtitle: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const SizedBox(height: 12),
- Text(listData[index]["subtitle"],
- style: const TextStyle(
- fontSize: 12, color: Colors.grey)),
- ],
- ), //小标题
- // trailing: Image.network(listData[index]["image"],
- // fit: BoxFit.fill, width: 110, height: 90),
- // visualDensity:
- // const VisualDensity(vertical: 4), //增加item高度,优化布局,便于图片展示
- minVerticalPadding: 8,
- )
- ]),
- );
- },
- ),
- ),
- drawer: const SizedBox(
- width: 500,
- child: Drawer(
- child: DrawerModalPage(),
- )),
- );
- }
- List listData = [
- {
- 'id': '0001',
- "title": "斗门希尔顿「林俭华&魏映雪」婚礼直播",
- "subtitle": "珠海",
- "image":
- "https://img-blog.csdnimg.cn/c6dfd375abf1433fa3a42951cc186a2b.jpeg",
- 'createTime': '2023年6月02日',
- },
- {
- 'id': '0002',
- "title": "嘉德诺家庭日",
- "subtitle": "上海",
- "image":
- "https://img-blog.csdnimg.cn/678c0686dc694b65ad6b20693dbc35f1.jpeg",
- 'createTime': '2023年5月16日',
- },
- {
- 'id': '0003',
- "title": "祥琪酒店「梁培安&丘凤」婚礼直播",
- "subtitle": "上海",
- "image":
- "https://img-blog.csdnimg.cn/63efe7acbac74e7ebce85e3801f948e3.jpeg",
- 'createTime': '2023年5月02日',
- },
- {
- 'id': '0004',
- "title": "黄府寿宴--广州华南理工大学西湖苑宾馆",
- "subtitle": "广州",
- "image":
- "https://img-blog.csdnimg.cn/c6dfd375abf1433fa3a42951cc186a2b.jpeg",
- 'createTime': '2023年4月30日',
- },
- {
- 'id': '0005',
- "title": "西卡德高广州总部大厦乔迁庆典",
- "subtitle": "广州",
- "image":
- "https://img-blog.csdnimg.cn/678c0686dc694b65ad6b20693dbc35f1.jpeg",
- 'createTime': '2023年4月15日',
- },
- {
- 'id': '0006',
- "title": "郭鹏&欧阳思昐 新婚之喜",
- "subtitle": "广州",
- "image":
- "https://img-blog.csdnimg.cn/63efe7acbac74e7ebce85e3801f948e3.jpeg",
- 'createTime': '2023年4月02日',
- },
- {
- 'id': '0007',
- "title": "深圳宝安格兰云天",
- "subtitle": "广州",
- "image":
- "https://img-blog.csdnimg.cn/c6dfd375abf1433fa3a42951cc186a2b.jpeg",
- 'createTime': '20201232',
- },
- {
- 'id': '0008',
- "title": "祥琪酒店「梁培安&丘凤」婚礼直播",
- "subtitle": "上海",
- "image":
- "https://img-blog.csdnimg.cn/c6dfd375abf1433fa3a42951cc186a2b.jpeg",
- 'createTime': '2023年5月24日',
- },
- {
- 'id': '0009',
- "title": "西卡德高广州总部大厦乔迁庆典",
- "subtitle": "上海",
- "image":
- "https://img-blog.csdnimg.cn/c6dfd375abf1433fa3a42951cc186a2b.jpeg",
- 'createTime': '2023年5月12日',
- },
- ];
- Future<dynamic> getList() async {
- try {
- // var params = {
- // "pageNo": currentPage,
- // "pageSize": 20,
- // "status": 'DONE', //READY
- // "saleOrderNo": ''
- // };
- // var res = await UtilHelper.updateList(params);
- var params = {
- "pageNo": currentPage,
- "pageSize": 30,
- "department": 'PACKING',
- "worklineId": 'workline-1-packing',
- "end": false
- };
- var res = await UtilHelper.updatePackingList(params);
- setState(() {
- // if (currentPage > 1) {
- // listData.addAll(res['records']);
- // } else {
- // listData = res['records'];
- // }
- // totalPage = res['pages'];
- });
- } catch (err) {
- debugPrint(err.toString());
- }
- }
- /// 处理刷新操作
- Future onRefresh() async {
- await Future.delayed(const Duration(seconds: 1), () {
- ++currentPage;
- getList();
- });
- }
- }
|