Skip to content

Commit 65b97cf

Browse files
Tidied up and... DONE!
1 parent 9aa271e commit 65b97cf

5 files changed

Lines changed: 105 additions & 53 deletions

File tree

lib/model/planets.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ List<Planet> planets = [
1919
location: "Milkyway Galaxy",
2020
distance: "54.6m Km",
2121
gravity: "3.711 m/s ",
22-
description: "Lorem ipsum...",
22+
description: "Mars is the fourth planet from the Sun and the second-smallest planet in the Solar System after Mercury. In English, Mars carries a name of the Roman god of war, and is often referred to as the 'Red Planet' because the reddish iron oxide prevalent on its surface gives it a reddish appearance that is distinctive among the astronomical bodies visible to the naked eye. Mars is a terrestrial planet with a thin atmosphere, having surface features reminiscent both of the impact craters of the Moon and the valleys, deserts, and polar ice caps of Earth.",
2323
image: "assets/img/mars.png",
2424
picture: "https://www.nasa.gov/sites/default/files/thumbnails/image/pia21723-16.jpg"
2525
),
@@ -29,7 +29,7 @@ List<Planet> planets = [
2929
location: "Milkyway Galaxy",
3030
distance: "54.6m Km",
3131
gravity: "3.711 m/s ",
32-
description: "Lorem ipsum...",
32+
description: "Neptune is the eighth and farthest known planet from the Sun in the Solar System. In the Solar System, it is the fourth-largest planet by diameter, the third-most-massive planet, and the densest giant planet. Neptune is 17 times the mass of Earth and is slightly more massive than its near-twin Uranus, which is 15 times the mass of Earth and slightly larger than Neptune. Neptune orbits the Sun once every 164.8 years at an average distance of 30.1 astronomical units (4.50×109 km). It is named after the Roman god of the sea and has the astronomical symbol ♆, a stylised version of the god Neptune's trident",
3333
image: "assets/img/neptune.png",
3434
picture: "https://www.nasa.gov/sites/default/files/styles/full_width_feature/public/images/110411main_Voyager2_280_yshires.jpg"
3535
),
@@ -39,7 +39,7 @@ List<Planet> planets = [
3939
location: "Milkyway Galaxy",
4040
distance: "54.6m Km",
4141
gravity: "3.711 m/s ",
42-
description: "Lorem ipsum...",
42+
description: "The Moon is an astronomical body that orbits planet Earth, being Earth's only permanent natural satellite. It is the fifth-largest natural satellite in the Solar System, and the largest among planetary satellites relative to the size of the planet that it orbits (its primary). Following Jupiter's satellite Io, the Moon is second-densest satellite among those whose densities are known.",
4343
image: "assets/img/moon.png",
4444
picture: "https://farm5.staticflickr.com/4086/5052125139_43c31b7012.jpg"
4545
),
@@ -49,7 +49,7 @@ List<Planet> planets = [
4949
location: "Milkyway Galaxy",
5050
distance: "54.6m Km",
5151
gravity: "3.711 m/s ",
52-
description: "Lorem ipsum...",
52+
description: "Earth is the third planet from the Sun and the only object in the Universe known to harbor life. According to radiometric dating and other sources of evidence, Earth formed over 4 billion years ago. Earth's gravity interacts with other objects in space, especially the Sun and the Moon, Earth's only natural satellite. Earth revolves around the Sun in 365.26 days, a period known as an Earth year. During this time, Earth rotates about its axis about 366.26 times.",
5353
image: "assets/img/earth.png",
5454
picture: "https://www.nasa.gov/sites/default/files/styles/full_width_feature/public/thumbnails/image/iss042e340851_1.jpg"
5555
),
@@ -59,7 +59,7 @@ List<Planet> planets = [
5959
location: "Milkyway Galaxy",
6060
distance: "54.6m Km",
6161
gravity: "3.711 m/s ",
62-
description: "Lorem ipsum...",
62+
description: "Mercury is the smallest and innermost planet in the Solar System. Its orbital period around the Sun of 88 days is the shortest of all the planets in the Solar System. It is named after the Roman deity Mercury, the messenger to the gods.",
6363
image: "assets/img/mercury.png",
6464
picture: "https://c1.staticflickr.com/9/8105/8497927473_2845ae671e_b.jpg"
6565
),

lib/ui/common/plannet_summary.dart

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_planets_tutorial/model/planets.dart';
3+
import 'package:flutter_planets_tutorial/ui/common/separator.dart';
34
import 'package:flutter_planets_tutorial/ui/detail/detail_page.dart';
45
import 'package:flutter_planets_tutorial/ui/text_style.dart';
56

