Browse Source

kivy: improve tx dialog layout

master
ThomasV 10 years ago
parent
commit
77ba716acb
  1. 108
      gui/kivy/uix/dialogs/tx_dialog.py

108
gui/kivy/uix/dialogs/tx_dialog.py

@ -11,57 +11,69 @@ Builder.load_string('''
<TxDialog@Popup> <TxDialog@Popup>
id: popup id: popup
title: _('Transaction') title: _('Transaction')
is_mine: True
can_sign: False can_sign: False
can_broadcast: False can_broadcast: False
fee_str: '' fee_str: ''
date_str: ''
amount_str: '' amount_str: ''
txid_str: '' txid_str: ''
status_str: '' status_str: ''
AnchorLayout: description: ''
anchor_x: 'center' BoxLayout:
BoxLayout: orientation: 'vertical'
orientation: 'vertical' GridLayout:
Label: cols: 2
id: status_label spacing: '10dp'
TopLabel:
text: _('Status')
TopLabel:
text: root.status_str text: root.status_str
text_size: self.size TopLabel:
Label: text: _('Description') if root.description else ''
id: amount_label TopLabel:
text: root.description
TopLabel:
text: _('Date') if root.date_str else ''
TopLabel:
text: root.date_str
TopLabel:
text: _('Amount sent') if root.is_mine else _('Amount received')
TopLabel:
text: root.amount_str text: root.amount_str
text_size: self.size TopLabel:
Label: text: _('Transaction fee') if root.fee_str else ''
id: fee_label TopLabel:
text: root.fee_str text: root.fee_str
text_size: self.size
Label: TopLabel:
id: txid_label text: root.txid_str
text: root.txid_str
text_size: self.width, None Widget:
size: self.texture_size size_hint: 1, 0.2
Widget:
size_hint: 1, 1 BoxLayout:
BoxLayout: size_hint: 1, None
size_hint: 1, None height: '48dp'
Button:
size_hint: 0.5, None
height: '48dp'
text: _('Sign') if root.can_sign else _('Broadcast') if root.can_broadcast else ''
opacity: 1 if root.can_sign or root.can_broadcast else 0
disabled: not( root.can_sign or root.can_broadcast )
on_release:
if root.can_sign: root.do_sign()
if root.can_broadcast: root.do_broadcast()
IconButton:
size_hint: 0.5, None
height: '48dp'
icon: 'atlas://gui/kivy/theming/light/qrcode'
on_release: root.show_qr()
Button:
size_hint: 0.5, None
height: '48dp' height: '48dp'
Button: text: _('Close')
size_hint: 0.5, None on_release: popup.dismiss()
height: '48dp'
text: _('Sign') if root.can_sign else _('Broadcast') if root.can_broadcast else ''
opacity: 1 if root.can_sign or root.can_broadcast else 0
disabled: not( root.can_sign or root.can_broadcast )
on_release:
if root.can_sign: root.do_sign()
if root.can_broadcast: root.do_broadcast()
IconButton:
size_hint: 0.5, None
height: '48dp'
icon: 'atlas://gui/kivy/theming/light/qrcode'
on_release: root.show_qr()
Button:
size_hint: 0.5, None
height: '48dp'
text: _('Close')
on_release: popup.dismiss()
''') ''')
class TxDialog(Factory.Popup): class TxDialog(Factory.Popup):
@ -82,7 +94,7 @@ class TxDialog(Factory.Popup):
conf, timestamp = self.wallet.get_confirmations(tx_hash) conf, timestamp = self.wallet.get_confirmations(tx_hash)
self.status_str = _("%d confirmations")%conf if conf else _('Pending') self.status_str = _("%d confirmations")%conf if conf else _('Pending')
if timestamp: if timestamp:
self.status_str += '\n' + _("Date") + ': ' + datetime.fromtimestamp(timestamp).isoformat(' ')[:-3] self.date_str = datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
else: else:
self.can_broadcast = self.app.network is not None self.can_broadcast = self.app.network is not None
self.status_str = _('Signed') self.status_str = _('Signed')
@ -90,17 +102,19 @@ class TxDialog(Factory.Popup):
s, r = self.tx.signature_count() s, r = self.tx.signature_count()
self.status_str = _("Unsigned") if s == 0 else _('Partially signed') + ' (%d/%d)'%(s,r) self.status_str = _("Unsigned") if s == 0 else _('Partially signed') + ' (%d/%d)'%(s,r)
self.description = self.wallet.get_label(tx_hash)
is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(self.tx) is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(self.tx)
self.is_mine = is_mine
if is_relevant: if is_relevant:
if is_mine: if is_mine:
if fee is not None: if fee is not None:
self.amount_str = _("Amount sent:")+' %s'% self.app.format_amount_and_units(-v+fee) self.amount_str = self.app.format_amount_and_units(-v+fee)
self.fee_str = _("Transaction fee")+': %s'% self.app.format_amount_and_units(-fee) self.fee_str = self.app.format_amount_and_units(-fee)
else: else:
self.amount_str = _("Amount sent:")+' %s'% self.app.format_amount_and_units(-v) self.amount_str = self.app.format_amount_and_units(-v)
self.fee_str = _("Transaction fee")+': '+ _("unknown") self.fee_str = _("unknown")
else: else:
self.amount_str = _("Amount received:")+' %s'% self.app.format_amount_and_units(v) self.amount_str = self.app.format_amount_and_units(v)
self.fee_str = '' self.fee_str = ''
else: else:
self.amount_str = _("Transaction unrelated to your wallet") self.amount_str = _("Transaction unrelated to your wallet")

Loading…
Cancel
Save