Skip to content

Commit 4125f99

Browse files
committed
Learnt a bit of loaders and date formatting
1 parent bcc7e35 commit 4125f99

File tree

5 files changed

+62
-15
lines changed

5 files changed

+62
-15
lines changed

lib/screens/home.dart

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,47 @@ class Home extends StatefulWidget {
66
}
77

88
class _HomeState extends State<Home> {
9+
Map data = {};
10+
911
@override
1012
Widget build(BuildContext context) {
13+
data = ModalRoute.of(context).settings.arguments;
14+
15+
print(data);
1116
return Scaffold(
1217
body: SafeArea(
13-
child: Column(
14-
children: [
15-
FlatButton.icon(
16-
onPressed: () {
17-
Navigator.pushNamed(context, '/location');
18-
},
19-
icon: Icon(Icons.edit_location),
20-
label: Text('Edit Location'))
21-
],
18+
child: Padding(
19+
padding: EdgeInsets.fromLTRB(0, 120, 0, 0),
20+
child: Column(
21+
children: [
22+
FlatButton.icon(
23+
onPressed: () {
24+
Navigator.pushNamed(context, '/location');
25+
},
26+
icon: Icon(Icons.edit_location),
27+
label: Text('Edit Location')),
28+
SizedBox(height: 20),
29+
Row(
30+
mainAxisAlignment: MainAxisAlignment.center,
31+
children: [
32+
Text(
33+
'${data['location']}',
34+
style: TextStyle(
35+
fontSize: 28.0,
36+
letterSpacing: 2.0,
37+
),
38+
),
39+
],
40+
),
41+
SizedBox(height: 20),
42+
Text(
43+
data['time'],
44+
style: TextStyle(
45+
fontSize: 66,
46+
),
47+
)
48+
],
49+
),
2250
)),
2351
);
2452
}

lib/screens/loading.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:flutter/material.dart';
2-
2+
import 'package:flutter_spinkit/flutter_spinkit.dart';
33
import 'package:ninja_app/services/world_time.dart';
44

55
class Loading extends StatefulWidget {
@@ -31,10 +31,11 @@ class _LoadingState extends State<Loading> {
3131
@override
3232
Widget build(BuildContext context) {
3333
return Scaffold(
34-
body: Padding(
35-
padding: const EdgeInsets.all(50.0),
36-
child: Text('$time'),
34+
body: Center(
35+
child: SpinKitFoldingCube(
36+
color: Colors.blue[900],
37+
size: 100,
3738
),
38-
);
39+
));
3940
}
4041
}

lib/services/world_time.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:http/http.dart';
22
import 'dart:convert';
3+
import 'package:intl/intl.dart';
34

45
class WorldTime {
56
String location;
@@ -20,7 +21,7 @@ class WorldTime {
2021
DateTime now = DateTime.parse(dateTime);
2122
now = now.add(new Duration(hours: int.parse(offset)));
2223

23-
this.time = now.toString();
24+
this.time = DateFormat.jm().format(now);
2425
} catch (e) {
2526
print(e);
2627
this.time = 'Could not get a time value';

pubspec.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ packages:
6262
description: flutter
6363
source: sdk
6464
version: "0.0.0"
65+
flutter_spinkit:
66+
dependency: "direct main"
67+
description:
68+
name: flutter_spinkit
69+
url: "https://pub.dartlang.org"
70+
source: hosted
71+
version: "4.1.2+1"
6572
flutter_test:
6673
dependency: "direct dev"
6774
description: flutter
@@ -81,6 +88,13 @@ packages:
8188
url: "https://pub.dartlang.org"
8289
source: hosted
8390
version: "3.1.4"
91+
intl:
92+
dependency: "direct main"
93+
description:
94+
name: intl
95+
url: "https://pub.dartlang.org"
96+
source: hosted
97+
version: "0.16.1"
8498
matcher:
8599
dependency: transitive
86100
description:
@@ -172,3 +186,4 @@ packages:
172186
version: "2.1.0-nullsafety.3"
173187
sdks:
174188
dart: ">=2.10.0-110 <2.11.0"
189+
flutter: ">=0.1.4 <2.0.0"

pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ dependencies:
2525
sdk: flutter
2626

2727
http: ^0.12.2
28+
intl: ^0.16.1
29+
flutter_spinkit: "^4.1.2"
2830
# The following adds the Cupertino Icons font to your application.
2931
# Use with the CupertinoIcons class for iOS style icons.
3032
cupertino_icons: ^1.0.0

0 commit comments

Comments
 (0)