LCOV - code coverage report
Current view: top level - lib/models - message_draft.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 32 0.0 %
Date: 2024-02-26 20:09:01 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/cupertino.dart';
       2             : 
       3             : /// A "MessageDraft" structure that stores information about in-progress message drafts.
       4             : /// MessageDraft stores text, quoted replies, and attached images.
       5             : /// Only one draft is stored per conversation.
       6             : class MessageDraft extends ChangeNotifier {
       7             :   QuotedReference? _quotedReference;
       8             :   int? _inviteHandle;
       9             :   TextEditingController ctrlCompose = TextEditingController();
      10             : 
      11           0 :   static MessageDraft empty() {
      12           0 :     return MessageDraft();
      13             :   }
      14             : 
      15           0 :   bool isEmpty() {
      16           0 :     return (this._quotedReference == null) || (this.messageText.isEmpty);
      17             :   }
      18             : 
      19           0 :   String get messageText => ctrlCompose.text;
      20             : 
      21           0 :   set messageText(String text) {
      22           0 :     this.ctrlCompose.text = text;
      23           0 :     notifyListeners();
      24             :   }
      25             : 
      26           0 :   set quotedReference(int index) {
      27           0 :     this._quotedReference = QuotedReference(index);
      28           0 :     notifyListeners();
      29             :   }
      30             : 
      31           0 :   void attachInvite(int handle) {
      32           0 :     this._inviteHandle = handle;
      33           0 :     notifyListeners();
      34             :   }
      35             : 
      36           0 :   int? getInviteHandle() {
      37           0 :     return this._inviteHandle;
      38             :   }
      39             : 
      40           0 :   QuotedReference? getQuotedMessage() {
      41           0 :     return this._quotedReference;
      42             :   }
      43             : 
      44           0 :   void clearQuotedReference() {
      45           0 :     this._quotedReference = null;
      46           0 :     notifyListeners();
      47             :   }
      48             : 
      49           0 :   void clearDraft() {
      50           0 :     this._quotedReference = null;
      51           0 :     this.ctrlCompose.clear();
      52           0 :     this._inviteHandle = null;
      53           0 :     notifyListeners();
      54             :   }
      55             : 
      56           0 :   @override
      57             :   void dispose() {
      58           0 :     ctrlCompose.dispose();
      59           0 :     super.dispose();
      60             :   }
      61             : 
      62           0 :   void clearInvite() {
      63           0 :     this._inviteHandle = null;
      64             :   }
      65             : }
      66             : 
      67             : /// A QuotedReference encapsulates the state of replied-to message.
      68             : class QuotedReference {
      69             :   int index;
      70           0 :   QuotedReference(this.index);
      71             : }

Generated by: LCOV version 1.14