-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1197 from digitalfabrik/1175-language-switch
1175: Language switch
- Loading branch information
Showing
11 changed files
with
158 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'package:ehrenamtskarte/build_config/build_config.dart' show buildConfig; | ||
import 'package:ehrenamtskarte/l10n/translations.g.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
Map<String, String> languages = {'en': 'Englisch', 'de': 'Deutsch'}; | ||
|
||
class LanguageChange extends StatelessWidget { | ||
const LanguageChange({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column(children: [ | ||
...buildConfig.appLocales.map((item) => DecoratedBox( | ||
decoration: BoxDecoration( | ||
color: LocaleSettings.currentLocale.languageCode == item | ||
? Theme.of(context).colorScheme.surfaceVariant | ||
: null), | ||
child: ListTile( | ||
title: Text( | ||
languages[item]!, | ||
textAlign: TextAlign.center, | ||
style: TextStyle(fontWeight: FontWeight.bold), | ||
), | ||
onTap: () => switchLanguage(context, item)))) | ||
]); | ||
} | ||
|
||
switchLanguage(BuildContext context, String language) { | ||
final messengerState = ScaffoldMessenger.of(context); | ||
LocaleSettings.setLocaleRaw(language); | ||
messengerState.showSnackBar( | ||
SnackBar( | ||
backgroundColor: Theme.of(context).colorScheme.primary, | ||
content: | ||
Text(t.about.languageChangeSuccessful, style: TextStyle(color: Theme.of(context).colorScheme.background)), | ||
), | ||
); | ||
Navigator.pop(context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class Section extends StatelessWidget { | ||
final String headline; | ||
final List<Widget> children; | ||
|
||
const Section({super.key, required this.headline, required this.children}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Padding( | ||
padding: EdgeInsets.only(top: 16, left: 16, right: 16), | ||
child: Text(headline, | ||
style: Theme.of(context) | ||
.textTheme | ||
.bodySmall | ||
?.merge(TextStyle(color: Theme.of(context).colorScheme.secondary))), | ||
), | ||
Column(children: children), | ||
const SizedBox(height: 10), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters