import 'package:farm_tpf/utils/const_assets.dart';
import 'package:farm_tpf/utils/const_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

class LoadingDialog {
  static void showLoadingDialog(BuildContext context) {
    showDialog(
        context: context,
        barrierDismissible: false,
        builder: (context) {
          return WillPopScope(
            onWillPop: () async => false,
            child: Opacity(
                opacity: 1,
                child: Stack(
                  children: <Widget>[
                    Align(
                      alignment: Alignment.center,
                      child: Container(
                          decoration: BoxDecoration(
                              color: Colors.white,
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(16.0))),
                          width: 80.0,
                          height: 80.0),
                    ),
                    Container(
                      alignment: Alignment.center,
                      child: SizedBox(
                          width: 25,
                          height: 25,
                          child: Image.asset(AppAssets.logo)),
                    ),
                    Container(
                      alignment: Alignment.center,
                      child: const SizedBox(
                        child: CircularProgressIndicator(
                          strokeWidth: 2.0,
                        ),
                        width: 60.0,
                        height: 60.0,
                      ),
                    )
                  ],
                )),
          );
        });
  }

  static void hideLoadingDialog(BuildContext context) {
    Navigator.pop(context, "");
  }
}
