1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-30 08:46:27 +00:00
comunicmobile/lib/ui/screens/menus_screen.dart

67 lines
1.7 KiB
Dart
Raw Normal View History

2019-04-23 09:48:49 +00:00
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);
},
)
],
);
}
}