90 lines
2.8 KiB
Dart
90 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../../api/marianumcloud/talk/get_participants/get_participants_cache.dart';
|
|
import '../../../../api/marianumcloud/talk/get_participants/get_participants_response.dart';
|
|
import '../../../../api/marianumcloud/talk/room/get_room_response.dart';
|
|
import '../../../../widget/large_profile_picture_view.dart';
|
|
import '../../../../widget/loading_spinner.dart';
|
|
import '../../../../widget/user_avatar.dart';
|
|
import '../talk_navigator.dart';
|
|
import 'participants_list_view.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) {
|
|
var 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(
|
|
id: isGroup ? widget.room.token : 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} Mitglieder'),
|
|
trailing: const Icon(Icons.arrow_right),
|
|
onTap: () => TalkNavigator.pushSplitView(
|
|
context,
|
|
ParticipantsListView(participants!),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|