import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:vbvs_app/common/color/appColors.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/mh_controller/repair_info_controller.dart';
import 'package:vbvs_app/controller/mh_controller/repair_list_controller.dart';
import 'package:vbvs_app/pages/mh_page/ColorChangeOnTap.dart';

import '../../common/color/appFontsize.dart';

class RepairHistoryWidget extends GetView<RepairInfoController> {
  int index;
  RepairListController repairListController;

  RepairHistoryWidget(
      {required this.index, required this.repairListController}) {}

  @override
  Widget build(BuildContext context) {
    int tmp = index;
    index = tmp;

    return ClickableContainer(
        backgroundColor: Colors.transparent,
        highlightColor: Color(0XFF055466),
        padding: EdgeInsets.only(top: 0),
        onTap: () {
          TopSlideNotification.show(
            context,
            text: "功能开发中...",
          );

          // Get.toNamed("/repairHistoryListPage",
          //     arguments: repairListController.model.repairList[index]);
        },
        child: Container(
            // height: 119.rpx,
            height: MediaQuery.sizeOf(context).height * 0.0733,
            decoration: BoxDecoration(
              // color: const Color(0xFF06486F),
              border: Border(
                top: index == 0
                    ? BorderSide(color: const Color(0xFF929699), width: 0.5.rpx)
                    : BorderSide.none,
                bottom:
                    BorderSide(color: const Color(0xFF929699), width: 0.5.rpx),
              ),
            ),
            child: Padding(
              padding: EdgeInsets.fromLTRB(17.rpx, 0, 30.rpx, 0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  // 左侧设备信息
                  Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        repairListController.model.repairList[index]['device']
                                [0]['mac'] ??
                            '',
                        style: TextStyle(
                            color: Colors.white, fontSize: 30.rpx, height: 1),
                      ),
                      const SizedBox(height: 4),
                      Text(
                        "提交时间：" +
                            (MyUtils.formatTimestamp(repairListController
                                    .model.repairList[index]["create_time"]) ??
                                ''),
                        style: TextStyle(
                            color: Colors.white60, fontSize: 20.rpx, height: 1),
                      ),
                    ],
                  ),
                  // 右侧状态
                  Row(
                    children: [
                      Text(
                        getStatusText(repairListController
                            .model.repairList[index]['status']),
                        style: TextStyle(color: Colors.white, fontSize: 26.rpx),
                      ),
                      ClickableContainer(
                          backgroundColor: Colors.transparent,
                          highlightColor: Colors.transparent,
                          padding: EdgeInsets.only(right: 0),
                          onTap: () {},
                          child: Container(
                              height: 30.rpx,
                              width: 30.rpx,
                              child: SvgPicture.asset(
                                'assets/img/icon/expand.svg',
                                color: Colors.white,
                              )
                              //  Icon(
                              //   Icons.arrow_forward_ios,
                              //   color: Colors.white,
                              //   // size: 14.rpx,
                              // ),
                              )),
                    ],
                  )
                ],
              ),
            )));
  }

  String getStatusText(dynamic status) {
    switch (status?.toString()) {
      case '1':
        return '审核中';
      case '2':
        return '审核通过';
      case '3':
        return '维修中';
      case '4':
        return '维修完成';
      case '5':
        return '已完成';
      case '6':
        return '已评价';
      default:
        return '未知状态';
    }
  }
}
