From 3363d514a07d52ec451fe094c6d9edd3ce4a2bc8 Mon Sep 17 00:00:00 2001 From: Benjamin Ramhorst Date: Wed, 9 Feb 2022 16:06:37 +0000 Subject: [PATCH] Added functionality for switching between pages --- lib/data.dart | 10 ++++++++++ lib/home.dart | 26 +++++++++++++++++++------- lib/map.dart | 10 ++++++++++ lib/settings.dart | 10 ++++++++++ lib/steps.dart | 10 ++++++++++ 5 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 lib/data.dart create mode 100644 lib/map.dart create mode 100644 lib/settings.dart create mode 100644 lib/steps.dart diff --git a/lib/data.dart b/lib/data.dart new file mode 100644 index 0000000..c34dc40 --- /dev/null +++ b/lib/data.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class DataPage extends StatelessWidget { + const DataPage({ Key? key }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Text("Data Page"); + } +} \ No newline at end of file diff --git a/lib/home.dart b/lib/home.dart index b164f41..3d4022b 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -1,4 +1,8 @@ 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'; class HomeScreen extends StatefulWidget { const HomeScreen({Key? key}) : super(key: key); @@ -8,21 +12,27 @@ class HomeScreen extends StatefulWidget { } class _HomeScreenState extends State { - int page = 0; - PageController pageController = PageController(); + int _page = 0; + PageController _pageController = PageController(); - void onBottomBarPressed(int newPage) { + void onBottomBarPressed(int page) { setState(() { - page = newPage; + _page = page; }); - pageController.jumpToPage(newPage); + _pageController.jumpToPage(page); } @override Widget build(BuildContext context) { return Scaffold( body: PageView( - controller: pageController, + controller: _pageController, + children: const [ + DataPage(), + StepsPage(), + MapPage(), + SettingsPage() + ], ), bottomNavigationBar: BottomNavigationBar( items: const [ @@ -31,9 +41,11 @@ class _HomeScreenState extends State { BottomNavigationBarItem(icon: Icon(Icons.location_on_outlined), label: 'Location'), BottomNavigationBarItem(icon: Icon(Icons.settings), label: 'Settings'), ], - currentIndex: page, + currentIndex: _page, selectedItemColor: Colors.green, unselectedItemColor: Colors.black, + showSelectedLabels: true, + showUnselectedLabels: false, backgroundColor: Colors.white, onTap: onBottomBarPressed, type: BottomNavigationBarType.fixed, diff --git a/lib/map.dart b/lib/map.dart new file mode 100644 index 0000000..5530505 --- /dev/null +++ b/lib/map.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class MapPage extends StatelessWidget { + const MapPage({ Key? key }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Text("Map Page"); + } +} \ No newline at end of file diff --git a/lib/settings.dart b/lib/settings.dart new file mode 100644 index 0000000..62c3525 --- /dev/null +++ b/lib/settings.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class SettingsPage extends StatelessWidget { + const SettingsPage({ Key? key }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Text("Settings Page"); + } +} \ No newline at end of file diff --git a/lib/steps.dart b/lib/steps.dart new file mode 100644 index 0000000..061f763 --- /dev/null +++ b/lib/steps.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class StepsPage extends StatelessWidget { + const StepsPage({ Key? key }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Text("Data Page"); + } +} \ No newline at end of file