Skip to content

Commit f722940

Browse files
committed
Add storageBar and storageText.
1 parent 65653dc commit f722940

File tree

3 files changed

+76
-8
lines changed

3 files changed

+76
-8
lines changed

src/qml/Nyuki.qml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import QtQuick
22
import QtQuick.Controls
3+
import Theme
34

45
/**
56
* \ingroup qml
@@ -66,7 +67,7 @@ Item {
6667
id: nyukiLeft
6768
width: 10
6869
height: 10
69-
color: "#4a6fae"
70+
color: Theme.qfieldCloudBlue
7071
x: 84
7172
y: 84
7273
radius: 5
@@ -91,7 +92,7 @@ Item {
9192
id: nyukiRight
9293
width: 10
9394
height: 10
94-
color: "#4a6fae"
95+
color: Theme.qfieldCloudBlue
9596
x: 106
9697
y: 84
9798
radius: 5

src/qml/QFieldCloudScreen.qml

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ Page {
3636
Layout.fillHeight: true
3737
spacing: 2
3838

39-
RowLayout {
39+
Item {
4040
id: connectionInformation
41-
spacing: 2
4241
Layout.fillWidth: true
42+
Layout.minimumHeight: cloudAvatarRect.height + (storageBar.visible * storageBar.height) + 8
43+
Layout.leftMargin: 10
44+
Layout.rightMargin: 10
45+
Layout.topMargin: 12
4346
visible: cloudConnection.hasToken || cloudProjectsModel.rowCount() > 0
4447

4548
Label {
46-
Layout.fillWidth: true
47-
padding: 10
49+
anchors.left: parent.left
4850
opacity: projects.visible ? 1 : 0
4951
text: switch (cloudConnection.status) {
5052
case 0:
@@ -64,8 +66,7 @@ Page {
6466

6567
Rectangle {
6668
id: cloudAvatarRect
67-
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
68-
Layout.margins: 10
69+
anchors.right: parent.right
6970
width: 48
7071
height: 48
7172
border.color: Theme.mainColor
@@ -123,6 +124,45 @@ Page {
123124
}
124125
}
125126
}
127+
128+
Label {
129+
id: storageText
130+
anchors.bottom: storageBar.top
131+
anchors.bottomMargin: 4
132+
color: Theme.mainTextColor
133+
font.italic: true
134+
textFormat: Text.RichText
135+
onLinkActivated: link => Qt.openUrlExternally(link)
136+
}
137+
138+
ProgressBar {
139+
id: storageBar
140+
anchors.top: cloudAvatarRect.bottom
141+
anchors.topMargin: 8
142+
width: parent.width
143+
visible: false
144+
from: 0
145+
to: 1
146+
value: usage
147+
148+
// The `value` property is being animated, so we need the actual value at all times.
149+
property double usage: 0
150+
151+
Material.accent: {
152+
if (usage < .9)
153+
return Theme.qfieldCloudBlue;
154+
else if (usage < .975)
155+
return Theme.warningColor;
156+
else
157+
return Theme.bookmarkRed;
158+
}
159+
160+
Behavior on value {
161+
NumberAnimation {
162+
duration: 1000
163+
}
164+
}
165+
}
126166
}
127167

128168
ColumnLayout {
@@ -629,10 +669,36 @@ Page {
629669
} else {
630670
projects.visible = true;
631671
connectionSettings.visible = false;
672+
673+
// uncomment when storage bar api is ready
674+
// showStorageBar()
632675
}
676+
} else
677+
// uncomment when storage bar api is ready
678+
// hideStorageBar()
679+
{
633680
}
634681
}
635682

683+
function showStorageBar() {
684+
const usedStorage = 1;
685+
const totalStorage = 1;
686+
storageBar.usage = usedStorage / totalStorage;
687+
storageText.text = qsTr(`${usedStorage} GB of ${totalStorage} GB used`);
688+
if (storageBar.usage >= .975) {
689+
const upgradeStorageText = qsTr("upgrade to more storage here");
690+
storageText.text += `; <a href="https://apps.qfield.cloud/plans">${upgradeStorageText}</a>`;
691+
}
692+
storageText.visible = true;
693+
storageBar.visible = true;
694+
}
695+
696+
function hideStorageBar() {
697+
storageBar.usage = 0;
698+
storageBar.visible = false;
699+
storageText.visible = false;
700+
}
701+
636702
Component.onCompleted: {
637703
prepareCloudLogin();
638704
}

src/qml/imports/Theme/Theme.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ QtObject {
106106
property color bookmarkOrange: "orange"
107107
property color bookmarkRed: "#c0392b"
108108
property color bookmarkBlue: "#64b5f6"
109+
property color qfieldCloudBlue: "#4a6fae"
109110

110111
property color vertexColor: "#FF0000"
111112
property color vertexColorSemiOpaque: "#40FF0000"

0 commit comments

Comments
 (0)