From c1196a63593321d460839a93f3984d3576b556b3 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 13 Mar 2021 08:33:55 +0100 Subject: [PATCH] Show files thumbnails, if available --- lib/ui/tiles/conversation_message_tile.dart | 2 +- lib/ui/widgets/conversation_file_tile.dart | 33 +++++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/lib/ui/tiles/conversation_message_tile.dart b/lib/ui/tiles/conversation_message_tile.dart index 2b25f9f..ec7b855 100644 --- a/lib/ui/tiles/conversation_message_tile.dart +++ b/lib/ui/tiles/conversation_message_tile.dart @@ -60,7 +60,7 @@ class ConversationMessageTile extends StatelessWidget { child: Icon( Icons.more_vert, color: Colors.white, - size: 12, + size: 14, ), onSelected: _menuOptionSelected, itemBuilder: (c) => >[ diff --git a/lib/ui/widgets/conversation_file_tile.dart b/lib/ui/widgets/conversation_file_tile.dart index badf66e..576a5d3 100644 --- a/lib/ui/widgets/conversation_file_tile.dart +++ b/lib/ui/widgets/conversation_file_tile.dart @@ -1,3 +1,4 @@ +import 'package:cached_network_image/cached_network_image.dart'; /// Chat file tile /// /// @author Pierre Hubert @@ -10,6 +11,9 @@ import 'package:filesize/filesize.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; +const _AreaWidth = 150.0; +const _AreaHeight = 100.0; + class ConversationFileWidget extends StatefulWidget { final int messageID; final ConversationMessageFile file; @@ -30,10 +34,25 @@ class _ConversationFileWidgetState extends State { ConversationMessageFile get file => widget.file; @override - Widget build(BuildContext context) => Container( - width: 150, - height: 100, - child: _buildContent(), + Widget build(BuildContext context) => Stack( + children: [ + !file.hasThumbnail + ? Container() + : Opacity( + opacity: 0.8, + child: CachedNetworkImage( + imageUrl: file.thumbnail, + width: _AreaWidth, + height: _AreaHeight, + fit: BoxFit.cover, + ), + ), + Container( + width: _AreaWidth, + height: _AreaHeight, + child: _buildContent(), + ) + ], ); Widget _buildContent() { @@ -60,7 +79,11 @@ class _ConversationFileWidgetState extends State { Spacer(flex: 2), Icon(file.icon, color: Colors.white), Spacer(), - Text(file.name, textAlign: TextAlign.center), + Text( + file.name.length < 23 + ? file.name + : file.name.substring(0, 20) + "...", + textAlign: TextAlign.center), Spacer(), Text( filesize(file.size),