status-desktop/ui/app/AppLayouts/Wallet/panels/BuyCryptoProvidersListPanel...

88 lines
2.5 KiB
QML

import QtQuick 2.15
import QtQuick.Layouts 1.0
import QtQml.Models 2.15
import SortFilterProxyModel 0.2
import StatusQ.Controls 0.1
import StatusQ.Core 0.1
import AppLayouts.Wallet.controls 1.0
ColumnLayout {
id: root
// required properties
required property bool providersLoading
// expected model structure:
// id, name, description, fees, logoUrl, hostname, supportsSinglePurchase, supportsRecurrentPurchase, supportedAssets, urlsNeedParameters
required property var providersModel
required property bool isUrlBeingFetched
required property string selectedProviderId
// exposed api
property alias currentTabIndex: tabBar.currentIndex
signal providerSelected(string id)
QtObject {
id: d
readonly property int loadingItemsCount: 5
}
spacing: 20
StatusSwitchTabBar {
id: tabBar
// As we skip Mercuryo and it is the only provider supported for recurrent, we hide the tab bar until there is at least one recurrent provider
visible: false
objectName: "tabBar"
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
StatusSwitchTabButton {
text: qsTr("One time")
}
StatusSwitchTabButton {
text: qsTr("Recurrent")
}
}
StatusListView {
objectName: "providersList"
Layout.fillWidth: true
Layout.fillHeight: true
DelegateModel {
id: regularModel
model: SortFilterProxyModel {
sourceModel: root.providersModel
filters: ValueFilter {
roleName: "name"
value: "Mercuryo"
inverted: true
}
}
delegate: BuyCryptoProvidersDelegate {
required property var model
width: ListView.view.width
name: model.name
logoUrl: model.logoUrl
fees: model.fees
urlsNeedParameters: model.urlsNeedParameters
isUrlLoading: root.isUrlBeingFetched && root.selectedProviderId === model.id
onClicked: root.providerSelected(model.id)
}
}
DelegateModel {
id: loadingModel
model: d.loadingItemsCount
delegate: BuyCryptoProvidersLoadingDelegate {
required property var model
width: ListView.view.width
}
}
model: root.providersLoading ? loadingModel : regularModel
}
}