fix dialogs
This commit is contained in:
@@ -251,24 +251,45 @@ class _MessageActionsModalState extends State<MessageActionsModal> {
|
|||||||
void _showFlagDialog() async {
|
void _showFlagDialog() async {
|
||||||
final client = StreamChat.of(context).client;
|
final client = StreamChat.of(context).client;
|
||||||
|
|
||||||
var answer = await showConfirmationDialog(context,
|
final answer = await showConfirmationDialog(
|
||||||
title: 'Flag Message',
|
context,
|
||||||
icon: StreamSvgIcon.flag(
|
title: 'Flag Message',
|
||||||
color: StreamChatTheme.of(context).colorTheme.accentRed,
|
icon: StreamSvgIcon.flag(
|
||||||
size: 24.0,
|
color: StreamChatTheme.of(context).colorTheme.accentRed,
|
||||||
),
|
size: 24.0,
|
||||||
question:
|
),
|
||||||
'Do you want to send a copy of this message to a\nmoderator for further investigation?',
|
question:
|
||||||
okText: 'FLAG',
|
'Do you want to send a copy of this message to a\nmoderator for further investigation?',
|
||||||
cancelText: 'CANCEL');
|
okText: 'FLAG',
|
||||||
|
cancelText: 'CANCEL',
|
||||||
|
);
|
||||||
|
|
||||||
if (answer) {
|
final theme = StreamChatTheme.of(context);
|
||||||
|
if (answer == true) {
|
||||||
try {
|
try {
|
||||||
await client.flagMessage(widget.message.id);
|
await client.flagMessage(widget.message.id);
|
||||||
_showDismissAlert();
|
await showInfoDialog(
|
||||||
|
context,
|
||||||
|
icon: StreamSvgIcon.flag(
|
||||||
|
color: theme.colorTheme.accentRed,
|
||||||
|
size: 24.0,
|
||||||
|
),
|
||||||
|
details: 'The message has been reported to a moderator.',
|
||||||
|
title: 'Message flagged',
|
||||||
|
okText: 'OK',
|
||||||
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (json.decode(err?.body ?? {})['code'] == 4) {
|
if (json.decode(err?.body ?? {})['code'] == 4) {
|
||||||
_showDismissAlert();
|
await showInfoDialog(
|
||||||
|
context,
|
||||||
|
icon: StreamSvgIcon.flag(
|
||||||
|
color: theme.colorTheme.accentRed,
|
||||||
|
size: 24.0,
|
||||||
|
),
|
||||||
|
details: 'The message has been reported to a moderator.',
|
||||||
|
title: 'Message flagged',
|
||||||
|
okText: 'OK',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
_showErrorAlert();
|
_showErrorAlert();
|
||||||
}
|
}
|
||||||
@@ -306,133 +327,16 @@ class _MessageActionsModalState extends State<MessageActionsModal> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showDismissAlert() {
|
|
||||||
showModalBottomSheet(
|
|
||||||
backgroundColor: StreamChatTheme.of(context).colorTheme.white,
|
|
||||||
context: context,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.only(
|
|
||||||
topLeft: Radius.circular(16.0),
|
|
||||||
topRight: Radius.circular(16.0),
|
|
||||||
)),
|
|
||||||
builder: (context) {
|
|
||||||
return Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
height: 26.0,
|
|
||||||
),
|
|
||||||
StreamSvgIcon.flag(
|
|
||||||
color: StreamChatTheme.of(context).colorTheme.accentRed,
|
|
||||||
size: 24.0,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 26.0,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Message flagged',
|
|
||||||
style: StreamChatTheme.of(context).textTheme.headlineBold,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 7.0,
|
|
||||||
),
|
|
||||||
Text('The message has been reported to a moderator.'),
|
|
||||||
SizedBox(
|
|
||||||
height: 36.0,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
color:
|
|
||||||
StreamChatTheme.of(context).colorTheme.black.withOpacity(.08),
|
|
||||||
height: 1.0,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
TextButton(
|
|
||||||
child: Text(
|
|
||||||
'OK',
|
|
||||||
style: StreamChatTheme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyBold
|
|
||||||
.copyWith(
|
|
||||||
color: StreamChatTheme.of(context)
|
|
||||||
.colorTheme
|
|
||||||
.accentBlue),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showErrorAlert() {
|
void _showErrorAlert() {
|
||||||
showModalBottomSheet(
|
showInfoDialog(
|
||||||
backgroundColor: StreamChatTheme.of(context).colorTheme.white,
|
context,
|
||||||
context: context,
|
icon: StreamSvgIcon.error(
|
||||||
shape: RoundedRectangleBorder(
|
color: StreamChatTheme.of(context).colorTheme.accentRed,
|
||||||
borderRadius: BorderRadius.only(
|
size: 24.0,
|
||||||
topLeft: Radius.circular(16.0),
|
),
|
||||||
topRight: Radius.circular(16.0),
|
details: 'The operation couldn\'t be completed.',
|
||||||
)),
|
title: 'Something went wrong',
|
||||||
builder: (context) {
|
okText: 'OK',
|
||||||
return Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
height: 26.0,
|
|
||||||
),
|
|
||||||
StreamSvgIcon.error(
|
|
||||||
color: StreamChatTheme.of(context).colorTheme.accentRed,
|
|
||||||
size: 24.0,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 26.0,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Something went wrong',
|
|
||||||
style: StreamChatTheme.of(context).textTheme.headlineBold,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 7.0,
|
|
||||||
),
|
|
||||||
Text('The operation couldn\'t be completed.'),
|
|
||||||
SizedBox(
|
|
||||||
height: 36.0,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
color:
|
|
||||||
StreamChatTheme.of(context).colorTheme.black.withOpacity(.08),
|
|
||||||
height: 1.0,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
TextButton(
|
|
||||||
child: Text(
|
|
||||||
'OK',
|
|
||||||
style: StreamChatTheme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyBold
|
|
||||||
.copyWith(
|
|
||||||
color: StreamChatTheme.of(context)
|
|
||||||
.colorTheme
|
|
||||||
.accentBlue),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,38 +58,47 @@ Future<bool> showConfirmationDialog(
|
|||||||
height: 1,
|
height: 1,
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
children: [
|
||||||
TextButton(
|
Flexible(
|
||||||
child: Text(
|
child: Container(
|
||||||
cancelText,
|
alignment: Alignment.center,
|
||||||
style: StreamChatTheme.of(context)
|
child: TextButton(
|
||||||
.textTheme
|
onPressed: () {
|
||||||
.bodyBold
|
Navigator.of(context).pop(false);
|
||||||
.copyWith(
|
},
|
||||||
color: StreamChatTheme.of(context)
|
child: Text(
|
||||||
.colorTheme
|
cancelText,
|
||||||
.black
|
style: StreamChatTheme.of(context)
|
||||||
.withOpacity(0.5)),
|
.textTheme
|
||||||
|
.bodyBold
|
||||||
|
.copyWith(
|
||||||
|
color: StreamChatTheme.of(context)
|
||||||
|
.colorTheme
|
||||||
|
.black
|
||||||
|
.withOpacity(0.5)),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop(false);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
TextButton(
|
Flexible(
|
||||||
child: Text(
|
child: Container(
|
||||||
okText,
|
alignment: Alignment.center,
|
||||||
style: StreamChatTheme.of(context)
|
child: TextButton(
|
||||||
.textTheme
|
onPressed: () {
|
||||||
.bodyBold
|
Navigator.pop(context, true);
|
||||||
.copyWith(
|
},
|
||||||
color: StreamChatTheme.of(context)
|
child: Text(
|
||||||
.colorTheme
|
okText,
|
||||||
.accentRed),
|
style: StreamChatTheme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyBold
|
||||||
|
.copyWith(
|
||||||
|
color: StreamChatTheme.of(context)
|
||||||
|
.colorTheme
|
||||||
|
.accentRed),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context, true);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -103,13 +112,13 @@ Future<bool> showInfoDialog(
|
|||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
String title,
|
String title,
|
||||||
Widget icon,
|
Widget icon,
|
||||||
String question,
|
String details,
|
||||||
String okText,
|
String okText,
|
||||||
StreamChatThemeData theme,
|
StreamChatThemeData theme,
|
||||||
}) {
|
}) {
|
||||||
return showModalBottomSheet(
|
return showModalBottomSheet(
|
||||||
backgroundColor:
|
backgroundColor: theme?.colorTheme?.white ??
|
||||||
theme.colorTheme.white ?? StreamChatTheme.of(context).colorTheme.white,
|
StreamChatTheme.of(context).colorTheme.white,
|
||||||
context: context,
|
context: context,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.only(
|
||||||
@@ -117,54 +126,51 @@ Future<bool> showInfoDialog(
|
|||||||
topRight: Radius.circular(16.0),
|
topRight: Radius.circular(16.0),
|
||||||
)),
|
)),
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return Column(
|
return SafeArea(
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Column(
|
||||||
children: [
|
mainAxisSize: MainAxisSize.min,
|
||||||
SizedBox(
|
children: [
|
||||||
height: 26.0,
|
SizedBox(
|
||||||
),
|
height: 26.0,
|
||||||
if (icon != null) icon,
|
),
|
||||||
SizedBox(
|
if (icon != null) icon,
|
||||||
height: 26.0,
|
SizedBox(
|
||||||
),
|
height: 26.0,
|
||||||
Text(
|
),
|
||||||
title,
|
Text(
|
||||||
style: theme.textTheme.headlineBold ??
|
title,
|
||||||
StreamChatTheme.of(context).textTheme.headlineBold,
|
style: theme?.textTheme?.headlineBold ??
|
||||||
),
|
StreamChatTheme.of(context).textTheme.headlineBold,
|
||||||
SizedBox(
|
),
|
||||||
height: 7.0,
|
SizedBox(
|
||||||
),
|
height: 7.0,
|
||||||
Text(question),
|
),
|
||||||
SizedBox(
|
Text(details),
|
||||||
height: 36.0,
|
SizedBox(
|
||||||
),
|
height: 36.0,
|
||||||
Container(
|
),
|
||||||
color: theme.colorTheme.black.withOpacity(.08) ??
|
Container(
|
||||||
StreamChatTheme.of(context).colorTheme.black.withOpacity(.08),
|
color: theme?.colorTheme?.black?.withOpacity(.08) ??
|
||||||
height: 1.0,
|
StreamChatTheme.of(context).colorTheme.black.withOpacity(.08),
|
||||||
),
|
height: 1.0,
|
||||||
Row(
|
),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
Center(
|
||||||
children: [
|
child: TextButton(
|
||||||
TextButton(
|
|
||||||
child: Text(
|
|
||||||
okText,
|
|
||||||
style: TextStyle(
|
|
||||||
color: theme.colorTheme.black.withOpacity(0.5) ??
|
|
||||||
StreamChatTheme.of(context)
|
|
||||||
.colorTheme
|
|
||||||
.black
|
|
||||||
.withOpacity(0.5),
|
|
||||||
fontWeight: FontWeight.w400),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
|
child: Text(
|
||||||
|
okText,
|
||||||
|
style: TextStyle(
|
||||||
|
color: theme?.colorTheme?.black?.withOpacity(0.5) ??
|
||||||
|
StreamChatTheme.of(context).colorTheme.accentBlue,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user