TransactionBubbleView and related sub-components removed

This commit is contained in:
Michał Cieślak 2024-10-14 17:07:43 +02:00 committed by Michał
parent d5a0589591
commit 912b94859d
8 changed files with 4 additions and 477 deletions

View File

@ -41,7 +41,6 @@ Control {
property list<Item> quickActions
property var statusChatInput
property alias linksComponent: linksLoader.sourceComponent
property alias transcationComponent: transactionBubbleLoader.sourceComponent
property alias invitationComponent: invitationBubbleLoader.sourceComponent
property alias mouseArea: mouseArea
@ -379,11 +378,6 @@ Control {
|| (!!root.gifLinks && root.gifLinks.length > 0))
visible: active
}
Loader {
id: transactionBubbleLoader
active: root.messageDetails.contentType === StatusMessage.ContentType.Transaction && !editMode
visible: active
}
Loader {
id: invitationBubbleLoader
// TODO remove this component in #12570

View File

@ -1,45 +0,0 @@
import QtQuick 2.3
import utils 1.0
import shared 1.0
import shared.panels 1.0
Item {
id: root
width: parent.width
height: childrenRect.height + Style.current.halfPadding
property var acc
property string fromAddress
property var selectedAsset
property string selectedAmount
property string selectedFiatAmount
signal sendTransaction()
Separator {
id: separator
}
StyledText {
id: signText
color: Style.current.blue
text: qsTr("Sign and send")
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
font.weight: Font.Medium
anchors.right: parent.right
anchors.left: parent.left
topPadding: Style.current.halfPadding
anchors.top: separator.bottom
font.pixelSize: 15
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
root.sendTransaction();
}
}
}
}

View File

@ -1,81 +0,0 @@
import QtQuick 2.3
import QtGraphicalEffects 1.13
import shared 1.0
import shared.panels 1.0
import utils 1.0
Rectangle {
property int state: Constants.pending
property bool outgoing: true
id: root
width: childrenRect.width + 24
height: 28
border.width: 1
border.color: Style.current.border
radius: 24
color: Style.current.background
SVGImage {
id: stateImage
source: {
switch (root.state) {
case Constants.pending:
case Constants.addressReceived:
case Constants.transactionRequested:
case Constants.addressRequested: return Style.svg("dotsLoadings")
case Constants.confirmed: return Style.svg("check")
case Constants.transactionDeclined:
case Constants.declined: return Style.svg("exclamation")
default: return ""
}
}
width: 16
height: 16
anchors.left: parent.left
anchors.leftMargin: Style.current.halfPadding
anchors.verticalCenter: stateText.verticalCenter
}
ColorOverlay {
anchors.fill: stateImage
source: stateImage
color: state === Constants.confirmed ? Style.current.transparent : Style.current.textColor
}
StyledText {
id: stateText
color: {
if (root.state === Constants.unknown || root.state === Constants.failure) {
return Style.current.danger
}
if (root.state === Constants.confirmed || root.state === Constants.declined) {
return Style.current.textColor
}
return Style.current.secondaryText
}
text: {
switch (root.state) {
case Constants.pending: return qsTr("Pending")
case Constants.confirmed: return qsTr("Confirmed")
case Constants.unknown: return qsTr("Unknown token")
case Constants.addressRequested: return qsTr("Address requested")
case Constants.transactionRequested: return qsTr("Waiting to accept")
case Constants.addressReceived: return (!root.outgoing ?
qsTr("Address shared") :
qsTr("Address received"))
case Constants.transactionDeclined:
case Constants.declined: return qsTr("Transaction declined")
case Constants.failure: return qsTr("failure")
default: return qsTr("Unknown state")
}
}
font.weight: Font.Medium
anchors.left: stateImage.right
anchors.leftMargin: 4
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 13
}
}

View File

@ -15,7 +15,6 @@ MessageReactionsRow 1.0 MessageReactionsRow.qml
ProfileHeader 1.0 ProfileHeader.qml
RectangleCorner 1.0 RectangleCorner.qml
Retry 1.0 Retry.qml
SendTransactionButton 1.0 SendTransactionButton.qml
SentMessage 1.0 SentMessage.qml
StateBubble 1.0 StateBubble.qml
UserImage 1.0 UserImage.qml

View File

