the gui for manual partitioning works :)

pull/2/head
axtlos 3 years ago
parent 808482e21c
commit 881b39648c
No known key found for this signature in database
GPG Key ID: A468AFD71DD51D4A

@ -1,5 +1,5 @@
class Partition {
final String partition;
String partition;
String mountpoint;
String filesystem;

@ -3,30 +3,10 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:jade_gui/classes/partition.dart';
Future<void> getPartition(setState, runningPart, setRunningPart) async {
if (!runningPart) {
final String partitions =
await Process.run("/opt/jade_gui/scripts/getPartitions.sh", [])
.then((ProcessResult result) {
return result.stdout;
});
var parts = <Partition>[];
for (int i = 0; i < partitions.split("\n").length; i++) {
if (partitions.split("\n")[i] != "") {
parts.add(Partition(partition: partitions.split("\n")[i]));
}
}
setState(parts);
setRunningPart(true);
}
}
Widget partitionTemplate(Partition partition, runningInfo, setRunningInfo,
mountpoints, setPartitionMountpoint) {
Widget partitionTemplate(partition, runningInfo, setRunningInfo, mountpoints,
setPartitionMountpoint) {
String mount = "none";
if (partition != "") {
print(partition.mountpoint);
print(partition.mountpoint);
if (partition().partition != "") {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
@ -41,7 +21,7 @@ Widget partitionTemplate(Partition partition, runningInfo, setRunningInfo,
child: Row(
children: [
Text(
partition.partition,
partition().partition,
style: const TextStyle(
fontWeight: FontWeight.bold, color: Colors.white),
),
@ -49,7 +29,7 @@ Widget partitionTemplate(Partition partition, runningInfo, setRunningInfo,
child: Container(),
),
DropdownButton<String>(
value: mount,
value: partition().mountpoint,
icon: const Icon(Icons.arrow_downward),
elevation: 16,
style: const TextStyle(color: Colors.deepPurple),
@ -59,8 +39,9 @@ Widget partitionTemplate(Partition partition, runningInfo, setRunningInfo,
),
onChanged: (String? newValue) {
setPartitionMountpoint(
partition, newValue == "" ? "none" : newValue);
partition(), newValue == "" ? "none" : newValue);
mount = newValue == "" ? "none" : newValue!;
print(partition().mountpoint);
},
items:
mountpoints.map<DropdownMenuItem<String>>((String value) {
@ -86,7 +67,6 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
"none",
"/",
"/boot",
"/efi",
"/boot/efi",
"/home",
"/opt",
@ -94,9 +74,6 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
"/usr",
"/var"
];
return FutureBuilder(
future: getPartition(setState, runningPart, setRunningPart),
builder: (BuildContext context, AsyncSnapshot snapshot) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@ -134,7 +111,9 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
children: partitions
.map<Widget>(
(partition) => partitionTemplate(
partition,
() {
return partition;
},
runningInfo,
setRunningInfo,
mountpoints,
@ -193,8 +172,7 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
),
),
const SizedBox(height: 5),
const Image(
image: AssetImage('assets/jade_logo.png')),
const Image(image: AssetImage('assets/jade_logo.png')),
const SizedBox(height: 10),
Container(
padding: const EdgeInsets.all(2),
@ -211,8 +189,7 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
primary: Colors.white,
backgroundColor:
const Color.fromARGB(0, 169, 0, 255),
shadowColor:
const Color.fromARGB(0, 169, 0, 255),
shadowColor: const Color.fromARGB(0, 169, 0, 255),
padding: const EdgeInsets.all(10),
),
child: const Text(
@ -251,8 +228,7 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
),
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor:
const Color.fromARGB(255, 169, 0, 255),
backgroundColor: const Color.fromARGB(255, 169, 0, 255),
minimumSize: const Size(100, 50),
padding: const EdgeInsets.all(10),
),
@ -268,6 +244,4 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
),
],
);
},
);
}

@ -38,6 +38,24 @@ Future<void> checkIsEfi(
}
}
Future<void> getPartition(setState, runningPart, setRunningPart) async {
if (!runningPart) {
final String partitions =
await Process.run("/opt/jade_gui/scripts/getPartitions.sh", [])
.then((ProcessResult result) {
return result.stdout;
});
var parts = <Partition>[];
for (int i = 0; i < partitions.split("\n").length; i++) {
if (partitions.split("\n")[i] != "") {
parts.add(Partition(partition: partitions.split("\n")[i]));
}
}
setState(parts);
setRunningPart(true);
}
}
Future<void> checkConnected(
setState,
) async {
@ -125,6 +143,18 @@ class _JadeguiState extends State<Jadegui> {
@override
Widget build(BuildContext context) {
getPartition(
(value) {
setState(() {
partitions = value;
});
},
runningPart,
(value) {
setState(() {
runningPart = value;
});
});
setWindowSize();
checkConnected(
(value) {

@ -1,5 +1,5 @@
#!/usr/bin/env bash
ping -c1 getcryst.al -q > /dev/null
ping -c3 getcryst.al -q > /dev/null
if [[ $? -eq 0 ]]; then
echo "connected"
else

Loading…
Cancel
Save