/*
 * @Author: WuWei
 * @Date: 2020-06-05 10:21:30
 * @LastEditors: WuWei
 * @LastEditTime: 2020-06-17 11:08:47
 * @Description:
 */
part of '../index.dart';

final Map type = {
  'dwelling': '住宅',
  'shop': '商铺',
  'virtual': '虚拟',
  'villa': '别墅',
  'office': '办公',
  'apartment': '公寓',
  'hotel': '酒店',
  'lowrent': '廉租房',
  'economic': '经适房'
};

final Map situation = {'selfLive': '自住', 'rent': '出租', 'vacant': '空置'};

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

  @override
  Widget build(BuildContext context) {
    final store = Provider.of<SearchHouseDetailStore>(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: const LinearGradient(
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                  colors: [const Color(0XFF0F67F8), const Color(0xFF9CDCFF)],
                  tileMode: TileMode.repeated,
                ),
              ),
            ),
          ),

          /// 住户信息卡片
          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.houseDetail?.roomNo ?? ''}',
                        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('${type[store.houseDetail?.type] ?? ''}',
                          color: Color(0xFF2D8CF0), size: 12.pt),
                    ),
                  ],
                ),
                Wisdom.row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  margin: EdgeInsets.only(bottom: 5.pt),
                  children: <Widget>[
                    WisText(
                        '${store.houseDetail?.buildName ?? ''}/${store.houseDetail?.unitName ?? ''}/${store.houseDetail?.roomNo ?? ''}',
                        color: Color(0xFF999999),
                        size: 14.pt),
                  ],
                ),

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

                Wisdom.row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    margin: EdgeInsets.only(bottom: 5.pt),
                    children: <Widget>[
                      InfoItem(
                        isRight: false,
                        title: '建筑面积(m²):',
                        content: '${store.houseDetail?.buildArea ?? ''}',
                      ),
                      InfoItem(
                        isRight: true,
                        title: '公摊面积(m²):',
                        content: '${store.houseDetail?.communalArea ?? ''}',
                      ),
                    ]),
                Wisdom.row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    margin: EdgeInsets.only(bottom: 5.pt),
                    children: <Widget>[
                      InfoItem(
                        isRight: false,
                        title: '计费面积(m²):',
                        content: '${store.houseDetail?.billingArea ?? ''}',
                      ),
                      InfoItem(
                        isRight: true,
                        title: '套内面积(m²):',
                        content: '${store.houseDetail?.innerArea ?? ''}',
                      ),
                    ]),
                Divider(
                  height: 10.pt,
                ),
                Wisdom.row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    margin: EdgeInsets.only(bottom: 5.pt),
                    children: <Widget>[
                      InfoItem(
                        title: '是否装修:',
                        isRight: false,
                        content:
                            '${(store.houseDetail?.isDecoration != null && store.houseDetail!.isDecoration!) ? '是' : '否'}',
                      ),
                      InfoItem(
                        title: '使用情况:',
                        isRight: true,
                        content:
                            '${situation[store.houseDetail?.useSituation] ?? ''}',
                      ),
                    ]),
                Wisdom.row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    margin: EdgeInsets.only(bottom: 5.pt),
                    children: <Widget>[
                      InfoItem(
                        title: '是否交房:',
                        isRight: false,
                        content:
                            '${(store.houseDetail?.isDelivery != null && store.houseDetail!.isDelivery!) ? '是' : '否'}',
                      ),
                      InfoItem(
                        title: '签署服务协议:',
                        isRight: true,
                        content:
                            '${(store.houseDetail?.isSignSerProtocol != null && store.houseDetail!.isSignSerProtocol!) ? '是' : '否'}',
                      ),
                    ]),
                Wisdom.row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    margin: EdgeInsets.only(bottom: 5.pt),
                    children: <Widget>[
                      InfoItem(
                        title: '是否入住:',
                        isRight: false,
                        content:
                            '${(store.houseDetail?.isCheckIn != null && store.houseDetail!.isCheckIn!) ? '是' : '否'}',
                      ),
                      InfoItem(
                        title: '分摊倍数:',
                        isRight: true,
                        content:
                            '${store.houseDetail?.allocationMultiple ?? ''}',
                      ),
                    ]),
                Divider(
                  height: 10.pt,
                ),
                Wisdom.row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      WisText.c999(
                        '交房时间',
                        size: 14.pt,
                      ),
                      WisText.c333(
                        '${store.houseDetail?.deliveryAt ?? ''}',
                        size: 14.pt,
                      ),
                    ]),
                Wisdom.row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      WisText.c999(
                        '备注',
                        size: 14.pt,
                      ),
                      WisText.c333(
                        '${store.houseDetail?.remark ?? ''}',
                        size: 14.pt,
                      ),
                    ]),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
