@@ -3,63 +3,66 @@ import 'package:flutter_ui_nice/const/color_const.dart';
3
3
4
4
class Button {
5
5
6
- static Widget home () => _buildButton ("HOME" , Icons .home);
6
+ static Widget home (VoidCallback onPressed ) => _buildButton (onPressed, "HOME" , Icons .home);
7
7
8
- static Widget chat ({int notification}) => _buildButton ("CHAT" , Icons .chat, notification: notification);
8
+ static Widget chat (VoidCallback onPressed, {int notification}) => _buildButton (onPressed, "CHAT" , Icons .chat, notification:
9
+ notification);
9
10
10
- static Widget feed () => _buildButton ("FEED" , Icons .rss_feed);
11
+ static Widget feed (VoidCallback onPressed ) => _buildButton (onPressed, "FEED" , Icons .rss_feed);
11
12
12
- static Widget profile () => _buildButton ("PROFILE" , Icons .person);
13
+ static Widget profile (VoidCallback onPressed ) => _buildButton (onPressed, "PROFILE" , Icons .person);
13
14
14
- static Widget settings () => _buildButton ("SETTINGS" , Icons .settings);
15
+ static Widget settings (VoidCallback onPressed ) => _buildButton (onPressed, "SETTINGS" , Icons .settings);
15
16
16
- static Widget _buildButton (String title, IconData icon, {int notification}) {
17
+ static Widget _buildButton (VoidCallback onPressed, String title, IconData icon, {int notification}) {
17
18
if (notification != null ) {
18
19
return Container (
19
20
child: Stack (
20
21
children: < Widget > [
21
- Container (
22
- decoration: BoxDecoration (
23
- borderRadius: BorderRadius .circular (50.0 ),
24
- color: RED
25
- ),
22
+ _button (onPressed, title, icon),
23
+ Positioned (
24
+ top: 0.0 ,
25
+ right: 0.0 ,
26
+ child: Container (
27
+ decoration: BoxDecoration (
28
+ shape: BoxShape .circle,
29
+ color: Colors .redAccent
30
+ ),
31
+ child: Padding (
32
+ padding: const EdgeInsets .all (6.0 ),
33
+ child: Text ("$notification " , style: TextStyle (color: Colors .white),),
34
+ ),
35
+ ),
26
36
),
27
- _button (title, icon)
28
37
],
29
38
),
30
39
);
31
40
} else {
32
- return _button (title, icon);
41
+ return _button (onPressed, title, icon);
33
42
}
34
43
}
35
44
36
- static Widget _button (String title, IconData icon) => Container (
37
- height: 50.0 ,
38
- width: 180.0 ,
39
- decoration: BoxDecoration (
40
- borderRadius: BorderRadius .circular (20.0 ),
41
- color: GREEN
42
- ),
43
- child: InkResponse (
44
- onTap: () => debugPrint ('Pressed' ),
45
- splashColor: BLUE_LIGHT ,
46
- borderRadius: BorderRadius .circular (100.0 ),
47
- child: Center (
48
- child: Row (
49
- mainAxisAlignment: MainAxisAlignment .center,
50
- children: < Widget > [
51
- Text (
52
- title,
53
- style: TextStyle (
54
- fontSize: 18.0 ,
55
- color: TEXT_BLACK ,
56
- ),
57
- ),
58
- SizedBox (width: 5.0 ,),
59
- Icon (icon)
60
- ],
61
- ),
62
- ),
45
+ static Widget _button (VoidCallback onPressed, String title, IconData icon) => RaisedButton (
46
+ color: GREEN ,
47
+ shape: RoundedRectangleBorder (borderRadius: BorderRadius .circular (20.0 )),
48
+ onPressed: onPressed,
49
+ child: Padding (
50
+ padding: const EdgeInsets .symmetric (horizontal: 8.0 , vertical: 10.0 ),
51
+ child: Row (
52
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
53
+ children: < Widget > [
54
+ Text (
55
+ title,
56
+ style: TextStyle (
57
+ fontSize: 18.0 ,
58
+ color: TEXT_BLACK ,
59
+ ),
60
+ ),
61
+ SizedBox (width: 5.0 ,),
62
+ Icon (icon)
63
+ ],
64
+ ),
63
65
),
64
66
);
67
+
65
68
}
0 commit comments