initial commit
This commit is contained in:
20
lib/models/editor.dart
Normal file
20
lib/models/editor.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import "package:flutter/material.dart";
|
||||
import "package:process_run/which.dart";
|
||||
|
||||
class Editor {
|
||||
final String name;
|
||||
final String command;
|
||||
final String commandTemplate;
|
||||
// final Icon icon;
|
||||
|
||||
const Editor(this.name, this.command, this.commandTemplate);
|
||||
|
||||
bool validateCommand() {
|
||||
final String? fullPath = whichSync(command);
|
||||
if (fullPath == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
68
lib/models/globalModel.dart
Normal file
68
lib/models/globalModel.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:prod/models/editor.dart';
|
||||
import 'package:prod/models/project.dart';
|
||||
|
||||
class GlobalModel extends ChangeNotifier {
|
||||
late List<Project> projects;
|
||||
late List<bool> hoverShow;
|
||||
late List<Editor> editors;
|
||||
|
||||
GlobalModel() {
|
||||
projects = [];
|
||||
editors = [];
|
||||
hoverShow = List.filled(projects.length, false, growable: true);
|
||||
}
|
||||
|
||||
void addPrj(Project prj) {
|
||||
projects.add(prj);
|
||||
hoverShow.add(false);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void delPrj(int index) {
|
||||
projects.removeAt(index);
|
||||
hoverShow.removeAt(index);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
List<Project> get lsPrj {
|
||||
return projects;
|
||||
}
|
||||
|
||||
int get lenPrj {
|
||||
return projects.length;
|
||||
}
|
||||
|
||||
Project nthPrj(int index) {
|
||||
return projects[index];
|
||||
}
|
||||
|
||||
void setHoverShow(int index, bool state) {
|
||||
hoverShow[index] = state;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool getHoverShow(int index) {
|
||||
return hoverShow[index];
|
||||
}
|
||||
|
||||
// Editor List Management.
|
||||
|
||||
void addEdt(Editor edt) {
|
||||
editors.add(edt);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void delEdt(int index) {
|
||||
editors.removeAt(index);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int get lenEdt {
|
||||
return editors.length;
|
||||
}
|
||||
|
||||
Editor nthEdt(int index) {
|
||||
return editors[index];
|
||||
}
|
||||
}
|
||||
44
lib/models/project.dart
Normal file
44
lib/models/project.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'package:prod/models/editor.dart';
|
||||
import "dart:io";
|
||||
import "package:path/path.dart" as p;
|
||||
|
||||
class Project {
|
||||
final String name;
|
||||
final String language;
|
||||
final File path;
|
||||
final List<Editor> editors;
|
||||
final bool isGit;
|
||||
final bool enableTerminal;
|
||||
|
||||
Project(
|
||||
this.name,
|
||||
this.language,
|
||||
this.path,
|
||||
this.editors,
|
||||
this.isGit,
|
||||
this.enableTerminal,
|
||||
);
|
||||
|
||||
factory Project.validated(
|
||||
String name,
|
||||
String lang,
|
||||
String path,
|
||||
List<Editor> editors,
|
||||
bool enableTerminal,
|
||||
) {
|
||||
final File fpath = File(path);
|
||||
if (fpath.existsSync()) {
|
||||
print("Project not found!!!");
|
||||
} else {
|
||||
print("Project Exists on disk");
|
||||
}
|
||||
String gitPath = p.join(path, ".git", "HEAD");
|
||||
final bool isGit = File(gitPath).existsSync();
|
||||
|
||||
return Project(name, lang, fpath, editors, isGit, enableTerminal);
|
||||
}
|
||||
|
||||
// bool validatePath(){
|
||||
// return File
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user