File tree Expand file tree Collapse file tree 3 files changed +50
-24
lines changed
Expand file tree Collapse file tree 3 files changed +50
-24
lines changed Original file line number Diff line number Diff line change 11import 'package:flutter/material.dart' ;
22import 'package:flutter_bloc/flutter_bloc.dart' ;
3+ import 'package:tmdb_flutter/app/view/main_page.dart' ;
34import 'api/movie_api.dart' ;
45import 'cubit/home_cubit.dart' ;
56import 'view/home_page.dart' ;
@@ -17,7 +18,7 @@ class App extends StatelessWidget {
1718 ),
1819 home: BlocProvider (
1920 create: (context) => HomeCubit (MovieAPI ()),
20- child: const HomePage (),
21+ child: const MainPage (),
2122 ),
2223 );
2324 }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import 'package:flutter/material.dart' ;
2+ import 'package:tmdb_flutter/app/view/favorites_page.dart' ;
3+ import 'package:tmdb_flutter/app/view/home_page.dart' ;
4+
5+ class MainPage extends StatefulWidget {
6+ const MainPage ({super .key});
7+
8+ @override
9+ State <MainPage > createState () => _MainPageState ();
10+ }
11+
12+ class _MainPageState extends State <MainPage > {
13+ int _selectedIndex = 0 ;
14+
15+ final List <Widget > _pages = const [
16+ HomePage (),
17+ FavoritesPage (),
18+ ];
19+
20+ void _onItemTapped (int index) {
21+ setState (() {
22+ _selectedIndex = index;
23+ });
24+ }
25+
26+ @override
27+ Widget build (BuildContext context) {
28+ return Scaffold (
29+ body: _pages[_selectedIndex],
30+ bottomNavigationBar: BottomNavigationBar (
31+ items: const < BottomNavigationBarItem > [
32+ BottomNavigationBarItem (
33+ icon: Icon (Icons .home),
34+ label: 'Home' ,
35+ ),
36+ BottomNavigationBarItem (
37+ icon: Icon (Icons .favorite),
38+ label: 'Favorites' ,
39+ ),
40+ ],
41+ currentIndex: _selectedIndex,
42+ selectedItemColor: Colors .pinkAccent,
43+ unselectedItemColor: Colors .grey,
44+ onTap: _onItemTapped,
45+ ),
46+ );
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments