Added details for chats with participants list
This commit is contained in:
79
lib/view/pages/talk/chatDetails/chatInfo.dart
Normal file
79
lib/view/pages/talk/chatDetails/chatInfo.dart
Normal file
@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../api/marianumcloud/talk/getParticipants/getParticipantsCache.dart';
|
||||
import '../../../../api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart';
|
||||
import '../../../../api/marianumcloud/talk/room/getRoomResponse.dart';
|
||||
import '../../../../widget/largeProfilePictureView.dart';
|
||||
import '../../../../widget/loadingSpinner.dart';
|
||||
import '../../../../widget/userAvatar.dart';
|
||||
import '../talkNavigator.dart';
|
||||
import 'participants/participantsListView.dart';
|
||||
|
||||
class ChatInfo extends StatefulWidget {
|
||||
final GetRoomResponseObject room;
|
||||
const ChatInfo(this.room, {super.key});
|
||||
|
||||
@override
|
||||
State<ChatInfo> createState() => _ChatInfoState();
|
||||
}
|
||||
|
||||
class _ChatInfoState extends State<ChatInfo> {
|
||||
GetParticipantsResponse? participants;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
GetParticipantsCache(
|
||||
chatToken: widget.room.token,
|
||||
onUpdate: (GetParticipantsResponse data) {
|
||||
setState(() {
|
||||
participants = data;
|
||||
});
|
||||
}
|
||||
);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool isGroup = widget.room.type != GetRoomResponseObjectConversationType.oneToOne;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.room.displayName),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 30),
|
||||
GestureDetector(
|
||||
child: UserAvatar(
|
||||
username: widget.room.name,
|
||||
isGroup: isGroup,
|
||||
size: 80,
|
||||
),
|
||||
onTap: () {
|
||||
if(isGroup) return;
|
||||
TalkNavigator.pushSplitView(context, LargeProfilePictureView(widget.room.name));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(widget.room.displayName, textAlign: TextAlign.center, style: const TextStyle(fontSize: 30)),
|
||||
if(!isGroup) Text(widget.room.name),
|
||||
const SizedBox(height: 10),
|
||||
if(isGroup) Text(widget.room.description, textAlign: TextAlign.center),
|
||||
const SizedBox(height: 30),
|
||||
if(participants == null) const LoadingSpinner(),
|
||||
if(participants != null) ...[
|
||||
ListTile(
|
||||
leading: const Icon(Icons.supervised_user_circle),
|
||||
title: Text("${participants!.data.length} Teilnehmer"),
|
||||
trailing: const Icon(Icons.arrow_right),
|
||||
onTap: () => TalkNavigator.pushSplitView(context, ParticipantsListView(participants!)),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart';
|
||||
import '../../../../../widget/userAvatar.dart';
|
||||
|
||||
class ParticipantsListView extends StatefulWidget {
|
||||
final GetParticipantsResponse participantsResponse;
|
||||
const ParticipantsListView(this.participantsResponse, {super.key});
|
||||
|
||||
@override
|
||||
State<ParticipantsListView> createState() => _ParticipantsListViewState();
|
||||
}
|
||||
|
||||
class _ParticipantsListViewState extends State<ParticipantsListView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Teilnehmende"),
|
||||
),
|
||||
body: ListView(
|
||||
children: widget.participantsResponse.data.map((participant) {
|
||||
return ListTile(
|
||||
leading: UserAvatar(username: participant.actorId),
|
||||
title: Text(participant.displayName),
|
||||
subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null,
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user