Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace TokenSelector with the new version #16321

Merged
merged 13 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions storybook/pages/AssetSelectorCompactPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import QtQuick 2.15
import QtQuick.Controls 2.15

import AppLayouts.Wallet.controls 1.0
import StatusQ.Core.Theme 0.1
import utils 1.0

Pane {
readonly property var assetsData: [
{
tokensKey: "key_1",
communityId: "",
name: "Status Test Token",
currencyBalanceAsString: "42,23 USD",
symbol: "STT",
iconSource: Constants.tokenIcon("STT"),
tokensKey: "STT",

balances: [
{
balanceAsString: "0,56",
iconUrl: "network/Network=Ethereum"
}
],

sectionText: "My assets on Mainnet"
},
{
tokensKey: "key_2",
communityId: "",
name: "Ether",
currencyBalanceAsString: "4 276,86 USD",
symbol: "ETH",
iconSource: Constants.tokenIcon("ETH"),
tokensKey: "ETH",

balances: [
{
balanceAsString: "0,12",
iconUrl: "network/Network=Ethereum"
}
],

sectionText: "My assets on Mainnet"
},
{
tokensKey: "key_2",
communityId: "",
name: "Dai Stablecoin",
currencyBalanceAsString: "45,92 USD",
symbol: "DAI",
iconSource: Constants.tokenIcon("DAI"),
tokensKey: "DAI",
balances: [],

sectionText: "Popular assets"
},
{
tokensKey: "key_3",
communityId: "",
name: "0x",
currencyBalanceAsString: "41,22 USD",
symbol: "ZRX",
iconSource: Constants.tokenIcon("ZRX"),
tokensKey: "ZRX",
balances: [],

sectionText: "Popular assets"
}
]

ListModel {
id: assetsModel

Component.onCompleted: append(assetsData)
}

background: Rectangle {
color: Theme.palette.baseColor3
}

AssetSelectorCompact {
id: panel

anchors.centerIn: parent
width: 400

model: assetsModel
sectionProperty: "sectionText"

onSelected: console.log("asset selected:", key)
}
}

// category: Controls
74 changes: 34 additions & 40 deletions storybook/pages/AssetSelectorPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,76 +8,60 @@ import utils 1.0
Pane {
readonly property var assetsData: [
{
tokensKey: "key_1",
tokensKey: "stt_key",
communityId: "",
name: "Status Test Token",
currencyBalanceAsString: "42,23 USD",
symbol: "STT",
iconSource: Constants.tokenIcon("STT"),
tokensKey: "STT",

balances: [
{
balanceAsString: "0,56",
iconUrl: "network/Network=Ethereum"
},
{
balanceAsString: "0,22",
iconUrl: "network/Network=Arbitrum"
},
{
balanceAsString: "0,12",
iconUrl: "network/Network=Optimism"
}
]
],

sectionText: "My assets on Mainnet"
},
{
tokensKey: "key_2",
tokensKey: "eth_key",
communityId: "",
name: "Ether",
currencyBalanceAsString: "4 276,86 USD",
symbol: "ETH",
iconSource: Constants.tokenIcon("ETH"),
tokensKey: "ETH",

balances: [
{
balanceAsString: "1,01",
iconUrl: "network/Network=Optimism"
},
{
balanceAsString: "0,47",
iconUrl: "network/Network=Arbitrum"
},
{
balanceAsString: "0,12",
iconUrl: "network/Network=Ethereum"
}
]
],

sectionText: "My assets on Mainnet"
},
{
tokensKey: "key_2",
tokensKey: "dai_key",
communityId: "",
name: "Dai Stablecoin",
currencyBalanceAsString: "45,92 USD",
symbol: "DAI",
iconSource: Constants.tokenIcon("DAI"),
tokensKey: "DAI",
balances: [],

balances: [
{
balanceAsString: "45,12",
iconUrl: "network/Network=Arbitrum"
},
{
balanceAsString: "0,56",
iconUrl: "network/Network=Optimism"
},
{
balanceAsString: "0,12",
iconUrl: "network/Network=Ethereum"
}
]
sectionText: "Popular assets"
},
{
tokensKey: "zrx_key",
communityId: "",
name: "0x",
currencyBalanceAsString: "41,22 USD",
symbol: "ZRX",
iconSource: Constants.tokenIcon("ZRX"),
balances: [],

sectionText: "Popular assets"
}
]

