LCOV - code coverage report
Current view: top level - lib/widgets - staticmessagebubble.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 28 0.0 %
Date: 2024-08-22 18:05:30 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:cwtch/models/contact.dart';
       2             : import 'package:cwtch/models/message.dart';
       3             : import 'package:cwtch/models/profile.dart';
       4             : import 'package:cwtch/widgets/malformedbubble.dart';
       5             : import 'package:flutter/material.dart';
       6             : 
       7             : import '../models/redaction.dart';
       8             : import '../settings.dart';
       9             : import 'messageBubbleWidgetHelpers.dart';
      10             : import 'messagebubbledecorations.dart';
      11             : 
      12             : class StaticMessageBubble extends StatefulWidget {
      13             :   final ProfileInfoState profile;
      14             :   final Settings settings;
      15             :   final MessageMetadata metadata;
      16             :   final Widget child;
      17             : 
      18           0 :   StaticMessageBubble(this.profile, this.settings, this.metadata, this.child);
      19             : 
      20           0 :   @override
      21           0 :   StaticMessageBubbleState createState() => StaticMessageBubbleState();
      22             : }
      23             : 
      24             : class StaticMessageBubbleState extends State<StaticMessageBubble> {
      25           0 :   @override
      26             :   Widget build(BuildContext context) {
      27           0 :     var fromMe = widget.metadata.senderHandle == widget.profile.onion;
      28             :     var borderRadiousEh = 15.0;
      29           0 :     DateTime messageDate = widget.metadata.timestamp;
      30             : 
      31             :     // If the sender is not us, then we want to give them a nickname...
      32             :     var senderDisplayStr = "";
      33             :     if (!fromMe) {
      34           0 :       ContactInfoState? contact = widget.profile.contactList.findContact(widget.metadata.senderHandle);
      35             :       if (contact != null) {
      36           0 :         senderDisplayStr = redactedNick(context, contact.onion, contact.nickname);
      37             :       } else {
      38           0 :         senderDisplayStr = widget.metadata.senderHandle;
      39             :       }
      40             :     } else {
      41           0 :       senderDisplayStr = widget.profile.nickname;
      42             :     }
      43             : 
      44           0 :     return LayoutBuilder(builder: (context, constraints) {
      45           0 :       var wdgSender = compileSenderWidget(context, constraints, fromMe, senderDisplayStr);
      46           0 :       var wdgDecorations = MessageBubbleDecoration(ackd: widget.metadata.ackd, errored: widget.metadata.error, fromMe: fromMe, messageDate: messageDate);
      47           0 :       var error = widget.metadata.error;
      48             :       //print(constraints.toString()+", "+constraints.maxWidth.toString());
      49           0 :       return RepaintBoundary(
      50           0 :           child: Container(
      51           0 :               child: Container(
      52           0 :                   decoration: BoxDecoration(
      53           0 :                     color: error ? malformedColor : (fromMe ? widget.settings.theme.messageFromMeBackgroundColor : widget.settings.theme.messageFromOtherBackgroundColor),
      54           0 :                     border: Border.all(color: error ? malformedColor : (fromMe ? widget.settings.theme.messageFromMeBackgroundColor : widget.settings.theme.messageFromOtherBackgroundColor), width: 1),
      55           0 :                     borderRadius: BorderRadius.only(
      56           0 :                       topLeft: Radius.circular(borderRadiousEh),
      57           0 :                       topRight: Radius.circular(borderRadiousEh),
      58             :                       bottomLeft: Radius.zero,
      59           0 :                       bottomRight: Radius.circular(borderRadiousEh),
      60             :                     ),
      61             :                   ),
      62           0 :                   child: Padding(
      63           0 :                       padding: EdgeInsets.all(9.0),
      64           0 :                       child: Column(
      65             :                           crossAxisAlignment: CrossAxisAlignment.start,
      66             :                           mainAxisAlignment: MainAxisAlignment.start,
      67             :                           mainAxisSize: MainAxisSize.min,
      68           0 :                           children: [wdgSender, widget.child, wdgDecorations])))));
      69             :     });
      70             :   }
      71             : }

Generated by: LCOV version 1.14