52 lines
1.3 KiB
Dart
52 lines
1.3 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../constants.dart';
|
|
import '../events/eventbus.dart';
|
|
import '../events/events.dart';
|
|
import '../generated/l10n.dart';
|
|
import '../routes.dart';
|
|
import '../store/actions.dart';
|
|
import '../store/store.dart';
|
|
import '../utils/utils.dart';
|
|
|
|
AlertDialog logoutDialog(BuildContext context) {
|
|
return AlertDialog(
|
|
title: Text(S
|
|
.of(context)
|
|
.warning),
|
|
content: Text(S
|
|
.of(context)
|
|
.are_you_sure_to_logout),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
child: Text(S
|
|
.of(context)
|
|
.cancel),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
TextButton(
|
|
child: Text(S
|
|
.of(context)
|
|
.yes_i_am_sure),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
Utils.getBox().then((box) {
|
|
box.delete(Constants.KEY_USER_ID);
|
|
box.delete(
|
|
Constants.KEY_ACCESS_TOKEN);
|
|
store.dispatch(
|
|
new UpdateCurrentUser(null));
|
|
eventBus.fire(
|
|
new OnCurrentUserUpdated());
|
|
Routes.router.navigateTo(
|
|
context, '/', replace: true,
|
|
clearStack: true);
|
|
});
|
|
},
|
|
)
|
|
],
|
|
);
|
|
} |