kivy: add OutputList class
This commit is contained in:
@@ -189,3 +189,26 @@ class InfoBubble(Factory.Bubble):
|
||||
anim.bind(on_complete=on_stop)
|
||||
anim.cancel_all(self)
|
||||
anim.start(self)
|
||||
|
||||
|
||||
class OutputList(Factory.GridLayout):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(Factory.GridLayout, self).__init__(**kwargs)
|
||||
self.app = App.get_running_app()
|
||||
|
||||
def add_output(self, address, amount):
|
||||
t = Factory.CardLabel(text = '[ref=%s]%s[/ref]'%(address,address), font_size = '6pt')
|
||||
t.shorten = True
|
||||
t.size_hint_x = 0.65
|
||||
t.on_ref_press = self.do_copy_address
|
||||
self.add_widget(t)
|
||||
t = Factory.CardLabel(text = self.app.format_amount_and_units(amount), font_size='6pt')
|
||||
t.size_hint_x = 0.35
|
||||
t.halign = 'right'
|
||||
self.add_widget(t)
|
||||
|
||||
def do_copy_address(self, text):
|
||||
self.app._clipboard.copy(text)
|
||||
self.app.show_info(_('Address copied to clipboard') + ' ' + text)
|
||||
|
||||
|
||||
@@ -52,23 +52,10 @@ Builder.load_string('''
|
||||
text: _('Transaction fee') if root.fee_str else ''
|
||||
TopLabel:
|
||||
text: root.fee_str
|
||||
|
||||
TopLabel:
|
||||
text: _('Outputs') + ':'
|
||||
|
||||
GridLayout:
|
||||
OutputList:
|
||||
id: outputs
|
||||
size_hint: 1, None
|
||||
height: self.minimum_height
|
||||
cols: 2
|
||||
spacing: '10dp'
|
||||
padding: '10dp'
|
||||
canvas.before:
|
||||
Color:
|
||||
rgb: .3, .3, .3
|
||||
Rectangle:
|
||||
size: self.size
|
||||
pos: self.pos
|
||||
TopLabel:
|
||||
text: _('Transaction ID') + ':' if root.tx_hash else ''
|
||||
TopLabel:
|
||||
@@ -111,6 +98,7 @@ Builder.load_string('''
|
||||
on_release: popup.dismiss()
|
||||
''')
|
||||
|
||||
|
||||
class TxDialog(Factory.Popup):
|
||||
|
||||
def __init__(self, app, tx):
|
||||
@@ -155,20 +143,9 @@ class TxDialog(Factory.Popup):
|
||||
self.fee_str = ''
|
||||
self.can_sign = self.wallet.can_sign(self.tx)
|
||||
|
||||
self.ids.outputs.clear_widgets()
|
||||
for (type, address, amount) in self.tx.outputs():
|
||||
t = Factory.CardLabel(text = '[ref=%s]%s[/ref]'%(address,address), font_size = '6pt')
|
||||
t.shorten = True
|
||||
t.size_hint_x = 0.65
|
||||
t.on_ref_press = self.do_copy_address
|
||||
self.ids.outputs.add_widget(t)
|
||||
t = Factory.CardLabel(text = self.app.format_amount_and_units(amount), font_size='6pt')
|
||||
t.size_hint_x = 0.35
|
||||
t.halign = 'right'
|
||||
self.ids.outputs.add_widget(t)
|
||||
|
||||
def do_copy_address(self, text):
|
||||
self.app._clipboard.copy(text)
|
||||
self.app.show_info(_('Address copied to clipboard'))
|
||||
self.ids.outputs.add_output(address, amount)
|
||||
|
||||
def do_sign(self):
|
||||
self.app.protected(_("Enter your PIN code in order to sign this transaction"), self._do_sign, ())
|
||||
|
||||
Reference in New Issue
Block a user