Maps, optimization, testing, code cleanup
This commit is contained in:
parent
c6e69b037b
commit
a512549778
29 changed files with 257 additions and 176 deletions
|
@ -76,10 +76,10 @@ class _CustomerGraphsState extends State<CustomerGraphs> {
|
|||
child: totalLastWeekGraph.graph != null
|
||||
? new charts.TimeSeriesChart(totalLastWeekGraph.graph)
|
||||
: Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: new AlwaysStoppedAnimation<Color>(Colors.orange),
|
||||
)
|
||||
), //List<Series<dynamic, DateTime>>es<dynamic, DateTime>>
|
||||
child: CircularProgressIndicator(
|
||||
valueColor:
|
||||
new AlwaysStoppedAnimation<Color>(Colors.orange),
|
||||
)), //List<Series<dynamic, DateTime>>es<dynamic, DateTime>>
|
||||
),
|
||||
),
|
||||
Container(
|
||||
|
@ -103,9 +103,8 @@ class _CustomerGraphsState extends State<CustomerGraphs> {
|
|||
? new charts.TimeSeriesChart(avgSpendLastWeekGraph.graph)
|
||||
: Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: new AlwaysStoppedAnimation<Color>(Colors.blue),
|
||||
)
|
||||
), //List<Series<dynamic, DateTime>>es<dynamic, DateTime>>
|
||||
valueColor: new AlwaysStoppedAnimation<Color>(Colors.blue),
|
||||
)), //List<Series<dynamic, DateTime>>es<dynamic, DateTime>>
|
||||
),
|
||||
),
|
||||
Container(
|
||||
|
@ -128,10 +127,9 @@ class _CustomerGraphsState extends State<CustomerGraphs> {
|
|||
child: totalLastMonthGraph.graph != null
|
||||
? new charts.TimeSeriesChart(totalLastMonthGraph.graph)
|
||||
: Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: new AlwaysStoppedAnimation<Color>(Colors.green),
|
||||
)
|
||||
), //List<Series<dynamic, DateTime>>es<dynamic, DateTime>>
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: new AlwaysStoppedAnimation<Color>(Colors.green),
|
||||
)), //List<Series<dynamic, DateTime>>es<dynamic, DateTime>>
|
||||
),
|
||||
),
|
||||
Container(
|
||||
|
@ -154,10 +152,9 @@ class _CustomerGraphsState extends State<CustomerGraphs> {
|
|||
child: avgSpendLastMonth.graph != null
|
||||
? new charts.TimeSeriesChart(avgSpendLastMonth.graph)
|
||||
: Center(
|
||||
child: CircularProgressIndicator(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: new AlwaysStoppedAnimation<Color>(Colors.red),
|
||||
)
|
||||
), //List<Series<dynamic, DateTime>>es<dynamic, DateTime>>
|
||||
)), //List<Series<dynamic, DateTime>>es<dynamic, DateTime>>
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -31,7 +31,7 @@ class _HomePageState extends State<HomePageWidget> {
|
|||
static List<Widget> _widgetOptions = <Widget>[
|
||||
ReceiptPage2(),
|
||||
StatsPage(),
|
||||
MapSample(),
|
||||
MapPage(),
|
||||
MorePage()
|
||||
];
|
||||
|
||||
|
@ -43,7 +43,6 @@ class _HomePageState extends State<HomePageWidget> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: _widgetOptions.elementAt(_selectedIndex),
|
||||
|
|
|
@ -20,10 +20,8 @@ class LoginPage extends StatefulWidget {
|
|||
|
||||
class LoginPageState extends State<LoginPage> {
|
||||
bool _isLoggingIn = false;
|
||||
final TextEditingController _emailController =
|
||||
TextEditingController();
|
||||
final TextEditingController _passwordController =
|
||||
TextEditingController();
|
||||
final TextEditingController _emailController = TextEditingController();
|
||||
final TextEditingController _passwordController = TextEditingController();
|
||||
bool _saveLoginDetails = true;
|
||||
|
||||
FocusNode focusNode; // added so focus can move automatically
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart' as gmaps;
|
||||
import 'package:local_spend/common/apifunctions/get_map_data.dart' as mapData;
|
||||
import 'package:local_spend/common/platform/platform_scaffold.dart';
|
||||
|
||||
class MapPage extends StatefulWidget {
|
||||
|
@ -13,13 +14,32 @@ class MapPage extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _MapPageState extends State<MapPage> {
|
||||
final Map<String, gmaps.Marker> _markers = {};
|
||||
Future<void> _onMapCreated(gmaps.GoogleMapController controller) async {
|
||||
final region = await controller.getVisibleRegion();
|
||||
final locations = await mapData.getLocations(region.northeast, region.southwest);
|
||||
setState(() {
|
||||
_markers.clear();
|
||||
for (final location in locations.locations) {
|
||||
final marker = gmaps.Marker(
|
||||
markerId: gmaps.MarkerId(location.organisation.name),
|
||||
position: gmaps.LatLng(location.lat, location.lng),
|
||||
infoWindow: gmaps.InfoWindow(
|
||||
title: location.organisation.name,
|
||||
snippet: location.organisation.postcode,
|
||||
),
|
||||
);
|
||||
_markers[location.organisation.name] = marker;
|
||||
}
|
||||
});
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PlatformScaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.blue[400],
|
||||
title: Text(
|
||||
"Submit Receipt",
|
||||
"Map",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.white,
|
||||
|
@ -28,34 +48,15 @@ class _MapPageState extends State<MapPage> {
|
|||
centerTitle: true,
|
||||
iconTheme: IconThemeData(color: Colors.black),
|
||||
),
|
||||
body: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MapSample extends StatefulWidget {
|
||||
@override
|
||||
State<MapSample> createState() => MapSampleState();
|
||||
}
|
||||
|
||||
class MapSampleState extends State<MapSample> {
|
||||
Completer<GoogleMapController> _controller = Completer();
|
||||
|
||||
static final CameraPosition _kGooglePlex = CameraPosition(
|
||||
target: LatLng(37.42796133580664, -122.085749655962),
|
||||
zoom: 14.4746,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
// body: GoogleMap(
|
||||
// mapType: MapType.hybrid,
|
||||
// initialCameraPosition: _kGooglePlex,
|
||||
// onMapCreated: (GoogleMapController controller) {
|
||||
// _controller.complete(controller);
|
||||
// },
|
||||
// ),
|
||||
body: gmaps.GoogleMap(
|
||||
myLocationButtonEnabled: false,
|
||||
mapType: gmaps.MapType.hybrid,
|
||||
onMapCreated: _onMapCreated,
|
||||
initialCameraPosition: gmaps.CameraPosition(
|
||||
target: gmaps.LatLng(54.0411301, -2.8104042),
|
||||
zoom: 15,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ class MorePageState extends State<MorePage> {
|
|||
height: 35,
|
||||
child: RaisedButton(
|
||||
onPressed: () => {},
|
||||
// launch(- something -),
|
||||
child: Text("Contact us",
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 18.0)),
|
||||
|
@ -120,25 +121,6 @@ class MorePageState extends State<MorePage> {
|
|||
onPressed: () =>
|
||||
launch('http://www.peartrade.org')),
|
||||
),
|
||||
Container(
|
||||
height: 35,
|
||||
margin: EdgeInsets.fromLTRB(10, 20, 10, 0),
|
||||
child: Material(
|
||||
child: OutlineButton(
|
||||
child: Text(
|
||||
'Shadowcat Systems',
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 18.0
|
||||
|
||||
/// I don't know what to do with this button
|
||||
),
|
||||
),
|
||||
onPressed: () => launch('https://shadow.cat/'),
|
||||
),
|
||||
color: Colors.lightGreenAccent,
|
||||
shadowColor: Colors.transparent,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
@ -170,6 +152,33 @@ class MorePageState extends State<MorePage> {
|
|||
),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(30.0, 20.0, 30.0, 0.0),
|
||||
child: Container(
|
||||
height: 75.0,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
onTap: () => launch('https://shadow.cat'),
|
||||
child: Column(
|
||||
children: [
|
||||
Align(
|
||||
child: Text("Developed by"),
|
||||
alignment: Alignment.centerLeft),
|
||||
FittedBox(
|
||||
fit: BoxFit.fitHeight,
|
||||
child: Image(
|
||||
image: ExactAssetImage('assets/images/text.png'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Padding(
|
||||
// padding: EdgeInsets.fromLTRB(30.0, 20.0, 30.0, 0.0),
|
||||
// child: Container(
|
||||
|
|
|
@ -12,7 +12,6 @@ class OrgGraphs extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _OrgGraphsState extends State<OrgGraphs> {
|
||||
|
||||
/// Organisations' graphs types: to fetch, POST to https://dev.localspend.co.uk/api/stats/[graph_type] as {"session_key":"[boop beep]"}
|
||||
/// - organisations_all : organisation
|
||||
/// - pies : organisation/pies
|
||||
|
@ -30,9 +29,12 @@ class _OrgGraphsState extends State<OrgGraphs> {
|
|||
/// {"graph":"total_last_week","session_key":"blahblahblah"}
|
||||
|
||||
// OrganisationGraph customersLastWeek = new OrganisationGraph("graphs", graphsType: "customers_last_7_days");
|
||||
OrganisationGraph customersLastMonth = new OrganisationGraph("graphs", graphsType: "customers_last_30_days");
|
||||
OrganisationGraph salesLastMonth = new OrganisationGraph("graphs", graphsType: "sales_last_30_days");
|
||||
OrganisationGraph purchasesLastMonth = new OrganisationGraph("graphs", graphsType: "purchases_last_30_days"); //purchases_last_30_days
|
||||
OrganisationGraph customersLastMonth =
|
||||
new OrganisationGraph("graphs", graphsType: "customers_last_30_days");
|
||||
OrganisationGraph salesLastMonth =
|
||||
new OrganisationGraph("graphs", graphsType: "sales_last_30_days");
|
||||
OrganisationGraph purchasesLastMonth = new OrganisationGraph("graphs",
|
||||
graphsType: "purchases_last_30_days"); //purchases_last_30_days
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -114,7 +116,8 @@ class _OrgGraphsState extends State<OrgGraphs> {
|
|||
child: customersLastMonth.graph != null
|
||||
? new charts.TimeSeriesChart(customersLastMonth.graph)
|
||||
: Center(
|
||||
child: CircularProgressIndicator()), //List<Series<dynamic, DateTime>>
|
||||
child:
|
||||
CircularProgressIndicator()), //List<Series<dynamic, DateTime>>
|
||||
),
|
||||
),
|
||||
|
||||
|
@ -138,9 +141,9 @@ class _OrgGraphsState extends State<OrgGraphs> {
|
|||
child: salesLastMonth.graph != null
|
||||
? new charts.TimeSeriesChart(salesLastMonth.graph)
|
||||
: Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: new AlwaysStoppedAnimation<Color>(Colors.green),
|
||||
)), //List<Series<dynamic, DateTime>>
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: new AlwaysStoppedAnimation<Color>(Colors.green),
|
||||
)), //List<Series<dynamic, DateTime>>
|
||||
),
|
||||
),
|
||||
|
||||
|
@ -164,13 +167,11 @@ class _OrgGraphsState extends State<OrgGraphs> {
|
|||
child: purchasesLastMonth.graph != null
|
||||
? new charts.TimeSeriesChart(purchasesLastMonth.graph)
|
||||
: Center(
|
||||
child: CircularProgressIndicator(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: new AlwaysStoppedAnimation<Color>(Colors.red),
|
||||
)
|
||||
), //List<Series<dynamic, DateTime>>
|
||||
)), //List<Series<dynamic, DateTime>>
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
submitReceiptAPI(context, receipt);
|
||||
}
|
||||
|
||||
List<String> _sampleRecurringOptions = new List<String>(7);
|
||||
List<String> _recurringOptions = new List<String>(7);
|
||||
List<String> _categories = new List<String>();
|
||||
|
||||
@override
|
||||
|
@ -100,13 +100,15 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var _widgetHeight = MediaQuery.of(context).size.height * 0.06 < 40.0
|
||||
? 40.0
|
||||
: MediaQuery.of(context).size.height * 0.06;
|
||||
|
||||
var _fontSize = _widgetHeight * 0.45;
|
||||
var _fontSizeButton = _widgetHeight * 0.5;
|
||||
|
||||
if (_categories.isEmpty) {
|
||||
Future<List<String>> _futureCats = getCats();
|
||||
_categories.add("Fetching categories...");
|
||||
|
@ -117,13 +119,13 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
});
|
||||
}
|
||||
|
||||
_sampleRecurringOptions[0] = "None";
|
||||
_sampleRecurringOptions[1] = "Daily";
|
||||
_sampleRecurringOptions[2] = "Weekly";
|
||||
_sampleRecurringOptions[3] = "Fortnightly";
|
||||
_sampleRecurringOptions[4] = "Monthly";
|
||||
_sampleRecurringOptions[5] = "Quarterly";
|
||||
_sampleRecurringOptions[6] = "Yearly";
|
||||
_recurringOptions[0] = "None";
|
||||
_recurringOptions[1] = "Daily";
|
||||
_recurringOptions[2] = "Weekly";
|
||||
_recurringOptions[3] = "Fortnightly";
|
||||
_recurringOptions[4] = "Monthly";
|
||||
_recurringOptions[5] = "Quarterly";
|
||||
_recurringOptions[6] = "Yearly";
|
||||
// these will be difficult to fetch from server as they are coded into the site's HTML rather than fetched
|
||||
|
||||
return PlatformScaffold(
|
||||
|
@ -175,7 +177,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
child: Text(
|
||||
"Date/Time",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontSize: _fontSize,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
|
@ -233,7 +235,8 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
: '${new DateFormat.MMMd().format(transaction.date)}' +
|
||||
" at " +
|
||||
'${new DateFormat.Hm().format(transaction.date)}',
|
||||
style: TextStyle(color: Colors.white, fontSize: 22.0),
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: _fontSizeButton),
|
||||
),
|
||||
color: Colors.blue,
|
||||
),
|
||||
|
@ -257,7 +260,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
child: Text(
|
||||
"Payee",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontSize: _fontSize,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
|
@ -291,7 +294,8 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
.substring(0, 12) +
|
||||
"..."
|
||||
: transaction.organisation.name,
|
||||
style: TextStyle(color: Colors.white, fontSize: 22.0),
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: _fontSizeButton),
|
||||
),
|
||||
color: Colors.blue,
|
||||
),
|
||||
|
@ -315,7 +319,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
child: Text(
|
||||
"Recurring",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontSize: _fontSize,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
|
@ -328,7 +332,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
width: MediaQuery.of(context).size.width * 0.6,
|
||||
child: RaisedButton(
|
||||
onPressed: () {
|
||||
transaction.recurring = _sampleRecurringOptions[0];
|
||||
transaction.recurring = _recurringOptions[0];
|
||||
setState(() {});
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
|
@ -341,13 +345,13 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
3,
|
||||
child: CupertinoPicker(
|
||||
backgroundColor: Colors.white,
|
||||
children: _sampleRecurringOptions
|
||||
children: _recurringOptions
|
||||
.map((thisOption) => Text(thisOption,
|
||||
style: TextStyle(fontSize: 30)))
|
||||
.toList(),
|
||||
onSelectedItemChanged: ((newValue) {
|
||||
transaction.recurring =
|
||||
_sampleRecurringOptions[newValue];
|
||||
_recurringOptions[newValue];
|
||||
setState(() {});
|
||||
}),
|
||||
magnification: 1.1,
|
||||
|
@ -361,7 +365,8 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
transaction.recurring == null
|
||||
? 'None'
|
||||
: transaction.recurring,
|
||||
style: TextStyle(color: Colors.white, fontSize: 22.0),
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: _fontSizeButton),
|
||||
),
|
||||
color: Colors.blue,
|
||||
),
|
||||
|
@ -383,7 +388,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
child: Text(
|
||||
"Category",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontSize: _fontSize,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
|
@ -407,7 +412,8 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
height: MediaQuery.of(context)
|
||||
.copyWith()
|
||||
.size
|
||||
.height / 3,
|
||||
.height /
|
||||
3,
|
||||
child: CupertinoPicker(
|
||||
backgroundColor: Colors.white,
|
||||
children: _categories
|
||||
|
@ -432,7 +438,8 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
transaction.category == null
|
||||
? 'None'
|
||||
: transaction.category,
|
||||
style: TextStyle(color: Colors.white, fontSize: 22.0),
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: _fontSizeButton),
|
||||
),
|
||||
color: Colors.blue,
|
||||
),
|
||||
|
@ -456,7 +463,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
child: Text(
|
||||
"Essential",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontSize: _fontSize,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
|
@ -492,7 +499,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
child: Text(
|
||||
"Amount",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontSize: _fontSize,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
|
@ -505,7 +512,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
|||
width: MediaQuery.of(context).size.width * 0.6,
|
||||
child: TextField(
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontSize: _fontSize,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
controller: transaction.amount,
|
||||
|
|
|
@ -27,10 +27,7 @@ class _SplashScreenState extends State<SplashScreen> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var drawer = Drawer();
|
||||
|
||||
return PlatformScaffold(
|
||||
drawer: drawer,
|
||||
body: Container(
|
||||
decoration: BoxDecoration(color: Colors.white),
|
||||
child: Column(
|
||||
|
@ -38,7 +35,6 @@ class _SplashScreenState extends State<SplashScreen> {
|
|||
Expanded(
|
||||
child: Container(
|
||||
margin: EdgeInsets.all(15),
|
||||
alignment: FractionalOffset(0.5, 0.3),
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/images/launch_image.png'),
|
||||
|
|
|
@ -10,8 +10,10 @@ const demonstration = false;
|
|||
class StatsPage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
print("TODO: The 'stats' page should be loaded on login and cached rather than reloading on every opening of the page.");
|
||||
print("Create new List<GraphData> in instantiated MyApp() and pass that or load it from this class' child with (graphs = super.graphList) or something.");
|
||||
print(
|
||||
"TODO: The 'stats' page should be loaded on login and cached rather than reloading on every opening of the page.");
|
||||
print(
|
||||
"Create new List<GraphData> in instantiated MyApp() and pass that or load it from this class' child with (graphs = super.graphList) or something.");
|
||||
return new StatsPageState();
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue