Skip to content

Commit

Permalink
Added Alert Dialogue
Browse files Browse the repository at this point in the history
  • Loading branch information
pratit989 committed Jun 12, 2021
1 parent e90e79f commit 8cd53bc
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions lib/Screens/More.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:school_management_system/main.dart';

class MorePage extends StatefulWidget {
const MorePage({Key? key}) : super(key: key);
Expand All @@ -12,6 +13,91 @@ class _MorePageState extends State<MorePage> {
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: Column(
children: [
Card(
child: TextButton(
onPressed: () {
authInstance.signOut();
Navigator.pushReplacementNamed(context, '/Login');
},
child: Row(
children: [
Icon(Icons.logout,),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Logout", style: TextStyle()),
),
],
),
style: ButtonStyle(
fixedSize: MaterialStateProperty.all(Size.fromWidth(MediaQuery.of(context).size.width-10))
),
),
),
Card(
child: TextButton(
onPressed: () {
showAlertDialog(
context,
acceptBtnText: "Delete",
onPressedAcceptBtn: () {authInstance.currentUser!.delete();Navigator.pushReplacementNamed(context, '/SignUp');},
onPressedCancelBtn: () {Navigator.of(context).pop();},
title: "Delete Alert",
description: "Are you sure you want to delete you account permanently?"
);
},
child: Row(
children: [
Icon(Icons.delete, color: Colors.red,),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Delete Account", style: TextStyle(color: Colors.red)),
),
],
),
),
)
],
),
);
}
}

showAlertDialog(BuildContext context, {
required String description,
required String title,
String cancelBtnText='Cancel',
required void Function()? onPressedCancelBtn,
String acceptBtnText='Accept',
required void Function()? onPressedAcceptBtn,
}) {

// set up the buttons
Widget cancelButton = TextButton(
child: Text(cancelBtnText),
onPressed: onPressedCancelBtn,
);
Widget continueButton = TextButton(
child: Text(acceptBtnText, style: TextStyle(color: Colors.red),),
onPressed: onPressedAcceptBtn,
);

// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: Text(title),
content: Text(description),
actions: [
cancelButton,
continueButton,
],
);

// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}

0 comments on commit 8cd53bc

Please sign in to comment.