2019-07-16 15:12:16 +01:00
import ' package:flutter/material.dart ' ;
import ' package:local_spend/common/platform/platform_scaffold.dart ' ;
import ' package:shared_preferences/shared_preferences.dart ' ;
import ' package:local_spend/common/functions/logout.dart ' ;
import ' package:url_launcher/url_launcher.dart ' ;
import ' package:local_spend/common/functions/customAbout.dart ' as custom ;
import ' package:local_spend/common/functions/showDialogTwoButtons.dart ' ;
2019-07-17 12:31:28 +01:00
import ' package:local_spend/common/widgets/charts/donut_chart.dart ' ;
import ' package:local_spend/common/widgets/charts/outside_label.dart ' ;
import ' package:local_spend/common/widgets/charts/auto_label.dart ' ;
import ' package:local_spend/common/widgets/charts/grouped_bar_chart.dart ' ;
import ' package:local_spend/common/widgets/charts/scatter_bucketingAxis_legend.dart ' ;
import ' package:local_spend/common/widgets/charts/numeric_line_bar_combo.dart ' ;
import ' package:local_spend/common/widgets/charts/series_legend_with_measures.dart ' ;
2019-07-18 12:05:09 +01:00
import ' package:local_spend/common/widgets/charts/time_series_simple.dart ' ;
import ' package:local_spend/common/apifunctions/get_graph_data.dart ' ;
import ' package:charts_flutter/flutter.dart ' as charts ;
2019-07-18 16:38:12 +01:00
import ' package:local_spend/common/widgets/charts/chart_builder.dart ' ;
2019-07-16 15:12:16 +01:00
const URL = " https://flutter.io/ " ;
const demonstration = false ;
class StatsPage extends StatefulWidget {
@ override
State < StatefulWidget > createState ( ) {
return new StatsPageState ( ) ;
}
}
class StatsPageState extends State < StatsPage > {
2019-07-18 12:05:09 +01:00
GraphData graphData = new GraphData ( ) ;
2019-08-12 16:03:00 +01:00
List < charts . Series < dynamic , DateTime > > displayedGraphData ;
2019-07-18 12:05:09 +01:00
2019-07-16 15:12:16 +01:00
@ override
void initState ( ) {
super . initState ( ) ;
_saveCurrentRoute ( " /StatsPageState " ) ;
}
@ override
void dispose ( ) {
super . dispose ( ) ;
}
_saveCurrentRoute ( String lastRoute ) async {
SharedPreferences preferences = await SharedPreferences . getInstance ( ) ;
await preferences . setString ( ' LastPageRoute ' , lastRoute ) ;
}
@ override
Widget build ( BuildContext context ) {
2019-08-12 16:03:00 +01:00
if ( graphData . data . length = = 0 ) {
graphData . getGraphData ( ' total_last_week ' ) . then ( ( fetchedData ) {
displayedGraphData = ( fetchedData ) ;
for ( int i = 0 ; i < fetchedData [ 0 ] . data . length ; i + + ) {
print ( fetchedData [ 0 ] . data [ i ] . time ) ; // this is getting very frustrating
}
setState ( ( ) { } ) ;
} ) ;
}
2019-07-18 12:05:09 +01:00
2019-07-16 15:12:16 +01:00
return PlatformScaffold (
appBar: AppBar (
backgroundColor: Colors . blue [ 400 ] ,
title: Text (
" Statistics " ,
style: TextStyle (
fontSize: 20 ,
color: Colors . white ,
) ,
) ,
// leading: BackButton(),
centerTitle: true ,
iconTheme: IconThemeData ( color: Colors . black ) ,
) ,
2019-07-17 12:31:28 +01:00
body : Container (
padding: EdgeInsets . fromLTRB ( 0 , 0 , 0 , 0 ) ,
child: ListView (
2019-07-16 15:12:16 +01:00
children: < Widget > [
2019-07-17 12:31:28 +01:00
Container (
padding: EdgeInsets . fromLTRB ( 0.0 , 17 , 0.0 , 0.0 ) ,
child : Text (
2019-07-18 12:05:09 +01:00
" This Week's Spend " ,
2019-07-17 12:31:28 +01:00
textAlign: TextAlign . center ,
style: TextStyle (
fontSize: 22.0 ,
color: Colors . black ,
fontWeight: FontWeight . bold ,
) ,
) ,
) ,
Container (
padding: EdgeInsets . symmetric ( horizontal: 10 ) ,
height: 200 ,
// width: 250,
2019-08-12 16:03:00 +01:00
// child: new TimeSeries(),
child: displayedGraphData ! = null ? new charts . TimeSeriesChart ( displayedGraphData ) : Container ( ) , //List<Series<dynamic, DateTime>>
// child: new charts.TimeSeriesChart(displayedGraphData),
// child: new SimpleTimeSeriesChart(),//seriesList: List<charts.Series>
2019-07-17 12:31:28 +01:00
) ,
2019-07-16 15:12:16 +01:00
] ,
) ,
) ,
) ;
}
}