75 lines
1.9 KiB
Dart
75 lines
1.9 KiB
Dart
import 'package:ernaehrung/pages/nav_pages/progress_page.dart';
|
|
import 'package:ernaehrung/pages/nav_pages/today_page.dart';
|
|
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();
|
|
}
|
|
|
|
class MainPageState extends State<MainPage> {
|
|
List pages = [
|
|
const TodayPage(title: 'Today',),
|
|
const MealPlanPage(title: 'Meal Plan'),
|
|
const ProgressPage(title: 'Progress',)
|
|
];
|
|
|
|
int currentIndex = 0;
|
|
void onTap(int index){
|
|
setState(() {
|
|
currentIndex = index;
|
|
getPageWithOrOutPadding();
|
|
});
|
|
}
|
|
|
|
Widget getPageWithOrOutPadding(){
|
|
if (pages[currentIndex] is TodayPage){
|
|
return Placeholder(
|
|
child: pages[currentIndex],
|
|
);
|
|
}else{
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 0, horizontal: 8),
|
|
child: pages[currentIndex],
|
|
);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Title'),
|
|
),
|
|
body: getPageWithOrOutPadding(),
|
|
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'
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|