mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-20 05:50:32 +00:00
fix(amm): keep trade controls reachable
This commit is contained in:
parent
d9852f2715
commit
7b595dc5da
@ -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,37 +88,61 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
Flickable {
|
||||||
anchors.centerIn: parent
|
id: swapScroll
|
||||||
spacing: 28
|
|
||||||
|
|
||||||
SwapCard {
|
objectName: "swapScroll"
|
||||||
id: swapCard
|
anchors.fill: parent
|
||||||
objectName: "swapCard"
|
clip: true
|
||||||
Layout.alignment: Qt.AlignHCenter
|
contentWidth: width
|
||||||
theme: pageTheme
|
contentHeight: Math.max(height,
|
||||||
tokens: root.tokens
|
swapContent.y + swapContent.implicitHeight + 16)
|
||||||
width: Math.min(480, root.width - 32)
|
flickableDirection: Flickable.VerticalFlick
|
||||||
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
|
||||||
onRequestTokenSelect: function(side) {
|
ScrollBar.vertical: ScrollBar {
|
||||||
tokenModal.targetSide = side
|
policy: ScrollBar.AsNeeded
|
||||||
tokenModal.open()
|
|
||||||
}
|
|
||||||
|
|
||||||
onPreviewRequested: function(snapshot) {
|
|
||||||
swapConfirmationDialog.openWithSnapshot(snapshot)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
ColumnLayout {
|
||||||
objectName: "swapPreviewNotice"
|
id: swapContent
|
||||||
Layout.alignment: Qt.AlignHCenter
|
|
||||||
Layout.maximumWidth: Math.max(0, Math.min(480, root.width - 32))
|
objectName: "swapContent"
|
||||||
text: qsTr("Preview only — sample data. No swap will be submitted.")
|
x: 16
|
||||||
color: pageTheme.colors.textSecondary
|
y: Math.max(56, Math.round((swapScroll.height - implicitHeight) / 2))
|
||||||
font.pixelSize: 15
|
width: Math.max(0, swapScroll.width - 32)
|
||||||
horizontalAlignment: Text.AlignHCenter
|
spacing: 28
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
|
SwapCard {
|
||||||
|
id: swapCard
|
||||||
|
objectName: "swapCard"
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.maximumWidth: 480
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
theme: pageTheme
|
||||||
|
tokens: root.tokens
|
||||||
|
|
||||||
|
onRequestTokenSelect: function(side) {
|
||||||
|
tokenModal.targetSide = side
|
||||||
|
tokenModal.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
onPreviewRequested: function(snapshot) {
|
||||||
|
swapConfirmationDialog.openWithSnapshot(snapshot)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
objectName: "swapPreviewNotice"
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.maximumWidth: 480
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
text: qsTr("Preview only — sample data. No swap will be submitted.")
|
||||||
|
color: pageTheme.colors.textSecondary
|
||||||
|
font.pixelSize: 15
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user