/*
 * @Author: WuWei
 * @Date: 2020-06-03 23:34:36
 * @LastEditors: XianKaiQun
 * @LastEditTime: 2020-10-09 09:50:25
 * @Description:
 */
part of '../index.dart';

final Map identity = {
  'selfOwner': '独立产权人',
  'jointOwner': '共有产权人',
  'tenant': '租户',
  'relatives': '亲属',
  'enterprise': '企事业单位',
};

final Map sex = {'male': '男', 'female': '女'};

final Map certificateType = {
  'IdCard': '身份证',
  'HKAndMacaoPass': '港澳通行证',
  'officerCertificate': '军官证',
  'other': '其他'
};

/// 住户信息卡片
class _TopInfoCard extends StatelessWidget {
  const _TopInfoCard({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final store = Provider.of<SearchResidentDetailStore>(context);
    return SliverToBoxAdapter(
      child: Stack(
        children: <Widget>[
          ClipPath(
            // 只裁切底部的方法
            clipper: BlockClipper(),
            child: Container(
              width: MediaQuery.of(context).size.width,
              height: 280.pt,
              decoration: new BoxDecoration(
                gradient: LinearGradient(
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                  colors: [const Color(0XFF0F67F8), const Color(0xFF9CDCFF)],
                ),
              ),
            ),
          ),

          /// 住户信息卡片
          Wisdom(
            padding: EdgeInsets.all(15.pt),
            margin: EdgeInsets.fromLTRB(10.pt, 20.pt, 10.pt, 10.pt),
            color: Colors.white,
            width: MediaQuery.of(context).size.width,
            borderRadius: BorderRadius.circular(14.pt),
            boxShadow: [
              //阴影
              BoxShadow(
                color: Color(0x40000000),
                blurRadius: 10.pt,
                spreadRadius: -5.pt,
              )
            ],
            child: Wisdom.column(
              children: <Widget>[
                Wisdom.row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  margin: EdgeInsets.only(bottom: 5.pt),
                  children: <Widget>[
                    WisText('${store.residentDetail?.name ?? ''}',
                        color: Color(0xFF2D8CF0), size: 20.pt),
                    Wisdom(
                      border: Border.all(
                        color: Color(0xFF2D8CF0),
                      ),
                      padding: EdgeInsets.fromLTRB(10.pt, 2.pt, 10.pt, 2.pt),
                      borderRadius: BorderRadius.circular(10.pt),
                      child: WisText(
                          '${identity[store.residentDetail?.identity] ?? ''}',
                          color: Color(0xFF2D8CF0),
                          size: 12.pt),
                    ),
                  ],
                ),
                Wisdom.row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  margin: EdgeInsets.only(bottom: 5.pt),
                  children: <Widget>[
                    WisText(
                        '${store.residentDetail?.buildName ?? ''}/${store.residentDetail?.unitName ?? ''}/${store.residentDetail?.roomNo ?? ''}',
                        color: Color(0xFF999999),
                        size: 14.pt),
                    Wisdom(
                      onTap: () =>
                          launch('tel:${store.residentDetail?.mobile}'),
                      child: Wisdom.row(
                        children: <Widget>[
                          Icon(FaIcons.phone,
                              size: 12.pt, color: Color(0xFF2D8CF0)),
                          WisText('${store.residentDetail?.mobile ?? ''}',
                              color: Color(0xFF2D8CF0), size: 14.pt)
                        ],
                      ),
                    )
                  ],
                ),

                /// 分割线
                Divider(
                  height: 10.pt,
                  color: Color(0xFFE4E4E4),
                ),

                /// 住户详细信息
                InfoItem(
                  title: '性别',
                  content: '${sex[store.residentDetail?.sex] ?? ''}',
                ),
                InfoItem(
                  title: '居住时间',
                  content:
                      '${store.residentDetail?.residenceStartAt ?? '-'} 至 ${store.residentDetail?.residenceEndAt ?? '-'}',
                ),
                InfoItem(
                  title: '证件类型',
                  content:
                      '${certificateType[store.residentDetail?.certificateType] ?? ''}',
                ),
                InfoItem(
                  title: '证件号码',
                  content: '${store.residentDetail?.idNumber ?? ''}',
                ),
                InfoItem(
                  title: '是否迁出',
                  content: '${store.residentDetail?.checkOutAt ?? '否'}',
                ),
                InfoItem(
                  title: '其他号码',
                  content: '${store.residentDetail?.otherMobile ?? ''}',
                ),
                InfoItem(
                  title: '常住地址',
                  content: '${store.residentDetail?.address ?? ''}',
                ),
                InfoItem(
                  title: '备注',
                  content: '${store.residentDetail?.remark ?? ''}',
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
