@@ -36,15 +36,17 @@ Page {
36
36
Layout .fillHeight : true
37
37
spacing: 2
38
38
39
- RowLayout {
39
+ Item {
40
40
id: connectionInformation
41
- spacing: 2
42
41
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
43
46
visible: cloudConnection .status === QFieldCloudConnection .LoggedIn || table .count > 0
44
47
45
48
Label {
46
- Layout .fillWidth : true
47
- padding: 10
49
+ anchors .left : parent .left
48
50
opacity: projects .visible ? 1 : 0
49
51
text: switch (cloudConnection .status ) {
50
52
case 0 :
64
66
65
67
Rectangle {
66
68
id: cloudAvatarRect
67
- Layout .alignment : Qt .AlignHCenter | Qt .AlignVCenter
68
- Layout .margins : 10
69
+ anchors .right : parent .right
69
70
width: 48
70
71
height: 48
71
72
border .color : Theme .mainColor
@@ -123,6 +124,45 @@ Page {
123
124
}
124
125
}
125
126
}
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
+ }
126
166
}
127
167
128
168
ColumnLayout {
@@ -620,10 +660,36 @@ Page {
620
660
} else {
621
661
projects .visible = true ;
622
662
connectionSettings .visible = false ;
663
+
664
+ // uncomment when storage bar api is ready
665
+ // showStorageBar()
623
666
}
667
+ } else
668
+ // uncomment when storage bar api is ready
669
+ // hideStorageBar()
670
+ {
624
671
}
625
672
}
626
673
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
+
627
693
Component .onCompleted : {
628
694
prepareCloudLogin ();
629
695
}
0 commit comments