3 Commits

Author SHA1 Message Date
f3de0bc165 centered file preview, made text copyable 2025-06-24 15:09:37 +02:00
8000475c1f aligned text to the left 2025-06-16 16:07:04 +02:00
da772f17cc changed file messages to show their text or their file name 2025-06-10 21:35:12 +02:00
3 changed files with 51 additions and 39 deletions

View File

@ -3,28 +3,26 @@ import 'package:flutter/material.dart';
import '../../../../../api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart'; import '../../../../../api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart';
import '../../../../../widget/userAvatar.dart'; import '../../../../../widget/userAvatar.dart';
class ParticipantsListView extends StatelessWidget { class ParticipantsListView extends StatefulWidget {
final GetParticipantsResponse participantsResponse; final GetParticipantsResponse participantsResponse;
const ParticipantsListView(this.participantsResponse, {super.key}); const ParticipantsListView(this.participantsResponse, {super.key});
@override @override
Widget build(BuildContext context) { State<ParticipantsListView> createState() => _ParticipantsListViewState();
final participants = participantsResponse.data.map((participant) => ListTile( }
leading: UserAvatar(id: participant.actorId),
title: Text(participant.displayName),
subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null,
)).toList();
lastname(participant) => participant.title.toString().split(' ').last; class _ParticipantsListViewState extends State<ParticipantsListView> {
participants.sort((a, b) => lastname(a).compareTo(lastname(b))); @override
Widget build(BuildContext context) => Scaffold(
return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Teilnehmende'), title: const Text('Teilnehmende'),
), ),
body: ListView( body: ListView(
children: participants, children: widget.participantsResponse.data.map((participant) => ListTile(
leading: UserAvatar(id: participant.actorId),
title: Text(participant.displayName),
subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null,
)).toList(),
), ),
); );
}
} }

View File

@ -206,7 +206,7 @@ class _ChatBubbleState extends State<ChatBubble> with SingleTickerProviderStateM
), ),
), ),
Visibility( Visibility(
visible: !message.containsFile, visible: widget.bubbleData.message != '{file}',
child: ListTile( child: ListTile(
leading: const Icon(Icons.copy), leading: const Icon(Icons.copy),
title: const Text('Nachricht kopieren'), title: const Text('Nachricht kopieren'),

View File

@ -21,39 +21,53 @@ 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(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const Icon(Icons.file_open_outlined, size: 35), Row(
const SizedBox(width: 10), mainAxisSize: MainAxisSize.max,
Flexible(child: Text(file!.name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.bold))), mainAxisAlignment: MainAxisAlignment.center,
const SizedBox(width: 10), children: [
CachedNetworkImage(
errorWidget: (context, url, error) => Row(
mainAxisSize: MainAxisSize.min,
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 {