diff --git a/jade_log.txt b/jade_log.txt index 30049f5..c68d39f 100644 --- a/jade_log.txt +++ b/jade_log.txt @@ -1,21 +1,3 @@ -Chosen layout: us -Chosen variant: colemak -Username: u -Username: us -Username: use -Username: user -Enable sudo: true -Enable root: true -Hostname: h -Hostname: ho -Hostname: hos -Hostname: host -Disks: /dev/sda -/dev/nvme0n1 - -Selected disk: /dev/sda -Partition info: 238.5G - -Selected disk: /dev/nvme0n1 -Is efi: true \ No newline at end of file +Chosen location: Africa +Chosen Region: Johannesburg \ No newline at end of file diff --git a/lib/functions/locale.dart b/lib/functions/locale.dart index ee3ae75..9e8aa59 100644 --- a/lib/functions/locale.dart +++ b/lib/functions/locale.dart @@ -1,16 +1,159 @@ import 'package:flutter/material.dart'; -import 'package:jade_gui/functions/location/region.dart'; -import 'package:jade_gui/functions/location/location.dart'; import 'package:jade_gui/locales/locales.dart'; +import 'package:jade_gui/classes/location.dart'; -Widget locale(next, nextPage, selectlocation, isnextpage, writeToLog) { - Widget widget; - selectlocation(getSelectedRegion()); - String selectedregion = getSelectedRegion(); - if (isnextpage == false) { - widget = region(nextPage, locations); - } else { - widget = location(selectedregion, next); - } - return widget; +Local chosenLocation = locations[0]; +Location chosenRegion = locations[0].location[0]; + +Widget regionTemplate(variant, chosenLayout, nextPage, writeToLog) { + 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: () { + chosenRegion = variant; + writeToLog("Chosen Region: ${chosenRegion.location}"); + nextPage(); + }, + 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( + variant.location, + style: const TextStyle( + fontWeight: FontWeight.bold, + ), + ), + ), + ), + const SizedBox(height: 10), + ], + ); +} + +Widget locationTemplate(location, setChosenLocation, writeToLog) { + 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: () { + setChosenLocation(location); + writeToLog("Chosen location: ${location.name}"); + }, + style: TextButton.styleFrom( + primary: Colors.white, + backgroundColor: const Color.fromARGB(255, 30, 30, 30), + shadowColor: const Color.fromARGB(100, 30, 30, 30), + padding: const EdgeInsets.all(10), + ), + child: Text( + location.name, + style: const TextStyle( + fontWeight: FontWeight.bold, + ), + ), + ), + ), + const SizedBox(height: 10), + ], + ); +} + +Widget locale(nextPage, showRegion, choseLocation, setChosenLocation, + Local chosenLocation, writeToLog) { + return Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + 'Please select a Time zone', + style: TextStyle( + fontSize: 50, + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 169, 0, 255)), + ), + const SizedBox(height: 20), + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + const SizedBox(width: 40), + 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: locations + .map((keymap) => locationTemplate( + keymap, setChosenLocation, writeToLog)) + .toList(), + ), + ), + ), + ), + const SizedBox(width: 50), + 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: chosenLocation.location + .map((map) => regionTemplate( + map, chosenLocation, nextPage, writeToLog)) + .toList(), + ), + ), + ), + ), + const SizedBox(width: 40), + ], + ), + ), + const SizedBox(height: 20), + ], + ); } diff --git a/lib/main.dart b/lib/main.dart index b811240..4266826 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -70,6 +70,7 @@ class _JadeguiState extends State { int _selectedIndex = 0; bool nextpage = false; bool choseLayout = false; + bool choseRegion = false; bool enableSudo = false; bool enableRoot = false; bool isEfi = false; @@ -301,21 +302,16 @@ class _JadeguiState extends State { }, () { setState(() { - nextpage = true; + choseRegion = true; }); }, - (region) { - if (region != "") { - setState(() { - nextpage = false; - }); - } else { - setState(() { - nextpage = true; - }); - } + choseRegion, + (location) { + setState(() { + chosenLocation = location; + }); }, - nextpage, + chosenLocation, (value) { writeToLog(value); },