/*
 * @Author: XianKaiQun
 * @Date: 2020-09-16 10:12:25
 * @LastEditors: ChenYaJin
 * @LastEditTime: 2023-04-06 11:28:53
 * @Description: 
 */
part of '../index.dart';

final _meterType = {
  'waterMeter': AssetList.$waterMeter_png_image,
  'electricMeter': AssetList.$amMeter_png_image,
};

class _DescComponent extends StatelessWidget {
  const _DescComponent({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    final store = Provider.of<PrivateDetailStore>(context);
    return Wisdom.column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      color: Colors.white,
      margin: EdgeInsets.only(bottom: 10.pt),
      children: [
        Container(
          height: 190.pt,
          color: colorScheme.background4,
          child: Wisdom.stack(
            clipBehavior: Clip.none,
            children: [
              Wisdom(
                color: colorScheme.primary,
                height: 85.pt,
              ),
              Positioned(
                bottom: 0,
                left: 0,
                right: 0,
                child: Wisdom.column(
                  height: 180.pt,
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: [
                    WisCard(
                      color: Colors.white,
                      margin: EdgeInsets.symmetric(horizontal: 15.pt),
                      padding: EdgeInsets.all(15.pt),
                      child: Wisdom.column(
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        children: [
                          Row(
                            children: [
                              Text.rich(
                                TextSpan(
                                  children: [
                                    if (_meterType[store.detail.type ??
                                            'electricMeter'] !=
                                        null)
                                      WidgetSpan(
                                        alignment: PlaceholderAlignment.middle,
                                        child: Image(
                                          image: _meterType[store.detail.type ??
                                              'electricMeter']!,
                                          width: 22.pt,
                                          height: 22.pt,
                                        ),
                                      ),
                                    TextSpan(
                                      text: ' ${store.detail.name ?? ''}',
                                      style: TextStyle(
                                        fontSize: 16.pt,
                                        fontWeight: FontWeight.bold,
                                      ),
                                    ),
                                  ],
                                ),
                                maxLines: 1,
                                overflow: TextOverflow.ellipsis,
                              ).nestExpanded(),
                            ],
                          ),
                          Wisdom.row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            margin: EdgeInsets.symmetric(vertical: 5.pt),
                            children: [
                              Wisdom.row(
                                children: [
                                  if (store.detail.multiple != null)
                                    WTag(
                                      color: colorScheme.primary,
                                      child: Text('${store.detail.multiple}倍',
                                          style: TextStyle(
                                            fontSize: 13.pt,
                                          )),
                                    ),
                                  WTag(
                                    color: store.detail.transcribes == true
                                        ? colorScheme.success
                                        : colorScheme.danger,
                                    child: Text(
                                        store.detail.transcribes == true
                                            ? '本期已抄'
                                            : '本期未抄',
                                        style: TextStyle(
                                          fontSize: 13.pt,
                                        )),
                                  ),
                                ],
                              ),
                              Text.rich(
                                TextSpan(
                                  style: TextStyle(fontSize: 14.pt),
                                  children: [
                                    TextSpan(
                                      text: '上次度数：',
                                      style: TextStyle(color: colorScheme.grey),
                                    ),
                                    TextSpan(
                                      text:
                                          '${store.detail.lastReadNum ?? '--'}',
                                      style:
                                          TextStyle(color: colorScheme.primary),
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                          Wisdom.row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            margin: EdgeInsets.symmetric(vertical: 5.pt),
                            children: [
                              Text(
                                '仪表回程',
                                style: TextStyle(
                                  color: colorScheme.minor,
                                ),
                              ),
                              Text(
                                '${store.detail.backhaul ?? '--'}',
                                style: TextStyle(
                                  fontSize: 14.pt,
                                  color: colorScheme.grey,
                                ),
                              ),
                            ],
                          ),
                          Wisdom.row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            margin: EdgeInsets.symmetric(vertical: 5.pt),
                            children: [
                              Text(
                                '抄表时间',
                                style: TextStyle(
                                  color: colorScheme.minor,
                                ),
                              ),
                              Text(
                                store.detail.date ?? '--',
                                style: TextStyle(
                                  fontSize: 14.pt,
                                  color: colorScheme.grey,
                                ),
                              ),
                            ],
                          ),
                          Wisdom.row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            margin: EdgeInsets.symmetric(vertical: 5.pt),
                            children: [
                              Text(
                                '表号',
                                style: TextStyle(
                                  color: colorScheme.minor,
                                ),
                              ),
                              Text(
                                '${store.detail.meterCode ?? ''}',
                                style: TextStyle(
                                  fontSize: 14.pt,
                                  color: colorScheme.grey,
                                ),
                              ),
                            ],
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }
}
