mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-23 05:19:22 +00:00
67 lines
1.7 KiB
Dart
67 lines
1.7 KiB
Dart
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);
|
|
},
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|