Commit 291b2f0c authored by Nicolas Fella's avatar Nicolas Fella Committed by Devin Lin
Browse files

Factor sunrise card into separate QML file

The one in flat and dynamic view are almost identical
parent ca5b9804
......@@ -416,10 +416,11 @@ Kirigami.ScrollablePage {
}
}
// sunrise/sunset card
Kirigami.Card {
SunriseCard {
Layout.fillWidth: true
textColor: weatherLocation.cardTextColor
background: Kirigami.ShadowedRectangle {
color: weatherLocation.cardBackgroundColor
radius: Kirigami.Units.smallSpacing
......@@ -429,82 +430,6 @@ Kirigami.ScrollablePage {
shadow.color: Qt.rgba(0.0, 0.0, 0.0, 0.15)
shadow.yOffset: Kirigami.Units.devicePixelRatio * 2
}
contentItem: Item {
implicitHeight: sunsetColumn.height
Column {
id: sunsetColumn
spacing: Kirigami.Units.largeSpacing * 2
// Sunrise
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "go-up"
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("Sunrise")
color: weatherLocation.cardTextColor
}
Label {
text: Qt.formatTime(currentDay.sunrise.sunRise, Locale.ShortFormat)
color: weatherLocation.cardTextColor
}
}
}
// Sunset
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "go-down"
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("Sunset")
color: weatherLocation.cardTextColor
}
Label {
text: Qt.formatTime(currentDay.sunrise.sunSet, Locale.ShortFormat)
color: weatherLocation.cardTextColor
}
}
}
// Moon phase
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "weather-clear-night"
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("Moon Phase")
color: weatherLocation.cardTextColor
}
Label {
text: currentDay.sunrise.moonPhaseString
color: weatherLocation.cardTextColor
}
}
}
}
}
}
}
}
......
......@@ -342,87 +342,9 @@ Kirigami.ScrollablePage {
}
}
// sunrise/sunset card
Kirigami.Card {
SunriseCard {
Layout.fillWidth: true
Layout.topMargin: Kirigami.Units.largeSpacing * 2
contentItem: Item {
implicitHeight: sunsetColumn.height
Column {
id: sunsetColumn
spacing: Kirigami.Units.largeSpacing
// Sunrise
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "go-up"
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("Sunrise")
}
Label {
text: Qt.formatTime(currentDay.sunrise.sunRise, Locale.ShortFormat)
}
}
}
Kirigami.Separator {
Layout.fillWidth: true
}
// Sunset
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "go-down"
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("Sunset")
}
Label {
text: Qt.formatTime(currentDay.sunrise.sunSet, Locale.ShortFormat)
}
}
}
Kirigami.Separator {
Layout.fillWidth: true
}
// Moon phase
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "weather-clear-night"
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("Moon Phase")
}
Label {
text: currentDay.sunrise.moonPhaseString
}
}
}
}
}
}
}
}
......
/*
* Copyright 2020 Han Young <hanyoung@protonmail.com>
* Copyright 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: sunsetColumn.height
Column {
id: sunsetColumn
spacing: Kirigami.Units.largeSpacing * 2
// Sunrise
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "go-up"
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("Sunrise")
color: root.textColor
}
Label {
text: Qt.formatTime(currentDay.sunrise.sunRise, Locale.ShortFormat)
color: root.textColor
}
}
}
// Sunset
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "go-down"
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("Sunset")
color: root.textColor
}
Label {
text: Qt.formatTime(currentDay.sunrise.sunSet, Locale.ShortFormat)
color: root.textColor
}
}
}
// Moon phase
RowLayout {
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
source: "weather-clear-night"
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("Moon Phase")
color: root.textColor
}
Label {
text: currentDay.sunrise.moonPhaseString
color: root.textColor
}
}
}
}
}
}
......@@ -21,6 +21,7 @@
<file>qml/AboutPage.qml</file>
<file>qml/PopupDialog.qml</file>
<file>qml/TemperatureChartCard.qml</file>
<file>qml/SunriseCard.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