From 7f4ca098de8f341f7961a861beb039db9d91719c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Sat, 10 Aug 2024 14:39:56 +0200 Subject: [PATCH] fix(SendModal): hide the Custom network mode in `production` - manage the lifetime of the Custom tab button dynamically; setting the tab button to `visible: false` doesn't unfortunately remove it from the tab bar Fixes #16052 --- storybook/pages/SendModalPage.qml | 9 +++++++- ui/app/mainui/AppMain.qml | 10 +++++---- ui/imports/shared/popups/send/SendModal.qml | 2 ++ .../popups/send/views/NetworkSelector.qml | 21 ++++++++++++++++++- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/storybook/pages/SendModalPage.qml b/storybook/pages/SendModalPage.qml index 20c28defa5..6dfdef505a 100644 --- a/storybook/pages/SendModalPage.qml +++ b/storybook/pages/SendModalPage.qml @@ -210,6 +210,7 @@ SplitView { preSelectedSendType: loader.preSelectedSendType preSelectedHoldingID: loader.preSelectedHoldingID preSelectedHoldingType: loader.preSelectedHoldingType + showCustomRoutingMode: ctrlShowCustomMode.checked } Component.onCompleted: loader.active = true } @@ -222,7 +223,7 @@ SplitView { ColumnLayout { width: parent.width - spacing: 20 + spacing: 10 ColumnLayout { spacing: 0 @@ -346,6 +347,12 @@ SplitView { } } + CheckBox { + id: ctrlShowCustomMode + text: "Show custom network routing panel" + checked: true + } + CheckBox { id: showCommunityAssetsCheckBox text: "Show community assets when sending tokens" diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 731be6ebe6..d2434bdeba 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -1,10 +1,10 @@ import QtQuick 2.15 -import QtQuick.Controls 2.13 -import QtQuick.Layouts 1.13 -import QtMultimedia 5.13 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.15 +import QtMultimedia 5.15 import Qt.labs.platform 1.1 import Qt.labs.settings 1.1 -import QtQml.Models 2.14 +import QtQml.Models 2.15 import QtQml 2.15 import AppLayouts.Wallet 1.0 @@ -1595,6 +1595,8 @@ Item { store: appMain.transactionStore collectiblesStore: appMain.walletCollectiblesStore + showCustomRoutingMode: !production + onClosed: { sendModal.closed() sendModal.preSelectedSendType = Constants.SendType.Unknown diff --git a/ui/imports/shared/popups/send/SendModal.qml b/ui/imports/shared/popups/send/SendModal.qml index 40fdb0b540..e983359d24 100644 --- a/ui/imports/shared/popups/send/SendModal.qml +++ b/ui/imports/shared/popups/send/SendModal.qml @@ -58,6 +58,7 @@ StatusDialog { property var bestRoutes property bool isLoading: false property int loginType + property bool showCustomRoutingMode property MessageDialog sendingError: MessageDialog { id: sendingError @@ -657,6 +658,7 @@ StatusDialog { totalFeesInFiat: d.totalFeesInFiat fromNetworksList: fromNetworksRouteModel toNetworksList: toNetworksRouteModel + showCustomRoutingMode: popup.showCustomRoutingMode routerError: d.routerError routerErrorDetails: d.routerErrorDetails diff --git a/ui/imports/shared/popups/send/views/NetworkSelector.qml b/ui/imports/shared/popups/send/views/NetworkSelector.qml index 99ffae6925..65b9af791e 100644 --- a/ui/imports/shared/popups/send/views/NetworkSelector.qml +++ b/ui/imports/shared/popups/send/views/NetworkSelector.qml @@ -36,6 +36,7 @@ Item { property int errorType: Constants.NoError property var bestRoutes property double totalFeesInFiat + property bool showCustomRoutingMode property string routerError: "" property string routerErrorDetails: "" @@ -46,6 +47,9 @@ Item { QtObject { id: d + + property var customButton + readonly property int backgroundRectRadius: 13 readonly property color backgroundRectColor: Theme.palette.indirectColor1 } @@ -62,9 +66,24 @@ Item { text: qsTr("Advanced") showBetaTag: true } + } + + // not visible in `production` for now, see https://github.com/status-im/status-desktop/issues/16052 + Component { + id: customButtonComponent StatusSwitchTabButton { text: qsTr("Custom") - enabled: false + } + } + + onShowCustomRoutingModeChanged: { + if (root.showCustomRoutingMode) { + if (!!d.customButton) + d.customButton.destroy() + d.customButton = customButtonComponent.createObject(tabBar) + tabBar.addItem(d.customButton) + } else if (!!d.customButton) { + d.customButton.destroy() } }