2022-01-18 21:26:52 +00:00
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
|
|
|
|
enum ModalState { none, storageMigration }
|
|
|
|
|
|
|
|
class AppState extends ChangeNotifier {
|
|
|
|
bool cwtchInit = false;
|
|
|
|
ModalState modalState = ModalState.none;
|
|
|
|
bool cwtchIsClosing = false;
|
|
|
|
String appError = "";
|
|
|
|
String? _selectedProfile;
|
|
|
|
int? _selectedConversation;
|
|
|
|
int _initialScrollIndex = 0;
|
|
|
|
int _hoveredIndex = -1;
|
|
|
|
int? _selectedIndex;
|
|
|
|
bool _unreadMessagesBelow = false;
|
2022-01-21 21:17:16 +00:00
|
|
|
bool _disableFilePicker = false;
|
2022-01-26 16:31:07 +00:00
|
|
|
bool _focus = true;
|
2022-01-18 21:26:52 +00:00
|
|
|
|
|
|
|
void SetCwtchInit() {
|
|
|
|
cwtchInit = true;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetAppError(String error) {
|
|
|
|
appError = error;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetModalState(ModalState newState) {
|
|
|
|
modalState = newState;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
String? get selectedProfile => _selectedProfile;
|
|
|
|
set selectedProfile(String? newVal) {
|
|
|
|
this._selectedProfile = newVal;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
int? get selectedConversation => _selectedConversation;
|
|
|
|
set selectedConversation(int? newVal) {
|
|
|
|
this._selectedConversation = newVal;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
int? get selectedIndex => _selectedIndex;
|
|
|
|
set selectedIndex(int? newVal) {
|
|
|
|
this._selectedIndex = newVal;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
2022-01-21 21:17:16 +00:00
|
|
|
bool get disableFilePicker => _disableFilePicker;
|
|
|
|
set disableFilePicker(bool newVal) {
|
|
|
|
this._disableFilePicker = newVal;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
2022-01-18 21:26:52 +00:00
|
|
|
// Never use this for message lookup - can be a non-indexed value
|
|
|
|
// e.g. -1
|
|
|
|
int get hoveredIndex => _hoveredIndex;
|
|
|
|
set hoveredIndex(int newVal) {
|
|
|
|
this._hoveredIndex = newVal;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool get unreadMessagesBelow => _unreadMessagesBelow;
|
|
|
|
set unreadMessagesBelow(bool newVal) {
|
|
|
|
this._unreadMessagesBelow = newVal;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
int get initialScrollIndex => _initialScrollIndex;
|
|
|
|
set initialScrollIndex(int newVal) {
|
|
|
|
this._initialScrollIndex = newVal;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
2022-01-26 16:31:07 +00:00
|
|
|
bool get focus => _focus;
|
|
|
|
set focus(bool newVal) {
|
|
|
|
_focus = newVal;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
2022-01-18 21:26:52 +00:00
|
|
|
bool isLandscape(BuildContext c) => MediaQuery.of(c).size.width > MediaQuery.of(c).size.height;
|
2022-01-19 21:58:52 +00:00
|
|
|
}
|