diff --git a/lib/classes/installPrefs.dart b/lib/classes/installPrefs.dart index d1f0e23..e1b6703 100644 --- a/lib/classes/installPrefs.dart +++ b/lib/classes/installPrefs.dart @@ -1,3 +1,4 @@ +import 'package:jade_gui/Locales/locales.dart'; import 'package:jade_gui/classes/desktop.dart'; import 'package:jade_gui/classes/location.dart'; @@ -6,23 +7,67 @@ class installPrefs { final String keymap; final String layout; final String username; + final String password; final bool enableSudo; - final bool enableRoot; + final String rootPass; final Desktop desktop; final String disk; + final bool isEfi; + final String bootloader; + final String hostname; + final bool ipv6; + final bool enableTimeshift; installPrefs({ this.locale = const Location(), this.keymap = "", this.layout = "", this.username = "", + this.password = "", this.enableSudo = false, - this.enableRoot = false, + this.rootPass = "", this.desktop = const Desktop(), this.disk = "", + this.isEfi = false, + this.bootloader = "", + this.hostname = "", + this.ipv6 = false, + this.enableTimeshift = false, }); - /* Map toJson() => { - - }*/ + Map toJson() => { + "partition": { + "device": disk, + "mode": "auto", + "efi": isEfi, + }, + "bootloader": { + "type": bootloader, + "location": "/boot/efi", + }, + "locale": { + "locale": [ + locale.locale, + ], + "keymap": keymap, + "timezone": locale.region, + }, + "networking": { + "hostname": hostname, + "ipv6": ipv6, + }, + "users": [ + { + "name": username, + "password": password, + "hasroot": enableSudo, + } + ], + "rootpass": rootPass, + "desktop": desktop.name, + "timeshift": enableTimeshift, + "extra_package": [ + "firefox", + ] + }; } diff --git a/lib/functions/install.dart b/lib/functions/install.dart index fbe73e6..6a3269c 100644 --- a/lib/functions/install.dart +++ b/lib/functions/install.dart @@ -2,25 +2,42 @@ import 'package:flutter/material.dart'; import 'package:jade_gui/classes/installPrefs.dart'; import 'package:jade_gui/classes/desktop.dart'; import 'package:jade_gui/classes/location.dart'; +import 'dart:convert'; Widget install( + Location locale, String keymap, String layout, - bool enableSudo, - bool enableRoot, String username, + String password, + bool enableSudo, + String rootPass, + Desktop desktop, String disk, - Desktop currDesktop, - Location locale, + bool isEfi, + String bootloader, + String hostname, + bool ipv6, + bool enableTimeshift, ) { installPrefs prefs = installPrefs( - locale: locale, - keymap: keymap, - layout: layout, - username: username, - enableSudo: enableSudo, - enableRoot: enableRoot, - desktop: currDesktop); + locale: locale, + keymap: keymap, + layout: layout, + username: username, + password: password, + enableSudo: enableSudo, + rootPass: rootPass, + desktop: desktop, + disk: disk, + isEfi: isEfi, + bootloader: bootloader, + hostname: hostname, + ipv6: ipv6, + enableTimeshift: enableTimeshift, + ); + String jsonPrefs = jsonEncode(prefs.toJson()); + print(jsonPrefs); return Column( children: [ const Text( @@ -30,6 +47,9 @@ Widget install( fontWeight: FontWeight.bold, color: Color.fromARGB(255, 169, 0, 255)), ), + const SizedBox( + height: 20, + ), ], ); } diff --git a/lib/functions/misc.dart b/lib/functions/misc.dart new file mode 100644 index 0000000..bd3a362 --- /dev/null +++ b/lib/functions/misc.dart @@ -0,0 +1,174 @@ +import 'package:flutter/material.dart'; + +final _formKey = GlobalKey(); +RegExp hostnameRegex = RegExp( + r'^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$'); +Widget misc( + setIpv6, setHostname, setTimeshift, ipv6, hostname, timeshift, next) { + return Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + //const SizedBox(height: 2), + const Text( + 'Misc Settings', + style: TextStyle( + fontSize: 60, + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 169, 0, 255)), + ), + const SizedBox(height: 90), + Form( + key: _formKey, + autovalidateMode: AutovalidateMode.always, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const SizedBox(width: 20), + SizedBox( + width: 600, + 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: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const SizedBox(height: 10), + TextFormField( + autovalidateMode: AutovalidateMode.always, + decoration: const InputDecoration( + border: OutlineInputBorder(), + labelText: 'Hostname', + labelStyle: TextStyle(color: Colors.white), + hintText: 'Enter your hostname', + hintStyle: TextStyle(color: Colors.white), + iconColor: Colors.white, + focusColor: Color.fromARGB(100, 169, 0, 255), + hoverColor: Colors.blue, + prefixIconColor: Colors.white, + suffixIconColor: Colors.white, + ), + style: const TextStyle(color: Colors.white), + onChanged: (String? value) { + setHostname(value); + }, + validator: (String? value) { + return (value != "" && + value != null && + !hostnameRegex.hasMatch(value)) + ? 'Bad username, may not contain spaces, uppercase, or special characters' + : null; + }, + ), + 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(100, 30, 30, 30), + ), + child: CheckboxListTile( + title: const Text('Enable ipv6', + style: TextStyle(color: Colors.white)), + value: ipv6, + onChanged: (bool? value) { + setIpv6(value!); + }, + secondary: Container( + decoration: const BoxDecoration( + shape: BoxShape.circle, + color: Colors.white, + ), + padding: const EdgeInsets.fromLTRB(10, 10, 10, 13), + child: const Text( + 'v6', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + ), + ), + 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(100, 30, 30, 30), + ), + child: CheckboxListTile( + title: const Text('Enable timeshift', + style: TextStyle(color: Colors.white)), + value: timeshift, + onChanged: (bool? value) { + setTimeshift(value!); + }, + secondary: Container( + decoration: const BoxDecoration( + shape: BoxShape.circle, + color: Colors.white, + ), + padding: const EdgeInsets.fromLTRB(10, 10, 10, 13), + child: const Icon(Icons.restore, color: Colors.black), + ), + ), + ), + const SizedBox(height: 10), + ], + ), + ), + ), + const SizedBox(width: 10), + ], + ), + ), + const SizedBox(height: 90), + 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 2769301..e2cfdf2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,6 +7,7 @@ import 'package:jade_gui/functions/users.dart'; import 'package:jade_gui/functions/desktop.dart'; import 'package:jade_gui/functions/partition.dart'; import 'package:jade_gui/functions/summary.dart'; +import 'package:jade_gui/functions/misc.dart'; import 'package:jade_gui/functions/install.dart'; import 'package:jade_gui/classes/keymap.dart'; import 'package:jade_gui/classes/desktop.dart'; @@ -47,6 +48,8 @@ class _JadeguiState extends State { bool enableSudo = false; bool enableRoot = false; bool isEfi = false; + bool ipv6 = false; + bool enableTimeshift = true; String password = ""; String confirmPassword = ""; String username = ""; @@ -56,8 +59,8 @@ class _JadeguiState extends State { String selectedDisk = ""; String partitionInfo = ""; String _diskType = ""; + String hostname = ""; Desktop currDesktop = desktops[0]; - Keymap chosenLayout = Keymap(); @override @@ -156,6 +159,22 @@ class _JadeguiState extends State { fontWeight: FontWeight.bold), ), ), + NavigationRailDestination( + icon: Icon( + Icons.miscellaneous_services_outlined, + color: Color.fromARGB(255, 169, 0, 255), + ), + selectedIcon: Icon( + Icons.miscellaneous_services, + color: Color.fromARGB(255, 169, 0, 255), + ), + label: Text( + 'Misc', + style: TextStyle( + color: Color.fromARGB(100, 255, 255, 255), + fontWeight: FontWeight.bold), + ), + ), NavigationRailDestination( icon: Icon( Icons.pie_chart_outline, @@ -354,6 +373,33 @@ class _JadeguiState extends State { ); break; case 5: + widget = misc( + (value) { + setState(() { + ipv6 = value; + }); + }, + (value) { + setState(() { + hostname = value; + }); + }, + (value) { + setState(() { + enableTimeshift = value; + }); + }, + ipv6, + hostname, + enableTimeshift, + () { + setState(() { + _selectedIndex = _selectedIndex + 1; + }); + }, + ); + break; + case 6: widget = partitioning( disks, (value) { @@ -380,7 +426,7 @@ class _JadeguiState extends State { partitionInfo, ); break; - case 6: + case 7: checkIsEfi((value) { setState(() { isEfi = value; @@ -410,8 +456,8 @@ class _JadeguiState extends State { isEfi, ); break; - case 7: - widget = install( + case 8: + /*widget = install( getChosenLayout(), getChosenVariant(), enableSudo, @@ -420,7 +466,8 @@ class _JadeguiState extends State { selectedDisk, currDesktop, getSelectedLocPack(), - ); + );*/ + widget = Text("Install"); break; default: widget = const Text(