1
+ import 'package:day34/pages/explore.dart' ;
2
+ import 'package:day34/pages/notification.dart' ;
3
+ import 'package:day34/pages/profile.dart' ;
4
+ import 'package:day34/pages/search.dart' ;
1
5
import 'package:flashy_tab_bar/flashy_tab_bar.dart' ;
2
6
import 'package:flutter/material.dart' ;
3
7
@@ -16,86 +20,42 @@ class HomePage extends StatefulWidget {
16
20
}
17
21
18
22
class _HomePageState extends State <HomePage > {
19
- int _selectedIndex = 0 ;
23
+ late PageController _myPage;
24
+ int _selectedPage = 0 ;
25
+
26
+ List <Widget > pages = [
27
+ ExplorePage (),
28
+ SearchPage (),
29
+ NotificationPage (),
30
+ ProfilePage ()
31
+ ];
20
32
21
33
void _onItemTapped (int index) {
22
34
setState (() {
23
- _selectedIndex = index;
35
+ _selectedPage = index;
36
+ _myPage.jumpToPage (index);
24
37
});
25
38
}
26
39
40
+ @override
41
+ void initState () {
42
+ // TODO: implement initState
43
+ _myPage = PageController (initialPage: 0 );
44
+
45
+ super .initState ();
46
+ }
47
+
27
48
@override
28
49
Widget build (BuildContext context) {
29
50
return Scaffold (
30
- body: SingleChildScrollView (
31
- child: Column (
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
- ),
93
- ),
94
- ],
95
- ),
51
+ body: PageView (
52
+ controller: _myPage,
53
+ children: [
54
+ ...pages
55
+ ],
96
56
),
97
57
bottomNavigationBar: FlashyTabBar (
98
- selectedIndex: _selectedIndex ,
58
+ selectedIndex: _selectedPage ,
99
59
showElevation: false ,
100
60
onItemSelected: (index) => _onItemTapped (index),
101
61
items: [
0 commit comments