From ee68605e7edb8ea849a68f25d07496db5943a764 Mon Sep 17 00:00:00 2001 From: axtlos Date: Mon, 25 Apr 2022 21:12:52 +0200 Subject: [PATCH] Add option to select boot device for legacy --- jade_log.txt | 2 +- lib/functions/partition.dart | 51 ++++---- lib/functions/partitioning/manual.dart | 105 ++++++++++++----- lib/main.dart | 154 ++++++++++++------------- 4 files changed, 182 insertions(+), 130 deletions(-) diff --git a/jade_log.txt b/jade_log.txt index 5a15f91..4e410ef 100644 --- a/jade_log.txt +++ b/jade_log.txt @@ -1,2 +1,2 @@ -[LOG] +Selected disk: /dev/nvme0n1 \ No newline at end of file diff --git a/lib/functions/partition.dart b/lib/functions/partition.dart index 8cd4e3c..b51bf2f 100644 --- a/lib/functions/partition.dart +++ b/lib/functions/partition.dart @@ -3,28 +3,28 @@ import 'package:jade_gui/functions/partitioning/auto.dart'; import 'package:jade_gui/functions/partitioning/manual.dart'; Widget partitioning( - disks, - setState, - setPartition, - next, - setPartitionInfo, - selectedPartition, - partitionInfo, - runningPart, - setRunningPart, - runningInfo, - setRunningInfo, - doManualPartitioning, - setManual, - runningPartMan, - runningInfoMan, - setRunningPartMan, - setRunningInfoMan, - setPartitions, - partitions, - setPartitionMountPoint, - setFilesystem, -) { + disks, + setState, + setPartition, + next, + setPartitionInfo, + selectedPartition, + partitionInfo, + runningPart, + setRunningPart, + runningInfo, + setRunningInfo, + doManualPartitioning, + setManual, + runningPartMan, + runningInfoMan, + setRunningPartMan, + setRunningInfoMan, + setPartitions, + partitions, + setPartitionMountPoint, + setFilesystem, + efi) { if (doManualPartitioning) { setRunningInfoMan(false); return manualPartitioning( @@ -38,6 +38,13 @@ Widget partitioning( setManual, next, setFilesystem, + efi, + selectedPartition, + disks, + setState, + runningPart, + setRunningPart, + setPartition, ); } else { setRunningInfo(false); diff --git a/lib/functions/partitioning/manual.dart b/lib/functions/partitioning/manual.dart index 23a81e9..827bc3c 100644 --- a/lib/functions/partitioning/manual.dart +++ b/lib/functions/partitioning/manual.dart @@ -2,9 +2,10 @@ import 'dart:async'; import 'dart:io'; import 'package:flutter/material.dart'; import 'package:jade_gui/classes/partition.dart'; +import 'package:jade_gui/functions/partitioning/auto.dart'; Widget partitionTemplate(partition, runningInfo, setRunningInfo, mountpoints, - setPartitionMountpoint, filesystems, setFilesystem) { + setPartitionMountpoint, filesystems, setFilesystem, efi) { if (partition().partition != "") { return Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, @@ -99,7 +100,14 @@ Widget manualPartitioning( setPartitionMountpoint, setManual, next, - setFilesystem) { + setFilesystem, + efi, + disk, + disks, + setDisks, + runningDisk, + setRunningDisk, + setPartition) { var mountpoints = [ "none", "/", @@ -125,6 +133,7 @@ Widget manualPartitioning( "minix", "vfat" ]; + getDisk(setDisks, runningDisk, setRunningDisk); return Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -159,21 +168,24 @@ Widget manualPartitioning( child: SingleChildScrollView( primary: false, child: Column( - children: partitions - .map( - (partition) => partitionTemplate( - () { - return partition; - }, - runningInfo, - setRunningInfo, - mountpoints, - setPartitionMountpoint, - filesystems, - setFilesystem, - ), - ) - .toList(), + children: [ + Column( + children: partitions + .map( + (partition) => partitionTemplate(() { + return partition; + }, + runningInfo, + setRunningInfo, + mountpoints, + setPartitionMountpoint, + filesystems, + setFilesystem, + efi), + ) + .toList(), + ), + ], ), ), ), @@ -206,23 +218,56 @@ Widget manualPartitioning( color: Color.fromARGB(255, 169, 0, 255), ), ), - const Text( - 'to format', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 169, 0, 255), + Visibility( + visible: efi, + child: const Text( + 'Bootloader Device:', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 169, 0, 255), + ), ), ), - const Text( - 'and mount', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 169, 0, 255), + const SizedBox(height: 6), + Visibility( + visible: efi, + child: Container( + padding: const EdgeInsets.fromLTRB(5, 2, 2, 5), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + border: Border.all(color: Colors.black45), + color: const Color.fromARGB(255, 30, 30, 30), + ), + child: DropdownButton( + value: disk, + icon: const Icon(Icons.arrow_downward), + elevation: 16, + style: const TextStyle(color: Colors.deepPurple), + dropdownColor: + const Color.fromARGB(255, 23, 23, 23), + underline: Container( + height: 2, + color: Colors.deepPurpleAccent, + ), + onChanged: (String? newValue) { + setPartition(newValue!); + print(disk); + }, + items: disks + .split('\n') + .map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value, + style: + const TextStyle(color: Colors.white)), + ); + }).toList(), + ), ), ), - const SizedBox(height: 5), + const SizedBox(height: 10), const Image(image: AssetImage('assets/jade_logo.png')), const SizedBox(height: 10), Container( diff --git a/lib/main.dart b/lib/main.dart index 507e242..e2dc7ec 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -580,83 +580,83 @@ class _JadeguiState extends State { width: logicWidth, height: logicHeight, child: partitioning( - disks, - (value) { - setState(() { - disks = value; - writeToLog("Disks:widget $disks"); - }); - }, - (value) { - setState(() { - selectedDisk = value; - writeToLog("Selected disk: $selectedDisk"); - }); - }, - () { - setState(() { - _selectedIndex = _selectedIndex + 1; - }); - }, - (value) { - setState(() { - diskInfo = value; - writeToLog("Partition info: $diskInfo"); - }); - }, - selectedDisk, - diskInfo, - runningPart, - (value) { - setState(() { - runningPart = value; - }); - }, - runningInfo, - (value) { - setState(() { - runningInfo = value; - }); - }, - manualPartitioning, - (value) { - setState(() { - manualPartitioning = value; - }); - }, - runningInfoMan, - runningPartMan, - (value) { - setState(() { - runningPartMan = value; - }); - }, - (value) { - setState(() { - runningInfoMan = value; - }); - }, - (value) { - setState(() { - partitions = value; - }); - }, - partitions, - (partition, value) { - setState(() { - partition.mountpoint = value; - print("moutnpoint: ${partition.mountpoint}"); - print("partition: ${partition.partition}"); - }); - }, - (partition, value) { - setState(() { - partition.filesystem = value; - print("filesystem: ${partition.filesystem}"); - print("partition: ${partition.partition}"); - }); - }, - ), + disks, + (value) { + setState(() { + disks = value; + writeToLog("Disks:widget $disks"); + }); + }, + (value) { + setState(() { + selectedDisk = value; + writeToLog("Selected disk: $selectedDisk"); + }); + }, + () { + setState(() { + _selectedIndex = _selectedIndex + 1; + }); + }, + (value) { + setState(() { + diskInfo = value; + writeToLog("Partition info: $diskInfo"); + }); + }, + selectedDisk, + diskInfo, + runningPart, + (value) { + setState(() { + runningPart = value; + }); + }, + runningInfo, + (value) { + setState(() { + runningInfo = value; + }); + }, + manualPartitioning, + (value) { + setState(() { + manualPartitioning = value; + }); + }, + runningInfoMan, + runningPartMan, + (value) { + setState(() { + runningPartMan = value; + }); + }, + (value) { + setState(() { + runningInfoMan = value; + }); + }, + (value) { + setState(() { + partitions = value; + }); + }, + partitions, + (partition, value) { + setState(() { + partition.mountpoint = value; + print("moutnpoint: ${partition.mountpoint}"); + print("partition: ${partition.partition}"); + }); + }, + (partition, value) { + setState(() { + partition.filesystem = value; + print("filesystem: ${partition.filesystem}"); + print("partition: ${partition.partition}"); + }); + }, + isEfi), ), ), );