many UI improvements and subtle tweaks

This commit is contained in:
Felix 2019-08-20 13:54:45 +01:00
parent 9a5bfbaaf0
commit 231ed2c9df
15 changed files with 191 additions and 153 deletions

View file

@ -5,7 +5,7 @@ import 'package:local_spend/common/functions/get_token.dart';
import 'package:flutter/material.dart';
Future<List<String>> getCategories() async {
const url = "https://dev.peartrade.org/api/search/category";
const url = "https://dev.localspend.co.uk/api/search/category";
var token;
await getToken().then((result) {

View file

@ -64,7 +64,7 @@ class Organisations {
}
Future<List<Organisation>> findOrganisations(String search) async {
final url = "https://dev.peartrade.org/api/search";
final url = "https://dev.localspend.co.uk/api/search";
var token;
await getToken().then((result) {

View file

@ -28,7 +28,7 @@ class GraphData {
];
}
final url = "https://dev.peartrade.org/api/v1/customer/graphs";
final url = "https://dev.localspend.co.uk/api/v1/customer/graphs";
SharedPreferences preferences = await SharedPreferences.getInstance();
Map<String, String> body = {
@ -88,13 +88,13 @@ class GraphData {
// TODO: Show available graph types based on whether or not the user is an Organisation or User
/// Customer graph types: https://dev.peartrade.org/api/v1/customer/graphs
/// Customer graph types: https://dev.localspend.co.uk/api/v1/customer/graphs
/// - total_last_week
/// - avg_spend_last_week
/// - total_last_month
/// - avg_spend_last_month
///
/// Organisations' graphs types: to fetch, POST to https://dev.peartrade.org/api/stats/[name] as {"session_key":"[boop beep]"}
/// Organisations' graphs types: to fetch, POST to https://dev.localspend.co.uk/api/stats/[name] as {"session_key":"[boop beep]"}
/// - organisations_all : organisation
/// - pies : organisation/pies
/// - snippets : organisation/snippets
@ -110,7 +110,7 @@ class GraphData {
/// HTTP POST request sample:
/// {"graph":"total_last_week","session_key":"blahblahblah"}
final url = "https://dev.peartrade.org/api/v1/customer/graphs";
final url = "https://dev.localspend.co.uk/api/v1/customer/graphs";
SharedPreferences preferences = await SharedPreferences.getInstance();
Map<String, String> body = {
@ -182,7 +182,7 @@ class OrgGraphData {
];
}
final url = "https://dev.peartrade.org/api/v1/customer/graphs";
final url = "https://dev.localspend.co.uk/api/v1/customer/graphs";
SharedPreferences preferences = await SharedPreferences.getInstance();
Map<String, String> body = {
@ -242,13 +242,13 @@ class OrgGraphData {
// TODO: Show available graph types based on whether or not the user is an Organisation or User
/// Customer graph types: https://dev.peartrade.org/api/v1/customer/graphs
/// Customer graph types: https://dev.localspend.co.uk/api/v1/customer/graphs
/// - total_last_week
/// - avg_spend_last_week
/// - total_last_month
/// - avg_spend_last_month
///
/// Organisations' graphs types: to fetch, POST to https://dev.peartrade.org/api/stats/[name] as {"session_key":"[boop beep]"}
/// Organisations' graphs types: to fetch, POST to https://dev.localspend.co.uk/api/stats/[name] as {"session_key":"[boop beep]"}
/// - organisations_all : organisation
/// - pies : organisation/pies
/// - snippets : organisation/snippets
@ -264,7 +264,7 @@ class OrgGraphData {
/// HTTP POST request sample:
/// {"graph":"total_last_week","session_key":"blahblahblah"}
final url = "https://dev.peartrade.org/api/v1/customer/graphs";
final url = "https://dev.localspend.co.uk/api/v1/customer/graphs";
SharedPreferences preferences = await SharedPreferences.getInstance();
Map<String, String> body = {

View file

@ -11,26 +11,27 @@ Future<void> _incorrectDialog(BuildContext context, bool isLoginWrong) async {
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return AlertDialog(
title: Text("Unable to Login"),
content: Text(isLoginWrong ? "Incorrect login details. Please try again." : "Our servers are having issues at the moment; sorry for the inconvenience. Please try again later."),
actions: <Widget>[
FlatButton(
child: Text('OK'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
return AnimatedContainer(
duration: Duration(seconds: 2),
child : AlertDialog(
title: Text("Uh-oh!"),
content: Text(isLoginWrong ? "Incorrect login details. Please try again." : "Our servers are having issues at the moment; sorry for the inconvenience. Please try again later."),
actions: <Widget>[
FlatButton(
child: Text('OK'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
),
);
},
);
}
Future<LoginModel> requestLoginAPI(
BuildContext context, String email, String password) async {
//var apiUrl = ConfigWrapper.of(context).apiKey;
final url = "https://dev.peartrade.org/api/login";
Future<LoginModel> requestLoginAPI(BuildContext context, String email, String password) async {
final url = "https://dev.localspend.co.uk/api/login";
Map<String, String> body = {
'email': email,
@ -43,7 +44,7 @@ Future<LoginModel> requestLoginAPI(
final response = await http.post(
url,
body: json.encode(body),
);
).timeout(Duration(seconds: 5));
if (response.statusCode == 200) {
final responseJson = json.decode(response.body);
@ -61,6 +62,8 @@ Future<LoginModel> requestLoginAPI(
return null;
}
} on TimeoutException catch (_) {
_incorrectDialog(context, false);
} catch (error) {
debugPrint(error.toString());
_incorrectDialog(context, false);

View file

@ -8,7 +8,7 @@ import 'package:local_spend/common/functions/save_logout.dart';
import 'package:local_spend/model/json/login_model.dart';
Future<LoginModel> requestLogoutAPI(BuildContext context) async {
final url = "https://dev.peartrade.org/api/logout";
final url = "https://dev.localspend.co.uk/api/logout";
var token;

View file

@ -23,7 +23,7 @@ class Receipt {
Future<LoginModel> submitReceiptAPI(
BuildContext context, Receipt receipt) async {
//var apiUrl = ConfigWrapper.of(context).apiKey;
final url = "https://dev.peartrade.org/api/upload";
final url = "https://dev.localspend.co.uk/api/upload";
SharedPreferences preferences = await SharedPreferences.getInstance();

View file

@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:simple_animations/simple_animations.dart';
class AnimatedBackground extends StatelessWidget {
@override
Widget build(BuildContext context) {
final tween = MultiTrackTween([
Track("color1").add(Duration(seconds: 4),
ColorTween(begin: Colors.lightBlue, end: Colors.lightBlue[300])),
]);
return ControlledAnimation(
playback: Playback.MIRROR,
tween: tween,
duration: tween.duration,
builder: (context, animation) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [animation["color1"], Colors.lightBlue])),
);
},
);
}
}