#20 Updated missing file preview message and download animation

This commit is contained in:
Elias Müller 2024-01-28 15:35:39 +01:00
parent df451032b4
commit 5532b4832c
2 changed files with 44 additions and 49 deletions

View File

@ -91,9 +91,9 @@ class _ChatBubbleState extends State<ChatBubble> {
BubbleStyle getStyle() { BubbleStyle getStyle() {
if(widget.bubbleData.messageType == GetRoomResponseObjectMessageType.comment) { if(widget.bubbleData.messageType == GetRoomResponseObjectMessageType.comment) {
if(widget.isSender) { if(widget.isSender) {
return getSelfStyle(message.containsFile); return getSelfStyle(false);
} else { } else {
return getRemoteStyle(message.containsFile); return getRemoteStyle(false);
} }
} else { } else {
return getSystemStyle(); return getSystemStyle();
@ -117,14 +117,16 @@ class _ChatBubbleState extends State<ChatBubble> {
children: [ children: [
GestureDetector( GestureDetector(
child: Bubble( child: Bubble(
style: getStyle(), style: getStyle(),
child: Container( child: Container(
constraints: BoxConstraints( constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * 0.9, maxWidth: MediaQuery.of(context).size.width * 0.9,
minWidth: showActorDisplayName ? _textSize(widget.bubbleData.actorDisplayName, actorTextStyle).width : 30, minWidth: showActorDisplayName ? _textSize(widget.bubbleData.actorDisplayName, actorTextStyle).width : 30,
), ),
child: Stack( child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Stack(
children: [ children: [
Padding( Padding(
padding: EdgeInsets.only(bottom: showBubbleTime ? 18 : 0, top: showActorDisplayName ? 18 : 0), padding: EdgeInsets.only(bottom: showBubbleTime ? 18 : 0, top: showActorDisplayName ? 18 : 0),
@ -154,26 +156,16 @@ class _ChatBubbleState extends State<ChatBubble> {
), ),
), ),
), ),
],
),
Visibility( Visibility(
visible: downloadProgress > 0, visible: downloadProgress > 0,
child: Positioned( child: LinearProgressIndicator(value: downloadProgress/100)
top: 0, ),
left: 0,
right: 0,
bottom: 0,
child: Stack(
children: [
const Center(child: Icon(Icons.download)),
const Center(child: CircularProgressIndicator(color: Colors.white)),
Center(child: CircularProgressIndicator(value: downloadProgress/100)),
], ],
) )
), ),
), ),
],
),
),
),
onLongPress: () { onLongPress: () {
showDialog(context: context, builder: (context) { showDialog(context: context, builder: (context) {
List<String> commonReactions = ["👍", "👎", "😆", "❤️", "👀", "🤔"]; List<String> commonReactions = ["👍", "👎", "😆", "❤️", "👀", "🤔"];

View File

@ -38,17 +38,22 @@ class ChatMessage {
return CachedNetworkImage( return CachedNetworkImage(
errorWidget: (context, url, error) { errorWidget: (context, url, error) {
return Column( return Padding(padding: const EdgeInsets.only(top: 10), child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
const Icon(Icons.image_not_supported_outlined, size: 35), const Icon(Icons.file_open_outlined, size: 35),
Text("Keine Dateivorschau:\n${file!.name}", style: const TextStyle(fontWeight: FontWeight.bold)) const SizedBox(width: 10),
Expanded(child: Text(file!.name, style: const TextStyle(fontWeight: FontWeight.bold)))
], ],
); ));
}, },
alignment: Alignment.center, alignment: Alignment.center,
placeholder: (context, url) { placeholder: (context, url) {
return const Padding(padding: EdgeInsets.all(10), child: CircularProgressIndicator()); return const Padding(padding: EdgeInsets.all(10), child: CircularProgressIndicator());
}, },
fadeInDuration: Duration.zero,
fadeOutDuration: Duration.zero,
errorListener: (value) {},
imageUrl: "https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/index.php/core/preview?fileId=${file!.id}&x=100&y=-1&a=1", imageUrl: "https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/index.php/core/preview?fileId=${file!.id}&x=100&y=-1&a=1",
); );
} }
@ -56,8 +61,6 @@ class ChatMessage {
void onOpen(LinkableElement link) async { void onOpen(LinkableElement link) async {
if(await canLaunchUrlString(link.url)) { if(await canLaunchUrlString(link.url)) {
await launchUrlString(link.url); await launchUrlString(link.url);
} else {
} }
} }
} }