import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import '../../common/color/appFontsize.dart';
import '../../controller/mh_controller/apply_repair_controller.dart';

class ImgPreviewWidget extends GetView {
  String imgUrl;
  int index;
  ApplyRepairController applyRepairController;
  bool isDel;

  ImgPreviewWidget(
      {required this.imgUrl,
      required this.index,
      required this.applyRepairController,
      required this.isDel}) {}

  @override
  Widget build(BuildContext context) {
    return Container(
      width: MediaQuery.sizeOf(context).width * 0.25,
      height: MediaQuery.sizeOf(context).height * 0.15,
      constraints: BoxConstraints(
        minHeight: 140,
      ),
      decoration: BoxDecoration(
        color: Colors.white,
      ),
      child: Column(
        mainAxisSize: MainAxisSize.max,
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Expanded(
            child: Container(
              width: MediaQuery.sizeOf(context).width,
              height: MediaQuery.sizeOf(context).height * 0.116,
              decoration: BoxDecoration(
                color: Color(0xFFF3F5F6),
                borderRadius: BorderRadius.circular(8),
              ),
              child: ClipRRect(
                borderRadius: BorderRadius.circular(8),
                child: Image.network(
                  imgUrl,

                  // applyRepairController.getPublicUrl(imgUrl),
                  width: 300,
                  height: 200,
                  fit: BoxFit.cover,
                ),
              ),
            ),
          ),
          Visibility(
              visible: isDel,
              child: Align(
                alignment: AlignmentDirectional(0, 0),
                child: Padding(
                    padding: EdgeInsetsDirectional.fromSTEB(0, 8, 0, 13),
                    child: InkWell(
                      onTap: () {
                        applyRepairController.model.issue_img!.removeAt(index);
                        applyRepairController.updateAll();
                      },
                      child: Text(
                        '删除',
                        style: TextStyle(
                          fontFamily: 'Readex Pro',
                          color: Color(0xFF9EA4B7),
                          fontSize: AppFontsize.small_text_size,
                          letterSpacing: 0,
                        ),
                      ),
                    )),
              )),
        ],
      ),
    );
  }
}
