mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-26 14:59:22 +00:00
75 lines
1.9 KiB
Dart
75 lines
1.9 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/account_utils.dart';
|
|
import 'package:comunic/utils/intl_utils.dart';
|
|
import 'package:comunic/utils/navigation_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("My page"),
|
|
onTap: () {
|
|
openUserPage(context: context, userID: userID());
|
|
},
|
|
),
|
|
MenuTile(
|
|
title: tr("Sign out"),
|
|
onTap: () {
|
|
_confirmSignOut(context);
|
|
},
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|