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

          Line data    Source code
       1             : import 'dart:async';
       2             : 
       3             : import 'package:cwtch/config.dart';
       4             : import 'package:cwtch/main.dart';
       5             : import 'package:flutter/widgets.dart';
       6             : 
       7             : enum ModalState { none, storageMigration, shutdown }
       8             : 
       9             : class AppState extends ChangeNotifier {
      10             :   bool cwtchInit = false;
      11             :   ModalState modalState = ModalState.none;
      12             :   bool cwtchIsClosing = false;
      13             :   String appError = "";
      14             :   String? _selectedProfile;
      15             :   int? _selectedConversation;
      16             :   int? _selectedSearchMessage;
      17             :   int _initialScrollIndex = 0;
      18             :   bool _unreadMessagesBelow = false;
      19             :   bool _disableFilePicker = false;
      20             :   bool _focus = true;
      21             :   bool _settingsLoaded = false;
      22             :   bool _themesLoaded = false;
      23             : 
      24             :   StreamController<bool> _profilesUnreadNotifyControler = StreamController<bool>();
      25             :   late Stream<bool> profilesUnreadNotify;
      26             : 
      27           0 :   AppState() {
      28           0 :     profilesUnreadNotify = _profilesUnreadNotifyControler.stream.asBroadcastStream();
      29             :   }
      30             : 
      31           0 :   void SetCwtchInit() {
      32           0 :     cwtchInit = true;
      33           0 :     notifyListeners();
      34             :   }
      35             : 
      36           0 :   void SetAppError(String error) {
      37           0 :     appError = error;
      38           0 :     EnvironmentConfig.debugLog("App Error: $appError");
      39           0 :     notifyListeners();
      40             :   }
      41             : 
      42           0 :   void SetModalState(ModalState newState) {
      43           0 :     modalState = newState;
      44           0 :     EnvironmentConfig.debugLog("Modal State: $newState");
      45           0 :     notifyListeners();
      46             :   }
      47             : 
      48           0 :   String? get selectedProfile => _selectedProfile;
      49           0 :   set selectedProfile(String? newVal) {
      50           0 :     this._selectedConversation = null;
      51           0 :     this._selectedProfile = newVal;
      52           0 :     notifyListeners();
      53             :   }
      54             : 
      55           0 :   int? get selectedConversation => _selectedConversation;
      56           0 :   set selectedConversation(int? newVal) {
      57           0 :     this._selectedConversation = newVal;
      58           0 :     notifyListeners();
      59             :   }
      60             : 
      61           0 :   int? get selectedSearchMessage => _selectedSearchMessage;
      62           0 :   set selectedSearchMessage(int? newVal) {
      63           0 :     this._selectedSearchMessage = newVal;
      64           0 :     notifyListeners();
      65             :   }
      66             : 
      67           0 :   bool get disableFilePicker => _disableFilePicker;
      68           0 :   set disableFilePicker(bool newVal) {
      69           0 :     this._disableFilePicker = newVal;
      70           0 :     notifyListeners();
      71             :   }
      72             : 
      73           0 :   bool get unreadMessagesBelow => _unreadMessagesBelow;
      74           0 :   set unreadMessagesBelow(bool newVal) {
      75           0 :     this._unreadMessagesBelow = newVal;
      76           0 :     notifyListeners();
      77             :   }
      78             : 
      79           0 :   int get initialScrollIndex => _initialScrollIndex;
      80           0 :   set initialScrollIndex(int newVal) {
      81           0 :     this._initialScrollIndex = newVal;
      82           0 :     notifyListeners();
      83             :   }
      84             : 
      85           0 :   bool get focus => _focus;
      86           0 :   set focus(bool newVal) {
      87           0 :     _focus = newVal;
      88           0 :     notifyListeners();
      89             :   }
      90             : 
      91           0 :   set settingsLoaded(bool newVal) {
      92           0 :     _settingsLoaded = newVal;
      93           0 :     notifyListeners();
      94             :   }
      95             : 
      96           0 :   set themesLoaded(bool newVal) {
      97           0 :     _themesLoaded = newVal;
      98           0 :     notifyListeners();
      99             :   }
     100             : 
     101           0 :   bool get loaded => cwtchInit && _settingsLoaded && globalSettings.themeloader.themes.length > 0 && modalState == ModalState.none;
     102             : 
     103           0 :   bool isLandscape(BuildContext c) => MediaQuery.of(c).size.width > MediaQuery.of(c).size.height;
     104             : 
     105           0 :   void notifyProfileUnread() {
     106           0 :     _profilesUnreadNotifyControler.add(true);
     107             :   }
     108             : 
     109           0 :   Stream<bool> getUnreadProfileNotifyStream() {
     110           0 :     return profilesUnreadNotify;
     111             :   }
     112             : }

Generated by: LCOV version 1.14