166 Start
parent
9f74693b2f
commit
ac8a7a4b96
@ -0,0 +1,54 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_navigation/screens/categories.dart';
|
||||
import 'package:flutter_navigation/screens/meals.dart';
|
||||
|
||||
class TabsScreen extends StatefulWidget {
|
||||
const TabsScreen({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _TabsScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _TabsScreenState extends State<TabsScreen> {
|
||||
int _selectedPageIndex = 0;
|
||||
|
||||
void _selectPage(int index) {
|
||||
setState(() {
|
||||
_selectedPageIndex = index;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget activePage = const CategoriesScreen();
|
||||
var activePageTitle = 'Categories';
|
||||
|
||||
if (_selectedPageIndex == 1) {
|
||||
activePage = const MealsScreen(meals: []);
|
||||
activePageTitle = 'Your Favorites';
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(activePageTitle),
|
||||
),
|
||||
body: activePage,
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
onTap: _selectPage,
|
||||
currentIndex: _selectedPageIndex,
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.set_meal),
|
||||
label: 'Categories',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.star),
|
||||
label: 'Favorites',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue