initial commit
This commit is contained in:
68
lib/models/globalModel.dart
Normal file
68
lib/models/globalModel.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:prod/models/editor.dart';
|
||||
import 'package:prod/models/project.dart';
|
||||
|
||||
class GlobalModel extends ChangeNotifier {
|
||||
late List<Project> projects;
|
||||
late List<bool> hoverShow;
|
||||
late List<Editor> editors;
|
||||
|
||||
GlobalModel() {
|
||||
projects = [];
|
||||
editors = [];
|
||||
hoverShow = List.filled(projects.length, false, growable: true);
|
||||
}
|
||||
|
||||
void addPrj(Project prj) {
|
||||
projects.add(prj);
|
||||
hoverShow.add(false);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void delPrj(int index) {
|
||||
projects.removeAt(index);
|
||||
hoverShow.removeAt(index);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
List<Project> get lsPrj {
|
||||
return projects;
|
||||
}
|
||||
|
||||
int get lenPrj {
|
||||
return projects.length;
|
||||
}
|
||||
|
||||
Project nthPrj(int index) {
|
||||
return projects[index];
|
||||
}
|
||||
|
||||
void setHoverShow(int index, bool state) {
|
||||
hoverShow[index] = state;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool getHoverShow(int index) {
|
||||
return hoverShow[index];
|
||||
}
|
||||
|
||||
// Editor List Management.
|
||||
|
||||
void addEdt(Editor edt) {
|
||||
editors.add(edt);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void delEdt(int index) {
|
||||
editors.removeAt(index);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int get lenEdt {
|
||||
return editors.length;
|
||||
}
|
||||
|
||||
Editor nthEdt(int index) {
|
||||
return editors[index];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user