add locale chooser, next step is to add the locales and timezones (pain)

pull/2/head
Amy 3 years ago
parent 08e8657393
commit 5ccc39c7cb
No known key found for this signature in database
GPG Key ID: C642EA4B2F4096BE

@ -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"
]
}

@ -0,0 +1,3 @@
import '../classes/location.dart';
List<Location> africa = [];

@ -0,0 +1,19 @@
import '../classes/location.dart';
List<Location> 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',
),
];

@ -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';

@ -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",
});
}

@ -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: <Widget>[
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;
}

@ -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;
}

@ -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<Widget> options(region, europe) {
List<Widget> widget;
switch (region) {
case "Europe":
{
widget = europe
.map<Widget>((location) => locationTemplate(location.location))
.toList();
break;
}
case "Asia":
{
widget = europe
.map<Widget>((location) => locationTemplate(location.location))
.toList();
break;
}
case "Africa":
{
widget = europe
.map<Widget>((location) => locationTemplate(location.location))
.toList();
break;
}
case "North America":
{
widget = europe
.map<Widget>((location) => locationTemplate(location.location))
.toList();
break;
}
case "South America":
{
widget = europe
.map<Widget>((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;
}

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:jade_gui/main.dart';
Widget welcome() { Widget welcome(next) {
return Container( return Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
image: DecorationImage( image: DecorationImage(
@ -46,13 +47,15 @@ Widget welcome() {
Column( Column(
children: [ children: [
TextButton( TextButton(
onPressed: () {}, onPressed: () {
next();
},
child: const Text('Start'), child: const Text('Start'),
style: TextButton.styleFrom( style: TextButton.styleFrom(
primary: Colors.white, primary: Colors.white,
backgroundColor: Color.fromARGB(255, 169, 0, 255), backgroundColor: const Color.fromARGB(255, 169, 0, 255),
minimumSize: Size(80, 50), minimumSize: const Size(80, 50),
padding: EdgeInsets.all(10), padding: const EdgeInsets.all(10),
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),

@ -1,5 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'functions/welcome.dart'; import 'functions/welcome.dart';
import 'functions/locale.dart';
import 'classes/location.dart';
import 'Locales/locales.dart';
void main() => runApp( void main() => runApp(
MaterialApp( MaterialApp(
@ -17,6 +20,27 @@ class jadegui extends StatefulWidget {
class _jadeguiState extends State<jadegui> { class _jadeguiState extends State<jadegui> {
int _selectedIndex = 0; int _selectedIndex = 0;
bool nextpage = false;
void nextslide() {
setState(() {
_selectedIndex = _selectedIndex + 1;
});
}
List<Location> america = [];
List<Location> antarctica = [];
List<Location> arctic = [];
List<Location> asia = [];
List<Location> atlantic = [];
List<Location> australia = [];
List<Location> brazil = [];
List<Location> canada = [];
List<Location> chile = [];
List<Location> indian = [];
List<Location> mexico = [];
List<Location> pacific = [];
List<Location> us = [];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -59,7 +83,7 @@ class _jadeguiState extends State<jadegui> {
color: Color.fromARGB(255, 169, 0, 255), color: Color.fromARGB(255, 169, 0, 255),
), ),
label: Text( label: Text(
'Locale', 'Location',
style: TextStyle( style: TextStyle(
color: Color.fromARGB(255, 169, 0, 255), color: Color.fromARGB(255, 169, 0, 255),
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
@ -81,22 +105,6 @@ class _jadeguiState extends State<jadegui> {
fontWeight: FontWeight.bold), 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( NavigationRailDestination(
icon: Icon( icon: Icon(
Icons.person_add_alt_outlined, Icons.person_add_alt_outlined,
@ -205,6 +213,21 @@ class _jadeguiState extends State<jadegui> {
); );
} }
bool loadnextpage(region) {
bool next = false;
print("here");
if (region != "") {
setState(() {
next = true;
});
} else {
setState(() {
next = true;
});
}
return next;
}
Widget condition() { Widget condition() {
// other logic // other logic
// Declare a widget variable, // Declare a widget variable,
@ -218,17 +241,32 @@ class _jadeguiState extends State<jadegui> {
// For simplicity I have used boolean contition // For simplicity I have used boolean contition
switch (_selectedIndex) { switch (_selectedIndex) {
case 0: case 0:
widget = welcome(); widget = welcome(() {
setState(() {
_selectedIndex = _selectedIndex + 1;
});
});
break; break;
case 1: case 1:
widget = const Text( widget = locale(() {
'Showing Locale screen', setState(() {
style: TextStyle( _selectedIndex = _selectedIndex + 1;
fontSize: 18, });
fontWeight: FontWeight.bold, }, () {
color: Color.fromARGB(255, 169, 0, 255), setState(() {
), nextpage = true;
); });
}, (region) {
if (region != "") {
setState(() {
nextpage = false;
});
} else {
setState(() {
nextpage = true;
});
}
}, nextpage, europe);
break; break;
case 2: case 2:
widget = const Text( widget = const Text(
@ -324,4 +362,6 @@ class _jadeguiState extends State<jadegui> {
// Finally returning a Widget // Finally returning a Widget
return widget; return widget;
} }
void selectlocation(region) {}
} }

Loading…
Cancel
Save