changed file messages to show their text or their file name
This commit is contained in:
parent
9d0cf8e313
commit
da772f17cc
@ -21,39 +21,46 @@ class ChatMessage {
|
|||||||
ChatMessage({required this.originalMessage, this.originalData}) {
|
ChatMessage({required this.originalMessage, this.originalData}) {
|
||||||
if(originalData?.containsKey('file') ?? false) {
|
if(originalData?.containsKey('file') ?? false) {
|
||||||
file = originalData?['file'];
|
file = originalData?['file'];
|
||||||
content = file?.name ?? 'Datei';
|
|
||||||
} else {
|
|
||||||
content = RichObjectStringProcessor.parseToString(originalMessage, originalData);
|
|
||||||
}
|
}
|
||||||
|
content = RichObjectStringProcessor.parseToString(originalMessage, originalData);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getWidget() {
|
Widget getWidget() {
|
||||||
|
|
||||||
if(file == null) {
|
var contentWidget = Linkify(
|
||||||
return Linkify(
|
text: content,
|
||||||
text: content,
|
onOpen: onOpen,
|
||||||
onOpen: onOpen,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Padding(padding: const EdgeInsets.only(top: 5), child: CachedNetworkImage(
|
if(file == null) return contentWidget;
|
||||||
errorWidget: (context, url, error) => Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
return Padding(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
padding: const EdgeInsets.only(top: 5),
|
||||||
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.file_open_outlined, size: 35),
|
CachedNetworkImage(
|
||||||
const SizedBox(width: 10),
|
errorWidget: (context, url, error) => Row(
|
||||||
Flexible(child: Text(file!.name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.bold))),
|
mainAxisSize: MainAxisSize.min,
|
||||||
const SizedBox(width: 10),
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.file_open_outlined, size: 35),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Flexible(child: Text(file!.name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.bold))),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
placeholder: (context, url) => const Padding(padding: EdgeInsets.all(15), child: SizedBox(width: 50, child: LinearProgressIndicator())),
|
||||||
|
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',
|
||||||
|
),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
contentWidget
|
||||||
],
|
],
|
||||||
),
|
)
|
||||||
alignment: Alignment.center,
|
);
|
||||||
placeholder: (context, url) => const Padding(padding: EdgeInsets.all(15), child: SizedBox(width: 50, child: LinearProgressIndicator())),
|
|
||||||
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',
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> onOpen(LinkableElement link) async {
|
Future<void> onOpen(LinkableElement link) async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user