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 id: prompt
text: "" text: ""
visible: false visible: false
Layout.fillWidth: true
anchors.top: svMessage.bottom anchors.top: svMessage.bottom
anchors.right: parent.right
anchors.left: parent.left
} }
footer: Item { footer: Item {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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