Skip to content

Commit

Permalink
fix(SendModal): Bridge modal Simple mode's scroll is very clunky
Browse files Browse the repository at this point in the history
- remove the nested unneeded ScrollView
- cleanups and fixes in mocked models and stores to unbreak showing the
networks/routing in storybook

Fixes #15902
  • Loading branch information
caybro committed Aug 2, 2024
1 parent b8bc0a9 commit b67ea66
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 85 deletions.
11 changes: 9 additions & 2 deletions storybook/pages/SendModalPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down
58 changes: 0 additions & 58 deletions storybook/src/Models/NetworksModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ({
Expand All @@ -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: ({
Expand All @@ -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: ({
Expand Down Expand Up @@ -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: ({
Expand All @@ -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,
Expand All @@ -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: ({
Expand Down
2 changes: 1 addition & 1 deletion ui/imports/shared/popups/send/SendModal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
41 changes: 17 additions & 24 deletions ui/imports/shared/popups/send/views/NetworksSimpleRoutingView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b67ea66

Please sign in to comment.