@@ -40,7 +41,7 @@ class PlanetSummary extends StatelessWidget {
4041
children: <Widget>[
4142
new Image.asset(image, height: 12.0),
4243
new Container(width: 8.0),
43-
new Text(planet.gravity, style: Style.regularTextStyle),
44+
new Text(planet.gravity, style: Style.smallTextStyle),
4445
]
4546
),
4647
);
@@ -54,15 +55,10 @@ class PlanetSummary extends StatelessWidget {
5455
crossAxisAlignment: horizontal ? CrossAxisAlignment.start : CrossAxisAlignment.center,
5556
children: <Widget>[
5657
new Container(height: 4.0),
57-
new Text(planet.name, style: Style.headerTextStyle),
58+
new Text(planet.name, style: Style.titleTextStyle),
5859
new Container(height: 10.0),
59-
new Text(planet.location, style: Style.subHeaderTextStyle),
60-
new Container(
61-
margin: new EdgeInsets.symmetric(vertical: 8.0),
62-
height: 2.0,
63-
width: 18.0,
64-
color: new Color(0xff00c6ff)
65-
),
60+
new Text(planet.location, style: Style.commonTextStyle),
61+
new Separator(),
6662
new Row(
6763
mainAxisAlignment: MainAxisAlignment.center,
6864
children: <Widget>[

lib/ui/common/separator.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import 'package:flutter/material.dart';
2+
3+
class Separator extends StatelessWidget {
4+
@override
5+
Widget build(BuildContext context) {
6+
return new Container(
7+
margin: new EdgeInsets.symmetric(vertical: 8.0),
8+
height: 2.0,
9+
width: 18.0,
10+
color: new Color(0xff00c6ff)
11+
);
12+
}
13+
}

lib/ui/detail/detail_page.dart

Lines changed: 71 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_planets_tutorial/model/planets.dart';
33
import 'package:flutter_planets_tutorial/ui/common/plannet_summary.dart';
4+
import 'package:flutter_planets_tutorial/ui/common/separator.dart';
5+
import 'package:flutter_planets_tutorial/ui/text_style.dart';
46

57

68
class DetailPage extends StatelessWidget {
@@ -17,43 +19,79 @@ class DetailPage extends StatelessWidget {
1719
color: new Color(0xFF736AB7),
1820
child: new Stack (
1921
children: <Widget>[
20-
new Container(
21-
child: new Image.network(planet.picture,
22-
fit: BoxFit.cover,
23-
height: 300.0,
24-
),
25-
constraints: new BoxConstraints.expand(height: 295.0),
22+
_getBackground(),
23+
_getGradient(),
24+
_getContent(),
25+
_getToolbar(context),
26+
],
27+
),
28+
),
29+
);
30+
}
31+
32+
Container _getBackground () {
33+
return new Container(
34+
child: new Image.network(planet.picture,
35+
fit: BoxFit.cover,
36+
height: 300.0,
2637
),
27-
new Container(
28-
margin: new EdgeInsets.only(top: 190.0),
29-
height: 110.0,
30-
decoration: new BoxDecoration(
31-
gradient: new LinearGradient(
32-
colors: <Color>[
33-
new Color(0x00736AB7),
34-
new Color(0xFF736AB7)
35-
],
36-
stops: [0.0, 0.9],
37-
begin: const FractionalOffset(0.0, 0.0),
38-
end: const FractionalOffset(0.0, 1.0),
39-
),
38+
constraints: new BoxConstraints.expand(height: 295.0),
39+
);
40+
}
41+
42+
Container _getGradient() {
43+
return new Container(
44+
margin: new EdgeInsets.only(top: 190.0),
45+
height: 110.0,
46+
decoration: new BoxDecoration(
47+
gradient: new LinearGradient(
48+
colors: <Color>[
49+
new Color(0x00736AB7),
50+
new Color(0xFF736AB7)
51+
],
52+
stops: [0.0, 0.9],
53+
begin: const FractionalOffset(0.0, 0.0),
54+
end: const FractionalOffset(0.0, 1.0),
4055
),
4156
),
42-
new Container(
43-
margin: new EdgeInsets.only(top: 72.0),
44-
child: new ListView(
45-
children: <Widget>[
46-
new PlanetSummary(planet,
47-
horizontal: false,
57+
);
58+
}
59+
60+
Container _getContent() {
61+
final _overviewTitle = "Overview".toUpperCase();
62+
return new Container(
63+
child: new ListView(
64+
padding: new EdgeInsets.fromLTRB(0.0, 72.0, 0.0, 32.0),
65+
children: <Widget>[
66+
new PlanetSummary(planet,
67+
horizontal: false,
68+
),
69+
new Container(
70+
padding: new EdgeInsets.symmetric(horizontal: 32.0),
71+
child: new Column(
72+
crossAxisAlignment: CrossAxisAlignment.start,
73+
children: <Widget>[
74+
new Text(_overviewTitle,
75+
style: Style.headerTextStyle,),
76+
new Separator(),
77+
new Text(
78+
planet.description, style: Style.commonTextStyle),
79+
],
4880
),
49-
new Text("Overview"),
50-
new Text(planet.description)
51-
],
52-
),
81+
),
82+
],
5383
),
54-
],
55-
),
56-
),
57-
);
84+
);
85+
}
86+
87+
Container _getToolbar(BuildContext context) {
88+
return new Container(
89+
margin: new EdgeInsets.only(
90+
top: MediaQuery
91+
.of(context)
92+
.padding
93+
.top),
94+
child: new BackButton(color: Colors.white),
95+
);
5896
}
5997
}

lib/ui/text_style.dart

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@ class Style {
44
static final baseTextStyle = const TextStyle(
55
fontFamily: 'Poppins'
66
);
7-
static final regularTextStyle = baseTextStyle.copyWith(
8-
color: const Color(0xffb6b2df),
7+
static final smallTextStyle = commonTextStyle.copyWith(
98
fontSize: 9.0,
10-
fontWeight: FontWeight.w400
119
);
12-
static final subHeaderTextStyle = regularTextStyle.copyWith(
13-
fontSize: 12.0
10+
static final commonTextStyle = baseTextStyle.copyWith(
11+
color: const Color(0xffb6b2df),
12+
fontSize: 14.0,
13+
fontWeight: FontWeight.w400
1414
);
15-
static final headerTextStyle = baseTextStyle.copyWith(
15+
static final titleTextStyle = baseTextStyle.copyWith(
1616
color: Colors.white,
1717
fontSize: 18.0,
1818
fontWeight: FontWeight.w600
1919
);
20+
static final headerTextStyle = baseTextStyle.copyWith(
21+
color: Colors.white,
22+
fontSize: 20.0,
23+
fontWeight: FontWeight.w400
24+
);
2025
}

0 commit comments

Comments
 (0)