1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 12:59:21 +00:00

Show files thumbnails, if available

This commit is contained in:
Pierre HUBERT 2021-03-13 08:33:55 +01:00
parent bedc3f5277
commit c1196a6359
2 changed files with 29 additions and 6 deletions

View File

@ -60,7 +60,7 @@ class ConversationMessageTile extends StatelessWidget {
child: Icon( child: Icon(
Icons.more_vert, Icons.more_vert,
color: Colors.white, color: Colors.white,
size: 12, size: 14,
), ),
onSelected: _menuOptionSelected, onSelected: _menuOptionSelected,
itemBuilder: (c) => <PopupMenuItem<_MenuChoices>>[ itemBuilder: (c) => <PopupMenuItem<_MenuChoices>>[

View File

@ -1,3 +1,4 @@
import 'package:cached_network_image/cached_network_image.dart';
/// Chat file tile /// Chat file tile
/// ///
/// @author Pierre Hubert /// @author Pierre Hubert
@ -10,6 +11,9 @@ import 'package:filesize/filesize.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
const _AreaWidth = 150.0;
const _AreaHeight = 100.0;
class ConversationFileWidget extends StatefulWidget { class ConversationFileWidget extends StatefulWidget {
final int messageID; final int messageID;
final ConversationMessageFile file; final ConversationMessageFile file;
@ -30,10 +34,25 @@ class _ConversationFileWidgetState extends State<ConversationFileWidget> {
ConversationMessageFile get file => widget.file; ConversationMessageFile get file => widget.file;
@override @override
Widget build(BuildContext context) => Container( Widget build(BuildContext context) => Stack(
width: 150, children: [
height: 100, !file.hasThumbnail
child: _buildContent(), ? 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() { Widget _buildContent() {
@ -60,7 +79,11 @@ class _ConversationFileWidgetState extends State<ConversationFileWidget> {
Spacer(flex: 2), Spacer(flex: 2),
Icon(file.icon, color: Colors.white), Icon(file.icon, color: Colors.white),
Spacer(), Spacer(),
Text(file.name, textAlign: TextAlign.center), Text(
file.name.length < 23
? file.name
: file.name.substring(0, 20) + "...",
textAlign: TextAlign.center),
Spacer(), Spacer(),
Text( Text(
filesize(file.size), filesize(file.size),