import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:vbvs_app/common/color/appColors.dart';
import 'package:vbvs_app/common/color/repair_status.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/controller/mh_controller/repair_info_controller.dart';

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

class RepairStatusWidget extends GetView {
  int index;
  RepairInfoController repairInfoController;

  RepairStatusWidget(
      {required this.index, required this.repairInfoController}) {}

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 0),
      child: Container(
        width: MediaQuery.sizeOf(context).width,
        decoration: BoxDecoration(
            // color: Colors.white,
            ),
        child: Container(
          width: MediaQuery.sizeOf(context).width,
          decoration: BoxDecoration(
            // color: Colors.white,
            borderRadius: BorderRadius.circular(8),
          ),
          child: Column(
            mainAxisSize: MainAxisSize.max,
            children: [
              Align(
                alignment: AlignmentDirectional(-1, 0),
                child: Padding(
                  padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 10),
                  child: Text(
                    // '2023-08-22 12:12:44',
                    MyUtils.formatDateTime(repairInfoController
                            .model.repairProcessList[index].create_time!) ??
                        '未知时间',
                    style: TextStyle(
                      fontFamily: 'Readex Pro',
                      fontSize: 26.rpx,
                      letterSpacing: 0,
                      color: index ==
                              repairInfoController
                                      .model.repairProcessList.length -
                                  1
                          ? Colors.white
                          : Colors.white,
                    ),
                  ),
                ),
              ),
              Align(
                alignment: AlignmentDirectional(-1, 0),
                child: Padding(
                  padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 10),
                  child: Text(
                    // '审核中',
                    repairInfoController
                            .model.repairProcessList[index].status ??
                        '未知状态',
                    style: TextStyle(
                      fontFamily: 'Readex Pro',
                      fontSize: 26.rpx,
                      letterSpacing: 0,
                      color: repairInfoController
                                  .model.repairProcessList[index].status ==
                              RepairStatus.pending
                          ? AppColors().check_Color
                          : repairInfoController.model.repairProcessList[index]
                                          .status ==
                                      RepairStatus.approved ||
                                  repairInfoController.model
                                          .repairProcessList[index].status ==
                                      '维修中'
                              ? AppColors().repair_Color
                              : repairInfoController.model
                                          .repairProcessList[index].status ==
                                      RepairStatus.completed
                                  ? AppColors().finish_Color
                                  : AppColors().unOp_Color, // 根据状态设置文字颜色
                    ),
                  ),
                ),
              ),
              Align(
                alignment: AlignmentDirectional(-1, 0),
                child: Text(
                  // repairProcessModel.content ?? '未备注',
                  (repairInfoController
                              .model.repairProcessList[index].desc?.isEmpty ??
                          true)
                      ? '未备注'
                      : repairInfoController
                          .model.repairProcessList[index].desc!,
                  style: TextStyle(
                    fontFamily: 'Readex Pro',
                    color: Colors.white,
                    fontSize: 20.rpx,
                    letterSpacing: 0,
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
