From b67ea6643a858dbc9dfa2a6e696e6a0344e507a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Fri, 2 Aug 2024 10:37:02 +0200 Subject: [PATCH] fix(SendModal): Bridge modal Simple mode's scroll is very clunky - remove the nested unneeded ScrollView - cleanups and fixes in mocked models and stores to unbreak showing the networks/routing in storybook Fixes #15902 --- storybook/pages/SendModalPage.qml | 11 +++- storybook/src/Models/NetworksModel.qml | 58 ------------------- ui/imports/shared/popups/send/SendModal.qml | 2 +- .../send/views/NetworksSimpleRoutingView.qml | 41 ++++++------- 4 files changed, 27 insertions(+), 85 deletions(-) diff --git a/storybook/pages/SendModalPage.qml b/storybook/pages/SendModalPage.qml index 202241c08e..20c28defa5 100644 --- a/storybook/pages/SendModalPage.qml +++ b/storybook/pages/SendModalPage.qml @@ -92,6 +92,11 @@ SplitView { TransactionStore { id: txStore + + property bool areTestNetworksEnabled: true + + function setRouteDisabledChains(chainId, disabled) {} + walletAssetStore: root.walletAssetStore tokensStore.showCommunityAssetsInSend: showCommunityAssetsCheckBox.checked tokensStore.displayAssetsBelowBalance: balanceThresholdCheckbox.checked @@ -104,10 +109,12 @@ SplitView { property ListModel toModel: ListModel { ListElement { chainId: 420 - chainName: "Optimism" - iconUrl: "network/Network=Optimism" amountOut: "3003845308235848343" } + ListElement { + chainId: 1 + amountOut: "30038453082358483445" + } } property var suggestesRoutes: [{ bridgeName:"Hop", diff --git a/storybook/src/Models/NetworksModel.qml b/storybook/src/Models/NetworksModel.qml index edd11d6bbb..4bf6a274fa 100644 --- a/storybook/src/Models/NetworksModel.qml +++ b/storybook/src/Models/NetworksModel.qml @@ -166,15 +166,6 @@ QtObject { Component.onCompleted: append([ { chainId: 1, - chainName: "Ethereum Mainnet", - iconUrl: ModelsData.networks.ethereum, - chainColor: "blue", - shortName: "ETH", - layer: 1, - nativeCurrencyDecimals: 18, - nativeCurrencyName: "Ether", - nativeCurrencySymbol: "ETH", - isRouteEnabled: true, isRoutePreferred: true, hasGas: true, tokenBalance: ({ @@ -190,15 +181,6 @@ QtObject { }, { chainId: 10, - chainName: "Optimism", - iconUrl: ModelsData.networks.optimism, - chainColor: "red", - shortName: "OPT", - layer: 2, - nativeCurrencyDecimals: 18, - nativeCurrencyName: "Ether", - nativeCurrencySymbol: "ETH", - isRouteEnabled: true, isRoutePreferred: true, hasGas: true, tokenBalance: ({ @@ -214,16 +196,6 @@ QtObject { }, { chainId: 42161, - chainName: "Arbitrum", - iconUrl: ModelsData.networks.arbitrum, - isActive: false, - shortName: "ARB", - chainColor: "purple", - layer: 2, - nativeCurrencyDecimals: 18, - nativeCurrencyName: "Ether", - nativeCurrencySymbol: "ETH", - isRouteEnabled: true, isRoutePreferred: true, hasGas: true, tokenBalance: ({ @@ -285,15 +257,6 @@ QtObject { Component.onCompleted: append([ { chainId: 1, - chainName: "Ethereum Mainnet", - iconUrl: ModelsData.networks.ethereum, - chainColor: "blue", - shortName: "ETH", - layer: 1, - nativeCurrencyDecimals: 18, - nativeCurrencyName: "Ether", - nativeCurrencySymbol: "ETH", - isRouteEnabled: true, isRoutePreferred: true, hasGas: true, tokenBalance: ({ @@ -309,16 +272,6 @@ QtObject { }, { chainId: 10, - chainName: "Optimism", - iconUrl: ModelsData.networks.optimism, - chainColor: "red", - shortName: "OPT", - layer: 2, - nativeCurrencyDecimals: 18, - nativeCurrencyName: "Ether", - nativeCurrencySymbol: "ETH", - isRouteEnabled: true, - isRoutePreferred: true, hasGas: true, tokenBalance: ({ displayDecimals: true, @@ -333,17 +286,6 @@ QtObject { }, { chainId: 42161, - chainName: "Arbitrum", - iconUrl: ModelsData.networks.arbitrum, - isActive: false, - isEnabled: true, - shortName: "ARB", - chainColor: "purple", - layer: 2, - nativeCurrencyDecimals: 18, - nativeCurrencyName: "Ether", - nativeCurrencySymbol: "ETH", - isRouteEnabled: true, isRoutePreferred: true, hasGas: true, tokenBalance: ({ diff --git a/ui/imports/shared/popups/send/SendModal.qml b/ui/imports/shared/popups/send/SendModal.qml index 1ebed083bc..99f1466b8a 100644 --- a/ui/imports/shared/popups/send/SendModal.qml +++ b/ui/imports/shared/popups/send/SendModal.qml @@ -143,7 +143,7 @@ StatusDialog { readonly property bool isCollectiblesTransfer: store.sendType === Constants.SendType.ERC721Transfer || store.sendType === Constants.SendType.ERC1155Transfer property var selectedHolding: null - property var selectedHoldingType: Constants.TokenType.Unknown + property int selectedHoldingType: Constants.TokenType.Unknown readonly property bool isSelectedHoldingValidAsset: !!selectedHolding && selectedHoldingType === Constants.TokenType.ERC20 onSelectedHoldingChanged: { diff --git a/ui/imports/shared/popups/send/views/NetworksSimpleRoutingView.qml b/ui/imports/shared/popups/send/views/NetworksSimpleRoutingView.qml index 3d592d89a6..f7de36c115 100644 --- a/ui/imports/shared/popups/send/views/NetworksSimpleRoutingView.qml +++ b/ui/imports/shared/popups/send/views/NetworksSimpleRoutingView.qml @@ -65,41 +65,34 @@ RowLayout { font.pixelSize: 15 color: Theme.palette.baseColor1 text: isBridgeTx ? qsTr("Routes will be automatically calculated to give you the lowest cost.") : - qsTr("The networks where the recipient will receive tokens. Amounts calculated automatically for the lowest cost.") + qsTr("The networks where the recipient will receive tokens. Amounts calculated automatically for the lowest cost.") wrapMode: Text.WordWrap } - ScrollView { + Column { Layout.fillWidth: true - Layout.preferredHeight: visible ? row.height + 10 : 0 Layout.topMargin: Style.current.smallPadding - contentWidth: row.width - contentHeight: row.height + 10 - ScrollBar.vertical.policy: ScrollBar.AlwaysOff - ScrollBar.horizontal.policy: ScrollBar.AsNeeded - clip: true + Layout.bottomMargin: Style.current.smallPadding + spacing: Style.current.halfPadding visible: root.isBridgeTx ? true : !root.isLoading ? root.errorType === Constants.NoError : false - Column { - id: row - spacing: Style.current.padding - // TODO: This transformation should come from an adaptor outside this component - LeftJoinModel { - id: toNetworksListLeftJoinModel + // TODO: This transformation should come from an adaptor outside this component + LeftJoinModel { + id: toNetworksListLeftJoinModel - leftModel: root.suggestedToNetworksList - rightModel: root.store.flatNetworksModel - joinRole: "chainId" - } + leftModel: root.suggestedToNetworksList + rightModel: root.store.flatNetworksModel + joinRole: "chainId" + } - Repeater { - id: repeater - objectName: "networksList" - model: isBridgeTx ? root.fromNetworksList : toNetworksListLeftJoinModel - delegate: isBridgeTx ? networkItem : routeItem - } + Repeater { + id: repeater + objectName: "networksList" + model: isBridgeTx ? root.fromNetworksList : toNetworksListLeftJoinModel + delegate: isBridgeTx ? networkItem : routeItem } } + BalanceExceeded { Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter