2019-05-08 19:54:14 +01:00
import ' package:flutter/material.dart ' ;
2019-08-05 09:33:39 +01:00
import ' package:local_spend/pages/receipt_page_2.dart ' ;
2019-07-16 15:12:16 +01:00
import ' package:local_spend/pages/more_page.dart ' ;
import ' package:local_spend/pages/stats_page.dart ' ;
2019-08-21 12:35:21 +01:00
import ' package:local_spend/pages/map_page.dart ' ;
2019-07-15 12:09:10 +01:00
class HomePage extends StatelessWidget {
2019-08-21 14:53:52 +01:00
static String _title = ' SpendTracker ' ;
2019-05-08 19:54:14 +01:00
@ override
2019-07-15 12:09:10 +01:00
Widget build ( BuildContext context ) {
return MaterialApp (
title: _title ,
home: HomePageWidget ( ) ,
) ;
}
2019-05-08 19:54:14 +01:00
}
2019-07-15 12:09:10 +01:00
class HomePageWidget extends StatefulWidget {
HomePageWidget ( { Key key } ) : super ( key: key ) ;
2019-07-05 13:39:24 +01:00
2019-07-15 12:09:10 +01:00
@ override
_HomePageState createState ( ) = > _HomePageState ( ) ;
}
2019-05-08 19:54:14 +01:00
2019-07-15 12:09:10 +01:00
class _HomePageState extends State < HomePageWidget > {
int _selectedIndex = 0 ;
2019-08-21 12:35:21 +01:00
2019-07-15 12:09:10 +01:00
static const TextStyle optionStyle =
2019-08-21 14:53:52 +01:00
TextStyle ( fontSize: 30 , fontWeight: FontWeight . bold ) ;
2019-07-15 12:09:10 +01:00
static List < Widget > _widgetOptions = < Widget > [
2019-08-05 09:33:39 +01:00
ReceiptPage2 ( ) ,
2019-07-16 15:12:16 +01:00
StatsPage ( ) ,
2019-08-21 14:53:52 +01:00
MapSample ( ) ,
2019-07-16 15:12:16 +01:00
MorePage ( )
2019-07-15 12:09:10 +01:00
] ;
void _onItemTapped ( int index ) {
setState ( ( ) {
_selectedIndex = index ;
} ) ;
2019-05-08 19:54:14 +01:00
}
@ override
Widget build ( BuildContext context ) {
2019-08-21 12:35:21 +01:00
2019-07-15 12:09:10 +01:00
return Scaffold (
body: Center (
child: _widgetOptions . elementAt ( _selectedIndex ) ,
2019-05-08 19:54:14 +01:00
) ,
2019-07-15 12:09:10 +01:00
bottomNavigationBar: BottomNavigationBar (
items: const < BottomNavigationBarItem > [
BottomNavigationBarItem (
icon: Icon ( Icons . receipt ) ,
title: Text ( ' Submit Receipt ' ) ,
2019-05-08 19:54:14 +01:00
) ,
2019-07-16 15:12:16 +01:00
BottomNavigationBarItem (
icon: Icon ( Icons . show_chart ) ,
title: Text ( ' Statistics ' ) ,
) ,
2019-08-21 12:35:21 +01:00
BottomNavigationBarItem (
icon: Icon ( Icons . map ) ,
title: Text ( ' Locations ' ) ,
) ,
2019-07-15 12:09:10 +01:00
BottomNavigationBarItem (
2019-07-15 14:59:09 +01:00
icon: Icon ( Icons . more_horiz ) ,
title: Text ( ' More ' ) ,
2019-07-15 12:09:10 +01:00
) ,
] ,
currentIndex: _selectedIndex ,
2019-08-21 12:35:21 +01:00
unselectedItemColor: Colors . grey [ 400 ] ,
2019-07-15 12:09:10 +01:00
selectedItemColor: Colors . blue [ 400 ] ,
onTap: _onItemTapped ,
2019-05-08 19:54:14 +01:00
) ,
) ;
}
2019-08-21 14:53:52 +01:00
}