mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Can sign out of the application
This commit is contained in:
66
lib/ui/screens/menus_screen.dart
Normal file
66
lib/ui/screens/menus_screen.dart
Normal file
@ -0,0 +1,66 @@
|
||||
import 'package:comunic/helpers/account_helper.dart';
|
||||
import 'package:comunic/ui/routes/login_route.dart';
|
||||
import 'package:comunic/ui/tiles/menu_tile.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Menu screen
|
||||
///
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
class MenuScreen extends StatelessWidget {
|
||||
/// Ask the user if he really wants to sign out from the application
|
||||
Future<void> _confirmSignOut(BuildContext context) async {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (c) {
|
||||
return AlertDialog(
|
||||
title: Text(tr("Confirm sign out")),
|
||||
content: Text(
|
||||
tr("Do your really want to sign out from the application ?")),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text(tr("Cancel").toUpperCase()),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, false);
|
||||
},
|
||||
),
|
||||
FlatButton(
|
||||
child: Text(
|
||||
tr("Sign out").toUpperCase(),
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, true);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if(result == null || !result)
|
||||
return;
|
||||
|
||||
await AccountHelper().signOut();
|
||||
|
||||
Navigator.pushReplacement(context, MaterialPageRoute(builder: (c){
|
||||
return LoginRoute();
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
children: <Widget>[
|
||||
MenuTile(
|
||||
title: tr("Sign out"),
|
||||
onTap: () {
|
||||
_confirmSignOut(context);
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user