import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'main.dart';

class Dialogs{
  static bool showing = false;
  static BuildContext? context;
  static List<Widget> popupsOpened=[];
  static waiting( String title){
    showing=true;
    context=navigatorKey.currentContext;
    if(context!=null) {
      return showDialog(
          context: context!,
          barrierDismissible: false,
          routeSettings: const RouteSettings(name: "Progress"),
          builder: (BuildContext context) {
            return AlertDialog(
              title: Row(
                mainAxisSize: MainAxisSize.max,
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  SpinKitChasingDots(color: Colors.green),
                  Expanded(child: Text(title,textAlign: TextAlign.center,)),
                ],
              ),
            );
          }
      );
    }
  }


  static hide(){
    showing=false;
    Navigator.of(navigatorKey.currentContext!).popUntil((route){
      return route.settings.name!="Progress";
    });
  }
}