added prj editing page, must change to dialog bcz page too big
All checks were successful
Build CI / AMD64 Build (push) Successful in 3m23s
Build CI / ARM64 Build (push) Successful in 7m16s

This commit is contained in:
2026-02-15 19:06:08 +05:30
parent 985d7e5e21
commit ec3e69ffa9
8 changed files with 203 additions and 32 deletions

View File

@@ -8,7 +8,6 @@ class Editor {
final String name;
final String command;
final String commandTemplate;
// final Icon icon;
const Editor(
this.sname,
@@ -39,6 +38,7 @@ class Editor {
Map<String, dynamic> toJson() {
return {
"sname": sname,
"name": name,
"command": command,
"commandTemplate": commandTemplate,
@@ -50,7 +50,8 @@ class Editor {
if (!data.containsKey("name") ||
!data.containsKey("command") ||
!data.containsKey("commandTemplate") ||
!data.containsKey("id")) {
!data.containsKey("id") ||
!data.containsKey("sname")) {
print("Found invalid editor config when parsing: $data");
return Editor("!!", "null", "null", "null", "null");
}

View File

@@ -12,11 +12,24 @@ class GlobalModel extends ChangeNotifier {
late List<Editor> editors;
late SharedPreferences prefs;
bool importedData = false;
bool edited = false;
GlobalModel() {
SharedPreferences.getInstance().then((a) {
print("Loaded sp");
prefs = a;
if (prefs.containsKey(kEditorsKey)) {
String edtData = prefs.getString(kEditorsKey)!;
List<dynamic> data = jsonDecode(edtData);
editors = [];
for (var d in data) {
editors.add(Editor.fromJson(d));
}
} else {
editors = [];
prefs.setString(kEditorsKey, jsonEncode(editors));
}
if (prefs.containsKey(kProjectsKey)) {
String prjData = prefs.getString(kProjectsKey)!;
List<dynamic> data = jsonDecode(prjData);
@@ -30,18 +43,6 @@ class GlobalModel extends ChangeNotifier {
}
print(projects);
if (prefs.containsKey(kEditorsKey)) {
String edtData = prefs.getString(kEditorsKey)!;
List<dynamic> data = jsonDecode(edtData);
editors = [];
for (var d in data) {
editors.add(Editor.fromJson(d));
}
} else {
editors = [];
prefs.setString(kEditorsKey, jsonEncode(editors));
}
hoverShow = List.filled(projects.length, false, growable: true);
print("loaded data");
importedData = true;
@@ -94,6 +95,11 @@ class GlobalModel extends ChangeNotifier {
return hoverShow[index];
}
void updatePrj(int index, Project prj) {
projects[index] = prj;
notifyListeners();
}
// Editor List Management.
void addEdt(Editor edt) {
@@ -115,4 +121,15 @@ class GlobalModel extends ChangeNotifier {
Editor nthEdt(int index) {
return editors[index];
}
// Editing controller
bool get isEdited {
return edited;
}
void updateEdited(bool a) {
edited = a;
notifyListeners();
}
}