Reform layout code
- Refactor layout code with simpler logic - Use `GridLayout` to avoid too must nesting
This commit is contained in:
parent
8c1af56e8a
commit
f5886ae8cf
@ -30,156 +30,132 @@ export component MainWindow inherits Window {
|
||||
padding: 12px;
|
||||
width: 100%;
|
||||
|
||||
// Top row
|
||||
// Top row - left: Icon
|
||||
Rectangle {
|
||||
//background: #b95f5f;
|
||||
row: 0;
|
||||
//background: #232323;
|
||||
height: 65px;
|
||||
width: 276px;
|
||||
|
||||
GridLayout {
|
||||
// Left - weather icon
|
||||
Rectangle {
|
||||
col: 0;
|
||||
colspan: 1;
|
||||
rowspan: 3;
|
||||
height: 65px;
|
||||
width: 65px;
|
||||
//background: #316481;
|
||||
row: 0;
|
||||
col:0;
|
||||
Text {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text: root.weather_icon;
|
||||
font-size: 65px;
|
||||
width: 100%;
|
||||
vertical-alignment: center;
|
||||
horizontal-alignment: center;
|
||||
font-size: 65px;
|
||||
text: root.weather_icon;
|
||||
}
|
||||
}
|
||||
// Right - Location and temperature
|
||||
// Top row - right: Location
|
||||
Rectangle {
|
||||
//background: #5fb6b9;
|
||||
row: 0;
|
||||
col: 1;
|
||||
//background: #318138;
|
||||
height: 65px;
|
||||
width: 211px;
|
||||
|
||||
GridLayout {
|
||||
// Top right - Location
|
||||
Rectangle {
|
||||
row: 0;
|
||||
col: 0;
|
||||
//background: #232323;
|
||||
colspan: 4;
|
||||
rowspan: 1;
|
||||
height: 20px;
|
||||
//width: 211px;
|
||||
min-width: 0px;
|
||||
Text {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text: root.city + "," + root.country;
|
||||
width: 100%;
|
||||
vertical-alignment: center;
|
||||
horizontal-alignment: right;
|
||||
font-size: 15px;
|
||||
text: root.city + "," + root.country;
|
||||
}
|
||||
}
|
||||
// Bottom right - Temperature block
|
||||
// Middle row - right - middle: Temperature value
|
||||
Rectangle {
|
||||
//background: #895fb9;
|
||||
row: 1;
|
||||
col: 0;
|
||||
//background: #7a2a70;
|
||||
height: 45px;
|
||||
GridLayout {
|
||||
// Temperature value
|
||||
Rectangle {
|
||||
//background: #7c3434;
|
||||
row: 0;
|
||||
col:0;
|
||||
col: 1;
|
||||
colspan: 3;
|
||||
rowspan: 2;
|
||||
height: 45px;
|
||||
min-width: 0px;
|
||||
Text {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
vertical-alignment: center;
|
||||
horizontal-alignment: right;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text: root.temperature;
|
||||
font-size: 40px;
|
||||
text: root.temperature;
|
||||
}
|
||||
}
|
||||
// Degree symbol
|
||||
// Middle row - right - right - top: Degree symbol
|
||||
Rectangle {
|
||||
//background: #39347c;
|
||||
row: 0;
|
||||
col:1;
|
||||
//background: #7bb95f;
|
||||
row: 1;
|
||||
col: 4;
|
||||
colspan: 1;
|
||||
rowspan: 1;
|
||||
width: 18px;
|
||||
height: 22.5px;
|
||||
min-width: 0px;
|
||||
Text {
|
||||
height: 100%;
|
||||
min-width: 0px;
|
||||
vertical-alignment: center;
|
||||
horizontal-alignment: right;
|
||||
font-size: 18px;
|
||||
text: "";
|
||||
font-size: 18px;
|
||||
vertical-alignment: bottom;
|
||||
horizontal-alignment: right;
|
||||
height: 100%;
|
||||
min-width: 0px;
|
||||
}
|
||||
}
|
||||
// Temperature unit
|
||||
// Middle row - right - right - bottom: Temperature unit
|
||||
Rectangle {
|
||||
//background: #577c34;
|
||||
row: 1;
|
||||
col:1;
|
||||
//background: #b95f9e;
|
||||
row: 2;
|
||||
col: 4;
|
||||
colspan: 1;
|
||||
rowspan: 1;
|
||||
width: 18px;
|
||||
height: 22.5px;
|
||||
min-width: 0px;
|
||||
Text {
|
||||
//text: root.unit;
|
||||
text: "C";
|
||||
font-size: 18px;
|
||||
vertical-alignment: top;
|
||||
horizontal-alignment: right;
|
||||
height: 100%;
|
||||
min-width: 0px;
|
||||
vertical-alignment: center;
|
||||
horizontal-alignment: right;
|
||||
font-size: 18px;
|
||||
text: root.unit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Bottom row
|
||||
// Bottom row - left: Weather condition
|
||||
Rectangle {
|
||||
row: 1;
|
||||
//background: #863b3b;
|
||||
height: 35px;
|
||||
width: 276px;
|
||||
|
||||
GridLayout {
|
||||
// Bottom left - Weather condition
|
||||
Rectangle {
|
||||
row: 0;
|
||||
//background: #5fb98f;
|
||||
row: 3;
|
||||
col: 0;
|
||||
width: 135px;
|
||||
colspan: 3;
|
||||
rowspan: 1;
|
||||
height: 35px;
|
||||
//background: #2f794e;
|
||||
width: 135px;
|
||||
Text {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
vertical-alignment: center;
|
||||
horizontal-alignment: left;
|
||||
text: root.weather_main;
|
||||
//text: "Thunderstorms";
|
||||
font-size: 21px;
|
||||
text: root.weather_main;
|
||||
}
|
||||
}
|
||||
// Bottom right - Weather description
|
||||
// Bottom row - right: Weather description
|
||||
Rectangle {
|
||||
row: 0;
|
||||
col: 1;
|
||||
//background: #b4a44a;
|
||||
//background: #b7b95f;
|
||||
row: 3;
|
||||
col: 3;
|
||||
colspan: 2;
|
||||
rowspan: 1;
|
||||
height: 35px;
|
||||
width: 141px;
|
||||
Text {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
vertical-alignment: top;
|
||||
horizontal-alignment: right;
|
||||
text: root.weather_description;
|
||||
font-size: 13.5px;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
text: root.weather_description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user