Skip to content

Commit

Permalink
updated ui and colour scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
SpiralArm Consulting Ltd committed Feb 2, 2019
1 parent 4585400 commit 202db87
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 119 deletions.
2 changes: 1 addition & 1 deletion ios/Runner/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ - (BOOL)application:(UIApplication *)application
methodChannelWithName:@"uk.spiralarm.watchtips/tipinfo"
binaryMessenger:controller];

//__weak typeof(self) weakSelf = self;

[tipinfoChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {

// activate Session
Expand Down
5 changes: 3 additions & 2 deletions lib/colors.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';

/// This defines the colours used in the app
const appPrimaryColor = Color(0xFF000000);
const appPrimaryColor = Color(0xFFE6E6E6);//Color(0xFF000000);
const appScaffoldColor = Color(0xFFE6E6E6);//Color(0xFF000000);
const appPrimaryTextColor = Color(0xFF0D5FFF);
const appTextColor = Color(0xFFFECC66);
const appTextColor = Color(0xFF333333);//Color(0xFFFECC66);
301 changes: 188 additions & 113 deletions lib/homescreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:intl/intl.dart';
import 'colors.dart';

class HomeScreen extends StatefulWidget {
@override
Expand All @@ -15,8 +16,7 @@ class _HomeScreenState extends State<HomeScreen> {
StreamSubscription tipSubscription;

NumberFormat formatter = NumberFormat("##0.00");
TextEditingController billTotalController =
TextEditingController(text: "0.00");
TextEditingController billTotalController = TextEditingController();
int tipPercent = 10, tipSplit = 1;
double billTotal = 0.0;
double totalWithTip = 0.0;
Expand All @@ -42,118 +42,192 @@ class _HomeScreenState extends State<HomeScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Tip Calculator"),
brightness: Brightness.light,
elevation: 0.0,
title: Text(
"Tip Calculator",
style: Theme.of(context).textTheme.headline,
),
),
body: Container(
margin: EdgeInsets.all(30.0),
padding: EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
TextField(
controller: billTotalController,
keyboardType: TextInputType.numberWithOptions(decimal: true),
decoration: InputDecoration(
labelText: "Bill Total",
suffixIcon: IconButton(
onPressed: () {
FocusScope.of(context).requestFocus(new FocusNode());
calculateBill(double.tryParse(billTotalController.text));
},
icon: Icon(
Icons.thumb_up,
color: Theme.of(context).textTheme.body1.color,
body: SingleChildScrollView(
child: Container(
margin: EdgeInsets.all(20.0),
padding: EdgeInsets.fromLTRB(10.0, 5.0, 10.0, 5.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
TextField(
controller: billTotalController,
keyboardType: TextInputType.numberWithOptions(decimal: true),
decoration: InputDecoration(
labelText: "Bill Total",
suffixIcon: IconButton(
onPressed: () {
FocusScope.of(context).requestFocus(new FocusNode());
calculateBill(double.tryParse(billTotalController.text));
},
icon: Icon(
Icons.keyboard_return,
color: Theme.of(context).textTheme.body1.color,
),
)),
),

Padding(
padding: EdgeInsets.fromLTRB(5.0, 10.0, 5.0, 10.0),
child: Text(
"Enter the total amount of your bill above and press the 'Return' icon.",
style: Theme.of(context).textTheme.body1,
),
),

Padding(
padding: EdgeInsets.fromLTRB(5.0, 10.0, 5.0, 10.0),
child: Text(
"Alter Tip and Split Between to update the bill breakdown.",
style: Theme.of(context).textTheme.body1,
),
),

Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
width: 110.0,
child: Text(
"Tip",
textAlign: TextAlign.left,
style: Theme.of(context).primaryTextTheme.subhead,
),
),
)),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Tip Percentage",
style: Theme.of(context).primaryTextTheme.title,
),
IconButton(
onPressed: () {
if (tipPercent > 0) {
tipPercent--;
calculateBill(null);
}
},
icon: Icon(Icons.remove_circle_outline),
),
Text(
"$tipPercent%",
style: Theme.of(context).textTheme.title,
textAlign: TextAlign.center,
),
IconButton(
onPressed: () {
if (tipPercent < 50) {
tipPercent++;
calculateBill(null);
}
},
icon: Icon(Icons.add_circle_outline),
),
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Split Between",
style: Theme.of(context).primaryTextTheme.title,
),
IconButton(
onPressed: () {
if (tipSplit > 1) {
tipSplit--;
calculateBill(null);
}
},
icon: Icon(Icons.remove_circle_outline),
),
Text(
"$tipSplit",
style: Theme.of(context).textTheme.title,
textAlign: TextAlign.center,
),
IconButton(
onPressed: () {
if (tipSplit < 50) {
tipSplit++;
calculateBill(null);
}
},
icon: Icon(Icons.add_circle_outline),
),
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Total with tip",
style: Theme.of(context).primaryTextTheme.title,
),
Text(
"${formatter.format(totalWithTip)}",
style: Theme.of(context).textTheme.title,
),
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Total cost each",
style: Theme.of(context).primaryTextTheme.title,
),
Text(
"${formatter.format(totalEach)}",
style: Theme.of(context).textTheme.title,

IconButton(
onPressed: () {
if (tipPercent > 0) {
tipPercent--;
calculateBill(null);
}
},
icon: Icon(Icons.remove),
),

Container(
width: 40.0,
child: Text(
"$tipPercent%",
style: Theme.of(context).textTheme.subhead,
textAlign: TextAlign.center,
),
),

IconButton(
onPressed: () {
if (tipPercent < 50) {
tipPercent++;
calculateBill(null);
}
},
icon: Icon(Icons.add),
),


]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
width: 110.0,
child: Text(
"Split Between",
textAlign: TextAlign.left,
style: Theme.of(context).primaryTextTheme.subhead,
),
),
IconButton(
onPressed: () {
if (tipSplit > 1) {
tipSplit--;
calculateBill(null);
}
},
icon: Icon(Icons.remove),
),
Container(
width: 40.0,
child: Text(
"$tipSplit",
style: Theme.of(context).textTheme.subhead,
textAlign: TextAlign.center,
),
),
IconButton(
onPressed: () {
if (tipSplit < 50) {
tipSplit++;
calculateBill(null);
}
},
icon: Icon(Icons.add),
),

]),

Container(
decoration: BoxDecoration(
border: Border.all(
color: appPrimaryTextColor,
width: 2.0
),
]),
],
borderRadius: BorderRadius.all( Radius.circular(5.0))
),
padding: EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Bill total",
style: Theme.of(context).primaryTextTheme.subhead,
),
Text(
"${formatter.format(billTotal)}",
style: Theme.of(context).textTheme.subhead,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"With tip",
style: Theme.of(context).primaryTextTheme.subhead,
),
Text(
"${formatter.format(totalWithTip)}",
style: Theme.of(context).textTheme.subhead,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Cost each",
style: Theme.of(context).primaryTextTheme.subhead,
),
Text(
"${formatter.format(totalEach)}",
style: Theme.of(context).textTheme.subhead,
),
]
),
],
),
),
],
),
),
),
);
Expand Down Expand Up @@ -188,13 +262,14 @@ class _HomeScreenState extends State<HomeScreen> {
});
}

