kivy: improve amount dialog
This commit is contained in:
@@ -221,20 +221,11 @@
|
|||||||
background_active: 'atlas://gui/kivy/theming/light/textinput_active'
|
background_active: 'atlas://gui/kivy/theming/light/textinput_active'
|
||||||
|
|
||||||
|
|
||||||
#<ElectrumScreen>
|
<KButton@Button>:
|
||||||
# ScrollView:
|
size_hint: 1, None
|
||||||
# do_scroll_x: False
|
height: '48dp'
|
||||||
# do_scroll_y: False if root.fullscreen else (content.height > root.height - dp(16))
|
on_release: self.label.amount = app.update_amount(self.label.amount, self.text)
|
||||||
# AnchorLayout:
|
|
||||||
# size_hint_y: None
|
|
||||||
# height: root.height if root.fullscreen else max(root.height, content.height)
|
|
||||||
# GridLayout:
|
|
||||||
# id: content
|
|
||||||
# cols: 1
|
|
||||||
# spacing: '8dp'
|
|
||||||
# padding: '8dp'
|
|
||||||
# size_hint: (1, 1) if root.fullscreen else (.8, None)
|
|
||||||
# height: self.height if root.fullscreen else self.minimum_height
|
|
||||||
|
|
||||||
<TabbedPanelStrip>:
|
<TabbedPanelStrip>:
|
||||||
on_parent:
|
on_parent:
|
||||||
|
|||||||
@@ -439,6 +439,17 @@ class ElectrumWindow(App):
|
|||||||
status_card.quote_text = quote_text.strip()
|
status_card.quote_text = quote_text.strip()
|
||||||
status_card.uncomfirmed = unconfirmed.strip()
|
status_card.uncomfirmed = unconfirmed.strip()
|
||||||
|
|
||||||
|
|
||||||
|
def update_amount(self, amount, c):
|
||||||
|
if c == '<':
|
||||||
|
return amount[:-1]
|
||||||
|
try:
|
||||||
|
s = amount + c
|
||||||
|
amount = s if Decimal(s)!=0 else ''
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return amount
|
||||||
|
|
||||||
def format_amount(self, x, is_diff=False, whitespaces=False):
|
def format_amount(self, x, is_diff=False, whitespaces=False):
|
||||||
from electrum.util import format_satoshis
|
from electrum.util import format_satoshis
|
||||||
return format_satoshis(x, is_diff, self.num_zeros,
|
return format_satoshis(x, is_diff, self.num_zeros,
|
||||||
@@ -712,9 +723,9 @@ class ElectrumWindow(App):
|
|||||||
if label.text != label.default_text:
|
if label.text != label.default_text:
|
||||||
a, u = label.text.split()
|
a, u = label.text.split()
|
||||||
assert u == self.base_unit
|
assert u == self.base_unit
|
||||||
popup.ids.amount_label.value = a
|
popup.ids.a.amount = a
|
||||||
def cb():
|
def cb():
|
||||||
o = popup.ids.amount_label.text
|
o = popup.ids.a.text
|
||||||
label.text = o if o else label.default_text
|
label.text = o if o else label.default_text
|
||||||
if callback:
|
if callback:
|
||||||
callback()
|
callback()
|
||||||
|
|||||||
@@ -1,79 +1,93 @@
|
|||||||
<KButton@Button>:
|
#:import Decimal decimal.Decimal
|
||||||
size_hint: 1, None
|
|
||||||
height: '38dp'
|
|
||||||
|
|
||||||
Popup:
|
Popup:
|
||||||
id: popup
|
id: popup
|
||||||
title: _('Amount')
|
title: _('Amount')
|
||||||
|
|
||||||
BoxLayout:
|
AnchorLayout:
|
||||||
|
anchor_x: 'center'
|
||||||
orientation: 'vertical'
|
|
||||||
|
|
||||||
halign: 'center'
|
|
||||||
|
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
Label:
|
orientation: 'vertical'
|
||||||
id: amount_label
|
size_hint: 0.8, 1
|
||||||
text: ''
|
|
||||||
value: ''
|
BoxLayout:
|
||||||
on_value:
|
size_hint: 1, None
|
||||||
self.text = self.value + ' ' + app.base_unit
|
height: '48dp'
|
||||||
|
id: 'spendable'
|
||||||
|
Label:
|
||||||
|
text: _('Spendable:')
|
||||||
|
size_hint_x: 1
|
||||||
|
Button:
|
||||||
|
size_hint_x: 1
|
||||||
|
height: '48dp'
|
||||||
|
text: ''
|
||||||
|
on_release: a.value = "max"
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
size_hint: 1, None
|
||||||
|
height: '48dp'
|
||||||
|
Label:
|
||||||
|
id: a
|
||||||
|
amount: ''
|
||||||
|
text: self.amount + ' ' + app.base_unit if self.amount else ''
|
||||||
|
Widget:
|
||||||
|
size_hint_x: 1
|
||||||
|
|
||||||
Widget:
|
Widget:
|
||||||
size_hint_x: 1
|
size_hint: 1, 1
|
||||||
|
|
||||||
GridLayout:
|
GridLayout:
|
||||||
cols: 3
|
size_hint: 1, None
|
||||||
size_hint: 0.5, 1
|
height: '300dp'
|
||||||
KButton:
|
cols: 3
|
||||||
text: '1'
|
KButton:
|
||||||
on_release: amount_label.value += self.text
|
text: '1'
|
||||||
KButton:
|
label: a
|
||||||
text: '2'
|
KButton:
|
||||||
on_release: amount_label.value += self.text
|
text: '2'
|
||||||
KButton:
|
label: a
|
||||||
text: '3'
|
KButton:
|
||||||
on_release: amount_label.value += self.text
|
text: '3'
|
||||||
KButton:
|
label: a
|
||||||
text: '4'
|
KButton:
|
||||||
on_release: amount_label.value += self.text
|
text: '4'
|
||||||
KButton:
|
label: a
|
||||||
text: '5'
|
KButton:
|
||||||
on_release: amount_label.value += self.text
|
text: '5'
|
||||||
KButton:
|
label: a
|
||||||
text: '6'
|
KButton:
|
||||||
on_release: amount_label.value += self.text
|
text: '6'
|
||||||
KButton:
|
label: a
|
||||||
text: '7'
|
KButton:
|
||||||
on_release: amount_label.value += self.text
|
text: '7'
|
||||||
KButton:
|
label: a
|
||||||
text: '8'
|
KButton:
|
||||||
on_release: amount_label.value += self.text
|
text: '8'
|
||||||
KButton:
|
label: a
|
||||||
text: '9'
|
KButton:
|
||||||
on_release: amount_label.value += self.text
|
text: '9'
|
||||||
KButton:
|
label: a
|
||||||
text: '.'
|
KButton:
|
||||||
on_release: amount_label.value += self.text
|
text: '.'
|
||||||
KButton:
|
label: a
|
||||||
text: '0'
|
KButton:
|
||||||
on_release: amount_label.value += self.text
|
text: '0'
|
||||||
KButton:
|
label: a
|
||||||
text: '<'
|
KButton:
|
||||||
on_release: amount_label.value = amount_label.value[:-1]
|
text: '<'
|
||||||
|
label: a
|
||||||
|
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
size_hint: 0.5, None
|
size_hint: 1, None
|
||||||
Button:
|
|
||||||
size_hint: 0.5, None
|
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
text: _('Max')
|
Widget:
|
||||||
on_release: popup.dismiss()
|
size_hint: 0.7, None
|
||||||
Button:
|
height: '48dp'
|
||||||
size_hint: 0.5, None
|
Button:
|
||||||
height: '48dp'
|
size_hint: 0.3, None
|
||||||
text: _('OK')
|
height: '48dp'
|
||||||
on_release: popup.dismiss()
|
text: _('OK')
|
||||||
|
on_release: popup.dismiss()
|
||||||
Widget:
|
|
||||||
size_hint: 1, None
|
|
||||||
|
|||||||
Reference in New Issue
Block a user