first working prototype
Some checks failed
Build CI / Build (push) Has been cancelled

This commit is contained in:
2026-02-11 22:59:25 +05:30
parent 6a10685033
commit 73827ea62c
13 changed files with 281 additions and 32 deletions

View File

@@ -1,13 +1,19 @@
import "package:flutter/material.dart";
import "package:process_run/which.dart";
import "package:prod/models/rand.dart";
class Editor {
final String id;
final String name;
final String command;
final String commandTemplate;
// final Icon icon;
const Editor(this.name, this.command, this.commandTemplate);
const Editor(this.name, this.command, this.commandTemplate, this.id);
factory Editor.create(String name, String command, String commandTemplate) {
return Editor(name, command, commandTemplate, getRandomString(5));
}
bool validateCommand() {
final String? fullPath = whichSync(command);
@@ -17,4 +23,29 @@ class Editor {
return true;
}
}
Map<String, dynamic> toJson() {
return {
"name": name,
"command": command,
"commandTemplate": commandTemplate,
"id": id,
};
}
factory Editor.fromJson(Map<String, dynamic> data) {
if (!data.containsKey("name") ||
!data.containsKey("command") ||
!data.containsKey("commandTemplate") ||
!data.containsKey("id")) {
print("Found invalid editor config when parsing: $data");
return Editor("null", "null", "null", "null");
}
return Editor(
data["name"] as String,
data["command"] as String,
data["commandTemplate"] as String,
data["id"] as String,
);
}
}