fix(amm): keep trade controls reachable

This commit is contained in:
Ricardo Guilherme Schmidt 2026-07-17 20:54:51 -03:00
parent d9852f2715
commit 7b595dc5da
No known key found for this signature in database
GPG Key ID: 1396EA17DE132FFE
2 changed files with 90 additions and 27 deletions

View File

@ -1,6 +1,7 @@
pragma ComponentBehavior: Bound pragma ComponentBehavior: Bound
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import Logos.Wallet import Logos.Wallet
import "../components/shared" import "../components/shared"
@ -87,17 +88,39 @@ Item {
} }
} }
Flickable {
id: swapScroll
objectName: "swapScroll"
anchors.fill: parent
clip: true
contentWidth: width
contentHeight: Math.max(height,
swapContent.y + swapContent.implicitHeight + 16)
flickableDirection: Flickable.VerticalFlick
boundsBehavior: Flickable.StopAtBounds
ScrollBar.vertical: ScrollBar {
policy: ScrollBar.AsNeeded
}
ColumnLayout { ColumnLayout {
anchors.centerIn: parent id: swapContent
objectName: "swapContent"
x: 16
y: Math.max(56, Math.round((swapScroll.height - implicitHeight) / 2))
width: Math.max(0, swapScroll.width - 32)
spacing: 28 spacing: 28
SwapCard { SwapCard {
id: swapCard id: swapCard
objectName: "swapCard" objectName: "swapCard"
Layout.fillWidth: true
Layout.maximumWidth: 480
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
theme: pageTheme theme: pageTheme
tokens: root.tokens tokens: root.tokens
width: Math.min(480, root.width - 32)
onRequestTokenSelect: function(side) { onRequestTokenSelect: function(side) {
tokenModal.targetSide = side tokenModal.targetSide = side
@ -111,8 +134,9 @@ Item {
Text { Text {
objectName: "swapPreviewNotice" objectName: "swapPreviewNotice"
Layout.fillWidth: true
Layout.maximumWidth: 480
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.maximumWidth: Math.max(0, Math.min(480, root.width - 32))
text: qsTr("Preview only — sample data. No swap will be submitted.") text: qsTr("Preview only — sample data. No swap will be submitted.")
color: pageTheme.colors.textSecondary color: pageTheme.colors.textSecondary
font.pixelSize: 15 font.pixelSize: 15
@ -120,6 +144,7 @@ Item {
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
} }
} }
}
TokenSelectorModal { TokenSelectorModal {
id: tokenModal id: tokenModal

View File

@ -138,5 +138,43 @@ Item {
verify(!card.canSubmit) verify(!card.canSubmit)
compare(card.submitButtonText, "Select different tokens") compare(card.submitButtonText, "Select different tokens")
} }
function test_tradeContentStaysReachable_data() {
return [
{ "tag": "short", "width": 360, "height": 184 },
{ "tag": "expanded", "width": 400, "height": 544 }
]
}
function test_tradeContentStaysReachable(data) {
const page = createTemporaryObject(pageComponent, root, {
"width": data.width,
"height": data.height
})
verify(page)
const scroll = findChild(page, "swapScroll")
const card = findChild(page, "swapCard")
const notice = findChild(page, "swapPreviewNotice")
verify(scroll)
verify(card)
verify(notice)
card.setToken("sell", page.tokens[0])
card.setToken("buy", page.tokens[1])
card.sellInput = "1"
card.editingSide = "sell"
wait(0)
const cardPosition = card.mapToItem(page, 0, 0)
verify(cardPosition.x >= 16)
verify(cardPosition.x + card.width <= page.width - 16)
if (scroll.contentHeight > scroll.height)
scroll.contentY = scroll.contentHeight - scroll.height
wait(0)
const noticePosition = notice.mapToItem(scroll, 0, 0)
verify(noticePosition.y >= 0)
verify(noticePosition.y + notice.height <= scroll.height)
}
} }
} }