/*
 * @Author: WuXiangNan
 * @Date: 2021-03-05 11:21:31
 * @LastEditTime : 2023-05-16 10:04:31
 * @LastEditors  : WuWei
 * @Description: 人员地图
 */

import 'package:flutter/material.dart';
import 'package:wisdom_cli/wisdom_cli.dart';
import '../../../../view_models/track_store.dart';
part './tab.dart';

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

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

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

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

class __PageViewState extends State<_PageView> {
  TrackStore get store => Provider.of<TrackStore>(context, listen: false);

  @override
  Widget build(BuildContext context) {
    final colorScheme = WTheme.of(context).colorScheme;
    return Scaffold(
      appBar: WAppBar(
        brightness: Brightness.light,
        iconTheme: IconThemeData(
          color: colorScheme.mainTitle,
          size: 19.pt,
        ),
        backgroundColor: Colors.white,
        title: WisText('刘大壮',
            size: 19.pt, weight: FontWeight.w600, color: colorScheme.mainTitle),
      ),
      body: Wisdom(),
      bottomNavigationBar: SafeArea(
        child: Wisdom.wrap(
          color: Colors.white,
          spacing: 1,
          children: [
            WisButton(
              buttonShape: WisButtonShape.square,
              constraints: BoxConstraints(
                minHeight: 44.pt,
                minWidth: MediaQuery.of(context).size.width / 3 - 1,
              ),
              onPressed: () => buildMemberInfo(context),
              child: WisText(
                '人员信息',
                size: 16.pt,
                color: Colors.white,
              ),
              color: Color(0XFF0F67F8),
            ),
            WisButton(
              buttonShape: WisButtonShape.square,
              constraints: BoxConstraints(
                minHeight: 44.pt,
                minWidth: MediaQuery.of(context).size.width / 3 - 1,
              ),
              onPressed: () => buildDutyInfo(context),
              child: WisText(
                '执勤信息',
                size: 16.pt,
                color: Colors.white,
              ),
              color: Color(0XFF0F67F8),
            ),
            WisButton(
              buttonShape: WisButtonShape.square,
              constraints: BoxConstraints(
                minHeight: 44.pt,
                minWidth: MediaQuery.of(context).size.width / 3,
              ),
              onPressed: () => {},
              child: WisText(
                '派任务',
                size: 16.pt,
                color: Colors.white,
              ),
              color: Color(0XFF0F67F8),
            ),
          ],
        ),
      ),
    );
  }

  buildMemberInfo(BuildContext context) {
    return WBottomModalUtil.show(
      context,
      title: Text('人员信息'),
      body: Wisdom.column(
        padding: EdgeInsets.all(15.pt),
        children: [
          Wisdom.row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            margin: EdgeInsets.only(bottom: 10.pt),
            children: [
              WisText(
                '姓名',
                color: Colors.grey,
              ),
              WisText(
                '刘大壮',
              ),
            ],
          ),
          Wisdom.row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            margin: EdgeInsets.only(bottom: 10.pt),
            children: [
              WisText(
                '部门',
                color: Colors.grey,
              ),
              WisText(
                '地勤',
              ),
            ],
          ),
          Wisdom.row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            margin: EdgeInsets.only(bottom: 10.pt),
            children: [
              WisText(
                '岗位',
                color: Colors.grey,
              ),
              WisText(
                '地勤专员',
              ),
            ],
          ),
          Wisdom.row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            margin: EdgeInsets.only(bottom: 10.pt),
            children: [
              WisText(
                '所属地勤机构',
                color: Colors.grey,
              ),
              WisText(
                '...',
              ),
            ],
          ),
          Wisdom.row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            margin: EdgeInsets.only(bottom: 10.pt),
            children: [
              WisText(
                '签到时间',
                color: Colors.grey,
              ),
              WisText(
                '2021-03-05 12:00:00',
              ),
            ],
          ),
          Wisdom.row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            margin: EdgeInsets.only(bottom: 10.pt),
            children: [
              WisText(
                '最后位置',
                color: Colors.grey,
              ),
              Wisdom(
                maxWidth: MediaQuery.of(context).size.width / 2,
                child: WisText(
                  '海口市美兰区和平大道35号蓝岛康城温泉花园',
                  textAlign: TextAlign.right,
                ),
              ),
            ],
          ),
          Wisdom.row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            margin: EdgeInsets.only(bottom: 10.pt),
            children: [
              WisText(
                '位置更新时间',
                color: Colors.grey,
              ),
              WisText(
                '2021-03-05 14:00:00',
              ),
            ],
          ),
          Wisdom.row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            margin: EdgeInsets.only(bottom: 10.pt),
            children: [
              WisText(
                '事件预警',
                color: Colors.grey,
              ),
              WisText(
                '迟到 1 小时',
                color: Color(0XFFFF495E),
              ),
            ],
          ),
        ],
      ),
    );
  }

  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: [
              Tab(),
            ],
          ),
          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,
          )
        ],
      ),
    );
  }
}
