diff --git a/jade_log.txt b/jade_log.txt index 74bd919..302ddb6 100644 --- a/jade_log.txt +++ b/jade_log.txt @@ -1,2 +1,2 @@ -Desktop: gnome \ No newline at end of file +Hostname: host \ No newline at end of file diff --git a/lib/functions/misc.dart b/lib/functions/misc.dart index bd3a362..5ba7a46 100644 --- a/lib/functions/misc.dart +++ b/lib/functions/misc.dart @@ -4,7 +4,19 @@ 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) { + setIpv6, + setHostname, + setTimeshift, + ipv6, + hostname, + timeshift, + setRootUser, + enableRoot, + setRootPass, + setConfirmRootPass, + rootPass, + confirmRootPass, + next) { return Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -67,11 +79,105 @@ Widget misc( return (value != "" && value != null && !hostnameRegex.hasMatch(value)) - ? 'Bad username, may not contain spaces, uppercase, or special characters' + ? 'Bad Hostname, 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 root user', + style: TextStyle(color: Colors.white)), + value: enableRoot, + onChanged: (bool? value) { + setRootUser(value!); + }, + secondary: Container( + decoration: const BoxDecoration( + shape: BoxShape.circle, + color: Colors.white, + ), + padding: const EdgeInsets.fromLTRB(10, 10, 10, 13), + child: const Text( + '#', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + ), + ), + Visibility( + child: const SizedBox(height: 10), visible: enableRoot), + Visibility( + visible: enableRoot, + child: TextFormField( + //obscureText: true, + decoration: const InputDecoration( + border: OutlineInputBorder(), + labelText: 'Password for root user', + labelStyle: TextStyle(color: Colors.white), + hintText: 'Password for the root user', + 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, + ), + obscureText: true, + + onChanged: (String? value) { + setRootPass(value); + }, + ), + ), + Visibility( + child: const SizedBox(height: 10), visible: enableRoot), + Visibility( + visible: enableRoot, + child: TextFormField( + //obscureText: true, + autovalidateMode: AutovalidateMode.always, + decoration: const InputDecoration( + border: OutlineInputBorder(), + labelText: 'Repeat root password', + labelStyle: TextStyle(color: Colors.white), + hintText: 'Repeat root password', + 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, + ), + obscureText: true, + + onChanged: (String? value) { + setConfirmRootPass(value); + }, + validator: (String? value) { + return (value != rootPass) + ? 'Password does not match' + : null; + }, + ), + ), + const SizedBox(height: 10), Container( padding: const EdgeInsets.all(2), decoration: BoxDecoration( diff --git a/lib/functions/users.dart b/lib/functions/users.dart index 7b56e50..9d4517d 100644 --- a/lib/functions/users.dart +++ b/lib/functions/users.dart @@ -3,22 +3,8 @@ import 'dart:io'; final _formKey = GlobalKey(); RegExp userRegex = RegExp(r'^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$'); -Widget users( - setState, - enableSudo, - setPass, - setConfirmPass, - clearPass, - confirmPassword, - setUsername, - username, - setRootUser, - enableRoot, - setRootPass, - setConfirmRootPass, - rootPass, - confirmRootPass, - next) { +Widget users(setState, enableSudo, setPass, setConfirmPass, clearPass, + confirmPassword, setUsername, username, next) { return Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -190,100 +176,7 @@ Widget users( ), ), 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 root user', - style: TextStyle(color: Colors.white)), - value: enableRoot, - onChanged: (bool? value) { - setRootUser(value!); - }, - secondary: Container( - decoration: const BoxDecoration( - shape: BoxShape.circle, - color: Colors.white, - ), - padding: const EdgeInsets.fromLTRB(10, 10, 10, 13), - child: const Text( - '#', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - ), - ), - ), - Visibility( - child: const SizedBox(height: 10), visible: enableRoot), - Visibility( - visible: enableRoot, - child: TextFormField( - //obscureText: true, - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Password for root user', - labelStyle: TextStyle(color: Colors.white), - hintText: 'Password for the root user', - 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, - ), - obscureText: true, - - onChanged: (String? value) { - setRootPass(value); - }, - ), - ), - Visibility( - child: const SizedBox(height: 10), visible: enableRoot), - Visibility( - visible: enableRoot, - child: TextFormField( - //obscureText: true, - autovalidateMode: AutovalidateMode.always, - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Repeat root password', - labelStyle: TextStyle(color: Colors.white), - hintText: 'Repeat root password', - 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, - ), - obscureText: true, - - onChanged: (String? value) { - setConfirmRootPass(value); - }, - validator: (String? value) { - return (value != rootPass) - ? 'Password does not match' - : null; - }, - ), - ), - const SizedBox(height: 10), + //const SizedBox(height: 10), ], ), ), diff --git a/lib/main.dart b/lib/main.dart index be64fe0..5ccf1c3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -416,27 +416,6 @@ class _JadeguiState extends State { }); }, username, - (value) { - setState(() { - enableRoot = value; - writeToLog("Enable root: $enableRoot"); - }); - }, - enableRoot, - (String? value) { - setState(() { - if (value != null) { - rootPass = value; - } - }); - }, - (value) { - setState(() { - confirmRootPass = value; - }); - }, - rootPass, - confirmRootPass, () { setState(() { _selectedIndex = _selectedIndex + 1; @@ -503,6 +482,27 @@ class _JadeguiState extends State { ipv6, hostname, enableTimeshift, + (value) { + setState(() { + enableRoot = value; + writeToLog("Enable root: $enableRoot"); + }); + }, + enableRoot, + (String? value) { + setState(() { + if (value != null) { + rootPass = value; + } + }); + }, + (value) { + setState(() { + confirmRootPass = value; + }); + }, + rootPass, + confirmRootPass, () { setState(() { _selectedIndex = _selectedIndex + 1;