Skip to content

Commit 202db87

Browse files
author
SpiralArm Consulting Ltd
committed
updated ui and colour scheme
1 parent 4585400 commit 202db87

File tree

4 files changed

+198
-119
lines changed

4 files changed

+198
-119
lines changed

ios/Runner/AppDelegate.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ - (BOOL)application:(UIApplication *)application
9191
methodChannelWithName:@"uk.spiralarm.watchtips/tipinfo"
9292
binaryMessenger:controller];
9393

94-
//__weak typeof(self) weakSelf = self;
94+
9595
[tipinfoChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
9696

9797
// activate Session

lib/colors.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22

33
/// This defines the colours used in the app
4-
const appPrimaryColor = Color(0xFF000000);
4+
const appPrimaryColor = Color(0xFFE6E6E6);//Color(0xFF000000);
5+
const appScaffoldColor = Color(0xFFE6E6E6);//Color(0xFF000000);
56
const appPrimaryTextColor = Color(0xFF0D5FFF);
6-
const appTextColor = Color(0xFFFECC66);
7+
const appTextColor = Color(0xFF333333);//Color(0xFFFECC66);

lib/homescreen.dart

+188-113
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:async';
22
import 'package:flutter/material.dart';
33
import 'package:flutter/services.dart';
44
import 'package:intl/intl.dart';
5+
import 'colors.dart';
56

67
class HomeScreen extends StatefulWidget {
78
@override
@@ -15,8 +16,7 @@ class _HomeScreenState extends State<HomeScreen> {
1516
StreamSubscription tipSubscription;
1617

1718
NumberFormat formatter = NumberFormat("##0.00");
18-
TextEditingController billTotalController =
19-
TextEditingController(text: "0.00");
19+
TextEditingController billTotalController = TextEditingController();
2020
int tipPercent = 10, tipSplit = 1;
2121
double billTotal = 0.0;
2222
double totalWithTip = 0.0;
@@ -42,118 +42,192 @@ class _HomeScreenState extends State<HomeScreen> {
4242
Widget build(BuildContext context) {
4343
return Scaffold(
4444
appBar: AppBar(
45-
title: Text("Tip Calculator"),
45+
brightness: Brightness.light,
46+
elevation: 0.0,
47+
title: Text(
48+
"Tip Calculator",
49+
style: Theme.of(context).textTheme.headline,
50+
),
4651
),
47-
body: Container(
48-
margin: EdgeInsets.all(30.0),
49-
padding: EdgeInsets.all(20.0),
50-
child: Column(
51-
crossAxisAlignment: CrossAxisAlignment.stretch,
52-
mainAxisAlignment: MainAxisAlignment.start,
53-
children: <Widget>[
54-
TextField(
55-
controller: billTotalController,
56-
keyboardType: TextInputType.numberWithOptions(decimal: true),
57-
decoration: InputDecoration(
58-
labelText: "Bill Total",
59-
suffixIcon: IconButton(
60-
onPressed: () {
61-
FocusScope.of(context).requestFocus(new FocusNode());
62-
calculateBill(double.tryParse(billTotalController.text));
63-
},
64-
icon: Icon(
65-
Icons.thumb_up,
66-
color: Theme.of(context).textTheme.body1.color,
52+
body: SingleChildScrollView(
53+
child: Container(
54+
margin: EdgeInsets.all(20.0),
55+
padding: EdgeInsets.fromLTRB(10.0, 5.0, 10.0, 5.0),
56+
child: Column(
57+
crossAxisAlignment: CrossAxisAlignment.stretch,
58+
mainAxisAlignment: MainAxisAlignment.start,
59+
children: <Widget>[
60+
TextField(
61+
controller: billTotalController,
62+
keyboardType: TextInputType.numberWithOptions(decimal: true),
63+
decoration: InputDecoration(
64+
labelText: "Bill Total",
65+
suffixIcon: IconButton(
66+
onPressed: () {
67+
FocusScope.of(context).requestFocus(new FocusNode());
68+
calculateBill(double.tryParse(billTotalController.text));
69+
},
70+
icon: Icon(
71+
Icons.keyboard_return,
72+
color: Theme.of(context).textTheme.body1.color,
73+
),
74+
)),
75+
),
76+
77+
Padding(
78+
padding: EdgeInsets.fromLTRB(5.0, 10.0, 5.0, 10.0),
79+
child: Text(
80+
"Enter the total amount of your bill above and press the 'Return' icon.",
81+
style: Theme.of(context).textTheme.body1,
82+
),
83+
),
84+
85+
Padding(
86+
padding: EdgeInsets.fromLTRB(5.0, 10.0, 5.0, 10.0),
87+
child: Text(
88+
"Alter Tip and Split Between to update the bill breakdown.",
89+
style: Theme.of(context).textTheme.body1,
90+
),
91+
),
92+
93+
Row(
94+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
95+
children: <Widget>[
96+
Container(
97+
width: 110.0,
98+
child: Text(
99+
"Tip",
100+
textAlign: TextAlign.left,
101+
style: Theme.of(context).primaryTextTheme.subhead,
102+
),
67103
),
68-
)),
69-
),
70-
Row(
71-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
72-
children: <Widget>[
73-
Text(
74-
"Tip Percentage",
75-
style: Theme.of(context).primaryTextTheme.title,
76-
),
77-
IconButton(
78-
onPressed: () {
79-
if (tipPercent > 0) {
80-
tipPercent--;
81-
calculateBill(null);
82-
}
83-
},
84-
icon: Icon(Icons.remove_circle_outline),
85-
),
86-
Text(
87-
"$tipPercent%",
88-
style: Theme.of(context).textTheme.title,
89-
textAlign: TextAlign.center,
90-
),
91-
IconButton(
92-
onPressed: () {
93-
if (tipPercent < 50) {
94-
tipPercent++;
95-
calculateBill(null);
96-
}
97-
},
98-
icon: Icon(Icons.add_circle_outline),
99-
),
100-
]),
101-
Row(
102-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
103-
children: <Widget>[
104-
Text(
105-
"Split Between",
106-
style: Theme.of(context).primaryTextTheme.title,
107-
),
108-
IconButton(
109-
onPressed: () {
110-
if (tipSplit > 1) {
111-
tipSplit--;
112-
calculateBill(null);
113-
}
114-
},
115-
icon: Icon(Icons.remove_circle_outline),
116-
),
117-
Text(
118-
"$tipSplit",
119-
style: Theme.of(context).textTheme.title,
120-
textAlign: TextAlign.center,
121-
),
122-
IconButton(
123-
onPressed: () {
124-
if (tipSplit < 50) {
125-
tipSplit++;
126-
calculateBill(null);
127-
}
128-
},
129-
icon: Icon(Icons.add_circle_outline),
130-
),
131-
]),
132-
Row(
133-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
134-
children: <Widget>[
135-
Text(
136-
"Total with tip",
137-
style: Theme.of(context).primaryTextTheme.title,
138-
),
139-
Text(
140-
"${formatter.format(totalWithTip)}",
141-
style: Theme.of(context).textTheme.title,
142-
),
143-
]),
144-
Row(
145-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
146-
children: <Widget>[
147-
Text(
148-
"Total cost each",
149-
style: Theme.of(context).primaryTextTheme.title,
150-
),
151-
Text(
152-
"${formatter.format(totalEach)}",
153-
style: Theme.of(context).textTheme.title,
104+
105+
IconButton(
106+
onPressed: () {
107+
if (tipPercent > 0) {
108+
tipPercent--;
109+
calculateBill(null);
110+
}
111+
},
112+
icon: Icon(Icons.remove),
113+
),
114+
115+
Container(
116+
width: 40.0,
117+
child: Text(
118+
"$tipPercent%",
119+
style: Theme.of(context).textTheme.subhead,
120+
textAlign: TextAlign.center,
121+
),
122+
),
123+
124+
IconButton(
125+
onPressed: () {
126+
if (tipPercent < 50) {
127+
tipPercent++;
128+
calculateBill(null);
129+
}
130+
},
131+
icon: Icon(Icons.add),
132+
),
133+
134+
135+
]),
136+
Row(
137+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
138+
children: <Widget>[
139+
Container(
140+
width: 110.0,
141+
child: Text(
142+
"Split Between",
143+
textAlign: TextAlign.left,
144+
style: Theme.of(context).primaryTextTheme.subhead,
145+
),
146+
),
147+
IconButton(
148+
onPressed: () {
149+
if (tipSplit > 1) {
150+
tipSplit--;
151+
calculateBill(null);
152+
}
153+
},
154+
icon: Icon(Icons.remove),
155+
),
156+
Container(
157+
width: 40.0,
158+
child: Text(
159+
"$tipSplit",
160+
style: Theme.of(context).textTheme.subhead,
161+
textAlign: TextAlign.center,
162+
),
163+
),
164+
IconButton(
165+
onPressed: () {
166+
if (tipSplit < 50) {
167+
tipSplit++;
168+
calculateBill(null);
169+
}
170+
},
171+
icon: Icon(Icons.add),
172+
),
173+
174+
]),
175+
176+
Container(
177+
decoration: BoxDecoration(
178+
border: Border.all(
179+
color: appPrimaryTextColor,
180+
width: 2.0
154181
),
155-
]),
156-
],
182+
borderRadius: BorderRadius.all( Radius.circular(5.0))
183+
),
184+
padding: EdgeInsets.all(8.0),
185+
child: Column(
186+
children: <Widget>[
187+
Row(
188+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
189+
children: <Widget>[
190+
Text(
191+
"Bill total",
192+
style: Theme.of(context).primaryTextTheme.subhead,
193+
),
194+
Text(
195+
"${formatter.format(billTotal)}",
196+
style: Theme.of(context).textTheme.subhead,
197+
),
198+
],
199+
),
200+
Row(
201+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
202+
children: <Widget>[
203+
Text(
204+
"With tip",
205+
style: Theme.of(context).primaryTextTheme.subhead,
206+
),
207+
Text(
208+
"${formatter.format(totalWithTip)}",
209+
style: Theme.of(context).textTheme.subhead,
210+
),
211+
],
212+
),
213+
Row(
214+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
215+
children: <Widget>[
216+
Text(
217+
"Cost each",
218+
style: Theme.of(context).primaryTextTheme.subhead,
219+
),
220+
Text(
221+
"${formatter.format(totalEach)}",
222+
style: Theme.of(context).textTheme.subhead,
223+
),
224+
]
225+
),
226+
],
227+
),
228+
),
229+
],
230+
),
157231
),
158232
),
159233
);
@@ -188,13 +262,14 @@ class _HomeScreenState extends State<HomeScreen> {
188262
});
189263
}
190264

191-
/// Get the set device locale so we can correctly format the currency
265+
/// Get the device locale so we can correctly format the currency
192266
setupDeviceLocale() async {
193267
List locales = await platform.invokeMethod("preferredLanguages");
194268
debugPrint("$locales");
195269
if(locales.length> 0){
196270
formatter = NumberFormat.simpleCurrency(locale: locales[0]);
197-
setState(() {});
198271
}
272+
billTotalController.text = formatter.format(0.0);
273+
setState((){});
199274
}
200275
}

lib/main.dart

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class TipCalculator extends StatelessWidget {
2020
final ThemeData base = ThemeData.light();
2121
return base.copyWith(
2222
primaryColor: appPrimaryColor,
23-
scaffoldBackgroundColor: appPrimaryColor,
24-
textSelectionColor: Colors.white,
25-
cursorColor: Colors.white,
23+
scaffoldBackgroundColor: appScaffoldColor,
24+
textSelectionColor: appPrimaryTextColor,
25+
cursorColor: appPrimaryTextColor,
2626
textTheme: base.textTheme.apply(
2727
bodyColor: appTextColor,
2828
displayColor: appTextColor,
@@ -33,6 +33,9 @@ class TipCalculator extends StatelessWidget {
3333
),
3434
iconTheme: base.iconTheme.copyWith(color: appPrimaryTextColor),
3535
inputDecorationTheme: InputDecorationTheme(
36+
//fillColor: Colors.white,
37+
//filled: true,
38+
3639
labelStyle: TextStyle(color: appTextColor, fontSize: 25.0),
3740
enabledBorder: const OutlineInputBorder(
3841
borderSide: const BorderSide(color: appPrimaryTextColor, width: 2.0),

0 commit comments

Comments
 (0)