示例#1
0
        public static float CalculateTextHeight(ChannelMessageView message, float width)
        {
            var attachment      = message.attachments.first();
            var fileTitleHeight = CTextUtils.CalculateTextHeight(text: attachment.filename, textStyle: _fileTitleStyle,
                                                                 width - _filePadding.horizontal - 42 - 16);
            var fileSizeHeight = CTextUtils.CalculateTextHeight(CStringUtils.FileSize(bytes: attachment.size),
                                                                textStyle: _fileSizeStyle, width - _filePadding.horizontal - 42 - 16);

            return(_filePadding.vertical + fileTitleHeight + fileSizeHeight + 4);
        }
示例#2
0
        public override Widget build(BuildContext context)
        {
            if (this.message == null)
            {
                return(new Container());
            }

            if (this.message.attachments.isNullOrEmpty())
            {
                return(new Container());
            }

            var attachment = this.message.attachments.first();
            var content    = new Container(
                padding: _filePadding,
                color: CColors.Transparent,
                child: new Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: new List <Widget> {
                new Expanded(
                    child: new Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: new List <Widget> {
                    new Text(
                        data: attachment.filename,
                        maxLines: 2,
                        overflow: TextOverflow.ellipsis,
                        style: _fileTitleStyle
                        ),
                    new SizedBox(height: 4),
                    new Text(
                        CStringUtils.FileSize(bytes: attachment.size),
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                        style: _fileSizeStyle
                        )
                }
                        )
                    ),
                new SizedBox(width: 16),
                this._buildFileIcon()
            }
                    )
                );

            if (this.onTap != null)
            {
                return(new GestureDetector(
                           onTap: this.onTap,
                           child: content
                           ));
            }

            return(content);
        }