From ea9813cef0f14d160700d5f812684664dcbcf3c2 Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Sat, 18 Jul 2026 19:35:52 -0300 Subject: [PATCH] fix(liquidity): reuse wallet copy controls --- .../components/liquidity/AmmCopyButton.qml | 66 ------------------- .../liquidity/CopyableAddressRow.qml | 17 ++--- .../LiquidityConfirmationSummary.qml | 10 ++- .../components/liquidity/TokenAmountInput.qml | 11 ++-- .../liquidity/TokenSelectorModal.qml | 11 ++-- 5 files changed, 29 insertions(+), 86 deletions(-) delete mode 100644 apps/amm/qml/components/liquidity/AmmCopyButton.qml diff --git a/apps/amm/qml/components/liquidity/AmmCopyButton.qml b/apps/amm/qml/components/liquidity/AmmCopyButton.qml deleted file mode 100644 index ecac447..0000000 --- a/apps/amm/qml/components/liquidity/AmmCopyButton.qml +++ /dev/null @@ -1,66 +0,0 @@ -pragma ComponentBehavior: Bound - -import QtQuick -import QtQuick.Controls.Basic - -Button { - id: root - - required property var theme - property string value: "" - property string accessibleName: qsTr("Copy address") - property int buttonWidth: 30 - property int labelFontPixelSize: 10 - property bool copied: false - - implicitWidth: root.buttonWidth - implicitHeight: 24 - visible: root.value.length > 0 - enabled: root.value.length > 0 - hoverEnabled: true - text: root.copied ? "\u2713" : qsTr("Copy") - Accessible.name: root.copied ? qsTr("Copied") : root.accessibleName - ToolTip.visible: hovered - ToolTip.text: Accessible.name - onClicked: { - root.copyToClipboard() - root.copied = true - copiedReset.restart() - } - - contentItem: Text { - text: root.text - color: root.enabled ? root.theme.colors.ctaBg : root.theme.colors.textPlaceholder - font.pixelSize: root.labelFontPixelSize - font.weight: Font.Medium - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - - background: Rectangle { - radius: 5 - color: root.hovered || root.activeFocus ? root.theme.colors.selection : "transparent" - } - - Timer { - id: copiedReset - - interval: 1600 - repeat: false - onTriggered: root.copied = false - } - - TextEdit { - id: clipboardProxy - - visible: false - } - - function copyToClipboard() { - clipboardProxy.text = root.value - clipboardProxy.selectAll() - clipboardProxy.copy() - clipboardProxy.deselect() - clipboardProxy.text = "" - } -} diff --git a/apps/amm/qml/components/liquidity/CopyableAddressRow.qml b/apps/amm/qml/components/liquidity/CopyableAddressRow.qml index e2aae89..2e8b1fe 100644 --- a/apps/amm/qml/components/liquidity/CopyableAddressRow.qml +++ b/apps/amm/qml/components/liquidity/CopyableAddressRow.qml @@ -4,6 +4,8 @@ import QtQuick import QtQuick.Controls.Basic import QtQuick.Layouts +import Logos.Wallet as Wallet + RowLayout { id: root @@ -56,16 +58,15 @@ RowLayout { ToolTip.visible: root.canCopy && addressText.truncated && addressHover.hovered ToolTip.text: root.address - AmmCopyButton { + Wallet.CopyButton { id: copyAddressButton objectName: "copyAddressButton" - Layout.preferredWidth: visible ? 48 : 0 - Layout.preferredHeight: 24 - theme: root.theme - value: root.address - accessibleName: qsTr("Copy %1 address").arg(root.label) - buttonWidth: 48 - labelFontPixelSize: 11 + Layout.preferredWidth: visible ? implicitWidth : 0 + Layout.preferredHeight: implicitHeight + copyText: root.address + copyLabel: qsTr("Copy %1 address").arg(root.label) + visible: root.canCopy + enabled: root.canCopy } } diff --git a/apps/amm/qml/components/liquidity/LiquidityConfirmationSummary.qml b/apps/amm/qml/components/liquidity/LiquidityConfirmationSummary.qml index 49e69d6..56f6919 100644 --- a/apps/amm/qml/components/liquidity/LiquidityConfirmationSummary.qml +++ b/apps/amm/qml/components/liquidity/LiquidityConfirmationSummary.qml @@ -4,6 +4,8 @@ import QtQuick import QtQuick.Controls.Basic import QtQuick.Layouts +import Logos.Wallet as Wallet + ColumnLayout { id: root @@ -157,12 +159,14 @@ ColumnLayout { } } - AmmCopyButton { + Wallet.CopyButton { objectName: "copyLpDestinationButton" Layout.preferredWidth: visible ? implicitWidth : 0 Layout.preferredHeight: implicitHeight - theme: root.theme - value: String(root.snapshot.selectedLpHoldingId || "") + copyText: String(root.snapshot.selectedLpHoldingId || "") + copyLabel: qsTr("Copy LP destination") + visible: copyText.length > 0 + enabled: copyText.length > 0 } } } diff --git a/apps/amm/qml/components/liquidity/TokenAmountInput.qml b/apps/amm/qml/components/liquidity/TokenAmountInput.qml index d3bbabd..25aec26 100644 --- a/apps/amm/qml/components/liquidity/TokenAmountInput.qml +++ b/apps/amm/qml/components/liquidity/TokenAmountInput.qml @@ -1,10 +1,9 @@ pragma ComponentBehavior: Bound import QtQuick -import QtQuick.Controls.Basic import QtQuick.Layouts -import "../shared" +import Logos.Wallet as Wallet AmmTokenAmountSurface { id: root @@ -119,12 +118,14 @@ AmmTokenAmountSurface { } } - AmmCopyButton { + Wallet.CopyButton { objectName: "copySelectedHoldingButton" Layout.preferredWidth: visible ? implicitWidth : 0 Layout.preferredHeight: implicitHeight - theme: root.theme - value: root.selectedHoldingId + copyText: root.selectedHoldingId + copyLabel: qsTr("Copy selected holding") + visible: copyText.length > 0 + enabled: copyText.length > 0 } } } diff --git a/apps/amm/qml/components/liquidity/TokenSelectorModal.qml b/apps/amm/qml/components/liquidity/TokenSelectorModal.qml index 73377cc..91a9f37 100644 --- a/apps/amm/qml/components/liquidity/TokenSelectorModal.qml +++ b/apps/amm/qml/components/liquidity/TokenSelectorModal.qml @@ -4,6 +4,8 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts +import Logos.Wallet as Wallet + Popup { id: root @@ -322,15 +324,16 @@ Popup { elide: Text.ElideRight } - AmmCopyButton { + Wallet.CopyButton { id: copyTokenDefinitionButton objectName: "copyTokenDefinitionButton" Layout.preferredWidth: visible ? implicitWidth : 0 Layout.preferredHeight: implicitHeight - theme: root.theme - value: tokenRow.tokenDefinitionId - accessibleName: qsTr("Copy TokenDefinition address") + copyText: tokenRow.tokenDefinitionId + copyLabel: qsTr("Copy TokenDefinition address") + visible: copyText.length > 0 + enabled: copyText.length > 0 } } }