/*
 * @Author       : WuWei
 * @LastEditors: ChenYaJin
 * @Date         : 2021-04-27 16:39:35
 * @LastEditTime: 2023-08-14 16:28:53
 * @FilePath     : /wisdom-huiguanjia-app/task_package/lib/src/pages/statistic/components/mine.dart
 * @Description  : 任务统计-我的任务
 */
part of '../index.dart';

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

  @override
  Widget build(BuildContext context) {
    final store = Provider.of<StatisticStore>(context, listen: false);

    return Column(
      children: [
        TabbarComponent(),
        WisScrollView(
          key: store.mineScrViewKey,
          onInit: () => store.onSetTabIndex(0),
          slivers: [
            SliverToBoxAdapter(
              child: BuildAllTaskCard(),
            ),
            SliverToBoxAdapter(
              child: BuildTaskListStat(),
            ),
          ],
        ).asExpanded(),
        SizedBox(
          height: 10.pt,
        )
      ],
    );
  }
}

class TabbarComponent extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<StatisticStore>(context, listen: false);
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;

    return Wisdom.column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Observer(builder: (_) {
          return Wisdom.row(
            borderRadius: BorderRadius.circular(13.pt),
            border: Border.all(color: colorScheme.primary, width: 1.pt),
            margin: EdgeInsets.symmetric(horizontal: 70.pt, vertical: 5.pt),
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Wisdom(
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(12.pt),
                  bottomLeft: Radius.circular(12.pt),
                ),
                onTap: store.isMyTask ? null : () => store.onSetMyTask(true),
                alignment: Alignment.center,
                color:
                    store.isMyTask ? colorScheme.primary : Colors.transparent,
                padding: EdgeInsets.symmetric(vertical: 6.pt),
                child: Text(
                  '我的任务',
                  style: TextStyle(
                    fontSize: 15.pt,
                    fontWeight: FontWeight.w300,
                    color: store.isMyTask ? Colors.white : colorScheme.primary,
                  ),
                ),
              ).asExpanded(),
              Wisdom(
                borderRadius: BorderRadius.only(
                  topRight: Radius.circular(12.pt),
                  bottomRight: Radius.circular(12.pt),
                ),
                onTap: store.isMyTask == false
                    ? null
                    : () => store.onSetMyTask(false),
                alignment: Alignment.center,
                color:
                    store.isMyTask ? Colors.transparent : colorScheme.primary,
                padding: EdgeInsets.symmetric(vertical: 6.pt),
                child: Text(
                  '抄送我的',
                  style: TextStyle(
                    fontSize: 15.pt,
                    fontWeight: FontWeight.w300,
                    color: !store.isMyTask ? Colors.white : colorScheme.primary,
                  ),
                ),
              ).asExpanded(),
            ],
          );
        }),
        Observer(
          builder: (_) {
            return Wisdom.row(
              margin: EdgeInsets.only(
                  top: 10.pt, bottom: 5.pt, left: 15.pt, right: 15.pt),
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Wisdom.row(
                  width: 100.pt,
                   borderRadius: BorderRadius.circular(10.pt),
                  border: Border.all(color: colorScheme.primary, width: 1.pt),
                  children: [
                    Wisdom(
                       borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(9.pt),
                  bottomLeft: Radius.circular(9.pt),
                ),
                      onTap: () => store.onSetToday(),
                      alignment: Alignment.center,
                      color: !store.isToday ? Colors.white : colorScheme.primary,
                      padding: EdgeInsets.symmetric(vertical: 4.pt),
                      child: Text(
                        '今日',
                        style: TextStyle(
                          fontSize: 15.pt,
                          fontWeight: FontWeight.w300,
                          color: store.isToday
                              ? Colors.white
                              : colorScheme.primary,
                        ),
                      ),
                    ).asExpanded(),
                    // Wisdom(
                    //   width: 1.pt,
                    //   height: 28.pt,
                    //   color: colorScheme.primary,
                    // ),
                    Wisdom(
                       borderRadius: BorderRadius.only(
                  topRight: Radius.circular(9.pt),
                  bottomRight: Radius.circular(9.pt),
                ),
                      onTap: () => store.onSetYesterday(),
                      alignment: Alignment.center,
                      color: !store.isYesterday ? Colors.white : colorScheme.primary,
                      padding: EdgeInsets.symmetric(vertical: 4.pt),
                      child: Text(
                        '昨日',
                        style: TextStyle(
                          fontSize: 15.pt,
                          fontWeight: FontWeight.w300,
                          color: store.isYesterday
                              ? Colors.white
                              : colorScheme.primary,
                        ),
                      ),
                    ).asExpanded(),
                  ],
                ),
                // Wisdom(
                //   color: colorScheme.background,
                //   margin: EdgeInsets.all(5.pt),
                //   child: Text(
                //     '全部任务',
                //     style: TextStyle(
                //       fontSize: 14.pt,
                //       fontWeight: FontWeight.bold,
                //     ),
                //   ),
                // ),
              ],
            );
          },
        ),
        Wisdom(
          color: colorScheme.background,
          margin: EdgeInsets.symmetric(horizontal: 15.pt),
          child: WisText.c999(
            "注：括号内为超时任务数。",
            size: 13.pt,
            weight: FontWeight.w300,
          ),
        ),
      ],
    );
  }
}
