1
+ import 'package:day59/controllers/theme/ThemesController.dart' ;
1
2
import 'package:flutter/material.dart' ;
3
+ import 'package:get/get.dart' ;
4
+ import 'package:day59/shared/helpers/extensions/StringExtension.dart' ;
2
5
3
6
class UserTab extends StatelessWidget {
4
- const UserTab ({ Key ? key }) : super (key: key);
7
+ UserTab ({ Key ? key }) : super (key: key);
8
+ final ThemesController _themesController = Get .find ();
5
9
6
10
@override
7
11
Widget build (BuildContext context) {
@@ -42,7 +46,7 @@ class UserTab extends StatelessWidget {
42
46
padding: EdgeInsets .all (16 ),
43
47
decoration: BoxDecoration (
44
48
borderRadius: BorderRadius .circular (8 ),
45
- color: Colors .grey.shade200
49
+ color: Get .isDarkMode ? Colors .grey.shade800. withAlpha ( 100 ) : Colors .grey.shade200
46
50
),
47
51
child: Row (
48
52
children: [
@@ -51,7 +55,7 @@ class UserTab extends StatelessWidget {
51
55
height: 52 ,
52
56
decoration: BoxDecoration (
53
57
shape: BoxShape .circle,
54
- color: Colors .grey.shade300
58
+ color: Get .isDarkMode ? Colors .grey.shade700 : Colors .grey.shade300
55
59
),
56
60
child: Center (
57
61
child: Icon (Icons .person, size: 32 , color: Colors .grey.shade500),
@@ -65,15 +69,18 @@ class UserTab extends StatelessWidget {
65
69
SizedBox (height: 32 ),
66
70
Text ("Settings" , style: theme.textTheme.headline6? .copyWith (fontWeight: FontWeight .w400)),
67
71
SizedBox (height: 16 ),
68
- _buildListTile ('Appearance' , Icons .dark_mode, 'Light' , Colors .purple, theme),
72
+ GetBuilder <ThemesController >(builder: (_) {
73
+ return _buildListTile ('Appearance' , Icons .dark_mode, _.theme.toCapitalized (), Colors .purple, theme, onTab: () => _showAppearanceModal (theme, _.theme));
74
+ // return Text(_.theme);
75
+ }),
69
76
SizedBox (height: 8 ),
70
- _buildListTile ('Language' , Icons .language, 'English' , Colors .orange, theme),
77
+ _buildListTile ('Language' , Icons .language, 'English' , Colors .orange, theme, onTab : () {} ),
71
78
SizedBox (height: 8 ),
72
- _buildListTile ('Notifications' , Icons .notifications_outlined, '' , Colors .blue, theme),
79
+ _buildListTile ('Notifications' , Icons .notifications_outlined, '' , Colors .blue, theme, onTab : () {} ),
73
80
SizedBox (height: 8 ),
74
- _buildListTile ('Help' , Icons .help, '' , Colors .green, theme),
81
+ _buildListTile ('Help' , Icons .help, '' , Colors .green, theme, onTab : () {} ),
75
82
SizedBox (height: 8 ),
76
- _buildListTile ('Logout' , Icons .exit_to_app, '' , Colors .red, theme),
83
+ _buildListTile ('Logout' , Icons .exit_to_app, '' , Colors .red, theme, onTab : () {} ),
77
84
78
85
],
79
86
),
@@ -85,7 +92,7 @@ class UserTab extends StatelessWidget {
85
92
);
86
93
}
87
94
88
- Widget _buildListTile (String title, IconData icon, String trailing, Color color, theme) {
95
+ Widget _buildListTile (String title, IconData icon, String trailing, Color color, theme, {onTab} ) {
89
96
return ListTile (
90
97
contentPadding: EdgeInsets .all (0 ),
91
98
leading: Container (
@@ -110,8 +117,60 @@ class UserTab extends StatelessWidget {
110
117
],
111
118
),
112
119
),
113
- onTap: () {
114
- },
120
+ onTap: onTab
115
121
);
116
122
}
123
+
124
+ _showAppearanceModal (ThemeData theme, String current) {
125
+ Get .bottomSheet (
126
+ Container (
127
+ padding: EdgeInsets .all (16 ),
128
+ height: 320 ,
129
+ decoration: BoxDecoration (
130
+ color: Get .isDarkMode ? Colors .grey.shade900 : Colors .grey.shade200,
131
+ borderRadius: BorderRadius .only (
132
+ topLeft: Radius .circular (16 ),
133
+ topRight: Radius .circular (16 ),
134
+ )
135
+ ),
136
+ child: Column (
137
+ mainAxisSize: MainAxisSize .min,
138
+ crossAxisAlignment: CrossAxisAlignment .start,
139
+ children: [
140
+ Text ("Select a Theme" , style: theme.textTheme.subtitle1,),
141
+ SizedBox (height: 32 ),
142
+ ListTile (
143
+ leading: Icon (Icons .brightness_5, color: Colors .blue,),
144
+ title: Text ("Light" , style: theme.textTheme.bodyText1),
145
+ onTap: () {
146
+ _themesController.setTheme ('light' );
147
+ Get .back ();
148
+ },
149
+ trailing: Icon (Icons .check, color: current == 'light' ? Colors .blue : Colors .transparent,),
150
+ ),
151
+ SizedBox (height: 16 ),
152
+ ListTile (
153
+ leading: Icon (Icons .brightness_2, color: Colors .orange,),
154
+ title: Text ("Dark" , style: theme.textTheme.bodyText1),
155
+ onTap: () {
156
+ _themesController.setTheme ('dark' );
157
+ Get .back ();
158
+ },
159
+ trailing: Icon (Icons .check, color: current == 'dark' ? Colors .orange : Colors .transparent,),
160
+ ),
161
+ SizedBox (height: 16 ),
162
+ ListTile (
163
+ leading: Icon (Icons .brightness_3, color: Colors .purple,),
164
+ title: Text ("System" , style: theme.textTheme.bodyText1),
165
+ onTap: () {
166
+ _themesController.setTheme ('system' );
167
+ Get .back ();
168
+ },
169
+ trailing: Icon (Icons .check, color: current == 'system' ? Colors .purple : Colors .transparent,),
170
+ ),
171
+ ],
172
+ ),
173
+ )
174
+ );
175
+ }
117
176
}
0 commit comments