moved editing page to popup
All checks were successful
Build CI / AMD64 Build (push) Successful in 1m54s

This commit is contained in:
2026-03-11 01:10:25 +05:30
parent cee48b3e4b
commit ce25d26f70
10 changed files with 164 additions and 181 deletions

View File

@@ -17,22 +17,20 @@ class GlobalModel extends ChangeNotifier {
GlobalModel() {
SharedPreferences.getInstance().then((a) {
print("Loaded sp");
prefs = a;
editors = [Editor("", "None", "NANII", "", "")];
id2EdtMap = {"NANII": 0};
editors = [];
id2EdtMap = {};
if (prefs.containsKey(kEditorsKey)) {
String edtData = prefs.getString(kEditorsKey)!;
List<dynamic> data = jsonDecode(edtData);
for (var (i, d) in data.indexed) {
var localEdt = Editor.fromJson(d);
editors.add(localEdt);
id2EdtMap[localEdt.id] = i + 1;
id2EdtMap[localEdt.id] = i;
}
} else {
prefs.setString(kEditorsKey, jsonEncode(editors));
}
print(id2EdtMap);
final List<String> idList = id2EdtMap.keys.toList();
projects = [];
@@ -45,6 +43,7 @@ class GlobalModel extends ChangeNotifier {
} else {
prefs.setString(kProjectsKey, jsonEncode(projects));
}
print("Project List:");
print(projects);
hoverShow = List.filled(projects.length, false, growable: true);
@@ -61,7 +60,6 @@ class GlobalModel extends ChangeNotifier {
void saveEditorState() {
var tempEditors = editors;
tempEditors.removeWhere((a) => a.id == "");
List<Map<String, dynamic>> arst = tempEditors
.map((a) => a.toJson())
.toList();
@@ -115,8 +113,7 @@ class GlobalModel extends ChangeNotifier {
void addEdt(Editor edt) {
editors.add(edt);
print(editors);
id2EdtMap[edt.id] = editors.length - 1;
rebuildIndex();
saveEditorState();
notifyListeners();
}
@@ -124,11 +121,19 @@ class GlobalModel extends ChangeNotifier {
void delEdt(int index) {
Editor removed = editors.removeAt(index);
int remmedID = id2EdtMap.remove(removed.id)!;
assert(index == remmedID);
assert(index == remmedID, "Index: $index removedID: $remmedID");
rebuildIndex();
saveEditorState();
notifyListeners();
}
void rebuildIndex() {
id2EdtMap.clear();
for (var (i, e) in editors.indexed) {
id2EdtMap[e.id] = i;
}
}
int get lenEdt {
return editors.length;
}
@@ -138,7 +143,7 @@ class GlobalModel extends ChangeNotifier {
}
int getEdtPosFromID(String id) {
return id2EdtMap[id] ?? 0;
return id2EdtMap[id] ?? -1;
}
// Editing controller