|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:efox_flutter/lang/index.dart' show AppLocalizations; |
| 3 | +import 'package:efox_flutter/router/index.dart' show FluroRouter; |
| 4 | +import 'package:efox_flutter/config/theme.dart' show AppTheme; |
| 5 | + |
| 6 | +class _IndexState extends State<Index> { |
| 7 | + @override |
| 8 | + void initState() { |
| 9 | + super.initState(); |
| 10 | + } |
| 11 | + |
| 12 | + void pop([message]) { |
| 13 | + Navigator.pop(context); |
| 14 | + if (message != null) { |
| 15 | + Scaffold.of(context).showSnackBar(new SnackBar( |
| 16 | + content: new Text(message), |
| 17 | + )); |
| 18 | + } |
| 19 | + } |
| 20 | + |
| 21 | + /** |
| 22 | + * 国际化 |
| 23 | + */ |
| 24 | + void openLanguageSelectMenu() async { |
| 25 | + await showModalBottomSheet( |
| 26 | + context: context, |
| 27 | + builder: (BuildContext bc) { |
| 28 | + return Container( |
| 29 | + child: Wrap( |
| 30 | + children: <Widget>[ |
| 31 | + ListTile( |
| 32 | + //leading: Icon(Icons.label_outline), |
| 33 | + title: Text( |
| 34 | + AppLocalizations.$t('common_mine_1.cn'), |
| 35 | + ), |
| 36 | + onTap: () { |
| 37 | + AppLocalizations.changeLanguage(Locale('zh')); |
| 38 | + this.pop(AppLocalizations.$t('common_mine_1.success')); |
| 39 | + }, |
| 40 | + ), |
| 41 | + ListTile( |
| 42 | + //leading: Icon(Icons.label_outline), |
| 43 | + title: Text(AppLocalizations.$t('common_mine_1.en')), |
| 44 | + onTap: () { |
| 45 | + AppLocalizations.changeLanguage(Locale('en')); |
| 46 | + this.pop(AppLocalizations.$t('common_mine_1.success')); |
| 47 | + }, |
| 48 | + ), |
| 49 | + ], |
| 50 | + ), |
| 51 | + ); |
| 52 | + }, |
| 53 | + ); |
| 54 | + } |
| 55 | + |
| 56 | + @override |
| 57 | + Widget build(BuildContext context) { |
| 58 | + return Scaffold( |
| 59 | + appBar: AppBar( |
| 60 | + elevation: 0, |
| 61 | + centerTitle: true, |
| 62 | + title: Text(AppLocalizations.$t('nav_title_1'))), |
| 63 | + body: ListView( |
| 64 | + children: <Widget>[ |
| 65 | + ListTile( |
| 66 | + onTap: () => this.openLanguageSelectMenu(), |
| 67 | + leading: Icon(Icons.language), |
| 68 | + title: Text(AppLocalizations.$t('common_mine_1.language')), |
| 69 | + trailing: Container( |
| 70 | + child: Row( |
| 71 | + mainAxisSize: MainAxisSize.min, |
| 72 | + children: <Widget>[ |
| 73 | + Text(AppLocalizations.languageCode), |
| 74 | + Icon(Icons.navigate_next) |
| 75 | + ], |
| 76 | + ), |
| 77 | + )), |
| 78 | + Divider( |
| 79 | + color: Color(AppTheme.lineColor), |
| 80 | + ), |
| 81 | + ExpansionTile( |
| 82 | + title: Text(AppLocalizations.$t('common_mine_1.theme')), |
| 83 | + children: <Widget>[ |
| 84 | + Wrap( |
| 85 | + //crossAxisAlignment: WrapCrossAlignment.start, |
| 86 | + alignment: WrapAlignment.spaceEvenly, |
| 87 | + runAlignment: WrapAlignment.spaceEvenly, |
| 88 | + children: <Widget>[ |
| 89 | + this.Edage(AppTheme.yellow), |
| 90 | + this.Edage(AppTheme.blue), |
| 91 | + this.Edage(AppTheme.orange), |
| 92 | + this.Edage(AppTheme.lightGreen), |
| 93 | + this.Edage(AppTheme.red), |
| 94 | + ], |
| 95 | + ) |
| 96 | + ], |
| 97 | + ) |
| 98 | + ], |
| 99 | + )); |
| 100 | + } |
| 101 | + |
| 102 | + Widget Edage(color) { |
| 103 | + return GestureDetector( |
| 104 | + onTap: () {}, |
| 105 | + child: Container( |
| 106 | + color: Color(color), |
| 107 | + height: 30, |
| 108 | + width: 30, |
| 109 | + ), |
| 110 | + ); |
| 111 | + } |
| 112 | +} |
| 113 | + |
| 114 | +class Index extends StatefulWidget { |
| 115 | + final dynamic model; |
| 116 | + |
| 117 | + Index({Key key, this.model}) : super(key: key); |
| 118 | + |
| 119 | + @override |
| 120 | + _IndexState createState() => _IndexState(); |
| 121 | +} |
0 commit comments