@@ -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 .hasToken || cloudProjectsModel .rowCount () > 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 {
@@ -629,10 +669,36 @@ Page {
629
669
} else {
630
670
projects .visible = true ;
631
671
connectionSettings .visible = false ;
672
+
673
+ // uncomment when storage bar api is ready
674
+ // showStorageBar()
632
675
}
676
+ } else
677
+ // uncomment when storage bar api is ready
678
+ // hideStorageBar()
679
+ {
633
680
}
634
681
}
635
682
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
+
636
702
Component .onCompleted : {
637
703
prepareCloudLogin ();
638
704
}
0 commit comments