formatting_toolbar #475
|
@ -64,6 +64,8 @@ class FileMessage extends Message {
|
|||
}
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: FileBubble(
|
||||
nameSuggestion,
|
||||
rootHash,
|
||||
|
@ -71,6 +73,7 @@ class FileMessage extends Message {
|
|||
fileSize,
|
||||
isAuto: metadata.isAuto,
|
||||
interactive: false,
|
||||
isPreview: true,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:cwtch/models/message.dart';
|
||||
import 'package:cwtch/models/messages/malformedmessage.dart';
|
||||
import 'package:cwtch/widgets/malformedbubble.dart';
|
||||
import 'package:cwtch/widgets/messagerow.dart';
|
||||
import 'package:cwtch/widgets/quotedmessage.dart';
|
||||
|
@ -30,8 +29,14 @@ class QuotedMessage extends Message {
|
|||
value: this.metadata,
|
||||
builder: (bcontext, child) {
|
||||
try {
|
||||
dynamic message = jsonDecode(this.content);
|
||||
return Text(message["body"]);
|
||||
dynamic message = jsonDecode(
|
||||
this.content,
|
||||
);
|
||||
var content = message["body"];
|
||||
return Text(
|
||||
content,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
} catch (e) {
|
||||
return MalformedBubble();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,10 @@ class TextMessage extends Message {
|
|||
return ChangeNotifierProvider.value(
|
||||
value: this.metadata,
|
||||
builder: (bcontext, child) {
|
||||
return Text(this.content.substring(0, min(this.content.length, 50)));
|
||||
return Text(
|
||||
this.content,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,9 @@ class FileBubble extends StatefulWidget {
|
|||
final int fileSize;
|
||||
final bool interactive;
|
||||
final bool isAuto;
|
||||
final bool isPreview;
|
||||
|
||||
FileBubble(this.nameSuggestion, this.rootHash, this.nonce, this.fileSize, {this.isAuto = false, this.interactive = true});
|
||||
FileBubble(this.nameSuggestion, this.rootHash, this.nonce, this.fileSize, {this.isAuto = false, this.interactive = true, this.isPreview = false});
|
||||
|
||||
@override
|
||||
FileBubbleState createState() => FileBubbleState();
|
||||
|
@ -44,6 +45,22 @@ class FileBubbleState extends State<FileBubble> {
|
|||
super.initState();
|
||||
}
|
||||
|
||||
Widget getPreview(context) {
|
||||
return Image.file(
|
||||
myFile!,
|
||||
cacheWidth: (MediaQuery.of(context).size.width * 0.6).floor(),
|
||||
// limit the amount of space the image can decode too, we keep this high-ish to allow quality previews...
|
||||
filterQuality: FilterQuality.medium,
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: Alignment.center,
|
||||
height: MediaQuery.of(context).size.height * 0.30,
|
||||
isAntiAlias: false,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return MalformedBubble();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var fromMe = Provider.of<MessageMetadata>(context).senderHandle == Provider.of<ProfileInfoState>(context).onion;
|
||||
|
@ -109,6 +126,12 @@ class FileBubbleState extends State<FileBubble> {
|
|||
senderDisplayStr = Provider.of<MessageMetadata>(context).senderHandle;
|
||||
}
|
||||
}
|
||||
|
||||
// we don't preview a non downloaded file...
|
||||
if (widget.isPreview && myFile != null) {
|
||||
return getPreview(context);
|
||||
}
|
||||
|
||||
return LayoutBuilder(builder: (bcontext, constraints) {
|
||||
var wdgSender = Visibility(
|
||||
visible: widget.interactive,
|
||||
|
@ -133,21 +156,7 @@ class FileBubbleState extends State<FileBubble> {
|
|||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(1.0),
|
||||
child: Image.file(
|
||||
myFile!,
|
||||
cacheWidth: (MediaQuery.of(bcontext).size.width * 0.6).floor(),
|
||||
// limit the amount of space the image can decode too, we keep this high-ish to allow quality previews...
|
||||
filterQuality: FilterQuality.medium,
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: Alignment.center,
|
||||
height: MediaQuery.of(bcontext).size.height * 0.30,
|
||||
isAntiAlias: false,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return MalformedBubble();
|
||||
},
|
||||
)),
|
||||
child: Padding(padding: EdgeInsets.all(1.0), child: getPreview(context)),
|
||||
onTap: () {
|
||||
pop(bcontext, myFile!, wdgMessage);
|
||||
},
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:cwtch/third_party/linkify/flutter_linkify.dart';
|
|||
import 'package:cwtch/views/contactsview.dart';
|
||||
import 'package:cwtch/widgets/malformedbubble.dart';
|
||||
import 'package:cwtch/widgets/messageloadingbubble.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
@ -94,10 +95,18 @@ class QuotedMessageBubbleState extends State<QuotedMessageBubble> {
|
|||
child: Container(
|
||||
margin: EdgeInsets.all(5),
|
||||
padding: EdgeInsets.all(5),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(),
|
||||
height: 75,
|
||||
color: fromMe ? Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor : Provider.of<Settings>(context).theme.messageFromMeBackgroundColor,
|
||||
child: Wrap(runAlignment: WrapAlignment.spaceEvenly, alignment: WrapAlignment.spaceEvenly, runSpacing: 1.0, crossAxisAlignment: WrapCrossAlignment.center, children: [
|
||||
Center(widthFactor: 1, child: Padding(padding: EdgeInsets.all(10.0), child: Icon(Icons.reply, size: 32, color: qTextColor))),
|
||||
Center(widthFactor: 1.0, child: DefaultTextStyle(child: qMessage.getPreviewWidget(context), style: TextStyle(color: qTextColor)))
|
||||
child: Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, children: [
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 10.0), child: Icon(Icons.reply, size: 32, color: qTextColor)),
|
||||
DefaultTextStyle(
|
||||
textWidthBasis: TextWidthBasis.parent,
|
||||
child: qMessage.getPreviewWidget(context),
|
||||
style: TextStyle(color: qTextColor),
|
||||
overflow: TextOverflow.fade,
|
||||
)
|
||||
]))));
|
||||
} catch (e) {
|
||||
print(e);
|
||||
|
|
Loading…
Reference in New Issue