Browse Source

qml: receive dialog flickable when challenged vertical space

master
Sander van Grieken 3 years ago
parent
commit
4c7ab67474
  1. 432
      electrum/gui/qml/components/ReceiveDialog.qml

432
electrum/gui/qml/components/ReceiveDialog.qml

@ -29,230 +29,250 @@ ElDialog {
color: "#aa000000" color: "#aa000000"
} }
ColumnLayout { padding: 0
id: rootLayout
width: parent.width
spacing: constants.paddingMedium
visible: !_ispaid
states: [
State {
name: 'bolt11'
PropertyChanges { target: qrloader; sourceComponent: qri_bolt11 }
PropertyChanges { target: bolt11label; font.bold: true; color: Material.accentColor }
},
State {
name: 'bip21uri'
PropertyChanges { target: qrloader; sourceComponent: qri_bip21uri }
PropertyChanges { target: bip21label; font.bold: true; color: Material.accentColor }
},
State {
name: 'address'
PropertyChanges { target: qrloader; sourceComponent: qri_address }
PropertyChanges { target: addresslabel; font.bold: true; color: Material.accentColor }
}
]
Item { ColumnLayout {
Layout.alignment: Qt.AlignHCenter anchors.fill: parent
Layout.topMargin: constants.paddingSmall spacing: 0
Layout.bottomMargin: constants.paddingSmall
Flickable {
// Layout.preferredWidth: qrloader.width Layout.preferredWidth: parent.width
// Layout.preferredHeight: qrloader.height Layout.fillHeight: true
Layout.preferredWidth: dialog.width * 7/8
Layout.preferredHeight: dialog.width * 7/8 leftMargin: constants.paddingLarge
rightMargin: constants.paddingLarge
Loader {
id: qrloader contentHeight: rootLayout.height
anchors.centerIn: parent clip:true
Component { interactive: height < contentHeight
id: qri_bolt11
QRImage { ColumnLayout {
qrdata: _bolt11 id: rootLayout
render: _render_qr width: parent.width
spacing: constants.paddingMedium
visible: !_ispaid
states: [
State {
name: 'bolt11'
PropertyChanges { target: qrloader; sourceComponent: qri_bolt11 }
PropertyChanges { target: bolt11label; font.bold: true; color: Material.accentColor }
},
State {
name: 'bip21uri'
PropertyChanges { target: qrloader; sourceComponent: qri_bip21uri }
PropertyChanges { target: bip21label; font.bold: true; color: Material.accentColor }
},
State {
name: 'address'
PropertyChanges { target: qrloader; sourceComponent: qri_address }
PropertyChanges { target: addresslabel; font.bold: true; color: Material.accentColor }
} }
} ]
Component {
id: qri_bip21uri Item {
QRImage { Layout.alignment: Qt.AlignHCenter
qrdata: _bip21uri Layout.topMargin: constants.paddingSmall
render: _render_qr Layout.bottomMargin: constants.paddingSmall
// Layout.preferredWidth: qrloader.width
// Layout.preferredHeight: qrloader.height
Layout.preferredWidth: dialog.width * 7/8
Layout.preferredHeight: dialog.width * 7/8
Loader {
id: qrloader
anchors.centerIn: parent
Component {
id: qri_bolt11
QRImage {
qrdata: _bolt11
render: _render_qr
}
}
Component {
id: qri_bip21uri
QRImage {
qrdata: _bip21uri
render: _render_qr
}
}
Component {
id: qri_address
QRImage {
qrdata: _address
render: _render_qr
}
}
} }
}
Component { MouseArea {
id: qri_address anchors.fill: parent
QRImage { onClicked: {
qrdata: _address if (rootLayout.state == 'bolt11') {
render: _render_qr if (_bip21uri != '')
rootLayout.state = 'bip21uri'
else if (_address != '')
rootLayout.state = 'address'
} else if (rootLayout.state == 'bip21uri') {
if (_address != '')
rootLayout.state = 'address'
else if (_bolt11 != '')
rootLayout.state = 'bolt11'
} else if (rootLayout.state == 'address') {
if (_bolt11 != '')
rootLayout.state = 'bolt11'
else if (_bip21uri != '')
rootLayout.state = 'bip21uri'
}
}
} }
} }
}
MouseArea { RowLayout {
anchors.fill: parent Layout.alignment: Qt.AlignHCenter
onClicked: { spacing: constants.paddingLarge
if (rootLayout.state == 'bolt11') { Label {
if (_bip21uri != '') id: bolt11label
rootLayout.state = 'bip21uri' text: qsTr('Lightning')
else if (_address != '') color: _bolt11 ? Material.foreground : constants.mutedForeground
rootLayout.state = 'address' MouseArea {
} else if (rootLayout.state == 'bip21uri') { anchors.fill: parent
if (_address != '') enabled: _bolt11
rootLayout.state = 'address' onClicked: rootLayout.state = 'bolt11'
else if (_bolt11 != '') }
rootLayout.state = 'bolt11' }
} else if (rootLayout.state == 'address') { Rectangle {
if (_bolt11 != '') Layout.preferredWidth: constants.paddingXXSmall
rootLayout.state = 'bolt11' Layout.preferredHeight: constants.paddingXXSmall
else if (_bip21uri != '') radius: constants.paddingXXSmall / 2
rootLayout.state = 'bip21uri' color: Material.accentColor
}
Label {
id: bip21label
text: qsTr('URI')
color: _bip21uri ? Material.foreground : constants.mutedForeground
MouseArea {
anchors.fill: parent
enabled: _bip21uri
onClicked: rootLayout.state = 'bip21uri'
}
}
Rectangle {
Layout.preferredWidth: constants.paddingXXSmall
Layout.preferredHeight: constants.paddingXXSmall
radius: constants.paddingXXSmall / 2
color: Material.accentColor
}
Label {
id: addresslabel
text: qsTr('Address')
color: _address ? Material.foreground : constants.mutedForeground
MouseArea {
anchors.fill: parent
enabled: _address
onClicked: rootLayout.state = 'address'
}
} }
} }
}
}
RowLayout { Rectangle {
Layout.alignment: Qt.AlignHCenter height: 1
spacing: constants.paddingLarge Layout.alignment: Qt.AlignHCenter
Label { Layout.preferredWidth: qrloader.width
id: bolt11label color: Material.accentColor
text: qsTr('Lightning')
color: _bolt11 ? Material.foreground : constants.mutedForeground
MouseArea {
anchors.fill: parent
enabled: _bolt11
onClicked: rootLayout.state = 'bolt11'
}
}
Rectangle {
Layout.preferredWidth: constants.paddingXXSmall
Layout.preferredHeight: constants.paddingXXSmall
radius: constants.paddingXXSmall / 2
color: Material.accentColor
}
Label {
id: bip21label
text: qsTr('URI')
color: _bip21uri ? Material.foreground : constants.mutedForeground
MouseArea {
anchors.fill: parent
enabled: _bip21uri
onClicked: rootLayout.state = 'bip21uri'
}
}
Rectangle {
Layout.preferredWidth: constants.paddingXXSmall
Layout.preferredHeight: constants.paddingXXSmall
radius: constants.paddingXXSmall / 2
color: Material.accentColor
}
Label {
id: addresslabel
text: qsTr('Address')
color: _address ? Material.foreground : constants.mutedForeground
MouseArea {
anchors.fill: parent
enabled: _address
onClicked: rootLayout.state = 'address'
} }
}
}
Rectangle { GridLayout {
height: 1 columns: 2
Layout.alignment: Qt.AlignHCenter visible: request.message || !request.amount.isEmpty
Layout.preferredWidth: qrloader.width Layout.maximumWidth: qrloader.width
color: Material.accentColor Layout.alignment: Qt.AlignHCenter
}
GridLayout { Label {
columns: 2 visible: request.message
visible: request.message || !request.amount.isEmpty text: qsTr('Message')
Layout.maximumWidth: qrloader.width color: Material.accentColor
Layout.alignment: Qt.AlignHCenter }
Label {
Label { visible: request.message
visible: request.message Layout.fillWidth: true
text: qsTr('Message') text: request.message
color: Material.accentColor wrapMode: Text.Wrap
} }
Label { Label {
visible: request.message visible: !request.amount.isEmpty
Layout.fillWidth: true text: qsTr('Amount')
text: request.message color: Material.accentColor
wrapMode: Text.Wrap }
} RowLayout {
Label { visible: !request.amount.isEmpty
visible: !request.amount.isEmpty Label {
text: qsTr('Amount') text: Config.formatSats(request.amount)
color: Material.accentColor font.family: FixedFont
} font.pixelSize: constants.fontSizeMedium
RowLayout { font.bold: true
visible: !request.amount.isEmpty }
Label { Label {
text: Config.formatSats(request.amount) text: Config.baseUnit
font.family: FixedFont color: Material.accentColor
font.pixelSize: constants.fontSizeMedium font.pixelSize: constants.fontSizeMedium
font.bold: true }
Label {
visible: Daemon.fx.enabled
text: '(' + Daemon.fx.fiatValue(request.amount, false) + ' ' + Daemon.fx.fiatCurrency + ')'
font.pixelSize: constants.fontSizeMedium
}
}
} }
Label {
text: Config.baseUnit Rectangle {
visible: request.message || !request.amount.isEmpty
height: 1
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: qrloader.width
color: Material.accentColor color: Material.accentColor
font.pixelSize: constants.fontSizeMedium
} }
Label {
visible: Daemon.fx.enabled
text: '(' + Daemon.fx.fiatValue(request.amount, false) + ' ' + Daemon.fx.fiatCurrency + ')'
font.pixelSize: constants.fontSizeMedium
}
}
}
Rectangle { RowLayout {
visible: request.message || !request.amount.isEmpty Layout.alignment: Qt.AlignHCenter
height: 1 FlatButton {
Layout.alignment: Qt.AlignHCenter icon.source: '../../icons/copy_bw.png'
Layout.preferredWidth: qrloader.width icon.color: 'transparent'
color: Material.accentColor text: 'Copy'
} onClicked: {
if (request.isLightning && rootLayout.state == 'bolt11')
RowLayout { AppController.textToClipboard(_bolt11)
Layout.alignment: Qt.AlignHCenter else if (rootLayout.state == 'bip21uri')
FlatButton { AppController.textToClipboard(_bip21uri)
icon.source: '../../icons/copy_bw.png' else
icon.color: 'transparent' AppController.textToClipboard(_address)
text: 'Copy' }
onClicked: { }
if (request.isLightning && rootLayout.state == 'bolt11') FlatButton {
AppController.textToClipboard(_bolt11) icon.source: '../../icons/share.png'
else if (rootLayout.state == 'bip21uri') text: 'Share'
AppController.textToClipboard(_bip21uri) onClicked: {
else enabled = false
AppController.textToClipboard(_address) if (request.isLightning && rootLayout.state == 'bolt11')
} AppController.doShare(_bolt11, qsTr('Payment Request'))
} else if (rootLayout.state == 'bip21uri')
FlatButton { AppController.doShare(_bip21uri, qsTr('Payment Request'))
icon.source: '../../icons/share.png' else
text: 'Share' AppController.doShare(_address, qsTr('Onchain address'))
onClicked: {
enabled = false enabled = true
if (request.isLightning && rootLayout.state == 'bolt11') }
AppController.doShare(_bolt11, qsTr('Payment Request')) }
else if (rootLayout.state == 'bip21uri') FlatButton {
AppController.doShare(_bip21uri, qsTr('Payment Request')) Layout.alignment: Qt.AlignHCenter
else icon.source: '../../icons/pen.png'
AppController.doShare(_address, qsTr('Onchain address')) text: qsTr('Edit')
onClicked: receiveDetailsDialog.open()
enabled = true }
} }
} }
FlatButton {
Layout.alignment: Qt.AlignHCenter
icon.source: '../../icons/pen.png'
text: qsTr('Edit')
onClicked: receiveDetailsDialog.open()
}
} }
} }

Loading…
Cancel
Save