kivy: move amount dialog
This commit is contained in:
@@ -733,26 +733,17 @@ class ElectrumWindow(App):
|
|||||||
|
|
||||||
|
|
||||||
def amount_dialog(self, screen, show_max):
|
def amount_dialog(self, screen, show_max):
|
||||||
popup = Builder.load_file('gui/kivy/uix/ui_screens/amount.kv')
|
from uix.dialogs.amount_dialog import AmountDialog
|
||||||
but_max = popup.ids.but_max
|
|
||||||
if not show_max:
|
|
||||||
but_max.disabled = True
|
|
||||||
but_max.opacity = 0
|
|
||||||
else:
|
|
||||||
but_max.disabled = False
|
|
||||||
but_max.opacity = 1
|
|
||||||
|
|
||||||
amount = screen.amount
|
amount = screen.amount
|
||||||
if amount:
|
if amount:
|
||||||
a, u = str(amount).split()
|
amount, u = str(amount).split()
|
||||||
assert u == self.base_unit
|
assert u == self.base_unit
|
||||||
popup.ids.kb.amount = a
|
else:
|
||||||
|
amount = None
|
||||||
|
|
||||||
def cb():
|
def cb(amount):
|
||||||
o = popup.ids.a.btc_text
|
screen.amount = amount
|
||||||
screen.amount = o
|
popup = AmountDialog(show_max, amount, cb)
|
||||||
|
|
||||||
popup.on_dismiss = cb
|
|
||||||
popup.open()
|
popup.open()
|
||||||
|
|
||||||
def protected(self, f, args):
|
def protected(self, f, args):
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
#:import Decimal decimal.Decimal
|
from kivy.app import App
|
||||||
|
from kivy.factory import Factory
|
||||||
|
from kivy.properties import ObjectProperty
|
||||||
|
from kivy.lang import Builder
|
||||||
|
|
||||||
|
|
||||||
Popup:
|
Builder.load_string('''
|
||||||
|
<AmountDialog@Popup>
|
||||||
id: popup
|
id: popup
|
||||||
title: _('Amount')
|
title: _('Amount')
|
||||||
|
|
||||||
AnchorLayout:
|
AnchorLayout:
|
||||||
anchor_x: 'center'
|
anchor_x: 'center'
|
||||||
|
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
size_hint: 0.8, 1
|
size_hint: 0.8, 1
|
||||||
@@ -60,6 +62,8 @@ Popup:
|
|||||||
text: '<'
|
text: '<'
|
||||||
Button:
|
Button:
|
||||||
id: but_max
|
id: but_max
|
||||||
|
opacity: 1 if root.show_max else 0
|
||||||
|
disabled: not root.show_max
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
text: 'Max'
|
text: 'Max'
|
||||||
@@ -80,10 +84,8 @@ Popup:
|
|||||||
on_release:
|
on_release:
|
||||||
kb.amount = ''
|
kb.amount = ''
|
||||||
kb.fiat_amount = ''
|
kb.fiat_amount = ''
|
||||||
|
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
|
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
@@ -94,4 +96,19 @@ Popup:
|
|||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
text: _('OK')
|
text: _('OK')
|
||||||
on_release: popup.dismiss()
|
on_release:
|
||||||
|
root.callback(a.btc_text)
|
||||||
|
popup.dismiss()
|
||||||
|
''')
|
||||||
|
|
||||||
|
from kivy.properties import BooleanProperty
|
||||||
|
|
||||||
|
class AmountDialog(Factory.Popup):
|
||||||
|
show_max = BooleanProperty(False)
|
||||||
|
def __init__(self, show_max, amount, cb):
|
||||||
|
Factory.Popup.__init__(self)
|
||||||
|
self.show_max = show_max
|
||||||
|
self.callback = cb
|
||||||
|
if amount:
|
||||||
|
self.ids.kb.amount = amount
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user