chore: Improve message info dialog
This commit is contained in:
parent
efad71e535
commit
188ce96ef3
1 changed files with 29 additions and 23 deletions
|
|
@ -27,7 +27,7 @@ class EventInfoDialog extends StatelessWidget {
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
String get prettyJson {
|
String prettyJson(MatrixEvent event) {
|
||||||
const decoder = JsonDecoder();
|
const decoder = JsonDecoder();
|
||||||
const encoder = JsonEncoder.withIndent(' ');
|
const encoder = JsonEncoder.withIndent(' ');
|
||||||
final object = decoder.convert(jsonEncode(event.toJson()));
|
final object = decoder.convert(jsonEncode(event.toJson()));
|
||||||
|
|
@ -37,6 +37,7 @@ class EventInfoDialog extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
final originalSource = event.originalSource;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(L10n.of(context)!.messageInfo),
|
title: Text(L10n.of(context)!.messageInfo),
|
||||||
|
|
@ -61,48 +62,53 @@ class EventInfoDialog extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(L10n.of(context)!.time),
|
title: Text('${L10n.of(context)!.time}:'),
|
||||||
subtitle: Text(event.originServerTs.localizedTime(context)),
|
subtitle: Text(event.originServerTs.localizedTime(context)),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(L10n.of(context)!.messageType),
|
title: Text('${L10n.of(context)!.status}:'),
|
||||||
subtitle: Text(event.humanreadableType),
|
subtitle: Text(event.status.name),
|
||||||
),
|
),
|
||||||
ListTile(title: Text('${L10n.of(context)!.sourceCode}:')),
|
ListTile(title: Text('${L10n.of(context)!.sourceCode}:')),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(12.0),
|
padding: const EdgeInsets.all(12.0),
|
||||||
child: Material(
|
child: Material(
|
||||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||||
color: theme.colorScheme.inverseSurface,
|
color: theme.colorScheme.surfaceContainer,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(16),
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: SelectableText(
|
child: SelectableText(
|
||||||
prettyJson,
|
prettyJson(MatrixEvent.fromJson(event.toJson())),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: theme.colorScheme.onInverseSurface,
|
color: theme.colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (originalSource != null) ...[
|
||||||
|
ListTile(title: Text('${L10n.of(context)!.encrypted}:')),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(12.0),
|
||||||
|
child: Material(
|
||||||
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||||
|
color: theme.colorScheme.surfaceContainer,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: SelectableText(
|
||||||
|
prettyJson(originalSource),
|
||||||
|
style: TextStyle(
|
||||||
|
color: theme.colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension on Event {
|
|
||||||
String get humanreadableType {
|
|
||||||
if (type == EventTypes.Message) {
|
|
||||||
return messageType.split('m.').last;
|
|
||||||
}
|
|
||||||
if (type.startsWith('m.room.')) {
|
|
||||||
return type.split('m.room.').last;
|
|
||||||
}
|
|
||||||
if (type.startsWith('m.')) {
|
|
||||||
return type.split('m.').last;
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue