123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import 'package:flutter/material.dart';
- import 'package:userstory2translate/classes/language.dart';
- import 'package:userstory2translate/localization/language_constants.dart';
- import 'package:userstory2translate/main.dart';
-
- class SettingsPage extends StatefulWidget {
- SettingsPage({Key key}) : super(key: key);
-
- @override
- _SettingsPageState createState() => _SettingsPageState();
- }
-
- class _SettingsPageState extends State<SettingsPage> {
- void _changeLanguage(Language language) async {
- Locale _locale = await setLocale(language.languageCode);
- MyApp.setLocale(context, _locale);
- }
-
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text(getTranslated(context, 'settings')),
- ),
- body: Container(
- child: Center(
- child: DropdownButton<Language>(
- iconSize: 30,
- hint: Text(getTranslated(context, 'change_language')),
- onChanged: (Language language) {
- _changeLanguage(language);
- },
- items: Language.languageList()
- .map<DropdownMenuItem<Language>>(
- (e) => DropdownMenuItem<Language>(
- value: e,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: <Widget>[
- Text(
- e.flag,
- style: TextStyle(fontSize: 30),
- ),
- Text(e.name)
- ],
- ),
- ),
- )
- .toList(),
- )),
- ),
- );
- }
- }
|