folder restructuring
This commit is contained in:
@@ -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/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!)),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../api/marianumcloud/talk/getReactions/getReactions.dart';
|
||||
import '../../../../api/marianumcloud/talk/getReactions/getReactionsResponse.dart';
|
||||
import '../../../../model/account_data.dart';
|
||||
import '../../../../widget/centered_leading.dart';
|
||||
import '../../../../widget/loading_spinner.dart';
|
||||
import '../../../../widget/placeholder_view.dart';
|
||||
import '../../../../widget/unimplemented_dialog.dart';
|
||||
import '../../../../widget/user_avatar.dart';
|
||||
|
||||
class MessageReactions extends StatefulWidget {
|
||||
final String token;
|
||||
final int messageId;
|
||||
const MessageReactions({super.key, required this.token, required this.messageId});
|
||||
|
||||
@override
|
||||
State<MessageReactions> createState() => _MessageReactionsState();
|
||||
}
|
||||
|
||||
class _MessageReactionsState extends State<MessageReactions> {
|
||||
late Future<GetReactionsResponse> data;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
data = GetReactions(chatToken: widget.token, messageId: widget.messageId).run();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Reaktionen'),
|
||||
),
|
||||
body: FutureBuilder(
|
||||
future: data,
|
||||
builder: (context, snapshot) {
|
||||
if(snapshot.connectionState == ConnectionState.waiting) return const LoadingSpinner();
|
||||
if(snapshot.data!.data.isEmpty) return const PlaceholderView(icon: Icons.search_off_outlined, text: 'Keine Reaktionen gefunden!');
|
||||
return ListView(
|
||||
children: [
|
||||
...snapshot.data!.data.entries.map<Widget>((entry) => ExpansionTile(
|
||||
textColor: Theme.of(context).colorScheme.onSurface,
|
||||
collapsedTextColor: Theme.of(context).colorScheme.onSurface,
|
||||
iconColor: Theme.of(context).colorScheme.onSurface,
|
||||
collapsedIconColor: Theme.of(context).colorScheme.onSurface,
|
||||
|
||||
subtitle: const Text('Tippe für mehr'),
|
||||
leading: CenteredLeading(Text(entry.key)),
|
||||
title: Text('${entry.value.length} mal reagiert'),
|
||||
children: entry.value.map((e) {
|
||||
var isSelf = AccountData().getUsername() == e.actorId;
|
||||
return ListTile(
|
||||
leading: UserAvatar(id: e.actorId, isGroup: false),
|
||||
title: Text(e.actorDisplayName),
|
||||
subtitle: isSelf
|
||||
? const Text('Du')
|
||||
: e.actorType == GetReactionsResponseObjectActorType.guests ? const Text('Gast') : null,
|
||||
trailing: isSelf
|
||||
? null
|
||||
: Visibility(
|
||||
visible: kReleaseMode,
|
||||
child: IconButton(
|
||||
onPressed: () => UnimplementedDialog.show(context),
|
||||
icon: const Icon(Icons.textsms_outlined),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
))
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart';
|
||||
import '../../../../widget/user_avatar.dart';
|
||||
|
||||
class ParticipantsListView extends StatelessWidget {
|
||||
final GetParticipantsResponse participantsResponse;
|
||||
const ParticipantsListView(this.participantsResponse, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
lastname(participant) => participant.displayName.toString().split(' ').last;
|
||||
|
||||
final participants = participantsResponse.data
|
||||
.sorted((a, b) {
|
||||
final typeComparison = a.participantType.index.compareTo(b.participantType.index);
|
||||
if (typeComparison != 0) return typeComparison;
|
||||
return lastname(a).compareTo(lastname(b));
|
||||
});
|
||||
var groupedParticipants = participants.groupListsBy((participant) => participant.participantType);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Mitglieder'),
|
||||
),
|
||||
body: ListView(
|
||||
children: [
|
||||
...groupedParticipants.entries.map((entry) => Column(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(entry.key.prettyName),
|
||||
titleTextStyle: Theme.of(context).textTheme.titleMedium
|
||||
),
|
||||
...entry.value.map((participant) => ListTile(
|
||||
leading: UserAvatar(id: participant.actorId),
|
||||
title: Text(participant.displayName),
|
||||
subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null,
|
||||
)),
|
||||
Divider(),
|
||||
],
|
||||
))
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user