import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';

class AttachmentOptions extends StatelessWidget {
  VoidCallback onCameraTap;
  VoidCallback onGalleryTap;
  VoidCallback onFilesTap;
  bool showFilesOption;

  AttachmentOptions({Key? key, required this.onCameraTap, required this.onGalleryTap, required this.onFilesTap, this.showFilesOption = true}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: double.infinity,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          "Upload Attachment".toSectionHeading(),
          "Select from gallery or open camera".toText11(weight: FontWeight.w500),
          GridView(
            gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 105 / 105, crossAxisSpacing: 9, mainAxisSpacing: 9),
            physics: const NeverScrollableScrollPhysics(),
            padding: const EdgeInsets.only(top: 21, bottom: 14),
            shrinkWrap: true,
            children: [
              itemView("open_camera.svg", "Open\nCamera", onCameraTap),
              itemView("gallery.svg", "Upload from\nGallery", onGalleryTap),
              if (showFilesOption) itemView("files.svg", "Upload from\nFiles", onFilesTap),
            ],
          )
        ],
      ).paddingOnly(left: 21, right: 21, bottom: 21),
    );
  }

  Widget itemView(String icon, String title, VoidCallback onTap) {
    return InkWell(
      onTap: onTap,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          SvgPicture.asset("assets/images/$icon"),
          title.toText11(isBold: true),
        ],
      ).paddingOnly(left: 13, right: 13, top: 16, bottom: 12).expanded.objectContainerBorderView(
            disablePadding: true,
            radius: 10,
            color: MyColors.greyF7Color.withOpacity(.48),
            borderColor: MyColors.lightGreyE5Color.withOpacity(.48),
          ),
    );
  }
}
