mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Show files thumbnails, if available
This commit is contained in:
		@@ -60,7 +60,7 @@ class ConversationMessageTile extends StatelessWidget {
 | 
			
		||||
                      child: Icon(
 | 
			
		||||
                        Icons.more_vert,
 | 
			
		||||
                        color: Colors.white,
 | 
			
		||||
                        size: 12,
 | 
			
		||||
                        size: 14,
 | 
			
		||||
                      ),
 | 
			
		||||
                      onSelected: _menuOptionSelected,
 | 
			
		||||
                      itemBuilder: (c) => <PopupMenuItem<_MenuChoices>>[
 | 
			
		||||
 
 | 
			
		||||
@@ -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<ConversationFileWidget> {
 | 
			
		||||
  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<ConversationFileWidget> {
 | 
			
		||||
                  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),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user