LCOV - code coverage report
Current view: top level - lib/models - appstate.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 50 0.0 %
Date: 2024-11-29 23:41:39 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 _initialScrollIndex = 0;
      17             :   bool _unreadMessagesBelow = false;
      18             :   bool _disableFilePicker = false;
      19             :   bool _focus = true;
      20             :   bool _settingsLoaded = false;
      21             :   bool _themesLoaded = false;
      22             : 
      23             :   StreamController<bool> _profilesUnreadNotifyControler = StreamController<bool>();
      24             :   late Stream<bool> profilesUnreadNotify;
      25             : 
      26           0 :   AppState() {
      27           0 :     profilesUnreadNotify = _profilesUnreadNotifyControler.stream.asBroadcastStream();
      28             :   }
      29             : 
      30           0 :   void SetCwtchInit() {
      31           0 :     cwtchInit = true;
      32           0 :     notifyListeners();
      33             :   }
      34             : 
      35           0 :   void SetAppError(String error) {
      36           0 :     appError = error;
      37           0 :     EnvironmentConfig.debugLog("App Error: $appError");
      38           0 :     notifyListeners();
      39             :   }
      40             : 
      41           0 :   void SetModalState(ModalState newState) {
      42           0 :     modalState = newState;
      43           0 :     EnvironmentConfig.debugLog("Modal State: $newState");
      44           0 :     notifyListeners();
      45             :   }
      46             : 
      47           0 :   String? get selectedProfile => _selectedProfile;
      48           0 :   set selectedProfile(String? newVal) {
      49           0 :     this._selectedConversation = null;
      50           0 :     this._selectedProfile = newVal;
      51           0 :     notifyListeners();
      52             :   }
      53             : 
      54           0 :   int? get selectedConversation => _selectedConversation;
      55           0 :   set selectedConversation(int? newVal) {
      56           0 :     this._selectedConversation = newVal;
      57           0 :     notifyListeners();
      58             :   }
      59             : 
      60           0 :   bool get disableFilePicker => _disableFilePicker;
      61           0 :   set disableFilePicker(bool newVal) {
      62           0 :     this._disableFilePicker = newVal;
      63           0 :     notifyListeners();
      64             :   }
      65             : 
      66           0 :   bool get unreadMessagesBelow => _unreadMessagesBelow;
      67           0 :   set unreadMessagesBelow(bool newVal) {
      68           0 :     this._unreadMessagesBelow = newVal;
      69           0 :     notifyListeners();
      70             :   }
      71             : 
      72           0 :   int get initialScrollIndex => _initialScrollIndex;
      73           0 :   set initialScrollIndex(int newVal) {
      74           0 :     this._initialScrollIndex = newVal;
      75           0 :     notifyListeners();
      76             :   }
      77             : 
      78           0 :   bool get focus => _focus;
      79           0 :   set focus(bool newVal) {
      80           0 :     _focus = newVal;
      81           0 :     notifyListeners();
      82             :   }
      83             : 
      84           0 :   set settingsLoaded(bool newVal) {
      85           0 :     _settingsLoaded = newVal;
      86           0 :     notifyListeners();
      87             :   }
      88             : 
      89           0 :   set themesLoaded(bool newVal) {
      90           0 :     _themesLoaded = newVal;
      91           0 :     notifyListeners();
      92             :   }
      93             : 
      94           0 :   bool get loaded => cwtchInit && _settingsLoaded && globalSettings.themeloader.themes.length > 0 && modalState == ModalState.none;
      95             : 
      96           0 :   bool isLandscape(BuildContext c) => MediaQuery.of(c).size.width > MediaQuery.of(c).size.height;
      97             : 
      98           0 :   void notifyProfileUnread() {
      99           0 :     _profilesUnreadNotifyControler.add(true);
     100             :   }
     101             : 
     102           0 :   Stream<bool> getUnreadProfileNotifyStream() {
     103           0 :     return profilesUnreadNotify;
     104             :   }
     105             : }

Generated by: LCOV version 1.14