kivy: display status of invoices and requests

This commit is contained in:
ThomasV 2016-02-05 19:40:05 +01:00
parent 84ac33f589
commit 6b13ed1f45
3 changed files with 53 additions and 24 deletions

View File

@ -350,6 +350,18 @@ class ContactsScreen(CScreen):
contact_list.add_widget(ci) contact_list.add_widget(ci)
pr_text = {
PR_UNPAID:_('Pending'),
PR_PAID:_('Paid'),
PR_EXPIRED:_('Expired')
}
pr_icon = {
PR_UNPAID: 'atlas://gui/kivy/theming/light/important',
PR_PAID: 'atlas://gui/kivy/theming/light/confirmed',
PR_EXPIRED: 'atlas://gui/kivy/theming/light/close'
}
class InvoicesScreen(CScreen): class InvoicesScreen(CScreen):
kvname = 'invoices' kvname = 'invoices'
@ -366,12 +378,8 @@ class InvoicesScreen(CScreen):
ci.memo = pr.memo ci.memo = pr.memo
ci.amount = self.app.format_amount_and_units(pr.get_amount()) ci.amount = self.app.format_amount_and_units(pr.get_amount())
status = self.app.invoices.get_status(ci.key) status = self.app.invoices.get_status(ci.key)
if status == PR_PAID: ci.status = pr_text[status]
ci.icon = "atlas://gui/kivy/theming/light/confirmed" ci.icon = pr_icon[status]
elif status == PR_EXPIRED:
ci.icon = "atlas://gui/kivy/theming/light/important"
else:
ci.icon = "atlas://gui/kivy/theming/light/important"
exp = pr.get_expiration_date() exp = pr.get_expiration_date()
ci.date = format_time(exp) if exp else _('Never') ci.date = format_time(exp) if exp else _('Never')
ci.screen = self ci.screen = self
@ -409,12 +417,8 @@ class RequestsScreen(CScreen):
ci.address = req['address'] ci.address = req['address']
ci.memo = self.app.wallet.get_label(address) ci.memo = self.app.wallet.get_label(address)
status = req.get('status') status = req.get('status')
if status == PR_PAID: ci.status = pr_text[status]
ci.icon = "atlas://gui/kivy/theming/light/confirmed" ci.icon = pr_icon[status]
elif status == PR_EXPIRED:
ci.icon = "atlas://gui/kivy/theming/light/important"
else:
ci.icon = "atlas://gui/kivy/theming/light/important"
ci.amount = self.app.format_amount_and_units(amount) if amount else '' ci.amount = self.app.format_amount_and_units(amount) if amount else ''
ci.date = format_time(timestamp) ci.date = format_time(timestamp)
ci.screen = self ci.screen = self

View File

@ -25,18 +25,31 @@
InvoicesLabel: InvoicesLabel:
text: root.requestor text: root.requestor
shorten: True shorten: True
Widget
InvoicesLabel: InvoicesLabel:
text: root.memo text: root.memo
color: .699, .699, .699, 1 color: .699, .699, .699, 1
font_size: '13sp' font_size: '13sp'
shorten: True shorten: True
Widget Widget
InvoicesLabel: BoxLayout:
halign: 'right' spacing: '8dp'
font_size: '15sp' height: '32dp'
size_hint: None, 1 orientation: 'vertical'
width: '110sp' Widget
text: root.amount InvoicesLabel:
text: root.amount
font_size: '15sp'
halign: 'right'
width: '110sp'
Widget
InvoicesLabel:
text: root.status
font_size: '13sp'
halign: 'right'
color: .699, .699, .699, 1
Widget
InvoicesScreen: InvoicesScreen:
name: 'invoices' name: 'invoices'

View File

@ -25,18 +25,30 @@
RequestLabel: RequestLabel:
text: root.address text: root.address
shorten: True shorten: True
Widget
RequestLabel: RequestLabel:
text: root.memo text: root.memo
color: .699, .699, .699, 1 color: .699, .699, .699, 1
font_size: '13sp' font_size: '13sp'
shorten: True shorten: True
Widget Widget
RequestLabel: BoxLayout:
halign: 'right' spacing: '8dp'
font_size: '15sp' height: '32dp'
size_hint: None, 1 orientation: 'vertical'
width: '110sp' Widget
text: root.amount RequestLabel:
text: root.amount
halign: 'right'
font_size: '15sp'
Widget
RequestLabel:
text: root.status
halign: 'right'
font_size: '13sp'
color: .699, .699, .699, 1
Widget
RequestsScreen: RequestsScreen: