Skip to content

Commit 976da59

Browse files
committed
Add bottom navigation bar
1 parent e60df22 commit 976da59

File tree

2 files changed

+122
-88
lines changed

2 files changed

+122
-88
lines changed

.vscode/launch.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "day34",
9+
"request": "launch",
10+
"type": "dart",
11+
"args": [
12+
"--no-sound-null-safety",
13+
]
14+
},
15+
{
16+
"name": "day34 (profile mode)",
17+
"request": "launch",
18+
"type": "dart",
19+
"flutterMode": "profile",
20+
"args": [
21+
"--no-sound-null-safety",
22+
]
23+
}
24+
]
25+
}

lib/main.dart

+97-88
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,122 @@
1+
import 'package:flashy_tab_bar/flashy_tab_bar.dart';
12
import 'package:flutter/material.dart';
23

34
void main() {
4-
runApp(MyApp());
5+
runApp(MaterialApp(
6+
home: HomePage(),
7+
debugShowCheckedModeBanner: false,
8+
));
59
}
610

7-
class MyApp extends StatelessWidget {
8-
// This widget is the root of your application.
9-
@override
10-
Widget build(BuildContext context) {
11-
return MaterialApp(
12-
title: 'Flutter Demo',
13-
theme: ThemeData(
14-
// This is the theme of your application.
15-
//
16-
// Try running your application with "flutter run". You'll see the
17-
// application has a blue toolbar. Then, without quitting the app, try
18-
// changing the primarySwatch below to Colors.green and then invoke
19-
// "hot reload" (press "r" in the console where you ran "flutter run",
20-
// or simply save your changes to "hot reload" in a Flutter IDE).
21-
// Notice that the counter didn't reset back to zero; the application
22-
// is not restarted.
23-
primarySwatch: Colors.blue,
24-
),
25-
home: MyHomePage(title: 'Flutter Demo Home Page'),
26-
);
27-
}
28-
}
29-
30-
class MyHomePage extends StatefulWidget {
31-
MyHomePage({Key? key, required this.title}) : super(key: key);
32-
33-
// This widget is the home page of your application. It is stateful, meaning
34-
// that it has a State object (defined below) that contains fields that affect
35-
// how it looks.
36-
37-
// This class is the configuration for the state. It holds the values (in this
38-
// case the title) provided by the parent (in this case the App widget) and
39-
// used by the build method of the State. Fields in a Widget subclass are
40-
// always marked "final".
41-
42-
final String title;
11+
class HomePage extends StatefulWidget {
12+
const HomePage({ Key? key }) : super(key: key);
4313

4414
@override
45-
_MyHomePageState createState() => _MyHomePageState();
15+
_HomePageState createState() => _HomePageState();
4616
}
4717

48-
class _MyHomePageState extends State<MyHomePage> {
49-
int _counter = 0;
18+
class _HomePageState extends State<HomePage> {
19+
int _selectedIndex = 0;
5020

51-
void _incrementCounter() {
21+
void _onItemTapped(int index) {
5222
setState(() {
53-
// This call to setState tells the Flutter framework that something has
54-
// changed in this State, which causes it to rerun the build method below
55-
// so that the display can reflect the updated values. If we changed
56-
// _counter without calling setState(), then the build method would not be
57-
// called again, and so nothing would appear to happen.
58-
_counter++;
23+
_selectedIndex = index;
5924
});
6025
}
6126

6227
@override
6328
Widget build(BuildContext context) {
64-
// This method is rerun every time setState is called, for instance as done
65-
// by the _incrementCounter method above.
66-
//
67-
// The Flutter framework has been optimized to make rerunning build methods
68-
// fast, so that you can just rebuild anything that needs updating rather
69-
// than having to individually change instances of widgets.
7029
return Scaffold(
71-
appBar: AppBar(
72-
// Here we take the value from the MyHomePage object that was created by
73-
// the App.build method, and use it to set our appbar title.
74-
title: Text(widget.title),
75-
),
76-
body: Center(
77-
// Center is a layout widget. It takes a single child and positions it
78-
// in the middle of the parent.
30+
body: SingleChildScrollView(
7931
child: Column(
80-
// Column is also a layout widget. It takes a list of children and
81-
// arranges them vertically. By default, it sizes itself to fit its
82-
// children horizontally, and tries to be as tall as its parent.
83-
//
84-
// Invoke "debug painting" (press "p" in the console, choose the
85-
// "Toggle Debug Paint" action from the Flutter Inspector in Android
86-
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
87-
// to see the wireframe for each widget.
88-
//
89-
// Column has various properties to control how it sizes itself and
90-
// how it positions its children. Here we use mainAxisAlignment to
91-
// center the children vertically; the main axis here is the vertical
92-
// axis because Columns are vertical (the cross axis would be
93-
// horizontal).
94-
mainAxisAlignment: MainAxisAlignment.center,
95-
children: <Widget>[
96-
Text(
97-
'You have pushed the button this many times:',
98-
),
99-
Text(
100-
'$_counter',
101-
style: Theme.of(context).textTheme.headline4,
32+
crossAxisAlignment: CrossAxisAlignment.start,
33+
children: [
34+
Container(
35+
padding: EdgeInsets.all(20),
36+
width: double.infinity,
37+
height: 350,
38+
decoration: BoxDecoration(
39+
image: DecorationImage(
40+
image: AssetImage('assets/images/background.png'),
41+
fit: BoxFit.cover,
42+
),
43+
),
44+
child: Column(
45+
crossAxisAlignment: CrossAxisAlignment.start,
46+
children: [
47+
SizedBox(height: 80,),
48+
Text("Find your 2021 Collections", style: TextStyle(color: Colors.black, fontSize: 40, height: 1.4),),
49+
SizedBox(height: 40,),
50+
Container(
51+
width: double.infinity,
52+
height: 60,
53+
child: Row(
54+
children: [
55+
Expanded(
56+
child: Container(
57+
height: 60,
58+
child: TextField(
59+
cursorColor: Colors.grey,
60+
decoration: InputDecoration(
61+
contentPadding: EdgeInsets.symmetric(horizontal: 20, vertical: 20),
62+
filled: true,
63+
fillColor: Colors.white,
64+
prefixIcon: Icon(Icons.search, color: Colors.black),
65+
border: OutlineInputBorder(
66+
borderRadius: BorderRadius.circular(10),
67+
borderSide: BorderSide.none
68+
),
69+
hintText: "Search e.g Login Page",
70+
hintStyle: TextStyle(fontSize: 14, color: Colors.black),
71+
72+
),
73+
),
74+
),
75+
),
76+
SizedBox(width: 20),
77+
Container(
78+
padding: EdgeInsets.all(10),
79+
decoration: BoxDecoration(
80+
color: Colors.white,
81+
borderRadius: BorderRadius.circular(10)
82+
),
83+
child: IconButton(
84+
onPressed: () {},
85+
icon: Icon(Icons.filter_list, size: 30,),
86+
),
87+
)
88+
],
89+
),
90+
),
91+
],
92+
),
10293
),
10394
],
10495
),
10596
),
106-
floatingActionButton: FloatingActionButton(
107-
onPressed: _incrementCounter,
108-
tooltip: 'Increment',
109-
child: Icon(Icons.add),
110-
), // This trailing comma makes auto-formatting nicer for build methods.
97+
bottomNavigationBar: FlashyTabBar(
98+
selectedIndex: _selectedIndex,
99+
showElevation: false,
100+
onItemSelected: (index) => _onItemTapped(index),
101+
items: [
102+
FlashyTabBarItem(
103+
icon: Icon(Icons.home_outlined, size: 25),
104+
title: Text('Home'),
105+
),
106+
FlashyTabBarItem(
107+
icon: Icon(Icons.search, size: 25),
108+
title: Text('Search'),
109+
),
110+
FlashyTabBarItem(
111+
icon: Icon(Icons.notifications_outlined, size: 25),
112+
title: Text('Notifications'),
113+
),
114+
FlashyTabBarItem(
115+
icon: Icon(Icons.account_circle_outlined, size: 25,),
116+
title: Text('Profile'),
117+
),
118+
],
119+
),
111120
);
112121
}
113122
}

0 commit comments

Comments
 (0)