/// Get the set device locale so we can correctly format the currency
/// Get the device locale so we can correctly format the currency
setupDeviceLocale() async {
List locales = await platform.invokeMethod("preferredLanguages");
debugPrint("$locales");
if(locales.length> 0){
formatter = NumberFormat.simpleCurrency(locale: locales[0]);
setState(() {});
}
billTotalController.text = formatter.format(0.0);
setState((){});
}
}
9 changes: 6 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class TipCalculator extends StatelessWidget {
final ThemeData base = ThemeData.light();
return base.copyWith(
primaryColor: appPrimaryColor,
scaffoldBackgroundColor: appPrimaryColor,
textSelectionColor: Colors.white,
cursorColor: Colors.white,
scaffoldBackgroundColor: appScaffoldColor,
textSelectionColor: appPrimaryTextColor,
cursorColor: appPrimaryTextColor,
textTheme: base.textTheme.apply(
bodyColor: appTextColor,
displayColor: appTextColor,
Expand All @@ -33,6 +33,9 @@ class TipCalculator extends StatelessWidget {
),
iconTheme: base.iconTheme.copyWith(color: appPrimaryTextColor),
inputDecorationTheme: InputDecorationTheme(
//fillColor: Colors.white,
//filled: true,

labelStyle: TextStyle(color: appTextColor, fontSize: 25.0),
enabledBorder: const OutlineInputBorder(
borderSide: const BorderSide(color: appPrimaryTextColor, width: 2.0),
Expand Down

0 comments on commit 202db87

Please sign in to comment.