import 'package:cached_network_image/cached_network_image.dart';
import 'package:hmg_patient_app/uitl/utils_new.dart';
import 'package:flutter/material.dart';

showZoomImageDialog(BuildContext context, String url, {bool isNetworkImage = true}) {
  showDialog(
    context: context,
    builder: (BuildContext context) => Dialog(
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(12.0),
      ), //this right here
      child: ShowZoomImage(url, isNetworkImage),
    ),
  );
}

class ShowZoomImage extends StatelessWidget {
  String url;
  bool isNetworkImage = true;

  ShowZoomImage(this.url, this.isNetworkImage);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      child: Column(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.end,
        crossAxisAlignment: CrossAxisAlignment.end,
        children: [
          IconButton(
            icon: Icon(Icons.close),
            onPressed: () {
              Navigator.pop(context);
            },
          ),
          isNetworkImage
              ? CachedNetworkImage(
                  imageUrl: url,
                  height: MediaQuery.of(context).size.width / 1.4,
                  width: double.infinity,
                )
              : Image.asset(
                  url,
                  height: MediaQuery.of(context).size.width / 1.4,
                  width: double.infinity,
                ),
          mHeight(12),
        ],
      ),
    );
  }
}
