75 lines
2.1 KiB
Dart
75 lines
2.1 KiB
Dart
import 'package:faucethub/Backend/login_mgr.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import '../main.dart';
|
|
|
|
class Dialogs{
|
|
|
|
static showAlertDialog(BuildContext context, String title, String message) {
|
|
// set up the button
|
|
Widget okButton = TextButton(
|
|
child: Text("OK"),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
);
|
|
|
|
// set up the AlertDialog
|
|
AlertDialog alert = AlertDialog(
|
|
backgroundColor: Color(0xFF1F1F1F),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
|
title: Text(title),
|
|
content: Text(message),
|
|
actions: [
|
|
okButton,
|
|
],
|
|
|
|
);
|
|
|
|
// show the dialog
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return alert;
|
|
},
|
|
);
|
|
}
|
|
|
|
static bool showing = false;
|
|
static BuildContext? context;
|
|
static waiting(){
|
|
showing=true;
|
|
context=navigatorKey.currentContext;
|
|
if(context!=null) {
|
|
return showDialog(
|
|
context: context!,
|
|
barrierDismissible: false,
|
|
routeSettings: const RouteSettings(name: "Progress"),
|
|
builder: (BuildContext context) {
|
|
return AlertDialog(
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
|
|
backgroundColor: Color(0xaa101010),
|
|
title: Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
SpinKitChasingDots(color: Colors.green),
|
|
Expanded(child: Text("Loading",textAlign: TextAlign.center,)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
);
|
|
}
|
|
}
|
|
static hide(){
|
|
showing=false;
|
|
Navigator.of(navigatorKey.currentContext!).popUntil((route){
|
|
return route.settings.name!="Progress";
|
|
});
|
|
}
|
|
} |