added launch buttons
All checks were successful
Build CI / AMD64 Build (push) Successful in 2m0s
Build CI / ARM64 Build (push) Successful in 7m45s

This commit is contained in:
2026-02-25 23:58:41 +05:30
parent e912992a40
commit d3a00dc394
5 changed files with 137 additions and 60 deletions

View File

@@ -6,26 +6,24 @@ class Project {
final String name; final String name;
final String language; final String language;
final File path; final File path;
final List<String> editors; final Editor? e0;
final Editor? e1;
final Editor? e2;
final Editor? e3;
final bool isGit; final bool isGit;
final bool enableTerminal;
Project( Project(
this.name, this.name,
this.language, this.language,
this.path, this.path,
this.editors, this.isGit, {
this.isGit, this.e0 = null,
this.enableTerminal, this.e1 = null,
); this.e2 = null,
this.e3 = null,
});
factory Project.newValidated( factory Project.newValidated(String name, String lang, String path) {
String name,
String lang,
String path,
List<String> editors,
bool enableTerminal,
) {
final File fpath = File(path); final File fpath = File(path);
print(fpath.absolute.path); print(fpath.absolute.path);
if (fpath.existsSync()) { if (fpath.existsSync()) {
@@ -36,28 +34,45 @@ class Project {
String gitPath = p.join(path, ".git", "HEAD"); String gitPath = p.join(path, ".git", "HEAD");
final bool isGit = File(gitPath).existsSync(); final bool isGit = File(gitPath).existsSync();
return Project(name, lang, fpath, editors, isGit, enableTerminal); return Project(name, lang, fpath, isGit);
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { Map<String, dynamic> fin = {
"name": name, "name": name,
"language": language, "language": language,
"path": path.path, "path": path.path,
"editors": editors,
"isGit": isGit, "isGit": isGit,
"enableTerminal": enableTerminal,
}; };
if (e0 == null) {
fin["e0"] = e0;
}
if (e1 == null) {
fin["e1"] = e1;
}
if (e2 == null) {
fin["e2"] = e2;
}
if (e3 == null) {
fin["e3"] = e3;
}
return fin;
} }
factory Project.fromJson(Map<String, dynamic> data) { factory Project.fromJson(Map<String, dynamic> data) {
final Editor? e0 = data["e0"];
final Editor? e1 = data["e1"];
final Editor? e2 = data["e2"];
final Editor? e3 = data["e3"];
return Project( return Project(
data["name"] as String, data["name"] as String,
data["language"] as String, data["language"] as String,
File(data["path"] as String), File(data["path"] as String),
(data["editors"] as List<dynamic>).map((a) => a.toString()).toList(),
data["isGit"] as bool, data["isGit"] as bool,
data["enableTerminal"] as bool, e0: e0,
e1: e1,
e2: e2,
e3: e3,
); );
} }

View File

@@ -77,6 +77,7 @@ class ManageProject extends StatelessWidget {
), ),
), ),
), ),
SliverList.list(children: [Row(children: [])]),
SliverList.list( SliverList.list(
children: [ children: [
@@ -109,9 +110,7 @@ class ManageProject extends StatelessWidget {
nameController.text, nameController.text,
langController.text, langController.text,
File(pathController.text), File(pathController.text),
prj.editors,
prj.isGit, prj.isGit,
prj.enableTerminal,
), ),
); );
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(

View File

@@ -0,0 +1,21 @@
import "package:flutter/material.dart";
import "package:prod/models/editor.dart";
import "package:yaru/yaru.dart";
class Editorselector extends StatelessWidget {
const Editorselector(this.turns, {super.key});
final int turns;
@override
Widget build(BuildContext context) {
return Row(
children: [
RotatedBox(
child: Icon(Icons.rounded_corner_rounded),
quarterTurns: this.turns,
),
// YaruPopupMenuButton<Editor>(child: ,),
],
);
}
}

View File

@@ -57,8 +57,6 @@ class ProjFAB extends StatelessWidget {
nameController.text, nameController.text,
languageController.text, languageController.text,
locationController.text, locationController.text,
[],
true,
), ),
); );

