2019-07-16 14:12:16 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:local_spend/common/platform/platform_scaffold.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2019-08-19 14:02:02 +00:00
|
|
|
import 'package:local_spend/pages/customerGraphs.dart';
|
|
|
|
import 'package:local_spend/pages/orgGraphs.dart';
|
2019-07-16 14:12:16 +00: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-08-19 14:02:02 +00:00
|
|
|
String userType = "-";
|
2019-07-18 11:05:09 +00:00
|
|
|
|
2019-07-16 14:12:16 +00: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);
|
|
|
|
}
|
|
|
|
|
2019-08-19 14:02:02 +00:00
|
|
|
Future<String> _getUserType() async {
|
|
|
|
SharedPreferences preferences = await SharedPreferences.getInstance();
|
|
|
|
return await preferences.get('LastUserType');
|
|
|
|
}
|
|
|
|
|
2019-07-16 14:12:16 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2019-08-19 14:02:02 +00:00
|
|
|
if (userType == "-") {
|
|
|
|
_getUserType().then((value) {
|
|
|
|
print(value);
|
|
|
|
userType = '${value[0].toUpperCase()}${value.substring(1)}'; // capitalises first letter
|
2019-08-12 15:03:00 +00:00
|
|
|
setState(() {});
|
|
|
|
});
|
|
|
|
}
|
2019-07-18 11:05:09 +00:00
|
|
|
|
2019-07-16 14:12:16 +00:00
|
|
|
return PlatformScaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
backgroundColor: Colors.blue[400],
|
2019-08-19 14:02:02 +00:00
|
|
|
title: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Statistics",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 20,
|
|
|
|
color: Colors.white,
|
2019-08-19 10:58:26 +00:00
|
|
|
),
|
2019-08-16 15:44:24 +00:00
|
|
|
),
|
2019-08-19 14:02:02 +00:00
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10)
|
2019-08-16 15:44:24 +00:00
|
|
|
),
|
|
|
|
|
2019-08-19 14:02:02 +00:00
|
|
|
Text(
|
|
|
|
"User type: " + userType,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 20,
|
|
|
|
color: Colors.white70,
|
2019-08-19 10:58:26 +00:00
|
|
|
),
|
2019-07-17 11:31:28 +00:00
|
|
|
),
|
2019-07-16 14:12:16 +00:00
|
|
|
],
|
|
|
|
),
|
2019-08-19 14:02:02 +00:00
|
|
|
centerTitle: true,
|
|
|
|
iconTheme: IconThemeData(color: Colors.black),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
body : Container(
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
|
|
|
|
child: (userType == "-" ? null : (userType.toLowerCase() == "customer" ? CustomerGraphs() : OrgGraphs())),
|
2019-07-16 14:12:16 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|