/*
 * @Author: WuXiangNan
 * @Date: 2021-03-05 17:42:23
 * @LastEditTime : 2021-04-08 11:05:16
 * @LastEditors  : WuWei
 * @Description: 地勤状态管理
 */

import 'package:flutter/material.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

class TrackStore with ChangeNotifier {
  static bool _isAllTask = true;
  static bool _isDoing = false;
  static bool _isNotStart = false;

  final BuildContext context;

  set isAllTask(value) => _isAllTask = value;
  get isAllTask => _isAllTask;
  set isDoing(value) => _isDoing = value;
  get isDoing => _isDoing;
  set isNotStart(value) => _isNotStart = value;
  get isNotStart => _isNotStart;

  TrackStore(this.context);

  changeIsAllTask() {
    isAllTask = true;
    isNotStart = false;
    isDoing = false;
    notifyListeners();
  }

  changeIsDoing() {
    isAllTask = false;
    isNotStart = false;
    isDoing = true;
    notifyListeners();
  }

  changeIsNotStart() {
    isAllTask = false;
    isNotStart = true;
    isDoing = false;
    notifyListeners();
  }

  buildDutyInfo(BuildContext context) {
    return WBottomModalUtil.show(
      context,
      title: Text('执勤信息'),
      body: Wisdom.column(
        color: Color(0xFFF8F8F8),
        children: [
          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: () => changeIsAllTask(),
                alignment: Alignment.center,
                padding: EdgeInsets.all(5.pt),
                borderRadius: BorderRadius.horizontal(
                  left: Radius.circular(4.pt),
                ),
                color: isAllTask ? Color(0XFF0F67F8) : Colors.white,
                child: Text(
                  '全部任务',
                  style: TextStyle(
                    color: isAllTask ? Colors.white : Color(0XFF0F67F8),
                    fontSize: 13.pt,
                  ),
                ),
              ).asExpanded(),
              Wisdom(
                onTap: () => changeIsDoing(),
                alignment: Alignment.center,
                padding: EdgeInsets.all(5.pt),
                border: Border.symmetric(
                  vertical: BorderSide(
                    width: 1.pt,
                    color: Color(0XFF0F67F8),
                  ),
                ),
                color: isDoing ? Color(0XFF0F67F8) : Colors.white,
                child: Text(
                  '进行中',
                  style: TextStyle(
                    color: isDoing ? Colors.white : Color(0XFF0F67F8),
                    fontSize: 13.pt,
                  ),
                ),
              ).asExpanded(),
              Wisdom(
                onTap: () => changeIsNotStart(),
                alignment: Alignment.center,
                padding: EdgeInsets.all(5.pt),
                borderRadius: BorderRadius.horizontal(
                  right: Radius.circular(4.pt),
                ),
                color: isNotStart ? Color(0XFF0F67F8) : Colors.white,
                child: Text(
                  '未开始',
                  style: TextStyle(
                    color: isNotStart ? Colors.white : Color(0XFF0F67F8),
                    fontSize: 13.pt,
                  ),
                ),
              ).asExpanded(),
            ],
          ),
          WisScrollView(
            slivers: [
              WisSliverList.childBuilder(
                childCount: 3,
                builder: (_, i) {
                  return buildDutyCarItem();
                },
              )
            ],
          ).asExpanded(),
        ],
      ),
    );
  }

  buildDutyCarItem() {
    return WisCard(
      color: Colors.white,
      elevation: 0,
      shape: BeveledRectangleBorder(),
      child: Wisdom.column(
        children: [
          Wisdom.column(
            padding: EdgeInsets.fromLTRB(15.pt, 20.pt, 15.pt, 0.pt),
            children: [
              Wisdom.wrap(
                alignment: Alignment.centerLeft,
                spacing: 10,
                margin: EdgeInsets.only(
                  bottom: 10.pt,
                ),
                children: [
                  WTag(
                    child: Text('进行中'),
                    color: Colors.orange,
                  ),
                  WisText(
                    '小区空调养护任务',
                    bold: true,
                    size: 15.pt,
                  ),
                ],
              ),
              Wisdom.wrap(
                spacing: 10,
                alignment: Alignment.centerLeft,
                margin: EdgeInsets.only(
                  bottom: 10.pt,
                ),
                children: [
                  WisText(
                    '添加时间',
                    color: Colors.grey,
                  ),
                  WisText('2021-03-05 15：00'),
                ],
              ),
              Wisdom.wrap(
                alignment: Alignment.centerLeft,
                spacing: 10,
                margin: EdgeInsets.only(
                  bottom: 20.pt,
                ),
                children: [
                  WisText(
                    '限时完成',
                    color: Colors.grey,
                  ),
                  WisText('2020-03-06'),
                ],
              ),
            ],
          ),
          Divider(
            height: 0.5.pt,
          )
        ],
      ),
    );
  }
}
