2022-03-01 10:14:13 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core 0.1
|
2022-08-18 14:44:48 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2022-03-01 10:14:13 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
2022-07-19 15:09:20 +00:00
|
|
|
import shared.controls 1.0
|
2022-03-01 10:14:13 +00:00
|
|
|
|
2022-07-19 15:09:20 +00:00
|
|
|
import "../stores"
|
2022-03-01 10:14:13 +00:00
|
|
|
import "../popups"
|
|
|
|
import "../controls"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
2022-07-19 13:16:14 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.rightMargin: Style.current.padding
|
2022-03-01 10:14:13 +00:00
|
|
|
|
2022-07-19 15:09:20 +00:00
|
|
|
property var sendModal
|
2022-03-01 10:14:13 +00:00
|
|
|
property var contactsStore
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: _internal
|
|
|
|
property bool loading: false
|
|
|
|
property string error: ""
|
2022-08-18 14:44:48 +00:00
|
|
|
function saveAddress(name, address, favourite) {
|
2022-09-05 09:15:47 +00:00
|
|
|
loading = true
|
2022-08-18 14:44:48 +00:00
|
|
|
error = RootStore.createOrUpdateSavedAddress(name, address, favourite)
|
2022-09-05 09:15:47 +00:00
|
|
|
loading = false
|
|
|
|
}
|
|
|
|
function deleteSavedAddress(address) {
|
|
|
|
loading = true
|
|
|
|
error = RootStore.deleteSavedAddress(address)
|
|
|
|
loading = false
|
|
|
|
}
|
2022-03-01 10:14:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: header
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
|
|
|
height: btnAdd.height
|
|
|
|
|
2022-07-19 13:16:14 +00:00
|
|
|
StatusBaseText {
|
2022-03-01 10:14:13 +00:00
|
|
|
anchors.left: parent.left
|
2022-07-19 13:16:14 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
id: title
|
|
|
|
text: qsTr("Saved addresses")
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: 28
|
|
|
|
color: Theme.palette.directColor1
|
2022-03-01 10:14:13 +00:00
|
|
|
}
|
|
|
|
StatusButton {
|
2022-08-03 10:08:46 +00:00
|
|
|
objectName: "addNewAddressBtn"
|
2022-03-01 10:14:13 +00:00
|
|
|
id: btnAdd
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
2022-07-19 13:16:14 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
size: StatusBaseButton.Size.Small
|
|
|
|
font.weight: Font.Medium
|
|
|
|
text: qsTr("Add new address")
|
2022-03-01 10:14:13 +00:00
|
|
|
visible: !_internal.loading
|
|
|
|
onClicked: {
|
|
|
|
Global.openPopup(addEditSavedAddress)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusLoadingIndicator {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: _internal.loading
|
|
|
|
color: Theme.palette.directColor4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SavedAddressesError {
|
|
|
|
id: errorMessage
|
|
|
|
anchors.top: header.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
visible: _internal.error !== ""
|
|
|
|
text: _internal.error
|
|
|
|
height: visible ? 36 : 0
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: listView.count === 0
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
text: qsTr("No saved addresses")
|
|
|
|
}
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
|
|
|
id: listView
|
2022-08-24 08:23:43 +00:00
|
|
|
objectName: "SavedAddressesView_savedAddresses"
|
2022-03-01 10:14:13 +00:00
|
|
|
anchors.top: errorMessage.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: Style.current.halfPadding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
|
|
|
visible: listView.count > 0
|
2022-07-14 11:03:36 +00:00
|
|
|
spacing: 5
|
|
|
|
model: RootStore.savedAddresses
|
2022-09-05 09:15:47 +00:00
|
|
|
delegate: SavedAddressesDelegate {
|
2022-08-24 08:23:43 +00:00
|
|
|
objectName: "savedAddressView_Delegate_" + name
|
|
|
|
|
2022-09-05 09:15:47 +00:00
|
|
|
name: model.name
|
|
|
|
address: model.address
|
2022-08-18 14:44:48 +00:00
|
|
|
favourite: model.favourite
|
2022-09-05 09:15:47 +00:00
|
|
|
store: RootStore
|
|
|
|
contactsStore: root.contactsStore
|
|
|
|
onOpenSendModal: root.sendModal.open(address);
|
2022-08-18 14:44:48 +00:00
|
|
|
saveAddress: function(name, address, favourite) {
|
|
|
|
_internal.saveAddress(name, address, favourite)
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
|
|
|
deleteSavedAddress: function(address) {
|
|
|
|
_internal.deleteSavedAddress(address)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: addEditSavedAddress
|
|
|
|
AddEditSavedAddressPopup {
|
|
|
|
id: addEditModal
|
|
|
|
anchors.centerIn: parent
|
|
|
|
onClosed: destroy()
|
|
|
|
contactsStore: root.contactsStore
|
|
|
|
onSave: {
|
2022-08-18 14:44:48 +00:00
|
|
|
_internal.saveAddress(name, address, favourite)
|
2022-09-05 09:15:47 +00:00
|
|
|
close()
|
|
|
|
}
|
|
|
|
}
|
2022-03-01 10:14:13 +00:00
|
|
|
}
|
|
|
|
}
|