simplified code across the app and consolidated duplicated helpers
This commit is contained in:
@@ -17,13 +17,13 @@ import '../../../../state/app/modules/chat_list/bloc/chat_list_bloc.dart';
|
||||
import '../../../../utils/haptics.dart';
|
||||
import '../../../../widget/a11y/a11y_labels.dart';
|
||||
import '../../../../widget/async_action_button.dart';
|
||||
import '../../../../widget/confirm_dialog.dart';
|
||||
import '../../../../widget/debug/debug_tile.dart';
|
||||
import '../../../../widget/details_bottom_sheet.dart';
|
||||
import '../../../../widget/user_avatar.dart';
|
||||
import '../data/talk_markdown.dart';
|
||||
import '../talk_navigator.dart';
|
||||
import 'notification_level_sheet.dart';
|
||||
import 'room_actions.dart';
|
||||
|
||||
class ChatTile extends StatefulWidget {
|
||||
final GetRoomResponseObject data;
|
||||
@@ -48,11 +48,12 @@ class ChatTile extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ChatTileState extends State<ChatTile> {
|
||||
String? selfUsername;
|
||||
String? selfUsername = SessionManager().current?.nextcloud?.username;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (selfUsername != null) return;
|
||||
SessionManager().waitForLoad().then((session) {
|
||||
if (!mounted) return;
|
||||
setState(() => selfUsername = session?.nextcloud?.username);
|
||||
@@ -124,9 +125,8 @@ class _ChatTileState extends State<ChatTile> {
|
||||
label: isGroup ? A11yLabels.group : null,
|
||||
child: ExcludeSemantics(child: circleAvatar),
|
||||
),
|
||||
Visibility(
|
||||
visible: widget.data.isFavorite,
|
||||
child: Positioned(
|
||||
if (widget.data.isFavorite)
|
||||
Positioned(
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
@@ -143,7 +143,6 @@ class _ChatTileState extends State<ChatTile> {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
title: Row(
|
||||
@@ -241,24 +240,16 @@ class _ChatTileState extends State<ChatTile> {
|
||||
if (mounted) _refreshList();
|
||||
},
|
||||
),
|
||||
if (widget.data.isFavorite)
|
||||
AsyncListTile(
|
||||
leading: const Icon(Icons.stars_outlined),
|
||||
title: const Text('Von Favoriten entfernen'),
|
||||
onPressed: () async {
|
||||
await SetFavorite(widget.data.token, false).run();
|
||||
if (mounted) _refreshList();
|
||||
},
|
||||
)
|
||||
else
|
||||
AsyncListTile(
|
||||
leading: const Icon(Icons.star_outline),
|
||||
title: const Text('Zu Favoriten hinzufügen'),
|
||||
onPressed: () async {
|
||||
await SetFavorite(widget.data.token, true).run();
|
||||
if (mounted) _refreshList();
|
||||
},
|
||||
),
|
||||
FavoriteToggleTile(
|
||||
isFavorite: widget.data.isFavorite,
|
||||
onPressed: () async {
|
||||
await SetFavorite(
|
||||
widget.data.token,
|
||||
!widget.data.isFavorite,
|
||||
).run();
|
||||
if (mounted) _refreshList();
|
||||
},
|
||||
),
|
||||
NotificationLevelTile(
|
||||
level: widget.data.effectiveNotificationLevel,
|
||||
onTap: () {
|
||||
@@ -275,16 +266,7 @@ class _ChatTileState extends State<ChatTile> {
|
||||
title: const Text('Talk-Chat verlassen'),
|
||||
onTap: () {
|
||||
Navigator.of(sheetCtx).pop();
|
||||
ConfirmDialog(
|
||||
title: 'Talk-Chat verlassen',
|
||||
content:
|
||||
'Du benötigst ggf. eine Einladung um erneut beizutreten.',
|
||||
confirmButton: 'Verlassen',
|
||||
onConfirmAsync: () async {
|
||||
await LeaveRoom(widget.data.token).run();
|
||||
if (mounted) _refreshList();
|
||||
},
|
||||
).asDialog(context);
|
||||
confirmLeaveRoom(context, widget.data.token);
|
||||
},
|
||||
),
|
||||
DebugTile(sheetCtx).jsonData(widget.data.toJson()),
|
||||
|
||||
Reference in New Issue
Block a user