Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into refund_countdown
Browse files Browse the repository at this point in the history
  • Loading branch information
syl committed Jun 15, 2022
2 parents ac1cc23 + c2929de commit 4733d71
Show file tree
Hide file tree
Showing 65 changed files with 2,092 additions and 2,016 deletions.
2 changes: 2 additions & 0 deletions assets/themes/Binance - Dark/colors.json
Expand Up @@ -71,6 +71,8 @@
"okColor": "#74fbeeFF",
"noColor": "#d13990FF",

"senderColorStart": "#F85757FF",
"receiverColorStart": "#845FEFFF",
"arrowUpColor": "#F85757FF",
"arrowDownColor": "#845FEFFF",

Expand Down
11 changes: 8 additions & 3 deletions assets/themes/Default - Dark/colors.json
Expand Up @@ -11,7 +11,7 @@

"buttonColorDisabled": "#28375AFF",
"buttonColorEnabled": "#293254FF",
"buttonColorHovered": "#4068B929FF",
"buttonColorHovered": "#4068B929",
"buttonColorPressed": "#2932546C",
"buttonTextDisabledColor": "#444444FF",
"buttonTextEnabledColor": "#ffffffFF",
Expand Down Expand Up @@ -80,8 +80,8 @@
"rangeSliderIndicatorBackgroundStartColor": "#5A68E6FF",
"rangeSliderIndicatorBackgroundEndColor": "#4986EAFF",

"loginWalletIconColorStart": "#5A68E6FF",
"loginWalletIconColorEnd": "#4986EAAD",
"userIconColorStart": "#5A68E6FF",
"userIconColorEnd": "#4986EAAD",

"sidebarBgColor": "#202337FF",
"sidebarVersionTextColor": "#2F5688FF",
Expand All @@ -96,9 +96,14 @@
"tradeSellModeSelectorBackgroundColorEnd": "#E216A9FF",
"tradeMarketModeSelectorNotSelectedBackgroundColor": "#89B6FF21",

"addressBookTagColors": ["#627EEAFF", "#FFD87AFF", "#F7931AFF"],

"okColor": "#00C058FF",
"noColor": "#E52167FF",

"senderColorStart": "#F85757FF",
"receiverColorStart": "#845FEFFF",

"arrowUpColor": "#F85757FF",
"arrowDownColor": "#845FEFFF",

Expand Down
9 changes: 7 additions & 2 deletions assets/themes/Default - Light/colors.json
Expand Up @@ -77,8 +77,8 @@
"rangeSliderIndicatorBackgroundStartColor": "#5A68E6FF",
"rangeSliderIndicatorBackgroundEndColor": "#4986EAFF",

"loginWalletIconColorStart": "#5A68E6FF",
"loginWalletIconColorEnd": "#4986EAAD",
"userIconColorStart": "#5A68E6FF",
"userIconColorEnd": "#4986EAAD",

"sidebarBgColor": "#FCFCFCFF",
"sidebarVersionTextColor": "#456078FF",
Expand All @@ -93,9 +93,14 @@
"tradeSellModeSelectorBackgroundColorEnd": "#E216A9FF",
"tradeMarketModeSelectorNotSelectedBackgroundColor": "#89B6FF21",

"addressBookTagColors": ["#627EEAFF", "#FFD87AFF", "#F7931AFF"],

"okColor": "#00C058FF",
"noColor": "#E52167FF",

"senderColorStart": "#F85757",
"receiverColorStart": "#845FEF",

"arrowUpColor": "#F85757FF",
"arrowDownColor": "#845FEFFF",

Expand Down
302 changes: 302 additions & 0 deletions atomic_defi_design/Dex/Addressbook/AddAddressForm.qml
@@ -0,0 +1,302 @@
import QtQuick 2.12
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15

import Qaterial 1.0 as Qaterial

import Dex.Themes 1.0 as Dex
import Dex.Components 1.0 as Dex
import "../Components" as Dex
import "../Constants" as Dex

