diff --git a/lib/screen/pages/talk/chatBubble.dart b/lib/screen/pages/talk/chatBubble.dart index aeba646..887b8d2 100644 --- a/lib/screen/pages/talk/chatBubble.dart +++ b/lib/screen/pages/talk/chatBubble.dart @@ -5,6 +5,7 @@ import 'package:marianum_mobile/api/marianumcloud/talk/chat/getChatResponse.dart import 'package:marianum_mobile/screen/pages/talk/chatMessage.dart'; import '../../../api/marianumcloud/talk/room/getRoomResponse.dart'; +import '../../settings/debug/jsonViewer.dart'; class ChatBubble { static const styleSystem = BubbleStyle( @@ -64,58 +65,81 @@ class ChatBubble { } } - Bubble generateBubble() { + Widget generateBubble() { bool showActorDisplayName = bubbleData.messageType == GetRoomResponseObjectMessageType.comment && chatData.type != GetRoomResponseObjectConversationType.oneToOne; bool showBubbleTime = bubbleData.messageType != GetRoomResponseObjectMessageType.system; var actorTextStyle = TextStyle(color: Theme.of(context).primaryColor, fontWeight: FontWeight.bold); - return Bubble( + return GestureDetector( + child: Bubble( - style: getStyle(), - child: Container( - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width * 0.9, - minWidth: showActorDisplayName ? _textSize(bubbleData.actorDisplayName, actorTextStyle).width : 30, - ), - child: Stack( - children: [ - Padding( - padding: EdgeInsets.only(bottom: showBubbleTime ? 18 : 0, top: showActorDisplayName ? 18 : 0), - child: FutureBuilder( - future: message.getWidget(), - builder: (context, snapshot) { - if(!snapshot.hasData) return const CircularProgressIndicator(); - return snapshot.data ?? const Icon(Icons.error); - }, - ) - ), - Visibility( - visible: showActorDisplayName, - child: Positioned( - top: 0, - left: 0, - child: Text( - bubbleData.actorDisplayName, - textAlign: TextAlign.start, - style: actorTextStyle, + style: getStyle(), + child: Container( + constraints: BoxConstraints( + maxWidth: MediaQuery.of(context).size.width * 0.9, + minWidth: showActorDisplayName ? _textSize(bubbleData.actorDisplayName, actorTextStyle).width : 30, + ), + child: Stack( + children: [ + Padding( + padding: EdgeInsets.only(bottom: showBubbleTime ? 18 : 0, top: showActorDisplayName ? 18 : 0), + child: FutureBuilder( + future: message.getWidget(), + builder: (context, snapshot) { + if(!snapshot.hasData) return const CircularProgressIndicator(); + return snapshot.data ?? const Icon(Icons.error); + }, + ) + ), + Visibility( + visible: showActorDisplayName, + child: Positioned( + top: 0, + left: 0, + child: Text( + bubbleData.actorDisplayName, + textAlign: TextAlign.start, + style: actorTextStyle, + ), ), ), - ), - Visibility( - visible: showBubbleTime, - child: Positioned( - bottom: 0, - right: 0, - child: Text( - Jiffy.unixFromSecondsSinceEpoch(bubbleData.timestamp).format("HH:mm"), - textAlign: TextAlign.end, - style: const TextStyle(color: Colors.grey, fontSize: 12), + Visibility( + visible: showBubbleTime, + child: Positioned( + bottom: 0, + right: 0, + child: Text( + Jiffy.unixFromSecondsSinceEpoch(bubbleData.timestamp).format("HH:mm"), + textAlign: TextAlign.end, + style: const TextStyle(color: Colors.grey, fontSize: 12), + ), ), ), - ), - ], + ], + ), ), ), + onLongPress: () { + showDialog(context: context, builder: (context) { + return SimpleDialog( + children: [ + ListTile( + leading: Icon(Icons.copy), + title: Text("Nachricht kopieren"), + ), + ListTile( + leading: Icon(Icons.person), + title: Text("Zu '${bubbleData.actorDisplayName}' wechseln"), + ), + ListTile( + leading: Icon(Icons.bug_report_outlined), + title: Text("Debugdaten anzeigen"), + onTap: () => JsonViewer.asDialog(context, bubbleData.toJson()), + ) + ], + ); + }); + }, ); } diff --git a/lib/screen/pages/talk/chatView.dart b/lib/screen/pages/talk/chatView.dart index 8672828..a9c0a6a 100644 --- a/lib/screen/pages/talk/chatView.dart +++ b/lib/screen/pages/talk/chatView.dart @@ -1,5 +1,4 @@ -import 'package:bubble/bubble.dart'; import 'package:flutter/material.dart'; import 'package:marianum_mobile/api/marianumcloud/talk/room/getRoomResponse.dart'; import 'package:marianum_mobile/data/chatList/chatProps.dart'; @@ -35,7 +34,7 @@ class _ChatViewState extends State { Widget build(BuildContext context) { return Consumer( builder: (context, data, child) { - List messages = List.empty(growable: true); + List messages = List.empty(growable: true); if(!data.primaryLoading()) { diff --git a/lib/screen/pages/timetable/weekView.dart b/lib/screen/pages/timetable/weekView.dart index 157b55c..aa3ae7d 100644 --- a/lib/screen/pages/timetable/weekView.dart +++ b/lib/screen/pages/timetable/weekView.dart @@ -86,16 +86,7 @@ class _WeekViewState extends State { ListTile( leading: const Icon(Icons.bug_report_outlined), title: const Text("Webuntis Rohdaten zeigen"), - onTap: () => showDialog(context: context, builder: (context) { - return AlertDialog( - scrollable: true, - title: const Text("Rohdaten"), - content: Text(JsonViewer.format(timetableData.toJson())), - actions: [ - TextButton(onPressed: () => Navigator.of(context).pop(), child: const SingleChildScrollView(child: Text("Schließen"))) - ], - ); - }), + onTap: () => JsonViewer.asDialog(context, timetableData.toJson()), ) ], ), diff --git a/lib/screen/settings/debug/jsonViewer.dart b/lib/screen/settings/debug/jsonViewer.dart index 616dda7..b49b9aa 100644 --- a/lib/screen/settings/debug/jsonViewer.dart +++ b/lib/screen/settings/debug/jsonViewer.dart @@ -24,4 +24,17 @@ class JsonViewer extends StatelessWidget { return prettyJson(jsonInput, indent: 2); //return jsonInput.replaceAllMapped(RegExp(r'[{,}]'), (match) => "${match.group(0)}\n "); } + + static void asDialog(BuildContext context, Map dataMap) { + showDialog(context: context, builder: (context) { + return AlertDialog( + scrollable: true, + title: const Text("Rohdaten"), + content: Text(JsonViewer.format(dataMap)), + actions: [ + TextButton(onPressed: () => Navigator.of(context).pop(), child: const SingleChildScrollView(child: Text("Schließen"))) + ], + ); + }); + } }