refactored HTTP error handling and streamlined UI components by centralizing shared logic and removing redundant parameters

This commit is contained in:
2026-07-13 22:58:02 +02:00
parent d7536ea5d0
commit 8274dd46cd
28 changed files with 284 additions and 447 deletions
-3
View File
@@ -245,7 +245,6 @@ class _ChatViewState extends State<ChatView> with RouteAware {
lastDate = elementDate;
messages.add(
ChatBubble(
context: context,
isSender: false,
bubbleData: GetChatResponseObject.getDateDummy(element.timestamp),
chatData: widget.room,
@@ -265,7 +264,6 @@ class _ChatViewState extends State<ChatView> with RouteAware {
messages.add(
ChatBubble(
context: context,
isSender:
element.actorId == widget.selfId &&
(element.messageType ==
@@ -287,7 +285,6 @@ class _ChatViewState extends State<ChatView> with RouteAware {
messages.insert(
0,
ChatBubble(
context: context,
isSender: false,
bubbleData: GetChatResponseObject.getTextDummy(
'Zurzeit können in dieser App nur die letzten 200 vergangenen Nachrichten angezeigt werden. '
@@ -24,29 +24,23 @@ class ChatBubbleStyles {
alignment: Alignment.center,
);
BubbleStyle getRemoteStyle(bool seamless) {
var color = AppTheme.isDarkMode(context)
BubbleStyle getRemoteStyle() => BubbleStyle(
nip: BubbleNip.leftTop,
color: AppTheme.isDarkMode(context)
? const Color(0xff202c33)
: Colors.white;
return BubbleStyle(
nip: BubbleNip.leftTop,
color: seamless ? Colors.transparent : color,
elevation: seamless ? 0 : 1,
margin: const BubbleEdges.only(bottom: 10, left: 10, right: 50),
alignment: Alignment.topLeft,
);
}
: Colors.white,
elevation: 1,
margin: const BubbleEdges.only(bottom: 10, left: 10, right: 50),
alignment: Alignment.topLeft,
);
BubbleStyle getSelfStyle(bool seamless) {
var color = AppTheme.isDarkMode(context)
BubbleStyle getSelfStyle() => BubbleStyle(
nip: BubbleNip.rightBottom,
color: AppTheme.isDarkMode(context)
? const Color(0xff005c4b)
: const Color(0xffd3d3d3);
return BubbleStyle(
nip: BubbleNip.rightBottom,
color: seamless ? Colors.transparent : color,
elevation: seamless ? 0 : 1,
margin: const BubbleEdges.only(bottom: 10, right: 10, left: 50),
alignment: Alignment.topRight,
);
}
: const Color(0xffd3d3d3),
elevation: 1,
margin: const BubbleEdges.only(bottom: 10, right: 10, left: 50),
alignment: Alignment.topRight,
);
}
@@ -5,11 +5,9 @@ import '../../../../api/marianumcloud/talk/chat/rich_object_string_processor.dar
import '../data/chat_bubble_styles.dart';
class AnswerReference extends StatelessWidget {
final BuildContext context;
final GetChatResponseObject referenceMessage;
final String? selfId;
const AnswerReference({
required this.context,
required this.referenceMessage,
required this.selfId,
super.key,
@@ -20,8 +18,8 @@ class AnswerReference extends StatelessWidget {
final style = ChatBubbleStyles(context);
final isSelf = referenceMessage.actorId == selfId;
final accent = isSelf
? style.getSelfStyle(false).color!.withGreen(200)
: style.getRemoteStyle(false).color!.withWhite(200);
? style.getSelfStyle().color!.withGreen(200)
: style.getRemoteStyle().color!.withWhite(200);
return DecoratedBox(
decoration: BoxDecoration(
color: accent.withValues(alpha: 0.2),
+2 -5
View File
@@ -23,7 +23,6 @@ import 'highlighted_linkify.dart';
enum SearchHighlight { none, secondary, active }
class ChatBubble extends StatefulWidget {
final BuildContext context;
final bool isSender;
final GetChatResponseObject bubbleData;
final GetRoomResponseObject chatData;
@@ -40,7 +39,6 @@ class ChatBubble extends StatefulWidget {
final SearchHighlight matchHighlight;
const ChatBubble({
required this.context,
required this.isSender,
required this.bubbleData,
required this.chatData,
@@ -123,8 +121,8 @@ class _ChatBubbleState extends State<ChatBubble>
base = styles.getSystemStyle();
} else {
base = widget.isSender
? styles.getSelfStyle(false)
: styles.getRemoteStyle(false);
? styles.getSelfStyle()
: styles.getRemoteStyle();
}
switch (widget.matchHighlight) {
case SearchHighlight.none:
@@ -366,7 +364,6 @@ class _BubbleContent extends StatelessWidget {
bubbleData.messageType ==
GetRoomResponseObjectMessageType.comment) ...[
AnswerReference(
context: context,
referenceMessage: parent!,
selfId: selfId,
),
@@ -263,7 +263,6 @@ class _ChatTextfieldState extends State<ChatTextfield> {
children: [
Expanded(
child: AnswerReference(
context: context,
referenceMessage: referenceMessage,
selfId: widget.selfId,
),