fix(Wallet): Saved address add/edit modal layout issues

- Also replaced StatusModal with StatusDialog

Closes #6495
This commit is contained in:
Alexandra Betouni 2022-07-25 18:16:22 +03:00 committed by Alexandra Betouni
parent 239b03625f
commit c11ee2d3e8
4 changed files with 45 additions and 60 deletions

View File

@ -1,6 +1,6 @@
import QtQuick 2.13 import QtQuick 2.13
import QtQuick.Controls 2.13 import QtQuick.Controls 2.13
import QtQuick.Dialogs 1.3 import QtQml.Models 2.14
import utils 1.0 import utils 1.0
import shared.controls 1.0 import shared.controls 1.0
@ -10,11 +10,11 @@ import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import StatusQ.Controls.Validators 0.1 import StatusQ.Controls.Validators 0.1
import StatusQ.Popups 0.1 import StatusQ.Popups.Dialog 0.1
import "../stores" import "../stores"
StatusModal { StatusDialog {
id: root id: root
property bool edit: false property bool edit: false
@ -35,8 +35,11 @@ StatusModal {
width: 574 width: 574
height: 490 height: 490
header.title: edit ? qsTr("Edit saved address") : qsTr("Add saved address")
header.subTitle: edit ? name : "" header: StatusDialogHeader {
headline.title: edit ? qsTr("Edit saved address") : qsTr("Add saved address")
headline.subtitle: edit ? name : ""
}
onOpened: { onOpened: {
if(edit) { if(edit) {
@ -45,11 +48,8 @@ StatusModal {
nameInput.input.edit.forceActiveFocus(Qt.MouseFocusReason) nameInput.input.edit.forceActiveFocus(Qt.MouseFocusReason)
} }
contentItem: Column { Column {
anchors.left: parent.left width: parent.width
anchors.leftMargin: 8
anchors.right: parent.right
anchors.rightMargin: 10
height: childrenRect.height height: childrenRect.height
topPadding: Style.current.xlPadding topPadding: Style.current.xlPadding
@ -57,8 +57,9 @@ StatusModal {
StatusInput { StatusInput {
id: nameInput id: nameInput
width: parent.width implicitWidth: parent.width
input.implicitHeight: 56 minimumHeight: 56
maximumHeight: 56
placeholderText: qsTr("Enter a name") placeholderText: qsTr("Enter a name")
label: qsTr("Name") label: qsTr("Name")
validators: [ validators: [
@ -76,38 +77,35 @@ StatusModal {
} }
// To-Do use StatusInput within the below component // To-Do use StatusInput within the below component
Item { RecipientSelector {
width: parent.width id: addressInput
height: addressInput.height implicitWidth: parent.width
RecipientSelector { inputWidth: implicitWidth
id: addressInput accounts: RootStore.accounts
anchors.left: parent.left contactsStore: root.contactsStore
anchors.leftMargin: Style.current.padding label: qsTr("Address")
anchors.top: parent.top input.placeholderText: qsTr("Enter ENS Name or Ethereum Address")
width: parent.width labelFont.pixelSize: 15
accounts: RootStore.accounts labelFont.weight: Font.Normal
contactsStore: root.contactsStore input.implicitHeight: 56
label: qsTr("Address") input.textField.anchors.rightMargin: 0
input.placeholderText: qsTr("Enter ENS Name or Ethereum Address") isSelectorVisible: false
labelFont.pixelSize: 15 addContactEnabled: false
labelFont.weight: Font.Normal onSelectedRecipientChanged: {
input.implicitHeight: 56 root.address = selectedRecipient.address
isSelectorVisible: false
addContactEnabled: false
onSelectedRecipientChanged: {
root.address = selectedRecipient.address
}
readOnly: root.edit
wrongInputValidationError: qsTr("Please enter a valid ENS name OR Ethereum Address")
} }
readOnly: root.edit
wrongInputValidationError: qsTr("Please enter a valid ENS name OR Ethereum Address")
} }
} }
rightButtons: [ footer: StatusDialogFooter {
StatusButton { rightButtons: ObjectModel {
text: root.edit ? qsTr("Save") : qsTr("Add address") StatusButton {
enabled: _internal.valid && _internal.dirty text: root.edit ? qsTr("Save") : qsTr("Add address")
onClicked: save(name, address) enabled: _internal.valid && _internal.dirty
onClicked: root.save(name, address)
}
} }
] }
} }

View File

@ -49,8 +49,6 @@ Item {
ContactsListAndSearch { ContactsListAndSearch {
id: contactFieldAndList id: contactFieldAndList
anchors.top: parent.top
anchors.bottom: parent.bottom
width: parent.width width: parent.width
showContactList: false showContactList: false
addContactEnabled: root.addContactEnabled addContactEnabled: root.addContactEnabled

View File

@ -64,10 +64,9 @@ Item {
Input { Input {
id: chatKey id: chatKey
property bool hasValidSearchResult: false property bool hasValidSearchResult: false
height: visible ? implicitHeight : 0
placeholderText: qsTr("Enter ENS username or chat key") placeholderText: qsTr("Enter ENS username or chat key")
visible: showSearch visible: showSearch
height: visible ? implicitHeight : 0
Keys.onReleased: { Keys.onReleased: {
successMessage = ""; successMessage = "";
searchResults.pubKey = ""; searchResults.pubKey = "";

View File

@ -49,12 +49,12 @@ Item {
signal textEdited(string inputValue) signal textEdited(string inputValue)
signal keyPressed(var event) signal keyPressed(var event)
anchors.right: parent.right
anchors.left: parent.left
implicitHeight: inputRectangle.height + implicitHeight: inputRectangle.height +
(hasLabel ? inputLabel.height + labelMargin : 0) + (hasLabel ? inputLabel.height + labelMargin : 0) +
(!keepHeight &&!!validationError ? (validationErrorText.height + validationErrorTopMargin) : 0) (!keepHeight &&!!validationError ? (validationErrorText.height + validationErrorTopMargin) : 0)
height: implicitHeight height: implicitHeight
anchors.right: parent.right
anchors.left: parent.left
function resetInternal() { function resetInternal() {
inputValue.text = "" inputValue.text = ""
@ -65,35 +65,25 @@ Item {
id: inputLabel id: inputLabel
text: inputBox.label text: inputBox.label
font.weight: Font.Medium font.weight: Font.Medium
anchors.left: parent.left
anchors.leftMargin: 0
anchors.top: parent.top
anchors.topMargin: 0
font.pixelSize: 13 font.pixelSize: 13
color: Style.current.textColor color: Style.current.textColor
} }
Item { Item {
id: inputField id: inputField
anchors.right: parent.right
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right
height: customHeight height: customHeight
anchors.top: inputBox.hasLabel ? inputLabel.bottom : parent.top anchors.top: inputBox.hasLabel ? inputLabel.bottom : parent.top
anchors.topMargin: inputBox.hasLabel ? inputBox.labelMargin : 0 anchors.topMargin: inputBox.hasLabel ? inputBox.labelMargin : 0
StyledTextField { StyledTextField {
id: inputValue id: inputValue
visible: !inputBox.isTextArea && !inputBox.isSelect visible: !inputBox.isTextArea && !inputBox.isSelect
placeholderText: inputBox.placeholderText placeholderText: inputBox.placeholderText
placeholderTextColor: inputBox.placeholderTextColor placeholderTextColor: inputBox.placeholderTextColor
anchors.top: parent.top anchors.fill: parent
anchors.topMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
anchors.right: clipboardButtonLoader.active ? clipboardButtonLoader.left : parent.right anchors.right: clipboardButtonLoader.active ? clipboardButtonLoader.left : parent.right
anchors.rightMargin: clipboardButtonLoader.active ? Style.current.padding : parent.rightMargin anchors.rightMargin: clipboardButtonLoader.active ? Style.current.padding : 0
anchors.left: parent.left
anchors.leftMargin: 0
leftPadding: inputBox.hasIcon ? iconWidth + 20 : Style.current.padding leftPadding: inputBox.hasIcon ? iconWidth + 20 : Style.current.padding
selectByMouse: true selectByMouse: true
font.pixelSize: fontPixelSize font.pixelSize: fontPixelSize