Skip to content

Commit 66b2fc8

Browse files
committed
create menu buttons ✨
1 parent 4af6759 commit 66b2fc8

File tree

3 files changed

+116
-42
lines changed

3 files changed

+116
-42
lines changed

lib/page/navigation/navigation1/coordinator.dart

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter_ui_nice/page/navigation/navigation1/widgets/button.dart';
2+
import 'package:flutter_ui_nice/page/navigation/navigation1/widgets/menu_buttons.dart';
33
import 'package:flutter_ui_nice/page/navigation/widgets/background_common.dart';
44

55
class NavigationOneCoordinator extends StatefulWidget {
@@ -14,12 +14,42 @@ class _Coordinator extends State<NavigationOneCoordinator> {
1414
super.initState();
1515
}
1616

17+
_onHomePressed() {
18+
debugPrint("Home Pressed");
19+
}
20+
21+
_onChatPressed() {
22+
debugPrint("Chat Pressed");
23+
}
24+
25+
_onFeedPressed() {
26+
debugPrint("Feed Pressed");
27+
}
28+
29+
_onProfilePressed() {
30+
debugPrint("Profile Pressed");
31+
}
32+
33+
_onSettingsPressed() {
34+
debugPrint("settings Pressed");
35+
}
36+
1737
@override
1838
Widget build(BuildContext context) => Material(
1939
child: BackgroundCommon(
2040
child: Stack(
2141
children: <Widget>[
22-
42+
Positioned(
43+
bottom: 100.0,
44+
right: 50.0,
45+
child: MenuButtons(
46+
onChatPressed: _onChatPressed,
47+
onFeedPressed: _onFeedPressed,
48+
onHomePressed: _onHomePressed,
49+
onProfilePressed: _onProfilePressed,
50+
onSettingsPressed: _onSettingsPressed,
51+
),
52+
)
2353
],
2454
),
2555
),

lib/page/navigation/navigation1/widgets/button.dart

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,66 @@ import 'package:flutter_ui_nice/const/color_const.dart';
33

44
class Button {
55

6-
static Widget home() => _buildButton("HOME", Icons.home);
6+
static Widget home(VoidCallback onPressed) => _buildButton(onPressed, "HOME", Icons.home);
77

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);
910

10-
static Widget feed() => _buildButton("FEED", Icons.rss_feed);
11+
static Widget feed(VoidCallback onPressed) => _buildButton(onPressed, "FEED", Icons.rss_feed);
1112

12-
static Widget profile() => _buildButton("PROFILE", Icons.person);
13+
static Widget profile(VoidCallback onPressed) => _buildButton(onPressed, "PROFILE", Icons.person);
1314

14-
static Widget settings() => _buildButton("SETTINGS", Icons.settings);
15+
static Widget settings(VoidCallback onPressed) => _buildButton(onPressed, "SETTINGS", Icons.settings);
1516

16-
static Widget _buildButton(String title, IconData icon, {int notification}) {
17+
static Widget _buildButton(VoidCallback onPressed, String title, IconData icon, {int notification}) {
1718
if (notification != null) {
1819
return Container(
1920
child: Stack(
2021
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+
),
2636
),
27-
_button(title, icon)
2837
],
2938
),
3039
);
3140
} else {
32-
return _button(title, icon);
41+
return _button(onPressed, title, icon);
3342
}
3443
}
3544

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+
),
6365
),
6466
);
67+
6568
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_ui_nice/page/navigation/navigation1/widgets/button.dart';
3+
4+
class MenuButtons extends StatelessWidget {
5+
MenuButtons({this.onHomePressed, this.onChatPressed, this.onFeedPressed, this.onProfilePressed, this
6+
.onSettingsPressed});
7+
final VoidCallback onHomePressed;
8+
final VoidCallback onChatPressed;
9+
final VoidCallback onFeedPressed;
10+
final VoidCallback onProfilePressed;
11+
final VoidCallback onSettingsPressed;
12+
13+
List<Widget> _allButtons({int notifications}) => [
14+
Padding(
15+
padding: const EdgeInsets.only(left: 10.0, right: 30.0, bottom: 20.0),
16+
child: Button.home(onHomePressed),
17+
),
18+
Padding(
19+
padding: const EdgeInsets.only(left: 50.0, bottom: 20.0),
20+
child: Button.chat(onChatPressed, notification: notifications),
21+
),
22+
Padding(
23+
padding: const EdgeInsets.only(left: 8.0, bottom: 20.0),
24+
child: Button.feed(onFeedPressed),
25+
),
26+
Padding(
27+
padding: const EdgeInsets.only(left: 50.0, bottom: 20.0),
28+
child: Button.profile(onProfilePressed),
29+
),
30+
Button.settings(onSettingsPressed)
31+
];
32+
33+
@override
34+
Widget build(BuildContext context) {
35+
return Container(
36+
child: Column(
37+
children: _allButtons(notifications: 5),
38+
),
39+
);
40+
}
41+
}

0 commit comments

Comments
 (0)