From 745db5f3d2fc4af1752e20db427779dcb14d54d8 Mon Sep 17 00:00:00 2001 From: axtlos Date: Sun, 27 Mar 2022 20:20:47 +0200 Subject: [PATCH] somewhat finish partitioning screen, only supports autopartitioning for now --- PKGBUILD | 3 + lib/functions/partition.dart | 202 +++++++++++++++++++++++++++++++++++ lib/main.dart | 29 +++-- pubspec.lock | 141 ++++++++++++++++++++++-- pubspec.yaml | 2 + scripts/getPartitionInfo.sh | 2 + scripts/getPartitions.sh | 2 + 7 files changed, 366 insertions(+), 15 deletions(-) create mode 100644 lib/functions/partition.dart create mode 100755 scripts/getPartitionInfo.sh create mode 100755 scripts/getPartitions.sh diff --git a/PKGBUILD b/PKGBUILD index 3d9a471..b2834cf 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -21,10 +21,13 @@ build() { } package() { + mkdir ${pkgdir}/opt/jade_gui/ install -dm755 ${pkgdir}/opt mv ${srcdir}/gui/build/linux/x64/release/bundle ${pkgdir}/opt/jade_gui install -dm755 ${pkgdir}/usr/bin ln -s /opt/jade_gui/jade_gui ${pkgdir}/usr/bin/jade_gui + mkdir -p ${pkgdir}/opt/jade_gui/scripts/ + mv ${srcdir}/scripts/* ${pkgdir}/opt/jade_gui/scripts/. } diff --git a/lib/functions/partition.dart b/lib/functions/partition.dart new file mode 100644 index 0000000..de616ff --- /dev/null +++ b/lib/functions/partition.dart @@ -0,0 +1,202 @@ +import 'dart:async'; +import 'dart:io'; +import 'package:flutter/material.dart'; + +Future getPartitionInfo(currPartition, setState) async { + final String partitionInfo = await Process.run( + "/opt/jade_gui/scripts/getPartitionInfo.sh", ['$currPartition']) + .then((ProcessResult results) { + return results.stdout; + }); + setState(partitionInfo); +} + +Future getPartitions(setState) async { + final String partitions = + await Process.run("/opt/jade_gui/scripts/getPartitions.sh", []) + .then((ProcessResult result) { + return result.stdout; + }); + setState(partitions); +} + +Widget partitionTemplate(partition, setPartition, setPartitionInfo) { + return Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + 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: () { + setPartition(partition); + getPartitionInfo(partition, setPartitionInfo); + }, + 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: Text( + partition, + style: const TextStyle( + fontWeight: FontWeight.bold, + ), + ), + ), + ), + const SizedBox(height: 10), + ], + ); +} + +Widget partitioning(partitions, setState, setPartition, next, setPartitionInfo, + selectedPartition, partitionInfo) { + return FutureBuilder( + future: getPartitions(setState), + 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 + .split('\n') + .map((partition) => partitionTemplate( + partition, setPartition, setPartitionInfo)) + .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), + Text( + selectedPartition, + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 169, 0, 255), + ), + ), + const SizedBox(height: 5), + Text( + 'Size: $partitionInfo', + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 169, 0, 255), + ), + ), + const SizedBox(height: 5), + Image(image: AssetImage('assets/jade_logo.png')), + ], + ), + ), + ], + ), + const SizedBox(width: 40), + ], + ), + ), + const SizedBox(height: 20), + const SizedBox(width: 60), + Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, + 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), + ], + ), + const SizedBox(width: 30), + ], + ), + const SizedBox(height: 7) + ], + ), + ], + ); + }, + ); +} diff --git a/lib/main.dart b/lib/main.dart index fe7fb7f..3012730 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,6 +8,7 @@ import 'package:jade_gui/functions/desktop.dart'; import 'package:jade_gui/classes/keymap.dart'; import 'package:jade_gui/classes/desktop.dart'; import 'package:jade_gui/desktops/desktops.dart'; +import 'package:jade_gui/functions/partition.dart'; void main() => runApp( const MaterialApp( @@ -35,6 +36,9 @@ class _JadeguiState extends State { String username = ""; String rootPass = ""; String confirmRootPass = ""; + String partitions = ""; + String selectedPartition = ""; + String partitionInfo = ""; Desktop currDesktop = desktops[0]; void nextslide() { setState(() { @@ -373,14 +377,23 @@ class _JadeguiState extends State { ); break; case 6: - widget = const Text( - 'Showing Partitioning screen', - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 169, 0, 255), - ), - ); + widget = partitioning(partitions, (value) { + setState(() { + partitions = value; + }); + }, (value) { + setState(() { + selectedPartition = value; + }); + }, () { + setState(() { + _selectedIndex = _selectedIndex + 1; + }); + }, (value) { + setState(() { + partitionInfo = value; + }); + }, selectedPartition, partitionInfo); break; case 7: widget = const Text( diff --git a/pubspec.lock b/pubspec.lock index f5d794a..f07e700 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,13 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" async: dependency: transitive description: @@ -42,7 +49,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: @@ -57,6 +64,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.2" flutter: dependency: "direct main" description: flutter @@ -109,6 +130,90 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.1" + path_provider: + dependency: "direct main" + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.12" + path_provider_ios: + dependency: transitive + description: + name: path_provider_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.8" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.5" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.4" + process_run: + dependency: "direct main" + description: + name: process_run + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.3+2" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" sky_engine: dependency: transitive description: flutter @@ -142,6 +247,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + synchronized: + dependency: transitive + description: + name: synchronized + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0+2" term_glyph: dependency: transitive description: @@ -156,19 +268,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.9" - typed_data: + vector_math: dependency: transitive description: - name: typed_data + name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" - vector_math: + version: "2.1.2" + win32: dependency: transitive description: - name: vector_math + name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.4.4" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0+1" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" sdks: dart: ">=2.15.1 <3.0.0" + flutter: ">=2.8.0" diff --git a/pubspec.yaml b/pubspec.yaml index 08e17a2..f1337ab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,6 +34,8 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + process_run: ^0.12.3+2 + path_provider: ^2.0.9 dev_dependencies: flutter_test: diff --git a/scripts/getPartitionInfo.sh b/scripts/getPartitionInfo.sh new file mode 100755 index 0000000..4cd49b7 --- /dev/null +++ b/scripts/getPartitionInfo.sh @@ -0,0 +1,2 @@ +#!/usr/bin/bash +lsblk -pdo SIZE $1 | grep -v SIZE diff --git a/scripts/getPartitions.sh b/scripts/getPartitions.sh new file mode 100755 index 0000000..5012e27 --- /dev/null +++ b/scripts/getPartitions.sh @@ -0,0 +1,2 @@ +#!/usr/bin/bash +lsblk -pdo name | grep -v zram | grep -v NAME