This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
LocalSpend-Tracker/lib/pages/stats_page.dart

90 lines
2.3 KiB
Dart
Raw Normal View History

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/pages/customerGraphs.dart';
import 'package:local_spend/pages/orgGraphs.dart';
const URL = "https://flutter.io/";
const demonstration = false;
class StatsPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return new StatsPageState();
}
}
class StatsPageState extends State<StatsPage> {
String userType = "-";
@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);
}
Future<String> _getUserType() async {
SharedPreferences preferences = await SharedPreferences.getInstance();
return await preferences.get('LastUserType');
}
@override
Widget build(BuildContext context) {
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(() {});
});
}
return PlatformScaffold(
appBar: AppBar(
backgroundColor: Colors.blue[400],
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
),
Padding(
2019-08-19 14:32:54 +00:00
padding: EdgeInsets.symmetric(horizontal: 4)
2019-08-16 15:44:24 +00:00
),
Text(
2019-08-19 14:32:54 +00:00
userType,
style: TextStyle(
fontSize: 20,
color: Colors.white70,
2019-08-19 10:58:26 +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())),
),
);
}
}