Flutter-Ernaehrungsapp/lib/android/pages/nav_pages/main_page.dart

64 lines
1.6 KiB
Dart
Raw Normal View History

import 'package:ernaehrung/android/pages/nav_pages/progress_page.dart';
import 'package:ernaehrung/android/pages/nav_pages/today_page.dart';
2023-04-23 13:08:04 +02:00
import 'package:flutter/material.dart';
import 'meal_plan_page.dart';
class MainPage extends StatefulWidget {
const MainPage({Key? key}) : super(key: key);
@override
MainPageState createState() => MainPageState();
2023-04-23 13:08:04 +02:00
}
class MainPageState extends State<MainPage> {
2023-04-23 13:08:04 +02:00
List pages = [
const TodayPage(title: 'Today'),
2023-04-23 13:08:04 +02:00
const MealPlanPage(title: 'Meal Plan'),
const ProgressPage(title: 'Progress')
2023-04-23 13:08:04 +02:00
];
int currentIndex = 0;
void onTap(int index){
setState(() {
currentIndex = index;
pages[currentIndex];
2023-04-23 13:08:04 +02:00
});
}
2023-04-23 13:08:04 +02:00
@override
Widget build(BuildContext context) {
2023-04-23 13:08:04 +02:00
return Scaffold(
appBar: AppBar(
title: Text(pages[currentIndex].title),
backgroundColor: pages[currentIndex].backgroundColor
2023-04-23 13:08:04 +02:00
),
body: pages[currentIndex],
2023-04-23 13:08:04 +02:00
bottomNavigationBar: BottomNavigationBar(
currentIndex: currentIndex,
selectedItemColor: Colors.black54,
unselectedItemColor: Colors.grey.withOpacity(0.5),
showSelectedLabels: false,
showUnselectedLabels: false,
elevation: 0,
onTap: onTap,
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.today),
label: 'Today'
),
BottomNavigationBarItem(
icon: Icon(Icons.area_chart),
label: 'Progress'
),
BottomNavigationBarItem(
icon: Icon(Icons.apple),
label: 'Meal Plan'
),
],
),
);
}
}