/*
 * @Author       : WuWei
 * @LastEditors: ChenYaJin
 * @Date         : 2021-05-25 11:18:53
 * @LastEditTime: 2023-04-13 15:20:30
 * @FilePath     : /wisdom-huiguanjia-app/task_package/lib/src/pages/index/components/mine.dart
 * @Description  : 任务管理-我的任务-列表页
 */
part of '../index.dart';

class _MineTaskList extends StatefulWidget {
  _MineTaskList({
    Key? key,
  }) : super(key: key);


  @override
  __MineTaskListState createState() => __MineTaskListState();
}

class __MineTaskListState extends State<_MineTaskList> {
  IndexStore get store => Provider.of(context, listen: false);

  @override
  Widget build(BuildContext context) {
    final store = Provider.of<IndexStore>(context);

    return NotificationListener<ScrollNotification>(
      onNotification: (ScrollNotification scrollInfo) {
        if (store.tabIndex == 0) {
          store.handleScrollEvent(scrollInfo);
        }
        return true;
      },
      child: CustomScrollView(
        slivers: <Widget>[
          SliverPadding(
            padding: const EdgeInsets.all(15.0),
            sliver: SliverToBoxAdapter(
              child: Observer(builder: (_) {
                return Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    for (var item in store.myTaskList)
                      Column(
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          TaskItem(
                            onClick: (item) =>
                                store.toTaskDetail(item.id, item.isChild),
                            item: item,
                            isMine: true,
                          ),
                          SizedBox(height: 10.pt),
                        ],
                      ),
                    if (store.isLast == true && store.isEmpty == false) ...[
                      LastText(),
                    ],
                    if (store.isEmpty == true) ...[
                      WEmptyWidget(text: WisText('暂无数据'))
                    ],
                    SizedBox(height: 34.pt),
                  ],
                );
              }),
            ),
          ),
        ],
      ),
    );
  }
}
