/*
 * @Author: WuXiangNan
 * @Date: 2021-03-08 09:50:33
 * @LastEditTime: 2021-03-08 11:57:10
 * @LastEditors: WuXiangNan
 * @Description: 任务类型
 */

part of './index.dart';

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

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (context) => TrackStore(context),
      child: _TabPage(),
      lazy: false,
    );
  }
}

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

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

class __TabPageState extends State<_TabPage> {
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<TrackStore>(context);
    return Wisdom.row(
      margin: EdgeInsets.all(15.pt),
      height: 30.pt,
      border: Border.all(width: 1.pt, color: Color(0XFF0F67F8)),
      borderRadius: BorderRadius.circular(4.pt),
      children: [
        Wisdom(
          onTap: () => store.changeIsAllTask(),
          alignment: Alignment.center,
          padding: EdgeInsets.all(5.pt),
          borderRadius: BorderRadius.horizontal(
            left: Radius.circular(4.pt),
          ),
          color: store.isAllTask ? Color(0XFF0F67F8) : Colors.white,
          child: Text(
            '全部任务',
            style: TextStyle(
              color: store.isAllTask ? Colors.white : Color(0XFF0F67F8),
              fontSize: 13.pt,
            ),
          ),
        ).asExpanded(),
        Wisdom(
          onTap: () => store.changeIsDoing(),
          alignment: Alignment.center,
          padding: EdgeInsets.all(5.pt),
          border: Border.symmetric(
            vertical: BorderSide(
              width: 1.pt,
              color: Color(0XFF0F67F8),
            ),
          ),
          color: store.isDoing ? Color(0XFF0F67F8) : Colors.white,
          child: Text(
            '进行中',
            style: TextStyle(
              color: store.isDoing ? Colors.white : Color(0XFF0F67F8),
              fontSize: 13.pt,
            ),
          ),
        ).asExpanded(),
        Wisdom(
          onTap: () => store.changeIsNotStart(),
          alignment: Alignment.center,
          padding: EdgeInsets.all(5.pt),
          borderRadius: BorderRadius.horizontal(
            right: Radius.circular(4.pt),
          ),
          color: store.isNotStart ? Color(0XFF0F67F8) : Colors.white,
          child: Text(
            '未开始',
            style: TextStyle(
              color: store.isNotStart ? Colors.white : Color(0XFF0F67F8),
              fontSize: 13.pt,
            ),
          ),
        ).asExpanded(),
      ],
    );
  }
}
