mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-09 22:06:25 +00:00
46b81b30a6
- create a reusable "Max" send button component - use it in SwapModal and SendModal - add some more tests in tst_SwapInputPanel.qml Fixes #15066
42 lines
1.1 KiB
QML
42 lines
1.1 KiB
QML
import QtQuick 2.15
|
|
import QtQuick.Controls 2.15
|
|
|
|
import StatusQ.Core 0.1
|
|
import StatusQ.Controls 0.1
|
|
|
|
import AppLayouts.Wallet 1.0
|
|
|
|
import utils 1.0
|
|
|
|
StatusButton {
|
|
id: root
|
|
|
|
required property double value
|
|
required property string symbol
|
|
required property bool valid
|
|
property var formatCurrencyAmount: (amount, symbol) => { return "FIXME" }
|
|
|
|
readonly property double maxSafeValue: WalletUtils.calculateMaxSafeSendAmount(value, symbol)
|
|
readonly property string maxSafeValueAsString: maxSafeValue.toLocaleString(locale, 'f', -128)
|
|
|
|
locale: LocaleUtils.userInputLocale
|
|
|
|
QtObject {
|
|
id: d
|
|
|
|
readonly property string maxInputBalanceFormatted:
|
|
root.formatCurrencyAmount(Math.trunc(root.maxSafeValue*100)/100, root.symbol)
|
|
}
|
|
|
|
implicitHeight: 22
|
|
|
|
type: valid ? StatusBaseButton.Type.Normal : StatusBaseButton.Type.Danger
|
|
text: qsTr("Max. %1").arg(value === 0 ? locale.zeroDigit : d.maxInputBalanceFormatted)
|
|
|
|
horizontalPadding: 8
|
|
verticalPadding: 3
|
|
radius: 20
|
|
font.pixelSize: 12
|
|
font.weight: Font.Normal
|
|
}
|