@@ -47,23 +47,52 @@ class _IndexState extends State<Index> {
4747 );
4848 }
4949
50+ List <Widget > renderTiles (id) {
51+ if (id != null ) {
52+ return [
53+ ListTile (
54+ leading: Icon (Icons .exit_to_app),
55+ title: Text (AppLocalizations .$t ('common.logout' )),
56+ onTap: () {
57+ Store .value <UserModel >(context).$clearUserInfo ();
58+ },
59+ )
60+ ];
61+ }
62+ return [
63+ ListTile (
64+ leading: Icon (Icons .account_circle),
65+ title: Text (AppLocalizations .$t ('common.login' )),
66+ onTap: () {
67+ Navigator .of (context).push (
68+ MaterialPageRoute (
69+ builder: (BuildContext context) {
70+ return LoginIndex .Index ();
71+ },
72+ ),
73+ );
74+ },
75+ )
76+ ];
77+ }
78+
5079 /**
5180 * 抽屉面板
5281 */
5382 renderDrawer () {
5483 print ('renderDrawer $context ' );
5584 return Drawer (
56- child: Column (
57- crossAxisAlignment : CrossAxisAlignment .start,
58- children : < Widget > [
59- Container (
60- height : 200 ,
61- decoration : BoxDecoration (
62- color : Color ( AppTheme .mainColor),
63- ),
64- child : Store . connect < UserModel >(
65- builder : (context, child, model) {
66- return Row ( children: < Widget > [
85+ child: Store . connect < UserModel >(builder : (context, child, model) {
86+ return Column (
87+ crossAxisAlignment : CrossAxisAlignment .start,
88+ children : < Widget > [
89+ Container (
90+ height : 200 ,
91+ decoration : BoxDecoration (
92+ color : Color ( AppTheme .mainColor ),
93+ ),
94+ child : Row (
95+ children: < Widget > [
6796 Padding (
6897 padding: EdgeInsets .symmetric (horizontal: 20.0 ),
6998 child: ClipOval (
@@ -76,40 +105,20 @@ class _IndexState extends State<Index> {
76105 ),
77106 ),
78107 Text (
79- Store . value < UserModel >(context) .user.name ?? 'Guest' ,
108+ model .user.name ?? 'Guest' ,
80109 style: TextStyle (fontWeight: FontWeight .bold),
81110 )
82- ]);
83- } ,
111+ ],
112+ ) ,
84113 ),
85- ),
86- Expanded (
87- child: ListView (
88- children: < Widget > [
89- ListTile (
90- leading: Icon (Icons .account_circle),
91- title: Text (AppLocalizations .$t ('common.login' )),
92- onTap: () {
93- Navigator .of (context).push (
94- MaterialPageRoute (builder: (BuildContext context) {
95- return LoginIndex .Index ();
96- }));
97- },
98- ),
99- Divider (),
100- ListTile (
101- leading: Icon (Icons .exit_to_app),
102- title: Text (AppLocalizations .$t ('common.logout' )),
103- onTap: () {
104- Store .value <UserModel >(context).$clearUserInfo ();
105- // Store.value<UserModel>(context).$getUserInfo();
106- },
107- ),
108- ],
114+ Expanded (
115+ child: ListView (
116+ children: renderTiles (model.user.node_id),
117+ ),
109118 ),
110- ) ,
111- ],
112- ),
119+ ] ,
120+ );
121+ } ),
113122 );
114123 }
115124
0 commit comments