/*
 * @Author       : WuWei
 * @LastEditors: wjc
 * @Date         : 2021-05-25 11:19:34
 * @LastEditTime: 2022-12-02 11:09:44
 * @FilePath     : /wisdom-huiguanjia-app/task_package/lib/src/pages/index/components/department.dart
 * @Description  : 任务管理-本部门-列表页
 */
part of '../index.dart';

class _DepartTaskList extends StatelessWidget {
  const _DepartTaskList({Key? key}) : super(key: key);

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

    return SafeArea(
      top: false,
      bottom: false,
      child: Builder(
        builder: (BuildContext context) {
          return NotificationListener<ScrollNotification>(
            onNotification: (ScrollNotification scrollInfo) {
              if (store.tabIndex == 3) {
                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.taskOrganList)
                            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),
                        ],
                      );
                    }),
                  ),
                ),
              ],
            ),
          );
        },
      ),
    );
  }
}