@ -1,94 +0,0 @@
import QtQuick 2.3
import shared 1.0
import shared.popups 1.0
import shared.panels 1.0
import shared.controls 1.0
import utils 1.0
import AppLayouts.Chat.stores 1.0 as ChatStores
import AppLayouts.Profile.stores 1.0 as ProfileStores
//TODO remove dynamic scoping
Item {
id: root
width: parent.width
height: childrenRect.height
property ChatStores.RootStore store
property ProfileStores.ContactsStore contactsStore
property var token
property string tokenAmount
property string fiatValue
property int state: Constants.addressRequested
Separator {
id: separator1
}
StyledText {
id: acceptText
color: Style.current.blue
text: root.state === Constants.addressRequested ?
qsTr("Accept and share address") :
qsTr("Accept and send")
padding: Style.current.halfPadding
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
font.weight: Font.Medium
anchors.right: parent.right
anchors.left: parent.left
anchors.top: separator1.bottom
font.pixelSize: 15
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
// ToDo launch send modal from here
}
}
}
Separator {
id: separator2
anchors.topMargin: 0
anchors.top: acceptText.bottom
}
StyledText {
id: declineText
color: Style.current.blue
text: qsTr("Decline")
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
font.weight: Font.Medium
anchors.right: parent.right
anchors.left: parent.left
padding: Style.current.halfPadding
anchors.top: separator2.bottom
font.pixelSize: 15
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
if (root.state === Constants.addressRequested) {
root.store.declineAddressRequest(messageId)
} else if (root.state === Constants.transactionRequested) {
root.store.declineRequest(messageId)
}
}
}
}
ConfirmationDialog {
id: gasEstimateErrorPopup
height: 220
onConfirmButtonClicked: {
gasEstimateErrorPopup.close();
}
}
}

View File

