11import 'package:flutter/material.dart' ;
22import 'package:efox_flutter/router/index.dart' ;
3- import 'package:efox_flutter/store/models/main_state_model.dart' ;
3+ import 'package:efox_flutter/store/models/main_state_model.dart'
4+ show MainStateModel;
5+ import 'package:efox_flutter/lang/application.dart' show Application;
6+ import 'package:efox_flutter/lang/app_translations.dart' show AppTranslations;
7+ import 'package:efox_flutter/components/header.dart' as Header;
48import 'package:efox_flutter/widget/index.dart' as WidgetRoot;
59import 'package:efox_flutter/config/theme.dart' show AppTheme;
610
@@ -25,6 +29,38 @@ class _IndexState extends State<Index> {
2529 this ._mapList = WidgetRoot .getAllWidgets ();
2630 }
2731
32+ List <Widget > appBarActions (model) {
33+ return [
34+ PopupMenuButton (
35+ icon: Icon (
36+ Icons .more_vert,
37+ ),
38+ onSelected: (local) {
39+ Application ().onLocaleChanged (Locale (local));
40+ print ('local=$local ' );
41+ },
42+ itemBuilder: (context) => [
43+ PopupMenuItem (
44+ child: Row (
45+ children: < Widget > [
46+ Text ('中文' ),
47+ ],
48+ ),
49+ value: 'zh' ,
50+ ),
51+ PopupMenuItem (
52+ child: Row (
53+ children: < Widget > [
54+ Text ('english' ),
55+ ],
56+ ),
57+ value: 'en' ,
58+ ),
59+ ],
60+ ),
61+ ];
62+ }
63+
2864 renderPanel (model, widgetsItem, index) {
2965 String nameSpaces = widgetsItem.nameSpaces;
3066 List _tmpWidgetList = widgetsItem.widgetList;
@@ -95,25 +131,35 @@ class _IndexState extends State<Index> {
95131 }
96132
97133 Widget build (BuildContext context) {
98- return SingleChildScrollView (
99- physics: BouncingScrollPhysics (),
100- // padding: EdgeInsets.all(10),
101- child: ExpansionPanelList (
102- animationDuration: Duration (milliseconds: 500 ),
103- children: List .generate (
104- _mapList.length,
105- (_index) {
106- return renderPanel (model, _mapList[_index], _index);
134+ // 实例化语言包
135+ AppTranslations lang = AppTranslations .of (context);
136+ return Scaffold (
137+ appBar: AppBar (
138+ title: Header .Index (
139+ lang.t ('nav_title_0' ),
140+ ),
141+ actions: appBarActions (model),
142+ ),
143+ body: SingleChildScrollView (
144+ physics: BouncingScrollPhysics (),
145+ // padding: EdgeInsets.all(10),
146+ child: ExpansionPanelList (
147+ animationDuration: Duration (milliseconds: 500 ),
148+ children: List .generate (
149+ _mapList.length,
150+ (_index) {
151+ return renderPanel (model, _mapList[_index], _index);
152+ },
153+ ),
154+ expansionCallback: (index, flag) {
155+ if (flag) {
156+ index = - 1 ;
157+ }
158+ setState (() {
159+ this ._isExpandedIndex = index;
160+ });
107161 },
108162 ),
109- expansionCallback: (index, flag) {
110- if (flag) {
111- index = - 1 ;
112- }
113- setState (() {
114- this ._isExpandedIndex = index;
115- });
116- },
117163 ),
118164 );
119165 }
0 commit comments