added proper editor buttons to prj card, APP BROKEN HERE.
All checks were successful
Build CI / AMD64 Build (push) Successful in 1m55s
Build CI / ARM64 Build (push) Successful in 7m8s

This commit is contained in:
2026-02-27 18:23:52 +05:30
parent 50c52b7619
commit 07f222a87e
7 changed files with 120 additions and 60 deletions

View File

@@ -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 {

View File

@@ -3,14 +3,14 @@ import "dart:io";
import "package:path/path.dart" as p;
class Project {
final String name;
final String language;
final File path;
final String? e0;
final String? e1;
final String? e2;
final String? e3;
final bool isGit;
String name;
String language;
File path;
String? e0;
String? e1;
String? e2;
String? e3;
bool isGit;
Project(
this.name,
@@ -76,6 +76,40 @@ class Project {
);
}
String? getEditor(enumb) {
switch (enumb) {
case 0:
return e0;
case 1:
return e1;
case 2:
return e2;
case 3:
return e3;
default:
return null;
break;
}
}
void setEditor(int enumb, String? edt) {
switch (enumb) {
case 0:
e0 = edt;
break;
case 1:
e1 = edt;
break;
case 2:
e2 = edt;
break;
case 3:
e3 = edt;
break;
default:
}
}
// bool validatePath(){
// return File
// }