ELEC60013-ES-CW1/lib/home.dart

58 lines
1.6 KiB
Dart
Raw Normal View History

2022-02-09 15:50:52 +00:00
import 'package:flutter/material.dart';
import 'package:leg_barkr_app/data.dart';
import 'package:leg_barkr_app/steps.dart';
import 'package:leg_barkr_app/map.dart';
import 'package:leg_barkr_app/settings.dart';
2022-02-09 15:50:52 +00:00
class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
int _page = 0;
PageController _pageController = PageController();
2022-02-09 15:50:52 +00:00
void onBottomBarPressed(int page) {
2022-02-09 15:50:52 +00:00
setState(() {
_page = page;
2022-02-09 15:50:52 +00:00
});
_pageController.jumpToPage(page);
2022-02-09 15:50:52 +00:00
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: PageView(
controller: _pageController,
children: const <Widget>[
DataPage(),
StepsPage(),
MapPage(),
SettingsPage()
],
2022-02-09 15:50:52 +00:00
),
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(icon: Icon(Icons.data_usage), label: 'Home'),
BottomNavigationBarItem(icon: Icon(Icons.search), label: 'Search'),
BottomNavigationBarItem(icon: Icon(Icons.location_on_outlined), label: 'Location'),
BottomNavigationBarItem(icon: Icon(Icons.settings), label: 'Settings'),
],
currentIndex: _page,
2022-02-09 15:50:52 +00:00
selectedItemColor: Colors.green,
unselectedItemColor: Colors.black,
showSelectedLabels: true,
showUnselectedLabels: false,
2022-02-09 15:50:52 +00:00
backgroundColor: Colors.white,
onTap: onBottomBarPressed,
type: BottomNavigationBarType.fixed,
)
);
}
}