added prj editing page, must change to dialog bcz page too big
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user