From 5ccc39c7cb8a194f1df7512ec2612bfee6a71db3 Mon Sep 17 00:00:00 2001 From: Amy Date: Thu, 3 Feb 2022 23:05:59 +0100 Subject: [PATCH] add locale chooser, next step is to add the locales and timezones (pain) --- assets/locales.json | 121 ++++++++++++++++++++++++++++++++++++ lib/Locales/Africa.dart | 3 + lib/Locales/America.dart | 0 lib/Locales/Antarctica.dart | 0 lib/Locales/Arctic.dart | 0 lib/Locales/Asia.dart | 0 lib/Locales/Atlantic.dart | 0 lib/Locales/Australia.dart | 0 lib/Locales/Brazil.dart | 0 lib/Locales/Canada.dart | 0 lib/Locales/Chile.dart | 0 lib/Locales/Europe.dart | 19 ++++++ lib/Locales/Indian.dart | 0 lib/Locales/Mexico.dart | 0 lib/Locales/Other.dart | 0 lib/Locales/Pacific.dart | 0 lib/Locales/US.dart | 0 lib/Locales/locales.dart | 15 +++++ lib/classes/location.dart | 13 ++++ lib/functions/Region.dart | 91 +++++++++++++++++++++++++++ lib/functions/locale.dart | 15 +++++ lib/functions/location.dart | 106 +++++++++++++++++++++++++++++++ lib/functions/welcome.dart | 13 ++-- lib/main.dart | 92 +++++++++++++++++++-------- 24 files changed, 457 insertions(+), 31 deletions(-) create mode 100644 assets/locales.json create mode 100644 lib/Locales/Africa.dart create mode 100644 lib/Locales/America.dart create mode 100644 lib/Locales/Antarctica.dart create mode 100644 lib/Locales/Arctic.dart create mode 100644 lib/Locales/Asia.dart create mode 100644 lib/Locales/Atlantic.dart create mode 100644 lib/Locales/Australia.dart create mode 100644 lib/Locales/Brazil.dart create mode 100644 lib/Locales/Canada.dart create mode 100644 lib/Locales/Chile.dart create mode 100644 lib/Locales/Europe.dart create mode 100644 lib/Locales/Indian.dart create mode 100644 lib/Locales/Mexico.dart create mode 100644 lib/Locales/Other.dart create mode 100644 lib/Locales/Pacific.dart create mode 100644 lib/Locales/US.dart create mode 100644 lib/Locales/locales.dart create mode 100644 lib/classes/location.dart create mode 100644 lib/functions/Region.dart create mode 100644 lib/functions/locale.dart create mode 100644 lib/functions/location.dart diff --git a/assets/locales.json b/assets/locales.json new file mode 100644 index 0000000..903f1c3 --- /dev/null +++ b/assets/locales.json @@ -0,0 +1,121 @@ +{ + "Europe": [ + "Amsterdam", + "Andorra", + "Astrakhan", + "Athens", + "Belfast", + "Belgrade", + "Berlin", + "Bratislava", + "Brussels", + "Bucharest", + "Budapest", + "Busingen", + "Chisinau", + "Copenhagen", + "Dublin", + "Gibraltar", + "Guernsey", + "Helsinki", + "Isle_of_Man", + "Istanbul", + "Jersey", + "Kaliningrad", + "Kiev", + "Lisbon", + "Ljubljana", + "London", + "Luxemburg", + "Madrid", + "Malta", + "Mariehamn", + "Minsk", + "Monaco", + "Moscow", + "Oslo", + "Paris", + "Podgorica", + "Prague", + "Riga", + "Rome", + "Samara", + "San_Marino", + "Sarajevo", + "Saratov", + "Simferopol", + "Skopje", + "Sofia", + "Stockholm", + "Tallinn", + "Tirane", + "Tiraspol", + "Ulyanovsk", + "Uzhgorod", + "Vaduz", + "Vatican", + "Vienna", + "Vilnius", + "Volgograd", + "Warsaw", + "Zagreb", + "Zaporozhye", + "Zurich" + ], + "Africa": [ + "Abidjan", + "Accra", + "Addis_Ababa", + "Algiers", + "Asmara", + "Asmera", + "Bamako", + "Bangui", + "Banjul", + "Bissau", + "Blantyre", + "Brazzaville", + "Bujumbura", + "Cairo", + "Casablanca", + "Ceuta", + "Conakry", + "Dakar", + "Dar_es_Salaam", + "Djibouti", + "Douala", + "El_Aaiun", + "Freetown", + "Gaborone", + "Harare", + "Johannesburg", + "Juba", + "Kampala", + "Khartoum", + "Kigali", + "Kinshasa", + "Lagos", + "Libreville", + "Lome", + "Luanda", + "Lubumbashi", + "Lusaka", + "Malabo", + "Maputo", + "Maseru", + "Mbabane", + "Mogadishu", + "Monrovia", + "Nairobi", + "Ndjamena", + "Niamey", + "Nouakchott", + "Ouagadougou", + "Porto-Novo", + "Sao_Tome", + "Timbuktu", + "Tripoli", + "Tunis", + "Windhoek" + ] +} \ No newline at end of file diff --git a/lib/Locales/Africa.dart b/lib/Locales/Africa.dart new file mode 100644 index 0000000..d3021fc --- /dev/null +++ b/lib/Locales/Africa.dart @@ -0,0 +1,3 @@ +import '../classes/location.dart'; + +List africa = []; diff --git a/lib/Locales/America.dart b/lib/Locales/America.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/Antarctica.dart b/lib/Locales/Antarctica.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/Arctic.dart b/lib/Locales/Arctic.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/Asia.dart b/lib/Locales/Asia.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/Atlantic.dart b/lib/Locales/Atlantic.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/Australia.dart b/lib/Locales/Australia.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/Brazil.dart b/lib/Locales/Brazil.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/Canada.dart b/lib/Locales/Canada.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/Chile.dart b/lib/Locales/Chile.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/Europe.dart b/lib/Locales/Europe.dart new file mode 100644 index 0000000..c4e2cef --- /dev/null +++ b/lib/Locales/Europe.dart @@ -0,0 +1,19 @@ +import '../classes/location.dart'; + +List europe = [ + Location( + region: 'Europe', + location: 'Berlin', + locale: 'de_DE.UTF-8 UTF-8', + ), + Location( + region: 'Europe', + location: 'Brussels', + locale: 'fr_BE.UTF-8 UTF-8', + ), + Location( + region: 'Europe', + location: 'Copenhagen', + locale: 'da_DK.UTF-8 UTF-8', + ), +]; diff --git a/lib/Locales/Indian.dart b/lib/Locales/Indian.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/Mexico.dart b/lib/Locales/Mexico.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/Other.dart b/lib/Locales/Other.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/Pacific.dart b/lib/Locales/Pacific.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/US.dart b/lib/Locales/US.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Locales/locales.dart b/lib/Locales/locales.dart new file mode 100644 index 0000000..8937a8a --- /dev/null +++ b/lib/Locales/locales.dart @@ -0,0 +1,15 @@ +export 'Africa.dart'; +export 'America.dart'; +export 'Antarctica.dart'; +export 'Asia.dart'; +export 'Atlantic.dart'; +export 'Australia.dart'; +export 'Brazil.dart'; +export 'Canada.dart'; +export 'Chile.dart'; +export 'Europe.dart'; +export 'Indian.dart'; +export 'Mexico.dart'; +export 'Pacific.dart'; +export 'US.dart'; +export 'Other.dart'; diff --git a/lib/classes/location.dart b/lib/classes/location.dart new file mode 100644 index 0000000..61cf511 --- /dev/null +++ b/lib/classes/location.dart @@ -0,0 +1,13 @@ +class Location { + String region = ""; + String location = ""; + String locale = ""; + String image = ""; + + Location({ + this.region = "", + this.location = "", + this.locale = "", + this.image = "assets/default.png", + }); +} diff --git a/lib/functions/Region.dart b/lib/functions/Region.dart new file mode 100644 index 0000000..aff8565 --- /dev/null +++ b/lib/functions/Region.dart @@ -0,0 +1,91 @@ +import 'package:flutter/material.dart'; + +String selectedRegion = ""; +Widget region(next) { + return SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const SizedBox(height: 20), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + 'Please choose your Locale', + style: TextStyle( + fontSize: 50, + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 169, 0, 255)), + ), + ], + ), + const SizedBox(height: 10), + GridView.count( + primary: false, + padding: const EdgeInsets.all(20), + shrinkWrap: true, + crossAxisSpacing: 10, + mainAxisSpacing: 10, + crossAxisCount: 3, + children: [ + Container( + padding: const EdgeInsets.all(8), + child: ElevatedButton( + onPressed: () { + next(); + selectedRegion = "Europe"; + }, + child: Text('Europe'), + ), + //color: Colors.teal[100], + ), + Container( + padding: const EdgeInsets.all(8), + child: ElevatedButton( + onPressed: () {}, + child: Text('English'), + ), + //color: Colors.teal[100], + ), + Container( + padding: const EdgeInsets.all(8), + child: ElevatedButton( + onPressed: () {}, + child: Text('English'), + ), + //color: Colors.teal[100], + ), + Container( + padding: const EdgeInsets.all(8), + child: ElevatedButton( + onPressed: () {}, + child: Text('English'), + ), + //color: Colors.teal[100], + ), + Container( + padding: const EdgeInsets.all(8), + child: ElevatedButton( + onPressed: () {}, + child: Text('English'), + ), + //color: Colors.teal[100], + ), + Container( + padding: const EdgeInsets.all(8), + child: ElevatedButton( + onPressed: () {}, + child: Text('English'), + ), + //color: Colors.teal[100], + ), + ], + ), + ], + ), + ); +} + +String getSelectedRegion() { + return selectedRegion; +} diff --git a/lib/functions/locale.dart b/lib/functions/locale.dart new file mode 100644 index 0000000..6bcae72 --- /dev/null +++ b/lib/functions/locale.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; +import 'Region.dart'; +import 'location.dart'; + +Widget locale(next, nextPage, selectlocation, isnextpage, Europe) { + Widget widget; + selectlocation(getSelectedRegion()); + String selectedregion = getSelectedRegion(); + if (isnextpage == false) { + widget = region(nextPage); + } else { + widget = location(selectedregion, Europe); + } + return widget; +} diff --git a/lib/functions/location.dart b/lib/functions/location.dart new file mode 100644 index 0000000..9994d9f --- /dev/null +++ b/lib/functions/location.dart @@ -0,0 +1,106 @@ +import 'package:flutter/material.dart'; +import '../classes/location.dart'; + +Widget locationTemplate(location) { + return Container( + padding: const EdgeInsets.all(8), + child: ElevatedButton( + onPressed: () {}, + child: Text(location), + ), + //color: Colors.teal[100], + ); +} + +Widget location(region, europe) { + return SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const SizedBox(height: 20), + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'Please choose your Locale', + style: TextStyle( + fontSize: 50, + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 169, 0, 255)), + ), + Text( + '$region/', + style: const TextStyle( + fontSize: 30, color: Color.fromARGB(255, 169, 0, 255)), + ) + ], + ), + const SizedBox(height: 10), + GridView.count( + primary: false, + padding: const EdgeInsets.all(20), + shrinkWrap: true, + crossAxisSpacing: 10, + mainAxisSpacing: 10, + crossAxisCount: 3, + children: options(region, europe), + ), + ], + ), + ); +} + +List options(region, europe) { + List widget; + + switch (region) { + case "Europe": + { + widget = europe + .map((location) => locationTemplate(location.location)) + .toList(); + break; + } + case "Asia": + { + widget = europe + .map((location) => locationTemplate(location.location)) + .toList(); + break; + } + case "Africa": + { + widget = europe + .map((location) => locationTemplate(location.location)) + .toList(); + break; + } + case "North America": + { + widget = europe + .map((location) => locationTemplate(location.location)) + .toList(); + break; + } + case "South America": + { + widget = europe + .map((location) => locationTemplate(location.location)) + .toList(); + break; + } + default: + widget = const [ + Text( + 'You should not see this, report this at git.tar.black/crystal/jade_gui', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.red, + ), + ), + ]; + } + // Finally returning a Widget + return widget; +} diff --git a/lib/functions/welcome.dart b/lib/functions/welcome.dart index cdcba40..f1602fd 100644 --- a/lib/functions/welcome.dart +++ b/lib/functions/welcome.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:jade_gui/main.dart'; -Widget welcome() { +Widget welcome(next) { return Container( decoration: const BoxDecoration( image: DecorationImage( @@ -46,13 +47,15 @@ Widget welcome() { Column( children: [ TextButton( - onPressed: () {}, + onPressed: () { + next(); + }, child: const Text('Start'), style: TextButton.styleFrom( primary: Colors.white, - backgroundColor: Color.fromARGB(255, 169, 0, 255), - minimumSize: Size(80, 50), - padding: EdgeInsets.all(10), + backgroundColor: const Color.fromARGB(255, 169, 0, 255), + minimumSize: const Size(80, 50), + padding: const EdgeInsets.all(10), ), ), const SizedBox(height: 10), diff --git a/lib/main.dart b/lib/main.dart index 12e25d6..4e39822 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,8 @@ import 'package:flutter/material.dart'; import 'functions/welcome.dart'; +import 'functions/locale.dart'; +import 'classes/location.dart'; +import 'Locales/locales.dart'; void main() => runApp( MaterialApp( @@ -17,6 +20,27 @@ class jadegui extends StatefulWidget { class _jadeguiState extends State { int _selectedIndex = 0; + bool nextpage = false; + void nextslide() { + setState(() { + _selectedIndex = _selectedIndex + 1; + }); + } + + List america = []; + List antarctica = []; + List arctic = []; + List asia = []; + List atlantic = []; + List australia = []; + List brazil = []; + List canada = []; + List chile = []; + List indian = []; + List mexico = []; + List pacific = []; + List us = []; + @override Widget build(BuildContext context) { return Scaffold( @@ -59,7 +83,7 @@ class _jadeguiState extends State { color: Color.fromARGB(255, 169, 0, 255), ), label: Text( - 'Locale', + 'Location', style: TextStyle( color: Color.fromARGB(255, 169, 0, 255), fontWeight: FontWeight.bold), @@ -81,22 +105,6 @@ class _jadeguiState extends State { fontWeight: FontWeight.bold), ), ), - NavigationRailDestination( - icon: Icon( - Icons.access_time, - color: Color.fromARGB(255, 169, 0, 255), - ), - selectedIcon: Icon( - Icons.access_time_filled, - color: Color.fromARGB(255, 169, 0, 255), - ), - label: Text( - 'Timezone', - style: TextStyle( - color: Color.fromARGB(255, 169, 0, 255), - fontWeight: FontWeight.bold), - ), - ), NavigationRailDestination( icon: Icon( Icons.person_add_alt_outlined, @@ -205,6 +213,21 @@ class _jadeguiState extends State { ); } + bool loadnextpage(region) { + bool next = false; + print("here"); + if (region != "") { + setState(() { + next = true; + }); + } else { + setState(() { + next = true; + }); + } + return next; + } + Widget condition() { // other logic // Declare a widget variable, @@ -218,17 +241,32 @@ class _jadeguiState extends State { // For simplicity I have used boolean contition switch (_selectedIndex) { case 0: - widget = welcome(); + widget = welcome(() { + setState(() { + _selectedIndex = _selectedIndex + 1; + }); + }); break; case 1: - widget = const Text( - 'Showing Locale screen', - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 169, 0, 255), - ), - ); + widget = locale(() { + setState(() { + _selectedIndex = _selectedIndex + 1; + }); + }, () { + setState(() { + nextpage = true; + }); + }, (region) { + if (region != "") { + setState(() { + nextpage = false; + }); + } else { + setState(() { + nextpage = true; + }); + } + }, nextpage, europe); break; case 2: widget = const Text( @@ -324,4 +362,6 @@ class _jadeguiState extends State { // Finally returning a Widget return widget; } + + void selectlocation(region) {} }