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 _confirmSignOut(BuildContext context) async { final result = await showDialog( 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: [ 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: [ MenuTile( title: tr("Sign out"), onTap: () { _confirmSignOut(context); }, ) ], ); } }