💄 Optimize de/encrypting animations
This commit is contained in:
parent
d6f3ffc655
commit
76d8cd943d
@ -20,6 +20,7 @@ import 'package:surface/widgets/attachment/attachment_list.dart';
|
|||||||
import 'package:surface/widgets/context_menu.dart';
|
import 'package:surface/widgets/context_menu.dart';
|
||||||
import 'package:surface/widgets/link_preview.dart';
|
import 'package:surface/widgets/link_preview.dart';
|
||||||
import 'package:surface/widgets/markdown_content.dart';
|
import 'package:surface/widgets/markdown_content.dart';
|
||||||
|
import 'package:flutter_animate/flutter_animate.dart';
|
||||||
import 'package:swipe_to/swipe_to.dart';
|
import 'package:swipe_to/swipe_to.dart';
|
||||||
|
|
||||||
class ChatMessage extends StatelessWidget {
|
class ChatMessage extends StatelessWidget {
|
||||||
@ -321,7 +322,7 @@ class _ChatMessageText extends StatelessWidget {
|
|||||||
const Gap(4),
|
const Gap(4),
|
||||||
Text('messageFileHint'.plural(data.body['attachments']!.length)),
|
Text('messageFileHint'.plural(data.body['attachments']!.length)),
|
||||||
],
|
],
|
||||||
).opacity(0.75);
|
).opacity(0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
@ -347,44 +348,44 @@ class _ChatMessageSystemNotify extends StatelessWidget {
|
|||||||
case 'messages.edit':
|
case 'messages.edit':
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Symbols.edit, size: 20),
|
const Icon(Symbols.edit, size: 16),
|
||||||
const Gap(4),
|
const Gap(8),
|
||||||
Text('messageEdited'.tr(args: ['#${data.relatedEventId}'])),
|
Text('messageEdited'.tr(args: ['#${data.relatedEventId}'])),
|
||||||
],
|
],
|
||||||
).opacity(0.75);
|
).opacity(0.8);
|
||||||
case 'messages.delete':
|
case 'messages.delete':
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Symbols.delete, size: 20),
|
const Icon(Symbols.delete, size: 16),
|
||||||
const Gap(4),
|
const Gap(8),
|
||||||
Text('messageDeleted'.tr(args: ['#${data.relatedEventId}'])),
|
Text('messageDeleted'.tr(args: ['#${data.relatedEventId}'])),
|
||||||
],
|
],
|
||||||
).opacity(0.75);
|
).opacity(0.8);
|
||||||
case 'calls.start':
|
case 'calls.start':
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Symbols.call, size: 20),
|
const Icon(Symbols.call, size: 16),
|
||||||
const Gap(4),
|
const Gap(8),
|
||||||
Text('callMessageStarted'.tr())
|
Text('callMessageStarted'.tr())
|
||||||
],
|
],
|
||||||
).opacity(0.75);
|
).opacity(0.8);
|
||||||
case 'calls.end':
|
case 'calls.end':
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Symbols.call_end, size: 20),
|
const Icon(Symbols.call_end, size: 16),
|
||||||
const Gap(4),
|
const Gap(8),
|
||||||
Text('callMessageEnded'.tr(
|
Text('callMessageEnded'.tr(
|
||||||
args: [_formatDuration(Duration(seconds: data.body['last']))])),
|
args: [_formatDuration(Duration(seconds: data.body['last']))])),
|
||||||
],
|
],
|
||||||
).opacity(0.75);
|
).opacity(0.8);
|
||||||
default:
|
default:
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Symbols.info, size: 20),
|
const Icon(Symbols.info, size: 16),
|
||||||
const Gap(4),
|
const Gap(8),
|
||||||
Text('messageUnsupported'.tr(args: [data.type])),
|
Text('messageUnsupported'.tr(args: [data.type])),
|
||||||
],
|
],
|
||||||
).opacity(0.75);
|
).opacity(0.8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -397,6 +398,7 @@ class _ChatDecryptMessage extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final kp = context.read<KeyPairProvider>();
|
final kp = context.read<KeyPairProvider>();
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
|
key: Key('chat-message-encrypted-${message.id}'),
|
||||||
future: kp.decryptText(
|
future: kp.decryptText(
|
||||||
message.body['text'],
|
message.body['text'],
|
||||||
message.body['keypair_id'],
|
message.body['keypair_id'],
|
||||||
@ -404,10 +406,37 @@ class _ChatDecryptMessage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.hasError) {
|
if (snapshot.hasError) {
|
||||||
return Text('decryptingKeyNotFound'.tr());
|
return Row(
|
||||||
|
children: [
|
||||||
|
Icon(Symbols.key_off, size: 16),
|
||||||
|
const Gap(8),
|
||||||
|
Expanded(
|
||||||
|
child: Text('decryptingKeyNotFound'.tr()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).opacity(0.8);
|
||||||
}
|
}
|
||||||
if (!snapshot.hasData) {
|
if (!snapshot.hasData) {
|
||||||
return Text('decrypting'.tr());
|
return Row(
|
||||||
|
children: [
|
||||||
|
Animate(
|
||||||
|
autoPlay: true,
|
||||||
|
onPlay: (e) => e.repeat(),
|
||||||
|
effects: [
|
||||||
|
RotateEffect(
|
||||||
|
duration: const Duration(seconds: 3),
|
||||||
|
begin: 0,
|
||||||
|
end: -1,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
child: Icon(Symbols.sync, size: 16),
|
||||||
|
),
|
||||||
|
const Gap(8),
|
||||||
|
Expanded(
|
||||||
|
child: Text('decrypting'.tr()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return MarkdownTextContent(
|
return MarkdownTextContent(
|
||||||
content: snapshot.data!,
|
content: snapshot.data!,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user