/*
 * @Author       : WuWei
 * @LastEditors: wuwei
 * @Date         : 2021-09-26 16:06:21
 * @LastEditTime: 2024-01-15 10:44:39
 * @Description  : Do not edit
 */
part of '../index.dart';

/// 基本信息
class _BuildInfo extends StatelessWidget {
  const _BuildInfo({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final colorScheme = WTheme.of(context).colorScheme;
    final store = Provider.of<PointFormStore>(context, listen: false);

    /// 204.07.08 去除水印组件
    return Observer(builder: (_) {
      return Wisdom.column(
        color: Colors.white,
        padding: EdgeInsets.all(15.pt),
        margin: EdgeInsets.only(
            top: 10.pt, bottom: 5.pt, right: 15.pt, left: 15.pt),
        borderRadius: BorderRadius.circular(10.pt),
        boxShadow: [
          BoxShadow(
            offset: Offset(0, 2.pt),
            color: Color(0x08000000),
            blurRadius: 10.pt,
            spreadRadius: 2.5.pt,
          ),
        ],
        children: [
          Wisdom.row(
            margin: EdgeInsets.only(
              bottom: 10.pt,
            ),
            children: <Widget>[
              WisText(
                store.detail?.relationName ?? '',
                color: colorScheme.mainTitle,
                size: 19.pt,
                weight: FontWeight.w600,
              ).asExpanded(),
            ],
          ),

          /// 非按序号巡检时候， 不显示这个序号
          if (store.detail?.nodeSequenceNumber != null) ...[
            Observer(builder: (_) {
              return _BuildInfoRowItem(
                title: '作业序号',
                data: WisText(
                  '${store.detail?.nodeSequenceNumber ?? ''}',
                  textAlign: TextAlign.right,
                  color: Color(0xFF9FA5B7),
                  size: 14.pt,
                  weight: FontWeight.w300,
                ),
              );
            })
          ],
          Observer(builder: (_) {
            return _BuildInfoRowItem(
              title: '所属小区',
              data: WisText(
                '${store.detail?.nodeData?.communityName ?? ''}',
                color: Color(0xFF9FA5B7),
                textAlign: TextAlign.right,
                size: 14.pt,
                weight: FontWeight.w300,
              ),
            );
          }),
          if (store.isHistory) ...[
            Observer(builder: (_) {
              return Wisdom.row(
                onTap: () => store.toTask(),
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  WisText(
                    '所属任务',
                    color: Color(0xFF616178),
                    size: 14.pt,
                    weight: FontWeight.w300,
                  ),
                  Row(children: [
                    SizedBox(width: 10.pt),
                    WisText(
                      '${store.detail?.exPlatformName ?? ''}',
                      color: colorScheme.primary,
                      textAlign: TextAlign.right,
                      size: 14.pt,
                      weight: FontWeight.w300,
                    ),
                    SizedBox(width: 5.pt),
                    Icon(
                      Icons.arrow_forward_ios,
                      size: 14.pt,
                      color: colorScheme.grey,
                    ),
                  ]),
                ],
              );
            })
          ]

          /// 2023.12.20 删除设备间、设备点类型字段
          // if (store.detail?.type == '451357265520177153' ||
          //     store.detail?.type == '451357265520177152') ...[
          //   Observer(builder: (_) {
          //     return _BuildInfoRowItem(
          //       title: '类型',
          //       data: WisText(
          //         '${store.repairPointType[store.detail?.relationType]}',
          //         color: colorScheme.mainTitle,
          //         textAlign: TextAlign.right,
          //         size: 14.pt,
          //         weight: FontWeight.w300,
          //       ),
          //     );
          //   }),
          // ],

          /// 如果作业指导，只有一个，直接进入详情
          /// 如果有多个作业指导，则进入列表

          // Observer(builder: (_) {
          //   return _BuildInfoRowItem(
          //     onTap: () => {
          //       if (store.instructionList.length > 1)
          //         {
          //           store.toWorkInstructionsList(),
          //         }
          //       else
          //         {
          //           store.toWorkInstructionsDetail(),
          //         }
          //     },
          //     title: '作业指导',
          //     data: WisText(
          //       (store.instructionList != null) &&
          //               store.instructionList.length > 1
          //           ? '查看'
          //           : (store.instructionList != null) &&
          //                   (store.instructionList.length > 0)
          //               ? store?.instructionList[0]?.name
          //               : '--',
          //       color: colorScheme.primary,
          //       textAlign: TextAlign.right,
          //       size: 15.pt,
          //       weight: FontWeight.w300,
          //     ),
          //     isLast: true,
          //   );
          // })
        ],
      );
    });
  }
}

/// 基本信息项
class _BuildInfoRowItem extends StatelessWidget {
  const _BuildInfoRowItem({
    Key? key,
    this.title,
    this.data,
    this.isLast,
  }) : super(key: key);
  final String? title;
  final Widget? data;
  final bool? isLast;
  // final Function onTap = () => {};
  @override
  Widget build(BuildContext context) {
    return Wisdom.row(
      // onTap: () => onTap!(),
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      crossAxisAlignment: CrossAxisAlignment.start,
      margin: EdgeInsets.only(bottom: isLast == true ? 0 : 10.pt),
      children: [
        Row(
          children: [
            WisText(
              title!,
              color: Color(0xFF616178),
              size: 14.pt,
              weight: FontWeight.w300,
            ),
            SizedBox(width: 10.pt),
          ],
        ),
        data!.asExpanded(),
      ],
    );
  }
}
