import 'dart:io';

import 'package:flutter/material.dart';

import '../../app_style/colors.dart';
import '../../app_style/sizing.dart';
import '../buttons/app_back_button.dart';

class MultiImagesPickerItem extends StatelessWidget {
  final File image;
  final Function(File)? onRemoveTap;

  const MultiImagesPickerItem({Key? key, required this.image, this.onRemoveTap}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 80 * AppStyle.getScaleFactor(context),
      height: 80 * AppStyle.getScaleFactor(context),
      decoration:
          BoxDecoration(boxShadow: [BoxShadow(color: Colors.black38, blurRadius: 2)], image: DecorationImage(image: FileImage(image), fit: BoxFit.cover), borderRadius: BorderRadius.circular(8)),
      child: MaterialButton(
        padding: EdgeInsets.zero,
        onPressed: () {
          Navigator.of(context).push(MaterialPageRoute(
              builder: (_) => Scaffold(
                    body: SafeArea(
                      child: Stack(
                        children: [
                          Center(
                            child: InteractiveViewer(
                                child: Image(
                              image: FileImage(image),
                            )),
                          ),
                          ABackButton(),
                        ],
                      ),
                    ),
                  )));
        },
        child: Align(
            alignment: Alignment.topRight,
            child: IconButton(
              padding: const EdgeInsets.all(2.0),
              icon: Container(
                  padding: EdgeInsets.all(1),
                  decoration: BoxDecoration(color: Theme.of(context).scaffoldBackgroundColor.withOpacity(.3), borderRadius: BorderRadius.circular(8)),
                  child: Icon(
                    Icons.remove_circle,
                    color: AColors.red,
                  )),
              onPressed: () {
                onRemoveTap!(image);
              },
            )),
      ),
    );
  }
}
