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 { class Partition {
final String partition; String partition;
String mountpoint; String mountpoint;
String filesystem; String filesystem;

@ -3,30 +3,10 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:jade_gui/classes/partition.dart'; import 'package:jade_gui/classes/partition.dart';
Future<void> getPartition(setState, runningPart, setRunningPart) async { Widget partitionTemplate(partition, runningInfo, setRunningInfo, mountpoints,
if (!runningPart) { setPartitionMountpoint) {
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) {
String mount = "none"; String mount = "none";
if (partition != "") { if (partition().partition != "") {
print(partition.mountpoint);
print(partition.mountpoint);
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@ -41,7 +21,7 @@ Widget partitionTemplate(Partition partition, runningInfo, setRunningInfo,
child: Row( child: Row(
children: [ children: [
Text( Text(
partition.partition, partition().partition,
style: const TextStyle( style: const TextStyle(
fontWeight: FontWeight.bold, color: Colors.white), fontWeight: FontWeight.bold, color: Colors.white),
), ),
@ -49,7 +29,7 @@ Widget partitionTemplate(Partition partition, runningInfo, setRunningInfo,
child: Container(), child: Container(),
), ),
DropdownButton<String>( DropdownButton<String>(
value: mount, value: partition().mountpoint,
icon: const Icon(Icons.arrow_downward), icon: const Icon(Icons.arrow_downward),
elevation: 16, elevation: 16,
style: const TextStyle(color: Colors.deepPurple), style: const TextStyle(color: Colors.deepPurple),
@ -59,8 +39,9 @@ Widget partitionTemplate(Partition partition, runningInfo, setRunningInfo,
), ),
onChanged: (String? newValue) { onChanged: (String? newValue) {
setPartitionMountpoint( setPartitionMountpoint(
partition, newValue == "" ? "none" : newValue); partition(), newValue == "" ? "none" : newValue);
mount = newValue == "" ? "none" : newValue!; mount = newValue == "" ? "none" : newValue!;
print(partition().mountpoint);
}, },
items: items:
mountpoints.map<DropdownMenuItem<String>>((String value) { mountpoints.map<DropdownMenuItem<String>>((String value) {
@ -86,7 +67,6 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
"none", "none",
"/", "/",
"/boot", "/boot",
"/efi",
"/boot/efi", "/boot/efi",
"/home", "/home",
"/opt", "/opt",
@ -94,9 +74,6 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
"/usr", "/usr",
"/var" "/var"
]; ];
return FutureBuilder(
future: getPartition(setState, runningPart, setRunningPart),
builder: (BuildContext context, AsyncSnapshot snapshot) {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@ -134,7 +111,9 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
children: partitions children: partitions
.map<Widget>( .map<Widget>(
(partition) => partitionTemplate( (partition) => partitionTemplate(
partition, () {
return partition;
},
runningInfo, runningInfo,
setRunningInfo, setRunningInfo,
mountpoints, mountpoints,
@ -193,8 +172,7 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
), ),
), ),
const SizedBox(height: 5), const SizedBox(height: 5),
const Image( const Image(image: AssetImage('assets/jade_logo.png')),
image: AssetImage('assets/jade_logo.png')),
const SizedBox(height: 10), const SizedBox(height: 10),
Container( Container(
padding: const EdgeInsets.all(2), padding: const EdgeInsets.all(2),
@ -211,8 +189,7 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
primary: Colors.white, primary: Colors.white,
backgroundColor: backgroundColor:
const Color.fromARGB(0, 169, 0, 255), const Color.fromARGB(0, 169, 0, 255),
shadowColor: shadowColor: const Color.fromARGB(0, 169, 0, 255),
const Color.fromARGB(0, 169, 0, 255),
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
), ),
child: const Text( child: const Text(
@ -251,8 +228,7 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
), ),
style: TextButton.styleFrom( style: TextButton.styleFrom(
primary: Colors.white, primary: Colors.white,
backgroundColor: backgroundColor: const Color.fromARGB(255, 169, 0, 255),
const Color.fromARGB(255, 169, 0, 255),
minimumSize: const Size(100, 50), minimumSize: const Size(100, 50),
padding: const EdgeInsets.all(10), 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( Future<void> checkConnected(
setState, setState,
) async { ) async {
@ -125,6 +143,18 @@ class _JadeguiState extends State<Jadegui> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
getPartition(
(value) {
setState(() {
partitions = value;
});
},
runningPart,
(value) {
setState(() {
runningPart = value;
});
});
setWindowSize(); setWindowSize();
checkConnected( checkConnected(
(value) { (value) {

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

Loading…
Cancel
Save