Skip to content

Commit a5d78fa

Browse files
committed
Tenery operators added
1 parent 4125f99 commit a5d78fa

File tree

5 files changed

+57
-29
lines changed

5 files changed

+57
-29
lines changed

assets/images/day.png

1.17 MB
Loading

assets/images/night.png

1.4 MB
Loading

lib/screens/home.dart

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,63 @@ class _HomeState extends State<Home> {
1313
data = ModalRoute.of(context).settings.arguments;
1414

1515
print(data);
16+
17+
String bgImage = (data['isDaytime'])
18+
? 'assets/images/day.png'
19+
: 'assets/images/night.png';
20+
21+
Color bgCol = (data['isDaytime']) ? Colors.blue : Colors.indigo[700];
1622
return Scaffold(
23+
backgroundColor: bgCol,
1724
body: SafeArea(
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,
25+
child: Container(
26+
decoration: BoxDecoration(
27+
image: DecorationImage(
28+
image: AssetImage(bgImage),
29+
fit: BoxFit.cover,
30+
)),
31+
child: Padding(
32+
padding: EdgeInsets.fromLTRB(0, 120, 0, 0),
33+
child: Column(
34+
children: [
35+
FlatButton.icon(
36+
onPressed: () {
37+
Navigator.pushNamed(context, '/location');
38+
},
39+
icon: Icon(
40+
Icons.edit_location,
41+
color: Colors.grey[300],
3742
),
38-
),
39-
],
40-
),
41-
SizedBox(height: 20),
42-
Text(
43-
data['time'],
44-
style: TextStyle(
45-
fontSize: 66,
43+
label: Text(
44+
'Edit Location',
45+
style: TextStyle(
46+
color: Colors.grey[300],
47+
),
48+
)),
49+
SizedBox(height: 20),
50+
Row(
51+
mainAxisAlignment: MainAxisAlignment.center,
52+
children: [
53+
Text(
54+
'${data['location']}',
55+
style: TextStyle(
56+
fontSize: 28.0,
57+
letterSpacing: 2.0,
58+
color: Colors.white,
59+
),
60+
),
61+
],
4662
),
47-
)
48-
],
63+
SizedBox(height: 20),
64+
Text(
65+
data['time'],
66+
style: TextStyle(
67+
fontSize: 66,
68+
color: Colors.white,
69+
),
70+
)
71+
],
72+
),
4973
),
5074
)),
5175
);

lib/screens/loading.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class _LoadingState extends State<Loading> {
1818
'location': current.location,
1919
'flag': current.flag,
2020
'time': current.time,
21+
'isDaytime': current.isDaytime,
2122
});
2223
}
2324

lib/services/world_time.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class WorldTime {
77
String time;
88
String flag; // url to asset flag icon
99
String url; // endpoint
10+
bool isDaytime;
1011

1112
WorldTime({this.location, this.flag, this.url});
1213

@@ -21,6 +22,8 @@ class WorldTime {
2122
DateTime now = DateTime.parse(dateTime);
2223
now = now.add(new Duration(hours: int.parse(offset)));
2324

25+
this.isDaytime = (now.hour > 6 && now.hour < 20) ? true : false;
26+
2427
this.time = DateFormat.jm().format(now);
2528
} catch (e) {
2629
print(e);

0 commit comments

Comments
 (0)