feat: Fixes to modal

This commit is contained in:
Emil Sawicki 2024-11-25 10:57:37 +01:00
parent 6556a356b7
commit 2d129c388a
12 changed files with 40 additions and 31 deletions

View File

@ -5,7 +5,7 @@ const DEFAULT_FLAG_DAPPS_ENABLED = true
const DEFAULT_FLAG_SWAP_ENABLED = true
const DEFAULT_FLAG_CONNECTOR_ENABLED* = false
const DEFAULT_FLAG_SEND_VIA_PERSONAL_CHAT_ENABLED = true
const DEFAULT_FLAG_PAYMENT_REQUEST_ENABLED = true
const DEFAULT_FLAG_PAYMENT_REQUEST_ENABLED = false
proc boolToEnv*(defaultValue: bool): string =
return if defaultValue: "1" else: "0"

View File

@ -51,7 +51,7 @@ SplitView {
readonly property int selectedNetworkChainId: ctrlSelectedNetworkChainId.currentValue ?? -1
readonly property var tokenAdaptor: TokenSelectorViewAdaptor {
assetsModel: d.walletAssetsStore.groupedAccountAssetsModel
assetsModel: d.walletAssetsStore.baseGroupedAccountAssetModel
flatNetworksModel: d.flatNetworks
currentCurrency: d.currencyStore.currentCurrency
plainTokensBySymbolModel: d.walletAssetsStore.walletTokensStore.plainTokensBySymbolModel
@ -85,7 +85,8 @@ SplitView {
closePolicy: Popup.CloseOnEscape
destroyOnClose: true
currencyStore: d.currencyStore
currentCurrency: d.currencyStore.currentCurrency
formatCurrencyAmount: d.currencyStore.formatCurrencyAmount
flatNetworksModel: d.flatNetworks
accountsModel: d.accounts
assetsModel: d.tokenAdaptor.outputAssetsModel

View File

@ -15,17 +15,18 @@ import AppLayouts.Wallet.adaptors 1.0
import shared.popups.send.views 1.0
import shared.controls 1.0
import shared.stores 1.0 as SharedStores
import StatusQ.Core.Utils 0.1 as SQUtils
import utils 1.0
StatusDialog {
id: root
// models
required property SharedStores.CurrenciesStore currencyStore
required property string currentCurrency
required property var flatNetworksModel
required property var accountsModel
required property var assetsModel
property var formatCurrencyAmount: function() {}
// input / output
property int selectedNetworkChainId: Constants.chains.mainnetChainId
@ -36,7 +37,7 @@ StatusDialog {
if (!d.isSelectedHoldingValidAsset || !d.selectedHolding.item.marketDetails || !d.selectedHolding.item.marketDetails.currencyPrice) {
return "0"
}
return amountToSendInput.text
return SQUtils.AmountsArithmetic.toNumber(amountToSendInput.amount, amountToSendInput.multiplierIndex)
}
objectName: "paymentRequestModal"
@ -106,9 +107,9 @@ StatusDialog {
multiplierIndex: d.isSelectedHoldingValidAsset && !!d.selectedHolding.item.decimals ? d.selectedHolding.item.decimals : 0
price: d.isSelectedHoldingValidAsset && !!d.selectedHolding.item.marketDetails ? d.selectedHolding.item.marketDetails.currencyPrice.amount : 1
formatFiat: amount => root.currencyStore.formatCurrencyAmount(
amount, root.currencyStore.currentCurrency)
formatBalance: amount => root.currencyStore.formatCurrencyAmount(
formatFiat: amount => root.formatCurrencyAmount(
amount, root.currentCurrency)
formatBalance: amount => root.formatCurrencyAmount(
amount, root.selectedTokenKey)
showSeparator: true
@ -159,6 +160,7 @@ StatusDialog {
statusListItemTitle.customColor: Theme.palette.directColor1
enabled: false
}
onCurrentAccountAddressChanged: root.selectedAccountAddress = currentAccountAddress
}
StatusBaseText {

View File

@ -272,14 +272,6 @@ QtObject {
return result
}
function addPaymentRequest(symbol, amount, address, chainId) {
currentChatContentModule().inputAreaModule.paymentRequestModel.addPaymentRequest(address, amount, symbol, chainId)
}
function removePaymentRequest(index) {
currentChatContentModule().inputAreaModule.paymentRequestModel.removeItemWithIndex(index)
}
function openCloseCreateChatView() {
if (root.openCreateChat) {
Global.closeCreateChatView()

View File

@ -297,6 +297,7 @@ Item {
sharedStore: root.sharedRootStore
linkPreviewModel: !!d.activeChatContentModule ? d.activeChatContentModule.inputAreaModule.linkPreviewModel : null
paymentRequestModel: !!d.activeChatContentModule ? d.activeChatContentModule.inputAreaModule.paymentRequestModel : null
urlsList: d.urlsList
askToEnableLinkPreview: {
if(!d.activeChatContentModule || !d.activeChatContentModule.inputAreaModule || !d.activeChatContentModule.inputAreaModule.preservedProperties)
@ -372,6 +373,7 @@ Item {
chatInput.setText("")
chatInput.textInput.textFormat = TextEdit.PlainText;
chatInput.textInput.textFormat = TextEdit.RichText;
d.activeChatContentModule.inputAreaModule.removeAllPaymentRequestPreviewData()
}
}
@ -396,7 +398,7 @@ Item {
d.activeChatContentModule.inputAreaModule.setLinkPreviewEnabledForCurrentMessage(false)
}
onDismissLinkPreview: (index) => d.activeChatContentModule.inputAreaModule.removeLinkPreviewData(index)
onOpenPaymentRequestModal: () => Global.openPaymentRequestModalRequested()
onOpenPaymentRequestModal: () => Global.openPaymentRequestModalRequested(d.activeChatContentModule.inputAreaModule)
}
ChatPermissionQualificationPanel {

View File

@ -164,6 +164,7 @@ Page {
closeGifPopupAfterSelection: true
usersModel: membersSelector.model
sharedStore: root.sharedRootStore
paymentRequestEnabled: false
onStickerSelected: {
root.createChatPropertiesStore.createChatStickerHashId = hashId;
root.createChatPropertiesStore.createChatStickerPackId = packId;

View File

@ -44,9 +44,9 @@ QtObject {
false, Constants.ephemeralNotificationType.success, "")
}
/* PRIVATE: This model renames the role "key" to "tokensKey" in TokensBySymbolModel so that
/* This model renames the role "key" to "tokensKey" in TokensBySymbolModel so that
it can be easily joined with the Account Assets model */
readonly property var _renamedTokensBySymbolModel: RolesRenamingModel {
readonly property var renamedTokensBySymbolModel: RolesRenamingModel {
sourceModel: walletTokensStore.plainTokensBySymbolModel
mapping: [
RoleRename {
@ -87,7 +87,7 @@ QtObject {
/* PRIVATE: This model joins the "Tokens By Symbol Model" and "Communities Model" by communityId */
property LeftJoinModel _jointTokensBySymbolModel: LeftJoinModel {
leftModel: _renamedTokensBySymbolModel
leftModel: renamedTokensBySymbolModel
rightModel: _renamedCommunitiesModel
joinRole: "communityId"
}

View File

@ -1395,6 +1395,8 @@ Item {
emojiPopup: statusEmojiPopup.item
stickersPopup: statusStickersPopupLoader.item
sendViaPersonalChatEnabled: featureFlagsStore.sendViaPersonalChatEnabled && appMain.networkConnectionStore.sendBuyBridgeEnabled
areTestNetworksEnabled: appMain.rootStore.profileSectionStore.walletStore.areTestNetworksEnabled
paymentRequestEnabled: featureFlagsStore.paymentRequestEnabled
onProfileButtonClicked: {
Global.changeAppSectionBySectionType(Constants.appSection.profile);
@ -1560,6 +1562,7 @@ Item {
transactionStore: appMain.transactionStore
walletAssetsStore: appMain.walletAssetsStore
currencyStore: appMain.currencyStore
paymentRequestEnabled: featureFlagsStore.paymentRequestEnabled
onProfileButtonClicked: {
Global.changeAppSectionBySectionType(Constants.appSection.profile);

View File

@ -53,7 +53,6 @@ QtObject {
property WalletStores.CollectiblesStore walletCollectiblesStore
property NetworkConnectionStore networkConnectionStore
property WalletStores.BuyCryptoStore buyCryptoStore
property ChatStores.RootStore chatStore
property bool isDevBuild
signal openExternalLink(string link)
@ -105,7 +104,7 @@ QtObject {
Global.openSwapModalRequested.connect(openSwapModal)
Global.openBuyCryptoModalRequested.connect(openBuyCryptoModal)
Global.privacyPolicyRequested.connect(() => openPopup(privacyPolicyPopupComponent))
Global.openPaymentRequestModalRequested.connect(() => openPopup(paymentRequestPopupComponent))
Global.openPaymentRequestModalRequested.connect(openPaymentRequestModal)
}
property var currentPopup
@ -406,6 +405,10 @@ QtObject {
})
}
function openPaymentRequestModal(inputAreaModule) {
openPopup(paymentRequestModalComponent, {inputAreaModule: inputAreaModule})
}
readonly property list<Component> _components: [
Component {
id: removeContactConfirmationDialog
@ -1277,21 +1280,25 @@ QtObject {
}
},
Component {
id: paymentRequestPopupComponent
id: paymentRequestModalComponent
PaymentRequestModal {
id: paymentRequestModal
readonly property var tokenAdaptor: TokenSelectorViewAdaptor {
assetsModel: WalletStores.RootStore.walletAssetsStore.groupedAccountAssetsModel
assetsModel: WalletStores.RootStore.walletAssetsStore._renamedTokensBySymbolModel
flatNetworksModel: WalletStores.RootStore.filteredFlatModel
currentCurrency: root.rootStore.currencyStore.currentCurrency
currentCurrency: root.currencyStore.currentCurrency
plainTokensBySymbolModel: WalletStores.RootStore.tokensStore.plainTokensBySymbolModel
enabledChainIds: [paymentRequestModal.selectedNetworkChainId]
showAllTokens: true
}
currencyStore: root.rootStore.currencyStore
property var inputAreaModule: null
currentCurrency: root.currencyStore.currentCurrency
formatCurrencyAmount: root.currencyStore.formatCurrencyAmount
flatNetworksModel: WalletStores.RootStore.filteredFlatModel
accountsModel: WalletStores.RootStore.nonWatchAccounts
assetsModel: tokenAdaptor.outputAssetsModel
onAccepted: root.chatStore.addPaymentRequest(selectedTokenKey, amount, selectedAccountAddress, selectedNetworkChainId)
onAccepted: inputAreaModule.addPaymentRequest(selectedAccountAddress, amount, selectedTokenKey, selectedNetworkChainId)
destroyOnClose: true
}
}

View File

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

View File

@ -72,6 +72,7 @@ Rectangle {
property var fileUrlsAndSources: []
property var linkPreviewModel: null
property var paymentRequestModel: null
property var urlsList: []
@ -1020,7 +1021,7 @@ Rectangle {
text: qsTr("Add payment request")
icon.name: "wallet"
visibleOnDisabled: control.paymentRequestEnabled
enabled: control.paymentRequestEnabled && !root.areTestNetworksEnabled
enabled: control.paymentRequestEnabled && !control.areTestNetworksEnabled
onTriggered: control.openPaymentRequestModal()
}

View File

@ -92,7 +92,7 @@ QtObject {
signal privacyPolicyRequested()
signal openPaymentRequestModalRequested()
signal openPaymentRequestModalRequested(var inputAreaModule)
// Swap
signal openSwapModalRequested(var formDataParams)