mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-25 23:12:37 +01:00
Fix no thumbnail bug
This commit is contained in:
parent
869cc46a15
commit
7c455ef56b
@ -6,10 +6,8 @@ import 'package:fluffychat/utils/event_extension.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:link_text/link_text.dart';
|
import 'package:link_text/link_text.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import 'package:fluffychat/utils/matrix_file_extension.dart';
|
|
||||||
|
|
||||||
import 'dialogs/simple_dialogs.dart';
|
|
||||||
import 'matrix.dart';
|
import 'matrix.dart';
|
||||||
|
import 'message_download_content.dart';
|
||||||
|
|
||||||
class MessageContent extends StatelessWidget {
|
class MessageContent extends StatelessWidget {
|
||||||
final Event event;
|
final Event event;
|
||||||
@ -26,7 +24,10 @@ class MessageContent extends StatelessWidget {
|
|||||||
switch (event.messageType) {
|
switch (event.messageType) {
|
||||||
case MessageTypes.Image:
|
case MessageTypes.Image:
|
||||||
case MessageTypes.Sticker:
|
case MessageTypes.Sticker:
|
||||||
|
if (event.hasThumbnail) {
|
||||||
return ImageBubble(event);
|
return ImageBubble(event);
|
||||||
|
}
|
||||||
|
return MessageDownloadContent(event, textColor);
|
||||||
case MessageTypes.Audio:
|
case MessageTypes.Audio:
|
||||||
return AudioPlayer(
|
return AudioPlayer(
|
||||||
event,
|
event,
|
||||||
@ -34,49 +35,7 @@ class MessageContent extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
case MessageTypes.Video:
|
case MessageTypes.Video:
|
||||||
case MessageTypes.File:
|
case MessageTypes.File:
|
||||||
return Container(
|
return MessageDownloadContent(event, textColor);
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: <Widget>[
|
|
||||||
RaisedButton(
|
|
||||||
color: Colors.blueGrey,
|
|
||||||
child: Text(
|
|
||||||
I18n.of(context).downloadFile,
|
|
||||||
overflow: TextOverflow.fade,
|
|
||||||
softWrap: false,
|
|
||||||
maxLines: 1,
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
final MatrixFile matrixFile =
|
|
||||||
await SimpleDialogs(context)
|
|
||||||
.tryRequestWithLoadingDialog(
|
|
||||||
event.downloadAndDecryptAttachment(),
|
|
||||||
);
|
|
||||||
matrixFile.open();
|
|
||||||
}),
|
|
||||||
Text(
|
|
||||||
"- " +
|
|
||||||
(event.content.containsKey("filename")
|
|
||||||
? event.content["filename"]
|
|
||||||
: event.body),
|
|
||||||
style: TextStyle(
|
|
||||||
color: textColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (event.sizeString != null)
|
|
||||||
Text(
|
|
||||||
"- " + event.sizeString,
|
|
||||||
style: TextStyle(
|
|
||||||
color: textColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
case MessageTypes.BadEncrypted:
|
case MessageTypes.BadEncrypted:
|
||||||
case MessageTypes.Text:
|
case MessageTypes.Text:
|
||||||
case MessageTypes.Reply:
|
case MessageTypes.Reply:
|
||||||
|
60
lib/components/message_download_content.dart
Normal file
60
lib/components/message_download_content.dart
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:fluffychat/i18n/i18n.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluffychat/utils/matrix_file_extension.dart';
|
||||||
|
import 'package:fluffychat/utils/event_extension.dart';
|
||||||
|
import 'dialogs/simple_dialogs.dart';
|
||||||
|
|
||||||
|
class MessageDownloadContent extends StatelessWidget {
|
||||||
|
final Event event;
|
||||||
|
final Color textColor;
|
||||||
|
|
||||||
|
const MessageDownloadContent(this.event, this.textColor, {Key key})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
RaisedButton(
|
||||||
|
color: Colors.blueGrey,
|
||||||
|
child: Text(
|
||||||
|
I18n.of(context).downloadFile,
|
||||||
|
overflow: TextOverflow.fade,
|
||||||
|
softWrap: false,
|
||||||
|
maxLines: 1,
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
final MatrixFile matrixFile =
|
||||||
|
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||||
|
event.downloadAndDecryptAttachment(),
|
||||||
|
);
|
||||||
|
matrixFile.open();
|
||||||
|
}),
|
||||||
|
Text(
|
||||||
|
"- " +
|
||||||
|
(event.content.containsKey("filename")
|
||||||
|
? event.content["filename"]
|
||||||
|
: event.body),
|
||||||
|
style: TextStyle(
|
||||||
|
color: textColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (event.sizeString != null)
|
||||||
|
Text(
|
||||||
|
"- " + event.sizeString,
|
||||||
|
style: TextStyle(
|
||||||
|
color: textColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user