fix(desktop): Move Input anchors binding to client code

This commit is contained in:
MishkaRogachev 2022-07-25 16:22:09 +03:00 committed by Mikhail Rogachev
parent 34671a27c1
commit 0418979e9c
11 changed files with 197 additions and 187 deletions

View File

@ -53,8 +53,9 @@ ModalPopup {
id: prompt
text: ""
visible: false
Layout.fillWidth: true
anchors.top: svMessage.bottom
anchors.right: parent.right
anchors.left: parent.left
}
footer: Item {

View File

@ -35,7 +35,9 @@ StatusModal {
contentItem: Item {
Input {
id: firstPINField
anchors.right: parent.right
anchors.rightMargin: 56
anchors.left: parent.left
anchors.leftMargin: 56
anchors.top: parent.top
anchors.topMargin: 88

View File

@ -34,6 +34,8 @@ ModalPopup {
Input {
id: firstPasswordField
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 56
anchors.leftMargin: 56
anchors.top: parent.top

View File

@ -97,6 +97,8 @@ StatusModal {
anchors.rightMargin: Style.current.padding
Input {
id: addressInput
anchors.left: parent.left
anchors.right: parent.right
readOnly: !editable
textField.maximumLength: 42
placeholderText: qsTr("Enter contract address...")
@ -107,9 +109,11 @@ StatusModal {
Input {
id: nameInput
readOnly: !editable
anchors.left: parent.left
anchors.right: parent.right
anchors.top: addressInput.bottom
anchors.topMargin: marginBetweenInputs
readOnly: !editable
placeholderText: qsTr("The name of your token...")
label: qsTr("Name")
}

View File

@ -44,9 +44,11 @@ SettingsContentBase {
Input {
id: deviceNameTxt
placeholderText: qsTr("Specify a name")
anchors.left: parent.left
anchors.right: parent.right
anchors.top: deviceNameLbl.bottom
anchors.topMargin: Style.current.padding
placeholderText: qsTr("Specify a name")
}
// TODO: replace with StatusQ component

View File

@ -138,6 +138,7 @@ Item {
Input {
id: ensUsername
placeholderText: !isStatus ? "vitalik94.domain.eth" : "vitalik94"
anchors.left: parent.left
anchors.top: circleAt.bottom
anchors.topMargin: Style.current.bigPadding
anchors.right: btnContinue.left

View File

@ -1,6 +1,6 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtGraphicalEffects 1.13
import QtQuick 2.14
import QtQuick.Layouts 1.4
import QtGraphicalEffects 1.14
import utils 1.0
import shared.stores 1.0
@ -15,8 +15,6 @@ import "."
Item {
id: root
height: (chatKey.height + message.height + existingContacts.height
+ searchResults.height + noContactsRect.height + 24)
property var rootStore
property var contactsStore
@ -34,14 +32,12 @@ Item {
property bool showCheckbox: false
property bool showContactList: true
property bool showSearch: true
signal userClicked(string pubKey, bool isAddedContact, string name, string address)
property var pubKeys: ([])
property bool hideCommunityMembers: false
property bool addContactEnabled: true
property string wrongInputValidationError: qsTr("Enter a valid chat key or ENS username");
property var resolveENS: Backpressure.debounce(root, 500, function (ensName) {
readonly property var resolveENS: Backpressure.debounce(root, 500, function (ensName) {
noContactsRect.visible = false
searchResults.loading = true
searchResults.showProfileNotFoundMessage = false
@ -61,12 +57,27 @@ Item {
return root.validationError === "";
}
signal userClicked(string pubKey, bool isAddedContact, string name, string address)
implicitWidth: column.implicitWidth
implicitHeight: column.implicitHeight
ColumnLayout {
id: column
anchors.fill: parent
spacing: Style.current.smallPadding
Input {
id: chatKey
property bool hasValidSearchResult: false
height: visible ? implicitHeight : 0
placeholderText: qsTr("Enter ENS username or chat key")
visible: showSearch
textField.anchors.rightMargin: clearBtn.width + Style.current.padding + 2
Layout.fillWidth: true
Layout.preferredHeight: visible ? implicitHeight : 0
Keys.onReleased: {
successMessage = "";
searchResults.pubKey = "";
@ -82,11 +93,11 @@ Item {
if (Utils.isChatKey(chatKey.text)) {
pubKey = chatKey.text;
let contactDetails = Utils.getContactDetailsAsJson(pubKey)
let contactDetails = Utils.getContactDetailsAsJson(pubKey);
if (!contactDetails.isContact) {
searchResults.username = contactDetails.alias
searchResults.username = contactDetails.alias;
searchResults.userAlias = Utils.compactAddress(pubKey, 4);
searchResults.pubKey = pubKey
searchResults.pubKey = pubKey;
}
noContactsRect.visible = false;
return;
@ -98,7 +109,6 @@ Item {
root.validationError = "";
}
}
textField.anchors.rightMargin: clearBtn.width + Style.current.padding + 2
Connections {
target: mainModule
@ -164,12 +174,10 @@ Item {
id: message
text: root.validationError || successMessage
visible: root.validationError !== "" || successMessage !== ""
height: visible ? contentHeight : 0
font.pixelSize: 13
color: !!root.validationError ? Style.current.danger : Style.current.success
anchors.top: chatKey.bottom
anchors.topMargin: Style.current.smallPadding
anchors.horizontalCenter: parent.horizontalCenter
Layout.alignment: Qt.AlignHCenter
Layout.preferredHeight: visible ? contentHeight : 0
}
ExistingContacts {
@ -179,15 +187,6 @@ Item {
community: root.community
visible: showContactList
hideCommunityMembers: root.hideCommunityMembers
anchors.topMargin: this.height > 0 ? Style.current.halfPadding : 0
anchors.top: {
if (message.visible) {
return message.bottom
}
if (chatKey.visible) {
return chatKey.bottom
}
}
showCheckbox: root.showCheckbox
filterText: chatKey.text
pubKeys: root.pubKeys
@ -208,16 +207,13 @@ Item {
userClicked(contact.pubKey, contact.isContact, contact.alias, contact.address)
}
expanded: !searchResults.loading && pubKey === "" && !searchResults.showProfileNotFoundMessage
Layout.fillWidth: true
}
SearchResults {
id: searchResults
anchors.top: existingContacts.visible ? existingContacts.bottom :
message.visible? message.bottom : chatKey.bottom
anchors.topMargin: Style.current.halfPadding
hasExistingContacts: existingContacts.visible
loading: false
width: searchResultsWidth > 0 ? searchResultsWidth : parent.width
addContactEnabled: root.addContactEnabled
onResultClicked: {
chatKey.hasValidSearchResult = false
@ -230,6 +226,8 @@ Item {
root.contactsStore.addContact(pubKey)
}
}
Layout.fillWidth: true
}
NoFriendsRectangle {
id: noContactsRect

View File

@ -334,7 +334,6 @@ Item {
anchors.top: parent.top
anchors.right: inputGasPrice.left
anchors.rightMargin: Style.current.padding
anchors.left: undefined
visible: root.suggestedFees.eip1559Enabled
width: 125
customHeight: 56
@ -364,7 +363,6 @@ Item {
label: qsTr("Per-gas overall limit")
inputLabel.color: Style.current.secondaryText
anchors.top: parent.top
anchors.left: undefined
anchors.right: parent.right
width: 125
customHeight: 56

View File

@ -12,9 +12,6 @@ import AppLayouts.Chat.controls 1.0
Item {
id: root
anchors.left: parent.left
anchors.right: parent.right
height: visible ? Math.min(contactListView.contentHeight, (expanded ? 320 : 192)) : 0
property var contactsStore
property var community
@ -24,6 +21,7 @@ Item {
property bool showCheckbox: false
property bool hideCommunityMembers: false
property var pubKeys: ([])
signal contactClicked(var contact)
function matchesAlias(name, filter) {
@ -31,6 +29,9 @@ Item {
return parts.some(p => p.startsWith(filter))
}
implicitWidth: contactListView.implicitWidth
implicitHeight: visible ? Math.min(contactListView.contentHeight, (expanded ? 320 : 192)) : 0
StatusListView {
id: contactListView
anchors.fill: parent
@ -38,6 +39,7 @@ Item {
model: root.contactsStore.myContactsModel
delegate: Contact {
width: contactListView.availableWidth
showCheckbox: root.showCheckbox
isChecked: root.pubKeys.indexOf(model.pubKey) > -1
pubKey: model.pubKey
@ -53,14 +55,12 @@ Item {
model.localNickname.toLowerCase().includes(root.filterText.toLowerCase()) ||
model.pubKey.toLowerCase().includes(root.filterText.toLowerCase())) &&
(!root.hideCommunityMembers ||
!root.community.hasMember(model.pubKey))
!root.community.hasMember(model.pubKey));
}
onContactClicked: function () {
root.contactClicked(model)
root.contactClicked(model);
}
}
ScrollBar.vertical: ScrollBar { policy: ScrollBar.AsNeeded }
}
}

View File

@ -96,6 +96,8 @@ Item {
Input {
id: txtPassword
anchors.left: parent.left
anchors.right: parent.right
anchors.top: signingPhrase.bottom
anchors.topMargin: Style.current.bigPadding
textField.objectName: "transactionSignerPasswordInput"