added proper editor buttons to prj card, APP BROKEN HERE.
This commit is contained in:
@@ -11,6 +11,7 @@ class GlobalModel extends ChangeNotifier {
|
||||
late List<bool> hoverShow;
|
||||
late List<Editor> editors;
|
||||
late SharedPreferences prefs;
|
||||
late Map<String, int> id2EdtMap;
|
||||
bool importedData = false;
|
||||
bool edited = false;
|
||||
|
||||
@@ -22,13 +23,17 @@ class GlobalModel extends ChangeNotifier {
|
||||
String edtData = prefs.getString(kEditorsKey)!;
|
||||
List<dynamic> data = jsonDecode(edtData);
|
||||
editors = [];
|
||||
for (var d in data) {
|
||||
editors.add(Editor.fromJson(d));
|
||||
id2EdtMap = {};
|
||||
for (var (i, d) in data.indexed) {
|
||||
var localEdt = Editor.fromJson(d);
|
||||
editors.add(localEdt);
|
||||
id2EdtMap[localEdt.id] = i;
|
||||
}
|
||||
} else {
|
||||
editors = [];
|
||||
prefs.setString(kEditorsKey, jsonEncode(editors));
|
||||
}
|
||||
print(id2EdtMap);
|
||||
|
||||
if (prefs.containsKey(kProjectsKey)) {
|
||||
String prjData = prefs.getString(kProjectsKey)!;
|
||||
@@ -60,6 +65,8 @@ class GlobalModel extends ChangeNotifier {
|
||||
prefs.setString(kEditorsKey, jsonEncode(arst));
|
||||
}
|
||||
|
||||
// Project management
|
||||
|
||||
void addPrj(Project prj) {
|
||||
projects.add(prj);
|
||||
hoverShow.add(false);
|
||||
@@ -97,6 +104,7 @@ class GlobalModel extends ChangeNotifier {
|
||||
|
||||
void updatePrj(int index, Project prj) {
|
||||
projects[index] = prj;
|
||||
saveProjectState();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -122,6 +130,10 @@ class GlobalModel extends ChangeNotifier {
|
||||
return editors[index];
|
||||
}
|
||||
|
||||
int? getFromID(String? id) {
|
||||
return id2EdtMap[id];
|
||||
}
|
||||
|
||||
// Editing controller
|
||||
|
||||
bool get isEdited {
|
||||
|
||||
Reference in New Issue
Block a user