Commit 0b795185 authored by Nicolas Fella's avatar Nicolas Fella Committed by Han Young
Browse files

Extract information card into own QML file

parent 1484243c
......@@ -303,9 +303,11 @@ Kirigami.ScrollablePage {
}
// bottom card (extra info for selected day)
Kirigami.Card {
InfoCard {
Layout.fillWidth: true
textColor: weatherLocation.cardTextColor
background: Kirigami.ShadowedRectangle {
color: weatherLocation.cardBackgroundColor
radius: Kirigami.Units.smallSpacing
......@@ -315,105 +317,6 @@ Kirigami.ScrollablePage {
shadow.color: Qt.rgba(0.0, 0.0, 0.0, 0.15)
shadow.yOffset: Kirigami.Units.devicePixelRatio * 2
}
contentItem: Item {
implicitHeight: column.height
Column {
id: column
spacing: Kirigami.Units.largeSpacing * 2
// precipitation
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "raindrop"
Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
Layout.minimumWidth: Layout.minimumHeight * 1.5
color: weatherLocation.iconColor
}
Column {
spacing: Kirigami.Units.smallSpacing
Label {
font.weight: Font.Bold
text: i18n("Precipitation")
color: weatherLocation.cardTextColor
}
Label {
text: currentDay == null ? "" : currentDay.precipitation.toFixed(1) + "mm"
color: weatherLocation.cardTextColor
}
}
}
// Humidity
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "compass"
Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
Layout.minimumWidth: Layout.minimumHeight * 1.5
color: weatherLocation.iconColor
}
Column {
spacing: Kirigami.Units.smallSpacing
Label {
font.weight: Font.Bold
text: i18n("Humidity")
color: weatherLocation.cardTextColor
}
Label {
text: currentDay == null ? "" : i18n("%1%", currentDay.humidity.toFixed(1))
color: weatherLocation.cardTextColor
}
}
}
// Atmospheric pressure
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "speedometer"
Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
Layout.minimumWidth: Layout.minimumHeight * 1.5
color: weatherLocation.iconColor
}
Column {
spacing: Kirigami.Units.smallSpacing
Label {
font.weight: Font.Bold
text: i18n("Pressure")
color: weatherLocation.cardTextColor
}
Label {
text: currentDay == null ? "" : i18n("%1hPa", currentDay.pressure.toFixed(1))
color: weatherLocation.cardTextColor
}
}
}
// UV Index
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "compass"
Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
Layout.minimumWidth: Layout.minimumHeight * 1.5
color: weatherLocation.iconColor
}
Column {
spacing: Kirigami.Units.smallSpacing
Label {
font.weight: Font.Bold
text: i18n("UV index")
color: weatherLocation.cardTextColor
}
Label {
text: currentDay == null ? "" : currentDay.uvIndex.toFixed(1)
color: weatherLocation.cardTextColor
}
}
}
}
}
}
SunriseCard {
......
......@@ -236,110 +236,9 @@ Kirigami.ScrollablePage {
}
// bottom card (extra info for selected day)
Kirigami.Card {
InfoCard {
Layout.fillWidth: true
Layout.topMargin: Kirigami.Units.largeSpacing * 2
contentItem: Item {
implicitHeight: column.height
Column {
id: column
spacing: Kirigami.Units.largeSpacing
// precipitation
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "raindrop"
Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
Layout.minimumWidth: Layout.minimumHeight * 1.5
}
Column {
spacing: Kirigami.Units.smallSpacing
Label {
font.weight: Font.Bold
text: i18n("Precipitation")
}
Label {
text: currentDay == null ? "" : currentDay.precipitation.toFixed(1) + "mm"
}
}
}
Kirigami.Separator {
Layout.fillWidth: true
}
// Humidity
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "compass"
Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
Layout.minimumWidth: Layout.minimumHeight * 1.5
}
Column {
spacing: Kirigami.Units.smallSpacing
Label {
font.weight: Font.Bold
text: i18n("Humidity")
}
Label {
text: currentDay == null ? "" : i18n("%1%", currentDay.humidity.toFixed(1))
}
}
}
Kirigami.Separator {
Layout.fillWidth: true
}
// Atmospheric pressure
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "speedometer"
Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
Layout.minimumWidth: Layout.minimumHeight * 1.5
}
Column {
spacing: Kirigami.Units.smallSpacing
Label {
font.weight: Font.Bold
text: i18n("Pressure")
}
Label {
text: currentDay == null ? "" : i18n("%1hPa", currentDay.pressure.toFixed(1))
}
}
}
Kirigami.Separator {
Layout.fillWidth: true
}
// UV Index
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "compass"
Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
Layout.minimumWidth: Layout.minimumHeight * 1.5
}
Column {
spacing: Kirigami.Units.smallSpacing
Label {
font.weight: Font.Bold
text: i18n("UV index")
}
Label {
text: currentDay == null ? "" : currentDay.uvIndex.toFixed(1)
}
}
}
}
}
}
SunriseCard {
......
/*
* SPDX-FileCopyrightText: 2020 Han Young <hanyoung@protonmail.com>
* SPDX-FileCopyrightText: 2020 Devin Lin <espidev@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.2
import QtCharts 2.3
import org.kde.kirigami 2.13 as Kirigami
import kweather 1.0
import "backgrounds"
Kirigami.Card {
id: root
property var textColor: Kirigami.Theme.textColor
contentItem: Item {
implicitHeight: column.height
Column {
id: column
spacing: Kirigami.Units.largeSpacing * 2
// precipitation
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "raindrop"
Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
Layout.minimumWidth: Layout.minimumHeight * 1.5
color: weatherLocation.iconColor
}
Column {
spacing: Kirigami.Units.smallSpacing
Label {
font.weight: Font.Bold
text: i18n("Precipitation")
color: root.textColor
}
Label {
text: currentDay == null ? "" : currentDay.precipitation.toFixed(1) + "mm"
color: root.textColor
}
}
}
// Humidity
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "compass"
Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
Layout.minimumWidth: Layout.minimumHeight * 1.5
color: weatherLocation.iconColor
}
Column {
spacing: Kirigami.Units.smallSpacing
Label {
font.weight: Font.Bold
text: i18n("Humidity")
color: root.textColor
}
Label {
text: currentDay == null ? "" : i18n("%1%", currentDay.humidity.toFixed(1))
color: root.textColor
}
}
}
// Atmospheric pressure
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "speedometer"
Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
Layout.minimumWidth: Layout.minimumHeight * 1.5
color: weatherLocation.iconColor
}
Column {
spacing: Kirigami.Units.smallSpacing
Label {
font.weight: Font.Bold
text: i18n("Pressure")
color: root.textColor
}
Label {
text: currentDay == null ? "" : i18n("%1hPa", currentDay.pressure.toFixed(1))
color: root.textColor
}
}
}
// UV Index
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "compass"
Layout.minimumHeight: Kirigami.Theme.defaultFont.pointSize * 2
Layout.minimumWidth: Layout.minimumHeight * 1.5
color: weatherLocation.iconColor
}
Column {
spacing: Kirigami.Units.smallSpacing
Label {
font.weight: Font.Bold
text: i18n("UV index")
color: root.textColor
}
Label {
text: currentDay == null ? "" : currentDay.uvIndex.toFixed(1)
color: root.textColor
}
}
}
}
}
}
......@@ -22,6 +22,7 @@
<file>qml/PopupDialog.qml</file>
<file>qml/TemperatureChartCard.qml</file>
<file>qml/SunriseCard.qml</file>
<file>qml/InfoCard.qml</file>
<file>qml/backgrounds/ClearDay.qml</file>
<file>qml/backgrounds/ClearNight.qml</file>
<file>qml/backgrounds/CloudyDay.qml</file>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment