add settings page for misc stuff

pull/2/head
axtlos 3 years ago
parent 35fa6a7e17
commit 3fd824cd31

@ -1,3 +1,4 @@
import 'package:jade_gui/Locales/locales.dart';
import 'package:jade_gui/classes/desktop.dart'; import 'package:jade_gui/classes/desktop.dart';
import 'package:jade_gui/classes/location.dart'; import 'package:jade_gui/classes/location.dart';
@ -6,23 +7,67 @@ class installPrefs {
final String keymap; final String keymap;
final String layout; final String layout;
final String username; final String username;
final String password;
final bool enableSudo; final bool enableSudo;
final bool enableRoot; final String rootPass;
final Desktop desktop; final Desktop desktop;
final String disk; final String disk;
final bool isEfi;
final String bootloader;
final String hostname;
final bool ipv6;
final bool enableTimeshift;
installPrefs({ installPrefs({
this.locale = const Location(), this.locale = const Location(),
this.keymap = "", this.keymap = "",
this.layout = "", this.layout = "",
this.username = "", this.username = "",
this.password = "",
this.enableSudo = false, this.enableSudo = false,
this.enableRoot = false, this.rootPass = "",
this.desktop = const Desktop(), this.desktop = const Desktop(),
this.disk = "", 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",
]
};
} }

@ -2,25 +2,42 @@ import 'package:flutter/material.dart';
import 'package:jade_gui/classes/installPrefs.dart'; import 'package:jade_gui/classes/installPrefs.dart';
import 'package:jade_gui/classes/desktop.dart'; import 'package:jade_gui/classes/desktop.dart';
import 'package:jade_gui/classes/location.dart'; import 'package:jade_gui/classes/location.dart';
import 'dart:convert';
Widget install( Widget install(
Location locale,
String keymap, String keymap,
String layout, String layout,
bool enableSudo,
bool enableRoot,
String username, String username,
String password,
bool enableSudo,
String rootPass,
Desktop desktop,
String disk, String disk,
Desktop currDesktop, bool isEfi,
Location locale, String bootloader,
String hostname,
bool ipv6,
bool enableTimeshift,
) { ) {
installPrefs prefs = installPrefs( installPrefs prefs = installPrefs(
locale: locale, locale: locale,
keymap: keymap, keymap: keymap,
layout: layout, layout: layout,
username: username, username: username,
enableSudo: enableSudo, password: password,
enableRoot: enableRoot, enableSudo: enableSudo,
desktop: currDesktop); 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( return Column(
children: [ children: [
const Text( const Text(
@ -30,6 +47,9 @@ Widget install(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 169, 0, 255)), color: Color.fromARGB(255, 169, 0, 255)),
), ),
const SizedBox(
height: 20,
),
], ],
); );
} }

@ -0,0 +1,174 @@
import 'package:flutter/material.dart';
final _formKey = GlobalKey<FormState>();
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)
],
),
],
);
}

@ -7,6 +7,7 @@ import 'package:jade_gui/functions/users.dart';
import 'package:jade_gui/functions/desktop.dart'; import 'package:jade_gui/functions/desktop.dart';
import 'package:jade_gui/functions/partition.dart'; import 'package:jade_gui/functions/partition.dart';
import 'package:jade_gui/functions/summary.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/functions/install.dart';
import 'package:jade_gui/classes/keymap.dart'; import 'package:jade_gui/classes/keymap.dart';
import 'package:jade_gui/classes/desktop.dart'; import 'package:jade_gui/classes/desktop.dart';
@ -47,6 +48,8 @@ class _JadeguiState extends State<Jadegui> {
bool enableSudo = false; bool enableSudo = false;
bool enableRoot = false; bool enableRoot = false;
bool isEfi = false; bool isEfi = false;
bool ipv6 = false;
bool enableTimeshift = true;
String password = ""; String password = "";
String confirmPassword = ""; String confirmPassword = "";
String username = ""; String username = "";
@ -56,8 +59,8 @@ class _JadeguiState extends State<Jadegui> {
String selectedDisk = ""; String selectedDisk = "";
String partitionInfo = ""; String partitionInfo = "";
String _diskType = ""; String _diskType = "";
String hostname = "";
Desktop currDesktop = desktops[0]; Desktop currDesktop = desktops[0];
Keymap chosenLayout = Keymap(); Keymap chosenLayout = Keymap();
@override @override
@ -156,6 +159,22 @@ class _JadeguiState extends State<Jadegui> {
fontWeight: FontWeight.bold), 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( NavigationRailDestination(
icon: Icon( icon: Icon(
Icons.pie_chart_outline, Icons.pie_chart_outline,
@ -354,6 +373,33 @@ class _JadeguiState extends State<Jadegui> {
); );
break; break;
case 5: 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( widget = partitioning(
disks, disks,
(value) { (value) {
@ -380,7 +426,7 @@ class _JadeguiState extends State<Jadegui> {
partitionInfo, partitionInfo,
); );
break; break;
case 6: case 7:
checkIsEfi((value) { checkIsEfi((value) {
setState(() { setState(() {
isEfi = value; isEfi = value;
@ -410,8 +456,8 @@ class _JadeguiState extends State<Jadegui> {
isEfi, isEfi,
); );
break; break;
case 7: case 8:
widget = install( /*widget = install(
getChosenLayout(), getChosenLayout(),
getChosenVariant(), getChosenVariant(),
enableSudo, enableSudo,
@ -420,7 +466,8 @@ class _JadeguiState extends State<Jadegui> {
selectedDisk, selectedDisk,
currDesktop, currDesktop,
getSelectedLocPack(), getSelectedLocPack(),
); );*/
widget = Text("Install");
break; break;
default: default:
widget = const Text( widget = const Text(

Loading…
Cancel
Save