igrate example

This commit is contained in:
Salvatore Giordano
2021-04-30 14:59:50 +02:00
parent 34888d0fff
commit 3283f008eb
13 changed files with 64 additions and 55 deletions
@@ -21,7 +21,12 @@ class GiphyAttachment extends AttachmentWidget {
this.onShowMessage,
this.onReturnAction,
this.onAttachmentTap,
}) : super(key: key, message: message, attachment: attachment, size: size);
}) : super(
key: key,
message: message,
attachment: attachment,
size: size,
);
@override
Widget build(BuildContext context) {
@@ -173,6 +178,7 @@ class GiphyAttachment extends AttachmentWidget {
.black
.withOpacity(0.5),
),
maxLines: 1,
),
),
),
@@ -177,7 +177,7 @@ class MediaThumbnailProvider extends ImageProvider<MediaThumbnailProvider> {
@override
ImageStreamCompleter load(key, decode) {
return MultiFrameImageStreamCompleter(
codec: _loadAsync(key, decode) as Future<ui.Codec>,
codec: _loadAsync(key, decode),
scale: 1.0,
informationCollector: () sync* {
yield ErrorDescription('Id: ${media.id}');
@@ -185,11 +185,10 @@ class MediaThumbnailProvider extends ImageProvider<MediaThumbnailProvider> {
);
}
Future<ui.Codec?> _loadAsync(
Future<ui.Codec> _loadAsync(
MediaThumbnailProvider key, DecoderCallback decode) async {
assert(key == this);
final bytes = await media.thumbData;
if (bytes?.isNotEmpty != true) return null;
return await decode(bytes!);
}
@@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:io';
import 'dart:math';
import 'package:cached_network_image/cached_network_image.dart';
@@ -610,7 +609,7 @@ class MessageInputState extends State<MessageInput> {
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
constraints: BoxConstraints.tight(Size(64, 24)),
constraints: BoxConstraints.tight(Size(84, 24)),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: theme.colorTheme.accentBlue,
@@ -1105,10 +1104,14 @@ class MessageInputState extends State<MessageInput> {
}
void _addAttachment(AssetEntity medium) async {
final mediaFile = await (medium.originFile.timeout(
final mediaFile = await medium.originFile.timeout(
Duration(seconds: 5),
onTimeout: () => medium.originFile,
) as FutureOr<File>);
);
if (mediaFile == null) {
return;
}
var file = AttachmentFile(
path: mediaFile.path,
@@ -446,7 +446,7 @@ class _MessageWidgetState extends State<MessageWidget>
transform: Matrix4.rotationY(widget.reverse ? pi : 0),
child: FractionallySizedBox(
alignment: Alignment.centerLeft,
widthFactor: 0.75,
widthFactor: 0.78,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,