Language Change

Dictionary has been modified, all texts are being translated now
This commit is contained in:
Ali
2024-11-25 01:41:44 +01:00
parent 431efb359c
commit bf5e6a8bf4
8 changed files with 704 additions and 704 deletions
+169 -166
View File
@@ -114,184 +114,187 @@ class MyHome extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(
Icons.home,
size: 36,
color: Theme.of(context).colorScheme.onPrimary,
return Consumer<LanguageProvider>(builder: (context, languageProvider, child) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(
Icons.home,
size: 36,
color: Theme.of(context).colorScheme.onPrimary,
),
onPressed: () {
// Aktion für diesen Button
},
),
onPressed: () {
// Aktion für diesen Button
},
),
title: Consumer<PageProvider>(
// Consumer verwenden, um den dynamischen Titel anzuzeigen
builder: (context, pageProvider, child) {
return Container(
height: 40,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primaryContainer,
borderRadius: BorderRadius.circular(15),
),
alignment: Alignment.centerLeft,
child: Text(
pageProvider.titleString[pageProvider.selectedPage],
// Hier wird der dynamische Titel angezeigt
style: TextStyle(
color: Theme.of(context).colorScheme.onPrimary,
fontWeight: FontWeight.bold,
title: Consumer<PageProvider>(
// Consumer verwenden, um den dynamischen Titel anzuzeigen
builder: (context, pageProvider, child) {
return Container(
height: 40,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primaryContainer,
borderRadius: BorderRadius.circular(15),
),
alignment: Alignment.centerLeft,
child: Text(
languageProvider.languageData[Provider.of<LanguageProvider>(context).language]["navBar"][pageProvider.selectedPage.toString()],
// Hier wird der dynamische Titel angezeigt
style: TextStyle(
color: Theme.of(context).colorScheme.onPrimary,
fontWeight: FontWeight.bold,
),
),
);
},
),
backgroundColor: Theme.of(context).colorScheme.primary,
actions: [
IconButton(
icon: Opacity(
opacity: Provider.of<LanguageProvider>(context).language == "de"
? 1.0 // Voll sichtbar
: 0.4, // Halb durchsichtig
child: Image.asset(
'assets/flags/de.png',
width: 34,
height: 24,
fit: BoxFit.cover,
),
),
onPressed: () {
Provider.of<LanguageProvider>(context, listen: false)
.setLanguage("de");
},
),
IconButton(
icon: Opacity(
opacity: Provider.of<LanguageProvider>(context).language == "en"
? 1.0 // Voll sichtbar
: 0.4, // Halb durchsichtig
child: Image.asset(
'assets/flags/en.png',
width: 34,
height: 24,
fit: BoxFit.cover,
),
),
onPressed: () {
Provider.of<LanguageProvider>(context, listen: false)
.setLanguage("en");
},
),
IconButton(
icon: Opacity(
opacity: Provider.of<LanguageProvider>(context).language == "fr"
? 1.0 // Voll sichtbar
: 0.4, // Halb durchsichtig
child: Image.asset(
'assets/flags/fr.png',
width: 34,
height: 24,
fit: BoxFit.cover,
),
),
onPressed: () {
Provider.of<LanguageProvider>(context, listen: false)
.setLanguage("fr");
},
),
],
),
body: Consumer<PageProvider>(
builder: (context, pageProvider, child) {
return Stack(
children: [
pageProvider.pages[pageProvider.selectedPage],
Positioned(
left: 10,
bottom: 10,
child: IconButton.filled(
padding: const EdgeInsets.all(15),
onPressed: () {
_showDeleteDialog(context); // Dialog anzeigen
},
icon: const Icon(
Icons.delete,
size: 30,
),
style: ButtonStyle(
shape: WidgetStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(17))),
backgroundColor: WidgetStateProperty.all(
Theme.of(context).colorScheme.primary,
),
),
),
)
],
);
},
),
backgroundColor: Theme.of(context).colorScheme.primary,
actions: [
IconButton(
icon: Opacity(
opacity: Provider.of<LanguageProvider>(context).language == "de"
? 1.0 // Voll sichtbar
: 0.4, // Halb durchsichtig
child: Image.asset(
'assets/flags/de.png',
width: 34,
height: 24,
fit: BoxFit.cover,
),
floatingActionButton: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
Provider.of<LanguageProvider>(context).languageData[Provider.of<LanguageProvider>(context).language]["floating"]["info"],
style: TextStyle(fontSize: 15),
),
onPressed: () {
Provider.of<LanguageProvider>(context, listen: false)
.setLanguage("de");
},
),
IconButton(
icon: Opacity(
opacity: Provider.of<LanguageProvider>(context).language == "en"
? 1.0 // Voll sichtbar
: 0.4, // Halb durchsichtig
child: Image.asset(
'assets/flags/en.png',
width: 34,
height: 24,
fit: BoxFit.cover,
),
const SizedBox(
height: 10,
),
onPressed: () {
Provider.of<LanguageProvider>(context, listen: false)
.setLanguage("en");
},
),
IconButton(
icon: Opacity(
opacity: Provider.of<LanguageProvider>(context).language == "fr"
? 1.0 // Voll sichtbar
: 0.4, // Halb durchsichtig
child: Image.asset(
'assets/flags/fr.png',
width: 34,
height: 24,
fit: BoxFit.cover,
FloatingActionButton.extended(
onPressed: () {},
label: Text(
Provider.of<LanguageProvider>(context).languageData[Provider.of<LanguageProvider>(context).language]["floating"]["return"],
style: TextStyle(fontSize: 20),
),
),
onPressed: () {
Provider.of<LanguageProvider>(context, listen: false)
.setLanguage("fr");
},
),
],
),
body: Consumer<PageProvider>(
builder: (context, pageProvider, child) {
return Stack(
children: [
pageProvider.pages[pageProvider.selectedPage],
Positioned(
left: 10,
bottom: 10,
child: IconButton.filled(
padding: const EdgeInsets.all(15),
onPressed: () {
_showDeleteDialog(context); // Dialog anzeigen
},
icon: const Icon(
Icons.delete,
size: 30,
),
style: ButtonStyle(
shape: WidgetStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(17))),
backgroundColor: WidgetStateProperty.all(
Theme.of(context).colorScheme.primary,
),
),
icon: const Icon(Icons.send),
)
],
),
bottomNavigationBar: Container(
color: Theme.of(context).colorScheme.secondary,
child: Padding(
padding: const EdgeInsets.all(5),
child: GNav(
onTabChange: (index) {
Provider.of<PageProvider>(context, listen: false)
.changePage(index);
},
gap: 8,
style: GnavStyle.google,
backgroundColor: Colors.transparent,
color: Theme.of(context).colorScheme.onSurface,
activeColor: Theme.of(context).colorScheme.onPrimary,
tabBackgroundColor: Theme.of(context).colorScheme.primary,
tabs: [
GButton(
icon: Icons.fastfood_outlined,
text: Provider.of<LanguageProvider>(context).languageData[Provider.of<LanguageProvider>(context).language]["navBar"]["0"],
),
)
],
);
},
),
floatingActionButton: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
"* Pflichtfeld",
style: TextStyle(fontSize: 15),
),
const SizedBox(
height: 10,
),
FloatingActionButton.extended(
onPressed: () {},
label: const Text(
"Absenden",
style: TextStyle(fontSize: 20),
GButton(
icon: Icons.chair, /* prev: landscape*/
text: Provider.of<LanguageProvider>(context).languageData[Provider.of<LanguageProvider>(context).language]["navBar"]["1"],
),
GButton(
icon: Icons.mood,
text: Provider.of<LanguageProvider>(context).languageData[Provider.of<LanguageProvider>(context).language]["navBar"]["2"],
),
GButton(
icon: Icons.feedback,
text: Provider.of<LanguageProvider>(context).languageData[Provider.of<LanguageProvider>(context).language]["navBar"]["3"],
),
GButton(
icon: Icons.grass,
text: Provider.of<LanguageProvider>(context).languageData[Provider.of<LanguageProvider>(context).language]["navBar"]["4"],
),
],
),
icon: const Icon(Icons.send),
)
],
),
bottomNavigationBar: Container(
color: Theme.of(context).colorScheme.secondary,
child: Padding(
padding: const EdgeInsets.all(5),
child: GNav(
onTabChange: (index) {
Provider.of<PageProvider>(context, listen: false)
.changePage(index);
},
gap: 8,
style: GnavStyle.google,
backgroundColor: Colors.transparent,
color: Theme.of(context).colorScheme.onSurface,
activeColor: Theme.of(context).colorScheme.onPrimary,
tabBackgroundColor: Theme.of(context).colorScheme.primary,
tabs: const [
GButton(
icon: Icons.fastfood_outlined,
text: "Essen",
),
GButton(
icon: Icons.chair, /* prev: landscape*/
text: "Ambiente",
),
GButton(
icon: Icons.mood,
text: "Service",
),
GButton(
icon: Icons.feedback,
text: "Anmerkungen",
),
GButton(
icon: Icons.grass,
text: "Spezielle Ernährung",
),
],
),
),
),
);
);
});
}
}