feat: qml fixes && open send modal

This commit is contained in:
Emil Sawicki 2024-11-24 08:23:16 +01:00
parent 141174a09f
commit 9ad2726794
8 changed files with 46 additions and 13 deletions

View File

@ -49,6 +49,7 @@ Control {
property string messageAttachments: "" property string messageAttachments: ""
property var reactionIcons: [] property var reactionIcons: []
property var linkPreviewModel property var linkPreviewModel
property var paymentRequestModel
property var gifLinks property var gifLinks
property string messageId: "" property string messageId: ""
@ -377,7 +378,8 @@ Control {
Layout.preferredHeight: implicitHeight Layout.preferredHeight: implicitHeight
active: !root.editMode && active: !root.editMode &&
((!!root.linkPreviewModel && root.linkPreviewModel.count > 0) ((!!root.linkPreviewModel && root.linkPreviewModel.count > 0)
|| (!!root.gifLinks && root.gifLinks.length > 0)) || (!!root.gifLinks && root.gifLinks.length > 0)
|| (!!root.paymentRequestModel && root.paymentRequestModel.count > 0))
visible: active visible: active
} }
Loader { Loader {

View File

@ -326,6 +326,7 @@ Item {
deletedByContactColorHash: model.deletedByContactColorHash deletedByContactColorHash: model.deletedByContactColorHash
linkPreviewModel: model.linkPreviewModel linkPreviewModel: model.linkPreviewModel
links: model.links links: model.links
paymentRequestModel: model.paymentRequestModel
messageAttachments: model.messageAttachments messageAttachments: model.messageAttachments
transactionParams: model.transactionParameters transactionParams: model.transactionParameters
hasMention: model.mentioned hasMention: model.mentioned

View File

@ -515,6 +515,21 @@ Item {
sendModal.open(address) sendModal.open(address)
} }
function onPaymentRequestClicked(receiverAddress: string, symbol: string, amount: string, chainId: int) {
if (!!symbol) {
sendModal.preSelectedHoldingID = symbol
sendModal.preSelectedHoldingType = Constants.TokenType.ERC20
}
if (!!amount) {
sendModal.preDefinedAmountToSend = amount
}
if (!!chainId) {
sendModal.preSelectedChainId = chainId
}
sendModal.open(receiverAddress)
}
function onSwitchToCommunity(communityId: string) { function onSwitchToCommunity(communityId: string) {
appMain.communitiesStore.setActiveCommunity(communityId) appMain.communitiesStore.setActiveCommunity(communityId)
} }

View File

@ -40,7 +40,7 @@ Control {
required property var requestPaymentModel required property var requestPaymentModel
readonly property alias hoveredUrl: d.hoveredUrl readonly property alias hoveredUrl: d.hoveredUrl
readonly property bool hasContent: imagePreviewArray.length > 0 || showLinkPreviewSettings || linkPreviewRepeater.count > 0 readonly property bool hasContent: imagePreviewArray.length > 0 || showLinkPreviewSettings || linkPreviewRepeater.count > 0 || requestPaymentRepeater.count > 0
signal imageRemoved(int index) signal imageRemoved(int index)
signal imageClicked(var chatImage) signal imageClicked(var chatImage)

View File

@ -20,7 +20,8 @@ CalloutCard {
required property string address required property string address
property string senderName property string senderName
property var senderImageAssetSettings property string senderThumbnailImage
property int senderColorId
property bool highlight: false property bool highlight: false
@ -97,7 +98,13 @@ CalloutCard {
StatusSmartIdenticon { StatusSmartIdenticon {
width: symbolImage.width width: symbolImage.width
height: symbolImage.height height: symbolImage.height
asset: root.senderImageAssetSettings asset.width: symbolImage.width
asset.height: symbolImage.height
asset.isImage: !!root.senderThumbnailImage
asset.name: root.senderThumbnailImage
asset.isLetterIdenticon: root.senderThumbnailImage === ""
asset.color: Theme.palette.userCustomizationColors[root.senderColorId]
asset.charactersLen: 2
name: root.senderName name: root.senderName
} }
} }

View File

@ -25,13 +25,14 @@ Flow {
required property var linkPreviewModel required property var linkPreviewModel
required property var gifLinks required property var gifLinks
required property var requestPaymentModel required property var paymentRequestModel
required property bool gifUnfurlingEnabled required property bool gifUnfurlingEnabled
required property bool canAskToUnfurlGifs required property bool canAskToUnfurlGifs
property string senderName property string senderName
property var senderImageAssetSettings property string senderThumbnailImage
property int senderColorId
readonly property alias hoveredLink: linksRepeater.hoveredUrl readonly property alias hoveredLink: linksRepeater.hoveredUrl
property string highlightLink: "" property string highlightLink: ""
@ -39,7 +40,7 @@ Flow {
signal imageClicked(var image, var mouse, string imageSource, string url) signal imageClicked(var image, var mouse, string imageSource, string url)
signal openContextMenu(var item, string url, string domain) signal openContextMenu(var item, string url, string domain)
signal setNeverAskAboutUnfurlingAgain(bool neverAskAgain) signal setNeverAskAboutUnfurlingAgain(bool neverAskAgain)
signal requestPaymentClicked(var symbol, var amount, var address, var chainId) signal requestPaymentClicked(var symbol, var amount, var receiver, var chainId)
function resetLocalAskAboutUnfurling() { function resetLocalAskAboutUnfurling() {
d.localAskAboutUnfurling = true d.localAskAboutUnfurling = true
@ -64,16 +65,17 @@ Flow {
Repeater { Repeater {
id: requestPaymentRepeater id: requestPaymentRepeater
model: root.requestPaymentModel model: root.paymentRequestModel
delegate: RequestPaymentCardDelegate { delegate: RequestPaymentCardDelegate {
required property var model required property var model
objectName: "RrequestPaymentDelegate_" + model.index objectName: "RrequestPaymentDelegate_" + model.index
amount: model.amount amount: model.amount
symbol: model.symbol symbol: model.symbol
address: model.address address: model.receiver
senderName: root.senderName senderName: root.senderName
senderImageAssetSettings: root.senderImageAssetSettings senderThumbnailImage: root.senderThumbnailImage
onClicked: root.requestPaymentClicked(model.symbol, model.amount, model.address, model.chainId) senderColorId: root.senderColorId
onClicked: root.requestPaymentClicked(model.symbol, model.amount, model.receiver, model.chainId)
} }
} }

View File

@ -70,7 +70,7 @@ Loader {
property string messagePinnedBy: "" property string messagePinnedBy: ""
property var reactionsModel: [] property var reactionsModel: []
property var linkPreviewModel property var linkPreviewModel
property var requestPaymentModel property var paymentRequestModel
property string messageAttachments: "" property string messageAttachments: ""
property var transactionParams property var transactionParams
property var emojiReactionsModel property var emojiReactionsModel
@ -721,6 +721,7 @@ Loader {
resendError: root.resendError resendError: root.resendError
reactionsModel: root.reactionsModel reactionsModel: root.reactionsModel
linkPreviewModel: root.linkPreviewModel linkPreviewModel: root.linkPreviewModel
paymentRequestModel: root.paymentRequestModel
gifLinks: root.gifLinks gifLinks: root.gifLinks
showHeader: root.shouldRepeatHeader || dateGroupLabel.visible || isAReply || showHeader: root.shouldRepeatHeader || dateGroupLabel.visible || isAReply ||
@ -974,7 +975,10 @@ Loader {
linkPreviewModel: root.linkPreviewModel linkPreviewModel: root.linkPreviewModel
gifLinks: root.gifLinks gifLinks: root.gifLinks
requestPaymentModel: root.requestPaymentModel senderName: root.senderDisplayName
senderThumbnailImage: root.senderIcon || ""
senderColorId: Utils.colorIdForPubkey(root.senderId)
paymentRequestModel: root.paymentRequestModel
playAnimations: root.Window.active && root.messageStore.isChatActive playAnimations: root.Window.active && root.messageStore.isChatActive
isOnline: root.rootStore.mainModuleInst.isOnline isOnline: root.rootStore.mainModuleInst.isOnline
highlightLink: delegate.hoveredLink highlightLink: delegate.hoveredLink
@ -988,6 +992,7 @@ Loader {
gifUnfurlingEnabled: root.sharedRootStore.gifUnfurlingEnabled gifUnfurlingEnabled: root.sharedRootStore.gifUnfurlingEnabled
canAskToUnfurlGifs: !root.sharedRootStore.neverAskAboutUnfurlingAgain canAskToUnfurlGifs: !root.sharedRootStore.neverAskAboutUnfurlingAgain
onSetNeverAskAboutUnfurlingAgain: root.sharedRootStore.setNeverAskAboutUnfurlingAgain(neverAskAgain) onSetNeverAskAboutUnfurlingAgain: root.sharedRootStore.setNeverAskAboutUnfurlingAgain(neverAskAgain)
onRequestPaymentClicked: Global.paymentRequestClicked(receiver, symbol, amount, chainId)
Component.onCompleted: { Component.onCompleted: {
root.messageStore.messageModule.forceLinkPreviewsLocalData(root.messageId) root.messageStore.messageModule.forceLinkPreviewsLocalData(root.messageId)

View File

@ -73,6 +73,7 @@ QtObject {
signal appSectionBySectionTypeChanged(int sectionType, int subsection, int subSubsection, var data) signal appSectionBySectionTypeChanged(int sectionType, int subsection, int subSubsection, var data)
signal openSendModal(string address) signal openSendModal(string address)
signal paymentRequestClicked(string receiverAddress, string symbol, string amount, int chainId)
signal switchToCommunity(string communityId) signal switchToCommunity(string communityId)
signal switchToCommunitySettings(string communityId) signal switchToCommunitySettings(string communityId)
signal switchToCommunityChannelsView(string communityId) signal switchToCommunityChannelsView(string communityId)