diff --git a/lib/classes/partition.dart b/lib/classes/partition.dart index 1cf75ee..6a52954 100644 --- a/lib/classes/partition.dart +++ b/lib/classes/partition.dart @@ -1,5 +1,5 @@ class Partition { - final String partition; + String partition; String mountpoint; String filesystem; diff --git a/lib/functions/partitioning/manual.dart b/lib/functions/partitioning/manual.dart index fc7e6eb..8aeb115 100644 --- a/lib/functions/partitioning/manual.dart +++ b/lib/functions/partitioning/manual.dart @@ -3,30 +3,10 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:jade_gui/classes/partition.dart'; -Future 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 = []; - 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( - 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>((String value) { @@ -86,7 +67,6 @@ Widget manualPartitioning(partitions, setState, runningPart, setRunningPart, "none", "/", "/boot", - "/efi", "/boot/efi", "/home", "/opt", @@ -94,180 +74,174 @@ 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: [ - const Text( - 'Please select a disk to install to', - style: TextStyle( - fontSize: 50, - fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 169, 0, 255)), - ), - const SizedBox(height: 20), - Expanded( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - const SizedBox(width: 100), - Expanded( - child: Container( - padding: const EdgeInsets.all(10), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - border: Border.all(color: Colors.black), - color: const Color.fromARGB(255, 30, 30, 30), - boxShadow: const [ - BoxShadow( - color: Colors.black, - blurRadius: 2, - offset: Offset(-2, 3), - ), - ], - ), - child: SingleChildScrollView( - primary: false, - child: Column( - children: partitions - .map( - (partition) => partitionTemplate( - partition, - runningInfo, - setRunningInfo, - mountpoints, - setPartitionMountpoint, - ), - ) - .toList(), - ), + return Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + 'Please select a disk to install to', + style: TextStyle( + fontSize: 50, + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 169, 0, 255)), + ), + const SizedBox(height: 20), + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const SizedBox(width: 100), + Expanded( + child: Container( + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + border: Border.all(color: Colors.black), + color: const Color.fromARGB(255, 30, 30, 30), + boxShadow: const [ + BoxShadow( + color: Colors.black, + blurRadius: 2, + offset: Offset(-2, 3), ), - ), + ], ), - const SizedBox(width: 100), - Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - padding: const EdgeInsets.all(20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - border: Border.all(color: Colors.black), - color: const Color.fromARGB(255, 30, 30, 30), - boxShadow: const [ - BoxShadow( - color: Colors.black, - blurRadius: 2, - offset: Offset(-2, 3), + child: SingleChildScrollView( + primary: false, + child: Column( + children: partitions + .map( + (partition) => partitionTemplate( + () { + return partition; + }, + runningInfo, + setRunningInfo, + mountpoints, + setPartitionMountpoint, ), - ], + ) + .toList(), + ), + ), + ), + ), + const SizedBox(width: 100), + Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + border: Border.all(color: Colors.black), + color: const Color.fromARGB(255, 30, 30, 30), + boxShadow: const [ + BoxShadow( + color: Colors.black, + blurRadius: 2, + offset: Offset(-2, 3), ), - child: Column( - children: [ - const Text( - 'Currently chosen Disk: ', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 169, 0, 255), - ), - ), - const SizedBox(height: 10), - const Text( - "selectedPartition", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 169, 0, 255), - ), + ], + ), + child: Column( + children: [ + const Text( + 'Currently chosen Disk: ', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 169, 0, 255), + ), + ), + const SizedBox(height: 10), + const Text( + "selectedPartition", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 169, 0, 255), + ), + ), + const SizedBox(height: 5), + const Text( + 'Size: diskInfo', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 169, 0, 255), + ), + ), + const SizedBox(height: 5), + const Image(image: AssetImage('assets/jade_logo.png')), + const SizedBox(height: 10), + Container( + padding: const EdgeInsets.all(2), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + border: Border.all(color: Colors.black45), + color: const Color.fromARGB(255, 30, 30, 30), + ), + child: ElevatedButton( + onPressed: () { + setManual(false); + }, + style: TextButton.styleFrom( + primary: Colors.white, + backgroundColor: + const Color.fromARGB(0, 169, 0, 255), + shadowColor: const Color.fromARGB(0, 169, 0, 255), + padding: const EdgeInsets.all(10), ), - const SizedBox(height: 5), - const Text( - 'Size: diskInfo', + child: const Text( + "Auto Partitioning", style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 169, 0, 255), ), ), - const SizedBox(height: 5), - const Image( - image: AssetImage('assets/jade_logo.png')), - const SizedBox(height: 10), - Container( - padding: const EdgeInsets.all(2), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - border: Border.all(color: Colors.black45), - color: const Color.fromARGB(255, 30, 30, 30), - ), - child: ElevatedButton( - onPressed: () { - setManual(false); - }, - style: TextButton.styleFrom( - primary: Colors.white, - backgroundColor: - const Color.fromARGB(0, 169, 0, 255), - shadowColor: - const Color.fromARGB(0, 169, 0, 255), - padding: const EdgeInsets.all(10), - ), - child: const Text( - "Auto Partitioning", - style: TextStyle( - fontWeight: FontWeight.bold, - ), - ), - ), - ), - ], + ), ), - ), - ], + ], + ), ), - const SizedBox(width: 40), ], ), - ), - const SizedBox(height: 20), - const SizedBox(width: 60), - Column( + const SizedBox(width: 40), + ], + ), + ), + const SizedBox(height: 20), + const SizedBox(width: 60), + Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.end, + Column( children: [ - Column( - children: [ - TextButton( - onPressed: () { - next(); - }, - child: const Text( - 'Next', - ), - style: TextButton.styleFrom( - primary: Colors.white, - backgroundColor: - const Color.fromARGB(255, 169, 0, 255), - minimumSize: const Size(100, 50), - padding: const EdgeInsets.all(10), - ), - ), - const SizedBox(height: 10), - ], + TextButton( + onPressed: () { + next(); + }, + child: const Text( + 'Next', + ), + style: TextButton.styleFrom( + primary: Colors.white, + backgroundColor: const Color.fromARGB(255, 169, 0, 255), + minimumSize: const Size(100, 50), + padding: const EdgeInsets.all(10), + ), ), - const SizedBox(width: 30), + const SizedBox(height: 10), ], ), - const SizedBox(height: 7) + const SizedBox(width: 30), ], ), + const SizedBox(height: 7) ], - ); - }, + ), + ], ); } diff --git a/lib/main.dart b/lib/main.dart index bc923dc..71f40de 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -38,6 +38,24 @@ Future checkIsEfi( } } +Future 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 = []; + 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 checkConnected( setState, ) async { @@ -125,6 +143,18 @@ class _JadeguiState extends State { @override Widget build(BuildContext context) { + getPartition( + (value) { + setState(() { + partitions = value; + }); + }, + runningPart, + (value) { + setState(() { + runningPart = value; + }); + }); setWindowSize(); checkConnected( (value) { diff --git a/scripts/checkNetwork.sh b/scripts/checkNetwork.sh index 85da728..1ce9160 100755 --- a/scripts/checkNetwork.sh +++ b/scripts/checkNetwork.sh @@ -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