View File

@@ -14,51 +14,95 @@ class ProjectCard extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
GlobalModel gm = Provider.of<GlobalModel>(context); GlobalModel gm = Provider.of<GlobalModel>(context);
final Project prj = gm.nthPrj(id); final Project prj = gm.nthPrj(id);
return YaruBanner( return InkWell(
padding: .only(
left: kYaruPagePadding,
top: kYaruPagePadding * 0.5,
bottom: kYaruPagePadding,
right: kYaruPagePadding,
),
onHover: (st) => gm.setHoverShow(id, st), onHover: (st) => gm.setHoverShow(id, st),
onTap: () { borderRadius: .circular(kYaruContainerRadius),
// var shell = Shell(); onTap: () async {
// Editor edt1 = gm.editors[0]; await Navigator.pushNamed(context, "/manageprj", arguments: id);
// String comm = edt1.commandTemplate.replaceAll("\$path", prj.path.path);
// shell.run(comm);
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(content: Text("Launched "), duration: Duration(seconds: 3)),
// );
Navigator.pushNamed(context, "/manageprj", arguments: id);
}, },
child: Center( child: Card(
child: Column( // decoration: BoxDecoration(
mainAxisAlignment: .start, // border: Border.all(color: Theme.of(context).dividerColor),
crossAxisAlignment: .start, // borderRadius: .circular(kYaruContainerRadius),
// ),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
kYaruContainerRadius,
).inner(const EdgeInsets.all(4)),
side: BorderSide(color: Theme.of(context).dividerColor, width: 0),
),
color: Colors.white,
shadowColor: Colors.transparent,
child: Row(
mainAxisAlignment: .spaceBetween,
children: [ children: [
Text( Container(
"${prj.name}", padding: .only(
style: TextStyle(fontSize: 30), top: kYaruPagePadding * 0.5,
overflow: .ellipsis, left: kYaruPagePadding * 0.5,
),
child: Column(
mainAxisAlignment: .start,
crossAxisAlignment: .start,
children: [
Text(
"${prj.name}",
style: TextStyle(fontSize: 30),
overflow: .ellipsis,
),
Row(
spacing: 10,
children: [
Text("${prj.language}", overflow: .ellipsis),
prj.isGit ? Icon(Icons.commit) : Container(),
],
),
gm.getHoverShow(id)
? Text("${prj.path.path}", overflow: .ellipsis)
: Container(),
// gm.getHoverShow(id)
// ? IconButton(
// icon: Icon(Icons.close),
// onPressed: () => gm.delPrj(id),
// style: IconButton.styleFrom(
// overlayColor: Color(0xffff0000),
// ),
// )
// : Container(),
],
),
), ),
Row( Row(
spacing: 10,
children: [ children: [
Text("${prj.language}"), Column(
prj.isGit ? Icon(Icons.commit) : Container(), children: [
Expanded(
flex: 1,
child: TextButton(child: Text("Ze"), onPressed: () {}),
),
Expanded(
flex: 1,
child: TextButton(child: Text("Ze"), onPressed: () {}),
),
],
),
Column(
children: [
Expanded(
child: TextButton(child: Text("Ze"), onPressed: () {}),
),
true
? Expanded(
child: TextButton(
child: Text("Ze"),
onPressed: () {},
),
)
: Container(),
],
),
], ],
), ),
gm.getHoverShow(id) ? Text("${prj.path.path}") : Container(),
// gm.getHoverShow(id)
// ? IconButton(
// icon: Icon(Icons.close),
// onPressed: () => gm.delPrj(id),
// style: IconButton.styleFrom(
// overlayColor: Color(0xffff0000),
// ),
// )
// : Container(),
], ],
), ),
), ),