mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-11 23:05:17 +00:00
691de11211
Major changes: - Don't allow empty network selection. End up using the nim model directly instead because of individual row changes issues encountered with nim models - Made the clone model a generic implementation to be used in other places where we need to clone a model: ReceiveModal, AddEditSavedAddressPopup - Use cloned model as alternative to NetworksExtraStoreProxy in ReceiveModal - Added tristate support to our generic checkbox control - UX improvements as per design - Fix save address tests naming and zero address issue - Various fixes Notes: - Failed to make NetworkSelectPopup follow ground-truth: show partially checked as user intention until the network is selected in the source model. Got stuck on nim models not being stable models and report wrong entry change when reset. Tried sorting and only updating changes without reset but it didn't work. - Moved grouped property SingleSelectionInfo to its own file from an inline component after finding out that it fails to load on Linux with error "Cannot assign to property of unknown type: "*".". It works on MacOS as expected Closes: #10119
204 lines
6.3 KiB
QML
204 lines
6.3 KiB
QML
pragma Singleton
|
|
|
|
import QtQuick 2.13
|
|
|
|
import utils 1.0
|
|
import SortFilterProxyModel 0.2
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import "../addaccount/stores"
|
|
|
|
QtObject {
|
|
id: root
|
|
|
|
readonly property string defaultSelectedKeyUid: userProfile.keyUid
|
|
readonly property bool defaultSelectedKeyUidMigratedToKeycard: userProfile.isKeycardUser
|
|
|
|
property bool loggedInUserAuthenticated: false
|
|
|
|
property string backButtonName: ""
|
|
property var overview: walletSectionOverview
|
|
property var assets: walletSectionCurrent
|
|
property var currentAccount: walletSectionCurrent
|
|
property var accounts: walletSectionAccounts.model
|
|
property var appSettings: localAppSettings
|
|
property var accountSensitiveSettings: localAccountSensitiveSettings
|
|
property bool hideSignPhraseModal: accountSensitiveSettings.hideSignPhraseModal
|
|
|
|
property var totalCurrencyBalance: walletSection.totalCurrencyBalance
|
|
property string signingPhrase: walletSection.signingPhrase
|
|
property string mnemonicBackedUp: walletSection.isMnemonicBackedUp
|
|
|
|
property var flatCollectibles: walletSectionCollectibles.model
|
|
property var currentCollectible: walletSectionCurrentCollectible
|
|
|
|
property var savedAddresses: SortFilterProxyModel {
|
|
sourceModel: walletSectionSavedAddresses.model
|
|
filters: [
|
|
ValueFilter {
|
|
roleName: "isTest"
|
|
value: networksModule.areTestNetworksEnabled
|
|
}
|
|
]
|
|
}
|
|
|
|
property QtObject _d: QtObject {
|
|
id: d
|
|
property var chainColors: ({})
|
|
|
|
function initChainColors(model) {
|
|
for (let i = 0; i < model.count; i++) {
|
|
chainColors[model.rowData(i, "shortName")] = model.rowData(i, "chainColor")
|
|
}
|
|
}
|
|
}
|
|
|
|
function colorForChainShortName(chainShortName) {
|
|
return d.chainColors[chainShortName]
|
|
}
|
|
|
|
property var layer1Networks: networksModule.layer1
|
|
property var layer2Networks: networksModule.layer2
|
|
property var testNetworks: networksModule.test
|
|
property var enabledNetworks: networksModule.enabled
|
|
property var allNetworks: networksModule.all
|
|
onAllNetworksChanged: {
|
|
d.initChainColors(allNetworks)
|
|
}
|
|
|
|
property var cryptoRampServicesModel: walletSectionBuySellCrypto.model
|
|
|
|
// This should be exposed to the UI via "walletModule", WalletModule should use
|
|
// Accounts Service which keeps the info about that (isFirstTimeAccountLogin).
|
|
// Then in the View of WalletModule we may have either QtProperty or
|
|
// Q_INVOKABLE function (proc marked as slot) depends on logic/need.
|
|
// The only need for onboardingModel here is actually to check if an account
|
|
// has been just created or an old one.
|
|
|
|
//property bool firstTimeLogin: onboardingModel.isFirstTimeLogin
|
|
|
|
// example wallet model
|
|
property ListModel exampleWalletModel: ListModel {
|
|
ListElement {
|
|
name: "Status account"
|
|
address: "0xcfc9f08bbcbcb80760e8cb9a3c1232d19662fc6f"
|
|
balance: "12.00 USD"
|
|
color: "#7CDA00"
|
|
}
|
|
|
|
ListElement {
|
|
name: "Test account 1"
|
|
address: "0x2Ef1...E0Ba"
|
|
balance: "12.00 USD"
|
|
color: "#FA6565"
|
|
}
|
|
ListElement {
|
|
name: "Status account"
|
|
address: "0x2Ef1...E0Ba"
|
|
balance: "12.00 USD"
|
|
color: "#7CDA00"
|
|
}
|
|
}
|
|
|
|
property ListModel exampleAssetModel: ListModel {
|
|
ListElement {
|
|
name: "Ethereum"
|
|
symbol: "ETH"
|
|
balance: "3423 ETH"
|
|
address: "token-icons/eth"
|
|
currencyBalance: "123 USD"
|
|
}
|
|
}
|
|
|
|
function setHideSignPhraseModal(value) {
|
|
localAccountSensitiveSettings.hideSignPhraseModal = value;
|
|
}
|
|
|
|
function getLatestBlockNumber() {
|
|
// TODO: Move to transaction root module and not wallet
|
|
// Not Refactored Yet
|
|
// return walletModel.getLatestBlockNumber()
|
|
}
|
|
|
|
function setInitialRange() {
|
|
// Not Refactored Yet
|
|
// walletModel.setInitialRange()
|
|
}
|
|
|
|
function switchAccount(newIndex) {
|
|
if(Constants.isCppApp)
|
|
walletSectionAccounts.switchAccount(newIndex)
|
|
else
|
|
walletSection.switchAccount(newIndex)
|
|
}
|
|
|
|
function switchAccountByAddress(address) {
|
|
walletSection.switchAccountByAddress(address)
|
|
}
|
|
|
|
function deleteAccount(keyUid, address) {
|
|
return walletSectionAccounts.deleteAccount(keyUid, address)
|
|
}
|
|
|
|
function updateCurrentAccount(address, accountName, color, emoji) {
|
|
return walletSectionCurrent.update(address, accountName, color, emoji)
|
|
}
|
|
|
|
function updateCurrency(newCurrency) {
|
|
walletSection.updateCurrency(newCurrency)
|
|
}
|
|
|
|
function getQrCode(address) {
|
|
return globalUtils.qrCode(address)
|
|
}
|
|
|
|
function hex2Dec(value) {
|
|
return globalUtils.hex2Dec(value)
|
|
}
|
|
|
|
function getCollectionMaxValue(traitType, value, maxValue, collectionIndex) {
|
|
// Not Refactored Yet
|
|
// if(maxValue !== "")
|
|
// return parseInt(value) + qsTr(" of ") + maxValue;
|
|
// else
|
|
// return parseInt(value) + qsTr(" of ") +
|
|
// walletModelV2Inst.collectiblesView.collections.getCollectionTraitMaxValue(collectionIndex, traitType).toString();
|
|
}
|
|
|
|
function selectCollectible(address, tokenId) {
|
|
walletSectionCurrentCollectible.update(address, tokenId)
|
|
}
|
|
|
|
function getNameForSavedWalletAddress(address) {
|
|
return walletSectionSavedAddresses.getNameByAddress(address)
|
|
}
|
|
|
|
function createOrUpdateSavedAddress(name, address, favourite, chainShortNames, ens) {
|
|
return walletSectionSavedAddresses.createOrUpdateSavedAddress(name, address, favourite, chainShortNames, ens)
|
|
}
|
|
|
|
function deleteSavedAddress(address, ens) {
|
|
return walletSectionSavedAddresses.deleteSavedAddress(address, ens)
|
|
}
|
|
|
|
function toggleNetwork(chainId) {
|
|
networksModule.toggleNetwork(chainId)
|
|
}
|
|
|
|
function copyToClipboard(text) {
|
|
globalUtils.copyToClipboard(text)
|
|
}
|
|
|
|
function runAddAccountPopup() {
|
|
walletSection.runAddAccountPopup(false)
|
|
}
|
|
|
|
function runAddWatchOnlyAccountPopup() {
|
|
walletSection.runAddAccountPopup(true)
|
|
}
|
|
|
|
function runEditAccountPopup(address) {
|
|
walletSection.runEditAccountPopup(address)
|
|
}
|
|
}
|