2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2022-11-14 09:30:42 +00:00
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-11-30 09:19:59 +00:00
|
|
|
import StatusQ.Components 0.1
|
2022-11-14 09:30:42 +00:00
|
|
|
|
|
|
|
import AppLayouts.Onboarding.stores 1.0
|
|
|
|
import AppLayouts.Onboarding.shared 1.0
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property StartupStore startupStore
|
|
|
|
|
2022-11-30 09:19:59 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
2023-01-09 10:20:13 +00:00
|
|
|
property int counter: Constants.onboarding.profileFetching.timeout
|
2023-10-09 13:24:15 +00:00
|
|
|
|
2024-04-24 16:31:22 +00:00
|
|
|
// NOTE: This block can be removed when fetching backup is optimized
|
|
|
|
// https://github.com/status-im/status-go/issues/5022
|
|
|
|
readonly property bool minimumWaitingTimePassed: (Constants.onboarding.profileFetching.timeout - counter) > 30000
|
|
|
|
readonly property bool fetching: root.startupStore.currentStartupState.stateType === Constants.startupState.profileFetching || !d.minimumWaitingTimePassed
|
|
|
|
|
2023-10-09 13:24:15 +00:00
|
|
|
readonly property string fetchingDataText: qsTr("Fetching data...")
|
|
|
|
readonly property string continueText: qsTr("Continue")
|
2022-11-30 09:19:59 +00:00
|
|
|
}
|
2022-11-14 09:30:42 +00:00
|
|
|
|
2022-12-26 16:35:47 +00:00
|
|
|
onStateChanged: {
|
2023-12-20 07:37:42 +00:00
|
|
|
if (root.state === Constants.startupState.profileFetching) {
|
2023-01-09 10:20:13 +00:00
|
|
|
d.counter = Constants.onboarding.profileFetching.timeout
|
2022-12-26 16:35:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-14 09:30:42 +00:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.centerIn: parent
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.bigPadding
|
2022-11-14 09:30:42 +00:00
|
|
|
|
|
|
|
ProfileFetchingAnimation {
|
|
|
|
id: loadingAnimation
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
state: root.state
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: title
|
|
|
|
visible: text.length > 0
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: Constants.onboarding.profileFetching.titleFontSize
|
|
|
|
}
|
|
|
|
|
2022-11-30 09:19:59 +00:00
|
|
|
ListView {
|
|
|
|
Layout.preferredWidth: 345
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
implicitHeight: contentItem.childrenRect.height
|
|
|
|
|
|
|
|
clip: true
|
|
|
|
spacing: 8
|
|
|
|
|
|
|
|
model: root.startupStore.fetchingDataModel
|
|
|
|
|
|
|
|
delegate: Item {
|
|
|
|
width: ListView.view.width
|
|
|
|
height: 32
|
|
|
|
|
|
|
|
StatusIcon {
|
|
|
|
id: icon
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
width: 20
|
|
|
|
height: 20
|
|
|
|
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
icon: model.icon
|
|
|
|
}
|
|
|
|
|
2023-07-25 15:25:41 +00:00
|
|
|
StatusBaseText {
|
2022-11-30 09:19:59 +00:00
|
|
|
id: entity
|
|
|
|
anchors.left: icon.right
|
|
|
|
anchors.right: indicator.visible? indicator.left : loaded.left
|
|
|
|
anchors.leftMargin: 16
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
leftPadding: 4
|
|
|
|
font.pixelSize: Constants.onboarding.profileFetching.entityFontSize
|
|
|
|
text: {
|
|
|
|
switch(model.entity) {
|
|
|
|
case Constants.onboarding.profileFetching.entity.profile:
|
|
|
|
return qsTr("Profile details")
|
|
|
|
case Constants.onboarding.profileFetching.entity.contacts:
|
|
|
|
return qsTr("Contacts")
|
|
|
|
case Constants.onboarding.profileFetching.entity.communities:
|
|
|
|
return qsTr("Community membership")
|
|
|
|
case Constants.onboarding.profileFetching.entity.settings:
|
|
|
|
return qsTr("Settings")
|
2023-05-18 18:28:46 +00:00
|
|
|
case Constants.onboarding.profileFetching.entity.keypairs:
|
2024-06-07 13:29:09 +00:00
|
|
|
return qsTr("Key pairs")
|
2023-05-18 18:28:46 +00:00
|
|
|
case Constants.onboarding.profileFetching.entity.watchOnlyAccounts:
|
2023-10-04 14:54:04 +00:00
|
|
|
return qsTr("Watched addresses")
|
2022-11-30 09:19:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusLoadingIndicator {
|
|
|
|
id: indicator
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
visible: model.totalMessages === 0
|
|
|
|
}
|
|
|
|
|
2023-07-25 15:25:41 +00:00
|
|
|
StatusBaseText {
|
2022-11-30 09:19:59 +00:00
|
|
|
id: loaded
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
visible: !indicator.visible
|
|
|
|
rightPadding: 4
|
|
|
|
font.pixelSize: Constants.onboarding.profileFetching.entityProgressFontSize
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
text: "%1/%2".arg(model.loadedMessages).arg(model.totalMessages)
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusProgressBar {
|
|
|
|
id: progress
|
|
|
|
anchors.top: entity.bottom
|
|
|
|
anchors.left: entity.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.topMargin: 4
|
|
|
|
height: 3
|
|
|
|
from: 0
|
|
|
|
to: model.totalMessages
|
|
|
|
value: model.loadedMessages
|
|
|
|
backgroundColor: Theme.palette.baseColor5
|
|
|
|
backgroundBorderColor: backgroundColor
|
|
|
|
fillColor: {
|
|
|
|
if (model.totalMessages > 0 && model.totalMessages === model.loadedMessages)
|
|
|
|
return Theme.palette.successColor1
|
|
|
|
return Theme.palette.primaryColor1
|
|
|
|
}
|
|
|
|
}
|
2022-11-14 09:30:42 +00:00
|
|
|
}
|
2022-11-30 09:19:59 +00:00
|
|
|
|
|
|
|
ScrollBar.vertical: ScrollBar {}
|
2022-11-14 09:30:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: button
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
focus: true
|
2024-04-24 16:31:22 +00:00
|
|
|
enabled: !d.fetching
|
2022-11-14 09:30:42 +00:00
|
|
|
|
2022-11-30 09:19:59 +00:00
|
|
|
Timer {
|
|
|
|
id: timer
|
|
|
|
interval: 1000
|
2024-04-24 16:31:22 +00:00
|
|
|
running: d.fetching
|
2022-11-30 09:19:59 +00:00
|
|
|
repeat: true
|
|
|
|
onTriggered: {
|
2023-01-09 10:20:13 +00:00
|
|
|
d.counter = d.counter - 1000 // decrease 1000 ms
|
2022-11-30 09:25:47 +00:00
|
|
|
if (d.counter == 0) {
|
2022-11-30 09:19:59 +00:00
|
|
|
root.startupStore.doPrimaryAction()
|
|
|
|
}
|
2022-11-14 09:30:42 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-30 09:19:59 +00:00
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
root.startupStore.doPrimaryAction()
|
|
|
|
}
|
2022-11-14 09:30:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
}
|
2022-11-30 09:19:59 +00:00
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: Constants.startupState.profileFetching
|
2024-04-24 16:31:22 +00:00
|
|
|
when: d.fetching
|
2022-11-30 09:19:59 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: title
|
2023-10-09 13:24:15 +00:00
|
|
|
text: d.fetchingDataText
|
2022-11-30 09:19:59 +00:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: button
|
2023-01-09 10:20:13 +00:00
|
|
|
text: {
|
|
|
|
let date = new Date(0)
|
|
|
|
date.setTime(date.getTime() + d.counter)
|
|
|
|
return Qt.formatTime(date, "m:ss")
|
|
|
|
}
|
2022-11-30 09:19:59 +00:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: d
|
2023-01-09 10:20:13 +00:00
|
|
|
counter: Constants.onboarding.profileFetching.timeout
|
2022-11-30 09:19:59 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: Constants.startupState.profileFetchingTimeout
|
|
|
|
when: root.startupStore.currentStartupState.stateType === Constants.startupState.profileFetchingTimeout
|
|
|
|
PropertyChanges {
|
|
|
|
target: title
|
2023-10-09 13:24:15 +00:00
|
|
|
text: d.fetchingDataText
|
2022-11-30 09:19:59 +00:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: button
|
2023-10-09 13:24:15 +00:00
|
|
|
text: d.continueText
|
2022-11-30 09:19:59 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: Constants.startupState.profileFetchingSuccess
|
|
|
|
when: root.startupStore.currentStartupState.stateType === Constants.startupState.profileFetchingSuccess
|
|
|
|
PropertyChanges {
|
|
|
|
target: title
|
2023-10-09 13:24:15 +00:00
|
|
|
text: d.fetchingDataText
|
2022-11-30 09:19:59 +00:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: button
|
2023-10-09 13:24:15 +00:00
|
|
|
text: d.continueText
|
2022-11-30 09:19:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2022-11-14 09:30:42 +00:00
|
|
|
}
|