import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import '../../../../core/constants/translation_keys.dart';
import '../../../../custom_widgets/custom_label.dart';
import '../../../../res/app_colors.dart';
import '../../../../res/app_dimensions.dart';
import 'bottom_sheet_login.dart';

class LoginWidgets {
  static Widget bottomTabs(BuildContext context, String text, String iconName, VoidCallback onPress, TextStyle textStyle) {
    return SizedBox(
      width: 95,
      height: 75,
      child: InkWell(
        onTap: onPress,
        customBorder: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(8), // Set the border radius
        ),
        child: Container(
          padding: const EdgeInsets.all(8), // Add padding as needed
          decoration: BoxDecoration(
            border: Border.all(
              color: Colors.grey.withOpacity(0),
            ), // Set border color
            borderRadius: BorderRadius.circular(8), // Set border radius
          ),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Expanded(
                child: Image(
                  image: AssetImage(iconName),
                  width: 30,
                  height: 30,
                ),
              ),
              const SizedBox(height: 3),
              Expanded(
                child: Center(
                  child: LabelText(text, style: textStyle),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

  static void showBottomSheet(BuildContext context, List<BottomSheetLogin> options, Function onPress) {

    Get.bottomSheet(
      isScrollControlled: true,
      Container(
        decoration: BoxDecoration(color: Colors.white, border: Border.all(color: AppColors.colorPrimary, width: 1), borderRadius: BorderRadius.only(topLeft: Radius.circular(AppDimensions.radiusCard), topRight: Radius.circular(AppDimensions.radiusCard))),
        margin: EdgeInsets.only(left: AppDimensions.screenVerticalPadding, right: AppDimensions.screenVerticalPadding),
        child: Wrap(
          children: [
            Padding(
              padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 15),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(TranslationKeys.makeTranslation(TranslationKeys.textLogin), style: Theme.of(context).textTheme.titleSmall),
                  InkWell(
                      onTap: () {
                        Navigator.pop(context);
                      },
                      child: SvgPicture.asset("assets/icons/ic_crossIcon.png")),
                ],
              ),
            ),
            GridView.builder(
                padding: const EdgeInsets.only(left: 15, right: 15, top: 0, bottom: 15),
                itemCount: options.length,
                shrinkWrap: true,
                physics: const NeverScrollableScrollPhysics(),
                itemBuilder: (context, index) {
                  BottomSheetLogin bottomSheetLogin = options[index];
                  return InkWell(
                      customBorder: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(AppDimensions.radiusCard),
                      ),
                      onTap: bottomSheetLogin.onTap,
                      child: Container(
                          padding: const EdgeInsets.all(8),
                          alignment: Alignment.center,
                          decoration: BoxDecoration(border: Border.all(color: AppColors.colorPrimary, width: 1), borderRadius: BorderRadius.all(Radius.circular(AppDimensions.radiusCard))),
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              Image(
                                image: AssetImage(bottomSheetLogin.icon),
                                width: 50,
                              ),
                              const SizedBox(height: 20),
                              Center(
                                child: LabelText(bottomSheetLogin.description, labelColor: AppColors.colorTitle, fontSize: 18),
                              ),
                            ],
                          )));
                },
                gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 2,
                  crossAxisSpacing: 10,
                  mainAxisSpacing: 10,
                )),
          ],
        ),
      ),
      backgroundColor: Colors.transparent,
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(AppDimensions.radiusCard), topRight: Radius.circular(AppDimensions.radiusCard))),
    );
  }
}
