fix 'max' button in Kivy (fix #6169)
This commit is contained in:
@@ -1173,7 +1173,12 @@ class ElectrumWindow(App, Logger):
|
|||||||
amount, u = str(amount).split()
|
amount, u = str(amount).split()
|
||||||
assert u == self.base_unit
|
assert u == self.base_unit
|
||||||
def cb(amount):
|
def cb(amount):
|
||||||
screen.amount = amount
|
if amount == '!':
|
||||||
|
screen.is_max = True
|
||||||
|
screen.amount = self.get_max_amount() + ' ' + self.base_unit
|
||||||
|
else:
|
||||||
|
screen.amount = amount
|
||||||
|
screen.is_max = False
|
||||||
popup = AmountDialog(show_max, amount, cb)
|
popup = AmountDialog(show_max, amount, cb)
|
||||||
popup.open()
|
popup.open()
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ Builder.load_string('''
|
|||||||
amount: ''
|
amount: ''
|
||||||
fiat_amount: ''
|
fiat_amount: ''
|
||||||
is_fiat: False
|
is_fiat: False
|
||||||
|
is_max: False
|
||||||
on_fiat_amount: if self.is_fiat: self.amount = app.fiat_to_btc(self.fiat_amount)
|
on_fiat_amount: if self.is_fiat: self.amount = app.fiat_to_btc(self.fiat_amount)
|
||||||
on_amount: if not self.is_fiat: self.fiat_amount = app.btc_to_fiat(self.amount)
|
on_amount: if not self.is_fiat: self.fiat_amount = app.btc_to_fiat(self.amount)
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
@@ -92,6 +93,7 @@ Builder.load_string('''
|
|||||||
on_release:
|
on_release:
|
||||||
kb.is_fiat = False
|
kb.is_fiat = False
|
||||||
kb.amount = app.get_max_amount()
|
kb.amount = app.get_max_amount()
|
||||||
|
kb.is_max = True
|
||||||
Button:
|
Button:
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
@@ -99,6 +101,7 @@ Builder.load_string('''
|
|||||||
on_release:
|
on_release:
|
||||||
kb.amount = ''
|
kb.amount = ''
|
||||||
kb.fiat_amount = ''
|
kb.fiat_amount = ''
|
||||||
|
kb.is_max = False
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 0.2
|
size_hint: 1, 0.2
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
@@ -112,7 +115,7 @@ Builder.load_string('''
|
|||||||
height: '48dp'
|
height: '48dp'
|
||||||
text: _('OK')
|
text: _('OK')
|
||||||
on_release:
|
on_release:
|
||||||
root.callback(btc.text if kb.amount else '')
|
root.callback('!' if kb.is_max else btc.text if kb.amount else '')
|
||||||
popup.dismiss()
|
popup.dismiss()
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ Builder.load_string('''
|
|||||||
title: _('Open Lightning Channel')
|
title: _('Open Lightning Channel')
|
||||||
pubkey: ''
|
pubkey: ''
|
||||||
amount: ''
|
amount: ''
|
||||||
|
is_max: False
|
||||||
ipport: ''
|
ipport: ''
|
||||||
BoxLayout
|
BoxLayout
|
||||||
spacing: '12dp'
|
spacing: '12dp'
|
||||||
@@ -154,7 +155,7 @@ class LightningOpenChannelDialog(Factory.Popup, Logger):
|
|||||||
conn_str = self.pubkey
|
conn_str = self.pubkey
|
||||||
if self.ipport:
|
if self.ipport:
|
||||||
conn_str += '@' + self.ipport.strip()
|
conn_str += '@' + self.ipport.strip()
|
||||||
amount = self.app.get_amount(self.amount)
|
amount = '!' if self.is_max else self.app.get_amount(self.amount)
|
||||||
self.app.protected('Create a new channel?', self.do_open_channel, (conn_str, amount))
|
self.app.protected('Create a new channel?', self.do_open_channel, (conn_str, amount))
|
||||||
self.dismiss()
|
self.dismiss()
|
||||||
|
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ class SendScreen(CScreen, Logger):
|
|||||||
self.address = uri.get('address', '')
|
self.address = uri.get('address', '')
|
||||||
self.message = uri.get('message', '')
|
self.message = uri.get('message', '')
|
||||||
self.amount = self.app.format_amount_and_units(amount) if amount else ''
|
self.amount = self.app.format_amount_and_units(amount) if amount else ''
|
||||||
|
self.is_max = False
|
||||||
self.payment_request = None
|
self.payment_request = None
|
||||||
self.is_lightning = False
|
self.is_lightning = False
|
||||||
|
|
||||||
@@ -260,6 +261,7 @@ class SendScreen(CScreen, Logger):
|
|||||||
self.is_lightning = False
|
self.is_lightning = False
|
||||||
self.is_bip70 = False
|
self.is_bip70 = False
|
||||||
self.parsed_URI = None
|
self.parsed_URI = None
|
||||||
|
self.is_max = False
|
||||||
|
|
||||||
def set_request(self, pr: 'PaymentRequest'):
|
def set_request(self, pr: 'PaymentRequest'):
|
||||||
self.address = pr.get_requestor()
|
self.address = pr.get_requestor()
|
||||||
@@ -298,11 +300,14 @@ class SendScreen(CScreen, Logger):
|
|||||||
if not self.amount:
|
if not self.amount:
|
||||||
self.app.show_error(_('Please enter an amount'))
|
self.app.show_error(_('Please enter an amount'))
|
||||||
return
|
return
|
||||||
try:
|
if self.is_max:
|
||||||
amount = self.app.get_amount(self.amount)
|
amount = '!'
|
||||||
except:
|
else:
|
||||||
self.app.show_error(_('Invalid amount') + ':\n' + self.amount)
|
try:
|
||||||
return
|
amount = self.app.get_amount(self.amount)
|
||||||
|
except:
|
||||||
|
self.app.show_error(_('Invalid amount') + ':\n' + self.amount)
|
||||||
|
return
|
||||||
message = self.message
|
message = self.message
|
||||||
if self.is_lightning:
|
if self.is_lightning:
|
||||||
return LNInvoice.from_bech32(address)
|
return LNInvoice.from_bech32(address)
|
||||||
@@ -439,6 +444,7 @@ class ReceiveScreen(CScreen):
|
|||||||
def clear(self):
|
def clear(self):
|
||||||
self.address = ''
|
self.address = ''
|
||||||
self.amount = ''
|
self.amount = ''
|
||||||
|
self.is_max = False # not used for receiving (see app.amount_dialog)
|
||||||
self.message = ''
|
self.message = ''
|
||||||
self.lnaddr = ''
|
self.lnaddr = ''
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user