import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';

import '../../../../core/constants/translation_keys.dart';
import '../../../../res/app_colors.dart';
import '../../../../routes/app_pages.dart';

// import 'package:url_launcher/url_launcher.dart';

class BottomSheetLogin {
  String _description = "";
  String _icon = "";
  String billTypes = "";
  Function()? onTap;

  BottomSheetLogin({
    required String description,
    required String icon,
    required this.onTap,
    this.billTypes = "",
  }) {
    _description = description;
    _icon = icon;
    this.billTypes = "";
  }

  String get description => _description;

  set description(String value) {
    _description = value;
  }

  String get icon => _icon;

  set icon(String value) {
    _icon = value;
  }

  static List<BottomSheetLogin> options = [
    BottomSheetLogin(
        description: TranslationKeys.makeTranslation(TranslationKeys.textLogin),
        icon: "assets/icons/handIcon.png",
        onTap: () {
          Get.offAndToNamed(Routes.LOGIN_SCREEN);
        }),
    BottomSheetLogin(
        description: TranslationKeys.makeTranslation(TranslationKeys.textLogin),
        icon: "assets/icons/productIcon.png",
        onTap: () {
          Get.offAndToNamed(Routes.LOGIN_SCREEN);
        }),
    BottomSheetLogin(
        description: TranslationKeys.makeTranslation(TranslationKeys.textLogin),
        icon: "assets/icons/faqsIcon.png",
        onTap: () {
          Get.offAndToNamed(Routes.LOGIN_SCREEN);
        }),
    BottomSheetLogin(
        description: TranslationKeys.makeTranslation(TranslationKeys.textLogin),
        icon: "assets/icons/ic_supportIcon.png",
        onTap: () {
          Get.back();
          showBottomSheet();
        }),
  ];

  /// Support Bottom Sheet Widget
  static showBottomSheet() {
    List<SupportBottomSheet> supportBottomSheetList = <SupportBottomSheet>[
      SupportBottomSheet(
          image: "assets/icons/email_icon.png",
          title: TranslationKeys.makeTranslation(TranslationKeys.textLogin),
          onTap: () {
            // launch("mailto:info@mfsys.com.pk");
          }),
      SupportBottomSheet(
          image: "assets/icons/phone_icon.png",
          title: TranslationKeys.makeTranslation(TranslationKeys.textLogin),
          onTap: () {
            // launch("tel:21213123123");
          }),
    ];
    Get.bottomSheet(
      Container(
        decoration: BoxDecoration(
          color: Colors.white,
          border: Border.all(color: Colors.grey, width: 1),
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(10), topRight: Radius.circular(10)),
        ),
        margin: EdgeInsets.symmetric(horizontal: 20),
        child: Wrap(
          children: [
            Padding(
              padding: EdgeInsets.symmetric(vertical: 20, horizontal: 15),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    TranslationKeys.makeTranslation(TranslationKeys.textLogin),
                    style: TextStyle(
                        color: AppColors.colorPrimary,
                        fontSize: 14,
                        fontWeight: FontWeight.w500),
                  ),
                  InkWell(
                      onTap: () {
                        Get.back();
                      },
                      child: SvgPicture.asset("assets/icons/ic_crossIcon.png")),
                ],
              ),
            ),
            Container(
              padding: EdgeInsets.all(10),
              child: GridView.builder(
                itemCount: supportBottomSheetList.length,
                shrinkWrap: true,
                physics: const NeverScrollableScrollPhysics(),
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 2,
                  crossAxisSpacing: 15,
                  mainAxisSpacing: 15,
                ),
                itemBuilder: (context, index) {
                  return InkWell(
                    customBorder: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(10),
                    ),
                    onTap: supportBottomSheetList[index].onTap,
                    child: Container(
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        border: Border.all(color: Colors.grey, width: 1),
                        borderRadius: BorderRadius.all(Radius.circular(10)),
                      ),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          SvgPicture.asset("${supportBottomSheetList[index].image}"),
                          SizedBox(height: 20),
                          Center(
                            child: Text("Data"),
                          ),
                        ],
                      ),
                    ),
                  );
                },
              ),
            ),
          ],
        ),
      ),
      isScrollControlled: true,
      backgroundColor: Colors.transparent,
      shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(10), topRight: Radius.circular(10))),
    );
  }
}

class SupportBottomSheet {
  String? image;
  String? title;
  Function()? onTap;

  SupportBottomSheet({this.image, this.title, this.onTap});
}