Dex.Rectangle
{
id: root

property var contactModel

// Edition mode variables
property bool editionMode: false
property string addressType
property string addressKey
property string addressValue

property var availableNetworkStandards: ["QRC-20", "ERC-20", "BEP-20", "Smart Chain"]

// Return the asset type that will be used in the backend to validate the address
function getTypeForAddressChecker(addressType)
{
switch (addressType)
{
case "QRC-20": return "QTUM"
case "BEP-20": return "BNB"
case "ERC-20": return "ETH"
case "Smart Chain": return "KMD"
case "SLP": return "BCH"
}

let coinInfo = Dex.API.app.portfolio_pg.global_cfg_mdl.get_coin_info(addressType);
if (coinInfo.has_parent_fees_ticker)
return coinInfo.fees_ticker;
return addressType
}

// Tells if the given address type represents a network standard address (e.g. BEP-20)
function isNetworkStandard(addressType)
{
switch (addressType)
{
case "QRC-20": return true
case "BEP-20": return true
case "ERC-20": return true
case "Smart Chain": return true
case "SLP": return true
}
return false
}

signal cancel()
signal addressCreated()

width: 500
height: column.height + 26
radius: 10

onVisibleChanged:
{
if (!visible)
{
// Resets data when address is added/edited.
addressKeyField.text = ""
addressValueField.text = ""
invalidAddressValueLabel.text = ""
editionMode = false
addressType = ""
addressKey = ""
addressValue = ""
}
else if (editionMode)
{
// Feeds form with the data we are currently editing.

if (!isNetworkStandard(addressType))
{
useStandardsCheckBox.checked = false
let addressTypeIndex =
Dex.API.app.portfolio_pg.global_cfg_mdl.all_proxy.match(
Dex.API.app.portfolio_pg.global_cfg_mdl.all_proxy.index(0, 0),
Qt.UserRole + 1, addressType, 1, Qt.MatchExactly)[0]
addressTypeComboBox.currentIndex = addressTypeIndex.row
}
else
{
useStandardsCheckBox.checked = true
let addressTypeIndex = availableNetworkStandards.indexOf(addressType)
addressTypeComboBox.currentIndex = addressTypeIndex
}
addressKeyField.text = addressKey
addressValueField.text = addressValue
}
}

ColumnLayout
{
id: column
anchors.centerIn: parent
spacing: 17

RowLayout
{
Layout.preferredWidth: 458
Layout.preferredHeight: 38

AddressTypeSelector
{
id: addressTypeComboBox
Layout.fillWidth: true
Layout.fillHeight: true
showAssetStandards: useStandardsCheckBox.checked
}

Dex.DefaultCheckBox
{
id: useStandardsCheckBox
Layout.preferredWidth: 150
Layout.leftMargin: 4
boxWidth: 22
boxHeight: 22
text: qsTr("Use standard network address")
font: Dex.DexTypo.caption
}
}

Dex.TextField
{
id: addressKeyField
Layout.preferredWidth: 458
Layout.preferredHeight: 38
placeholderText: qsTr("Label")

Dex.ToolTip
{
id: addressKeyAlreadyExistsToolTip
contentItem: Dex.Text { text_value: qsTr("This key already exists.") }
}
}

Dex.TextField
{
id: addressValueField
Layout.preferredWidth: 458
Layout.preferredHeight: 38
placeholderText: qsTr("Address")
}

Dex.Text
{
id: invalidAddressValueLabel
Layout.fillWidth: true
visible: text !== ""
color: Dex.CurrentTheme.noColor
wrapMode: Dex.Text.Wrap
horizontalAlignment: Text.AlignHCenter
}

RowLayout
{
Layout.topMargin: 10
Layout.fillWidth: true

Dex.Button
{
Layout.preferredWidth: 116
Layout.preferredHeight: 38
radius: 18
text: qsTr("Cancel")
onClicked: cancel()
}

Item { Layout.fillWidth: true }

Dex.GradientButton
{
property bool isConvertMode: Dex.API.app.wallet_pg.validate_address_data.convertible ?? false

enabled: addressKeyField.length > 0 && addressValueField.length > 0 && !Dex.API.app.wallet_pg.validate_address_busy
Layout.preferredWidth: 116
Layout.preferredHeight: 38
radius: 18
text: isConvertMode ? qsTr("Convert") : editionMode ? qsTr("Edit") : qsTr("Add")
onClicked:
{
let addressType = getTypeForAddressChecker(addressTypeComboBox.currentText)

if (!Dex.API.app.portfolio_pg.global_cfg_mdl.get_coin_info(addressType).is_enabled)
{
enableAssetModal.assetTicker = addressType
enableAssetModal.open()
}
else if (isConvertMode)
Dex.API.app.wallet_pg.convert_address(addressValueField.text, addressType, Dex.API.app.wallet_pg.validate_address_data.to_address_format);
else
Dex.API.app.wallet_pg.validate_address(addressValueField.text, addressType)
}
}
}
}

Connections
{
target: Dex.API.app.wallet_pg

function onConvertAddressBusyChanged()
{
if (Dex.API.app.wallet_pg.convert_address_busy) // Currently converting entered address
{
return
}

addressValueField.text = Dex.API.app.wallet_pg.converted_address
Dex.API.app.wallet_pg.validate_address_data = {}
invalidAddressValueLabel.text = ""
}

function onValidateAddressBusyChanged()
{
if (Dex.API.app.wallet_pg.validate_address_busy) // Currently checking entered address
{
return
}

if (!Dex.API.app.wallet_pg.validate_address_data.is_valid) // Entered address is invalid.
{
invalidAddressValueLabel.text = Dex.API.app.wallet_pg.validate_address_data.reason
return
}

if (editionMode) // Removes old address entry before if we are in edition mode.
{
contactModel.removeAddressEntry(addressType, addressKey);
}

var createAddressResult = contactModel.addAddressEntry(addressTypeComboBox.currentText, addressKeyField.text, addressValueField.text);
if (createAddressResult === true)
{
addressCreated()
}
else
{
addressKeyAlreadyExistsToolTip.visible = true
}
}
}

Dex.ModalLoader
{
id: enableAssetModal

property string assetTicker

onLoaded: item.assetTicker = assetTicker

sourceComponent: Dex.MultipageModal
{
property string assetTicker
Dex.MultipageModalContent
{
Layout.fillWidth: true
titleText: qsTr("Enable " + assetTicker)

Dex.Text
{
Layout.fillWidth: true
text: qsTr("You need to enable %1 before adding this kind of address.").arg(assetTicker)
}

footer:
[
// Enable button
Dex.Button
{
text: qsTr("Enable")

onClicked:
{
Dex.API.app.enable_coin(assetTicker)
close()
}
},

// Cancel button
Dex.Button
{
Layout.rightMargin: 5
text: qsTr("Cancel")

onClicked: close()
}
]
}
}
}
}

0 comments on commit 4733d71

Please sign in to comment.