Expand All @@ -96,9 +80,19 @@ Pane {

anchors.centerIn: parent

assetsModel: assetsModel
model: assetsModel
sectionProperty: "sectionText"

onSelected: console.log("asset selected:", key)
}

Button {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter

text: "reset"

onAssetSelected: console.log("asset selected:", key)
onClicked: panel.reset()
}
}

Expand Down
2 changes: 1 addition & 1 deletion storybook/pages/CollectiblesSelectionAdaptorPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ Pane {
ColumnLayout {
anchors.fill: parent

TokenSelectorNew {
TokenSelector {
collectiblesModel: adaptor.model
}

Expand Down
111 changes: 111 additions & 0 deletions storybook/pages/SearchableAssetsPanelPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15

import AppLayouts.Wallet.panels 1.0
import utils 1.0

Pane {
readonly property var assetsData: [
{
tokensKey: "stt_key",
communityId: "",
name: "Status Test Token",
currencyBalanceAsString: "42,23 USD",
symbol: "STT",
iconSource: Constants.tokenIcon("STT"),
balances: [
{
balanceAsString: "0,56",
iconUrl: "network/Network=Ethereum"
},
{
balanceAsString: "0,22",
iconUrl: "network/Network=Arbitrum"
},
{
balanceAsString: "0,12",
iconUrl: "network/Network=Optimism"
}
],

sectionText: ""
},
{
tokensKey: "eth_key",
communityId: "",
name: "Ether",
currencyBalanceAsString: "4 276,86 USD",
symbol: "ETH",
iconSource: Constants.tokenIcon("ETH"),
balances: [
{
balanceAsString: "1,01",
iconUrl: "network/Network=Optimism"
},
{
balanceAsString: "0,47",
iconUrl: "network/Network=Arbitrum"
},
{
balanceAsString: "0,12",
iconUrl: "network/Network=Ethereum"
}
],

sectionText: ""
},
{
tokensKey: "dai_key",
communityId: "",
name: "Dai Stablecoin",
currencyBalanceAsString: "45,92 USD",
symbol: "DAI",
iconSource: Constants.tokenIcon("DAI"),
balances: [],

sectionText: "Popular assets"
},
{
tokensKey: "zrx_key",
communityId: "",
name: "0x",
currencyBalanceAsString: "41,22 USD",
symbol: "ZRX",
iconSource: Constants.tokenIcon("ZRX"),
balances: [],

sectionText: "Popular assets"
}
]

ListModel {
id: assetsModel

Component.onCompleted: append(assetsData)
}

Rectangle {
anchors.fill: panel
anchors.margins: -1

color: "transparent"
border.color: "lightgray"
}

SearchableAssetsPanel {
id: panel

anchors.centerIn: parent

width: 450
highlightedKey: "key_2"

model: assetsModel
sectionProperty: "sectionText"

onSelected: console.log("selected:", key)
}
}

// category: Panels
15 changes: 6 additions & 9 deletions storybook/pages/TokenSelectorAssetDelegatePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ SplitView {
anchors.centerIn: parent

TokenSelectorAssetDelegate {
implicitWidth: 333
width: 333
anchors.centerIn: parent

tokensKey: "ETH"
name: "Ethereum"
symbol: "ETH"
currencyBalanceAsString: "14,456.42 USD"
iconSource: Constants.tokenIcon(symbol)

balancesModel: ListModel {
readonly property var data: [
{ chainId: 1, balanceAsString: "1234.50", iconUrl: "network/Network=Ethereum" },
Expand All @@ -57,13 +57,10 @@ SplitView {
Component.onCompleted: append(data)
}

interactive: ctrlInteractive.checked
enabled: ctrlEnabled.checked
highlighted: ctrlHighlighted.checked

onAssetSelected: (tokensKey) => {
console.warn("!!! TOKEN SELECTED:", tokensKey)
logs.logEvent("TokenSelectorAssetDelegate::onTokenSelected", ["tokensKey"], arguments)
}
onClicked: key => logs.logEvent("TokenSelectorAssetDelegate::onClicked")
}
}
}
Expand All @@ -79,8 +76,8 @@ SplitView {

ColumnLayout {
Switch {
id: ctrlInteractive
text: "Interactive"
id: ctrlEnabled
text: "Enabled"
checked: true
}
Switch {
Expand Down
Loading