Skip to content

Commit 21e61d6

Browse files
mohsenD98nirvn
authored andcommitted
Add storageBar and storageText.
1 parent 24acf9d commit 21e61d6

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.status === QFieldCloudConnection.LoggedIn || table.count > 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 {
@@ -620,10 +660,36 @@ Page {
620660
} else {
621661
projects.visible = true;
622662
connectionSettings.visible = false;
663+
664+
// uncomment when storage bar api is ready
665+
// showStorageBar()
623666
}
667+
} else
668+
// uncomment when storage bar api is ready
669+
// hideStorageBar()
670+
{
624671
}
625672
}
626673

674+
function showStorageBar() {
675+
const usedStorage = 1;
676+
const totalStorage = 1;
677+
storageBar.usage = usedStorage / totalStorage;
678+
storageText.text = qsTr(`${usedStorage} GB of ${totalStorage} GB used`);
679+
if (storageBar.usage >= .975) {
680+
const upgradeStorageText = qsTr("upgrade to more storage here");
681+
storageText.text += `; <a href="https://apps.qfield.cloud/plans">${upgradeStorageText}</a>`;
682+
}
683+
storageText.visible = true;
684+
storageBar.visible = true;
685+
}
686+
687+
function hideStorageBar() {
688+
storageBar.usage = 0;
689+
storageBar.visible = false;
690+
storageText.visible = false;
691+
}
692+
627693
Component.onCompleted: {
628694
prepareCloudLogin();
629695
}

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)