@ -977,14 +977,6 @@ Loader {
}
}
transcationComponent: Component {
TransactionBubbleView {
transactionParams: root.transactionParams
store: root.rootStore
contactsStore: root.contactsStore
}
}
invitationComponent: Component {
InvitationBubbleView {
store: root.rootStore

View File

@ -1,236 +0,0 @@
import QtQuick 2.3
import StatusQ.Core 0.1
import utils 1.0
import shared 1.0
import shared.panels 1.0
import shared.popups 1.0
import shared.views.chat 1.0
import shared.controls.chat 1.0
import shared.controls 1.0
import shared.stores 1.0
import AppLayouts.Chat.stores 1.0 as ChatStores
import AppLayouts.Profile.stores 1.0 as ProfileStores
Item {
id: root
width: rectangleBubble.width
height: rectangleBubble.height
property ChatStores.RootStore store
property ProfileStores.ContactsStore contactsStore
property var transactionParams
property var transactionParamsObject: {
try {
return JSON.parse(transactionParams)
} catch (e) {
console.error('Error parsing command parameters')
console.error('JSON:', transactionParams)
console.error('Error:', e)
return {
id: "",
fromAddress: "",
address: "",
contract: "",
value: "",
transactionHash: "",
commandState: 1,
signature: null
}
}
}
property var token:{
try {
return JSON.parse(transactionParamsObject.contract)
} catch (e) {
console.error('Error parsing command parameters')
console.error('JSON:', transactionParamsObject.contract)
console.error('Error:', e)
return ""
}
}
property string tokenAmount: transactionParamsObject.value
property string tokenSymbol: token.symbol || ""
property string fiatValue: {
if (!tokenAmount || !token.symbol) {
return "0"
}
return root.store.getFiatValue(tokenAmount, token.symbol) + " " + defaultFiatSymbol
}
property int state: transactionParamsObject.commandState
// Any transaction where isCurrentUser is true is actually outgoing transaction.
property bool outgoing: isCurrentUser
property int innerMargin: 12
property bool isError: transactionParamsObject.contract === "{}"
onTokenSymbolChanged: {
if (!!tokenSymbol) {
tokenImage.source = Style.png("tokens/"+root.tokenSymbol)
}
}
Rectangle {
id: rectangleBubble
width: (bubbleLoader.active ? bubbleLoader.width : valueContainer.width)
+ timeText.width + 3 * root.innerMargin
height: childrenRect.height + root.innerMargin
radius: 16
color: Style.current.background
border.color: Style.current.border
border.width: 1
StyledText {
id: title
color: Style.current.secondaryText
text: {
if (root.state === Constants.transactionRequested) {
let prefix = outgoing? "↑ " : "↓ "
return prefix + qsTr("Transaction request")
}
return outgoing ?
qsTr("↑ Outgoing transaction") :
qsTr("↓ Incoming transaction")
}
font.weight: Font.Medium
anchors.top: parent.top
anchors.topMargin: Style.current.halfPadding
anchors.left: parent.left
anchors.leftMargin: root.innerMargin
font.pixelSize: 13
}
Item {
id: valueContainer
width: childrenRect.width
height: tokenText.height + fiatText.height
anchors.top: title.bottom
anchors.topMargin: 4
anchors.left: parent.left
anchors.leftMargin: root.innerMargin
StyledText {
id: txtError
color: Style.current.danger
visible: root.isError
text: qsTr("Token not found on your current network")
}
Image {
id: tokenImage
visible: !root.isError
width: 24
height: 24
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
id: tokenText
visible: !root.isError
color: Style.current.textColor
text: `${root.tokenAmount} ${root.tokenSymbol}`
anchors.left: tokenImage.right
anchors.leftMargin: Style.current.halfPadding
font.pixelSize: 22
}
StyledText {
id: fiatText
visible: !root.isError
color: Style.current.secondaryText
text: root.fiatValue
anchors.top: tokenText.bottom
anchors.left: tokenText.left
font.pixelSize: 13
}
}
Loader {
id: bubbleLoader
active: {
return !root.isError && (
isCurrentUser ||
(!isCurrentUser &&
!(root.state === Constants.addressRequested ||
root.state === Constants.transactionRequested)
)
)
}
sourceComponent: stateBubbleComponent
anchors.top: valueContainer.bottom
anchors.topMargin: Style.current.halfPadding
anchors.left: parent.left
anchors.leftMargin: root.innerMargin
}
Component {
id: stateBubbleComponent
StateBubble {
state: root.state
outgoing: root.outgoing
}
}
Loader {
id: buttonsLoader
active: !root.isError && (
(root.state === Constants.addressRequested && !root.outgoing) ||
(root.state === Constants.addressReceived && root.outgoing) ||
(root.state === Constants.transactionRequested && !root.outgoing)
)
sourceComponent: root.outgoing ? signAndSendComponent : acceptTransactionComponent
anchors.top: bubbleLoader.active ? bubbleLoader.bottom : valueContainer.bottom
anchors.topMargin: bubbleLoader.active ? root.innerMargin : 20
width: parent.width
}
Component {
id: acceptTransactionComponent
AcceptTransactionView {
state: root.state
store: root.store
contactsStore: root.contactsStore
token: root.token
fiatValue: root.fiatValue
tokenAmount: root.tokenAmount
}
}
Component {
id: signAndSendComponent
SendTransactionButton {
selectedAsset: token
selectedAmount: tokenAmount
selectedFiatAmount: fiatValue
fromAddress: transactionParamsObject.fromAddress
onSendTransaction: {
// TODO: https://github.com/status-im/status-desktop/issues/6778
console.log("not implemented")
}
}
}
StyledText {
id: timeText
color: Style.current.secondaryText
text: LocaleUtils.formatTime(messageTimestamp, Locale.ShortFormat)
anchors.left: bubbleLoader.active ? bubbleLoader.right : undefined
anchors.leftMargin: bubbleLoader.active ? 13 : 0
anchors.right: bubbleLoader.active ? undefined : parent.right
anchors.rightMargin: bubbleLoader.active ? 0 : root.innerMargin
anchors.bottom: bubbleLoader.active ? bubbleLoader.bottom : buttonsLoader.top
anchors.bottomMargin: bubbleLoader.active ? -root.innerMargin : 7
font.pixelSize: 10
}
}
}

View File

@ -1,15 +1,13 @@
AcceptTransactionView 1.0 AcceptTransactionView.qml
ChannelIdentifierView 1.0 ChannelIdentifierView.qml
ChatContextMenuView 1.0 ChatContextMenuView.qml
CompactMessageView 1.0 CompactMessageView.qml
InvitationBubbleView 1.0 InvitationBubbleView.qml
LinksMessageView 1.0 LinksMessageView.qml
MessageAddReactionContextMenu 1.0 MessageAddReactionContextMenu.qml
MessageContextMenuView 1.0 MessageContextMenuView.qml
MessageView 1.0 MessageView.qml
NormalMessageView 1.0 NormalMessageView.qml
ProfileHeaderContextMenuView 1.0 ProfileHeaderContextMenuView.qml
TransactionBubbleView 1.0 TransactionBubbleView.qml
NewMessagesMarker 1.0 NewMessagesMarker.qml
SimplifiedMessageView 1.0 SimplifiedMessageView.qml
NormalMessageView 1.0 NormalMessageView.qml
ProfileContextMenu 1.0 ProfileContextMenu.qml
MessageAddReactionContextMenu 1.0 MessageAddReactionContextMenu.qml
ProfileHeaderContextMenuView 1.0 ProfileHeaderContextMenuView.qml
SimplifiedMessageView 1.0 SimplifiedMessageView.qml