import 'package:flutter/material.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:get/get.dart';
import 'package:flutter/services.dart';
import 'package:lottie/lottie.dart';
import '../../Helper/Constants/Assetconstants.dart';
import '../../Helper/Constants/Colorconstants.dart';
import '../../Helper/toast.dart';


class NoInternetScreen extends StatelessWidget {
  final connectivityResult;

  NoInternetScreen({super.key, this.connectivityResult});
  final _scaffoldKey = GlobalKey<ScaffoldState>();
  // InterNetConnectionController interNetConnectionController = Get.put(InterNetConnectionController());

  Future<bool> actionFunction() {
    SystemNavigator.pop();
    return Future.value(true);
  }
  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: ()async{
        bool navigateStatus  = false;
        if(connectivityResult.contains(ConnectivityResult.wifi) || connectivityResult.contains(ConnectivityResult.mobile) ||connectivityResult.contains(ConnectivityResult.ethernet) ||connectivityResult.contains(ConnectivityResult.vpn)){
          navigateStatus = true;
        }

        return navigateStatus;
      },
      child: Scaffold(
        key: _scaffoldKey,
        body: Container(
          height: Get.height,
          width: Get.width,
          color: ColorConstants.secondaryColor,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              Stack(
                alignment: Alignment.topLeft,
                children: [
                  Container(
                    height: Get.height * 0.25,
                    width: Get.width,
                    decoration: const BoxDecoration(
                        image: DecorationImage(
                            image: AssetImage(
                              AssetConstants.nearleAppbarTop,
                            ),
                            fit: BoxFit.fill),
                        // color: ColorConstants.primaryColor,
                        borderRadius: BorderRadius.only(
                            bottomLeft: Radius.elliptical(20, 20),
                            bottomRight: Radius.elliptical(20, 20))),
                  ),
                  Padding(
                    padding: const EdgeInsets.only(top: 64, left: 20),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        CircleAvatar(
                          radius: 40,
                          backgroundColor: Colors.white,
                          child: SizedBox(
                            height: Get.height*0.08,
                            width: Get.width*0.7,
                            child: Image.asset(AssetConstants.nearleAppbarDarkLogo),

                          ),
                        ),

                        SizedBox(
                          height: Get.height*0.09,
                          width: Get.width*0.6,
                          child: Padding(
                            padding: const EdgeInsets.only(left: 25),
                            child: Image.asset(AssetConstants.nearleTextLogoWhite),
                          ),

                        ),
                      ],
                    ),
                  ),
                ],
              ),


              const Padding(
                padding: EdgeInsets.only(left: 30,right: 30),
                child: Text(
                  "Please Connect to the Network and Try Again",
                  textAlign: TextAlign.center,
                  style: TextStyle(
                      fontSize: 20,height: 1.4,
                      color: ColorConstants.primaryColor,
                      fontFamily: 'Inter',
                      fontWeight: FontWeight.bold
                  ),

                ),
              ),
              const SizedBox(
                height: 40,
              ),

              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Container(
                      height: Get.height*0.50,
                      width: Get.width*0.6,
                      color:ColorConstants.secondaryColor,
                      child: Lottie.asset('assets/images/nointernet.json',width: Get.width*0.8,fit: BoxFit.cover)),
                ],
              ),

            ],
          ),
        ),
        bottomNavigationBar:  Container(
          height: Get.height*0.1,
          width: Get.width,
          decoration: const BoxDecoration(
              image:DecorationImage(image:AssetImage(AssetConstants.nearleAppbarBottom,),fit: BoxFit.fill),
              // color: ColorConstants.primaryColor,
              borderRadius: BorderRadius.only(
                  bottomLeft: Radius.elliptical(3, 3),
                  bottomRight: Radius.elliptical(3, 3))),
        ),

      ),
    );
  }
}
