import 'package:auto_size_text/auto_size_text.dart';
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/models/hmg_services.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_page.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/E-Referral/e_referral_page.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/home_health_care_page.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/h2o_page.dart';
import 'package:diplomaticquarterapp/pages/ContactUs/contact_us_page.dart';
import 'package:diplomaticquarterapp/pages/ContactUs/findus/findus_page.dart';
import 'package:diplomaticquarterapp/pages/Covid-DriveThru/covid-drivethru-location.dart';
import 'package:diplomaticquarterapp/pages/ErService/ErOptions.dart';
import 'package:diplomaticquarterapp/pages/livecare/livecare_home.dart';
import 'package:diplomaticquarterapp/pages/paymentService/payment_service.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class ServicesView extends StatelessWidget {
  HmgServices hmgServices;
  int index;

  ServicesView(this.hmgServices, this.index);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        if (index == 0) {
          Navigator.push(context, FadePage(page: LiveCareHome()));
        } else if (index == 1) {
          Navigator.push(context, FadePage(page: CovidDrivethruLocation()));
        } else if (index == 2) {
          Navigator.push(context, FadePage(page: PaymentService()));
        } else if (index == 3) {
          Navigator.push(context, FadePage(page: HomeHealthCarePage()));
        } else if (index == 4) {
          Navigator.push(context, FadePage(page: CMCPage()));
        } else if (index == 5) {
          Navigator.push(context, FadePage(page: ErOptions(isAppbar: true)));
        } else if (index == 6) {
          Navigator.push(context, FadePage(page: EReferralPage()));
        } else if (index == 7) {
          Navigator.push(context, FadePage(page: H2OPage()));
        } else if (index == 8) {
          Navigator.push(context, FadePage(page: ContactUsPage()));
        }
      },
      child: Container(
        width: double.infinity,
        height: double.infinity,
        decoration: containerRadiusWithGradientServices(20, lightColor: CustomColors.lightGreyColor, darkColor: CustomColors.darkGreyColor),
        child: Stack(
          children: [
            Container(
              width: double.infinity,
              height: double.infinity,
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  mFlex(1),
                  Flexible(
                    flex: 8,
                    child: Column(
                      children: [
                        Flexible(
                          flex: 5,
                          child: Padding(
                            padding: const EdgeInsets.all(12.0),
                            child: Opacity(
                              opacity: 0.04,
                              child: hmgServices.action == 2
                                  ? Image.asset(
                                      hmgServices.icon,
                                      width: double.infinity,
                                      height: double.infinity,
                                    )
                                  : SvgPicture.asset(
                                      hmgServices.icon,
                                      width: double.infinity,
                                      height: double.infinity,
                                    ),
                            ),
                          ),
                        ),
                        mFlex(1),
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Container(
              width: double.infinity,
              height: double.infinity,
              padding: EdgeInsets.only(left: SizeConfig.widthMultiplier * 3, right: SizeConfig.widthMultiplier * 3, top: SizeConfig.widthMultiplier * 3, bottom: SizeConfig.widthMultiplier * 2),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  mFlex(1),
                  hmgServices.action == 2
                      ? Image.asset(
                          hmgServices.icon,
                          height: index == 0 ? MediaQuery.of(context).size.width / 18 : MediaQuery.of(context).size.width / 18,
                        )
                      : Container(
                          // color: Colors.yellow,
                          width: index == 4 ? MediaQuery.of(context).size.width / 12 : MediaQuery.of(context).size.width / 12,
                          height: index == 4 ? MediaQuery.of(context).size.width / 10 : MediaQuery.of(context).size.width / 12,
                          child: SvgPicture.asset(
                            hmgServices.icon,
// width: MediaQuery.of(context).size.width / 12,
                            // height: MediaQuery.of(context).size.width / 12,
                          ),
                        ),
                  mFlex(4),
                  AutoSizeText(
                    hmgServices.title,
                    maxLines: 1,
                    minFontSize: 10,
                    style: TextStyle(
                      fontSize: SizeConfig.textMultiplier * 1.6,
                      fontWeight: FontWeight.bold,
                      letterSpacing: -0.39,
                      height: 0.8,
                    ),
                  ),
                  AutoSizeText(
                    hmgServices.subTitle,
                    maxLines: 1,
                    minFontSize: 8,
                    style: TextStyle(
                      fontSize: SizeConfig.textMultiplier * 1.4,
                      letterSpacing: -0.27,
                      fontWeight: FontWeight.w600,
                    ),
                  ),
                  mFlex(1),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
