Enhanced UX and clean up
This commit is contained in:
parent
7b2f4c0163
commit
e665f4adc3
6 changed files with 41 additions and 89 deletions
|
|
@ -7,6 +7,7 @@ import 'package:fluffychat/views/chat_details.dart';
|
|||
import 'package:fluffychat/views/chat_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'dialogs/simple_dialogs.dart';
|
||||
import 'matrix.dart';
|
||||
|
||||
class ChatSettingsPopupMenu extends StatefulWidget {
|
||||
|
|
@ -66,11 +67,16 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
onSelected: (String choice) async {
|
||||
switch (choice) {
|
||||
case "leave":
|
||||
await Matrix.of(context)
|
||||
.tryRequestWithLoadingDialog(widget.room.leave());
|
||||
await Navigator.of(context).pushAndRemoveUntil(
|
||||
AppRoute.defaultRoute(context, ChatListView()),
|
||||
(Route r) => false);
|
||||
bool confirmed = await SimpleDialogs(context).askConfirmation();
|
||||
if (confirmed) {
|
||||
final success = await Matrix.of(context)
|
||||
.tryRequestWithLoadingDialog(widget.room.leave());
|
||||
if (success != false) {
|
||||
await Navigator.of(context).pushAndRemoveUntil(
|
||||
AppRoute.defaultRoute(context, ChatListView()),
|
||||
(Route r) => false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "mute":
|
||||
await Matrix.of(context).tryRequestWithLoadingDialog(
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ConfirmDialog extends StatelessWidget {
|
||||
const ConfirmDialog(
|
||||
this.text,
|
||||
this.confirmText,
|
||||
this.onConfirmed,
|
||||
);
|
||||
final String text;
|
||||
final String confirmText;
|
||||
final Function(BuildContext) onConfirmed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(text),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text(I18n.of(context).close.toUpperCase(),
|
||||
style: TextStyle(color: Colors.blueGrey)),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
FlatButton(
|
||||
child: Text(
|
||||
confirmText.toUpperCase(),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
onConfirmed(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -37,18 +37,23 @@ class SimpleDialogs {
|
|||
labelText: labelText,
|
||||
prefixText: prefixText,
|
||||
suffixText: suffixText,
|
||||
prefixStyle: TextStyle(color: Theme.of(context).primaryColor),
|
||||
suffixStyle: TextStyle(color: Theme.of(context).primaryColor),
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text(cancelText ?? I18n.of(context).close.toUpperCase(),
|
||||
child: Text(
|
||||
cancelText?.toUpperCase() ??
|
||||
I18n.of(context).close.toUpperCase(),
|
||||
style: TextStyle(color: Colors.blueGrey)),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
FlatButton(
|
||||
child: Text(
|
||||
confirmText ?? I18n.of(context).confirm.toUpperCase(),
|
||||
confirmText?.toUpperCase() ??
|
||||
I18n.of(context).confirm.toUpperCase(),
|
||||
),
|
||||
onPressed: () {
|
||||
input = controller.text;
|
||||
|
|
@ -70,16 +75,19 @@ class SimpleDialogs {
|
|||
await showDialog(
|
||||
context: context,
|
||||
builder: (c) => AlertDialog(
|
||||
title: Text(I18n.of(context).areYouSure ?? titleText),
|
||||
title: Text(titleText ?? I18n.of(context).areYouSure),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text(cancelText ?? I18n.of(context).close.toUpperCase(),
|
||||
child: Text(
|
||||
cancelText?.toUpperCase() ??
|
||||
I18n.of(context).close.toUpperCase(),
|
||||
style: TextStyle(color: Colors.blueGrey)),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
FlatButton(
|
||||
child: Text(
|
||||
confirmText ?? I18n.of(context).confirm.toUpperCase(),
|
||||
confirmText?.toUpperCase() ??
|
||||
I18n.of(context).confirm.toUpperCase(),
|
||||
),
|
||||
onPressed: () {
|
||||
confirmed = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue