mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-20 18:09:48 +00:00
kivy: add status icons, improve requests layout
This commit is contained in:
parent
b1704ce911
commit
9caf174d7f
5 changed files with 94 additions and 63 deletions
|
@ -10,20 +10,20 @@ from kivy.factory import Factory
|
||||||
Builder.load_string('''
|
Builder.load_string('''
|
||||||
<MenuItem@Button>
|
<MenuItem@Button>
|
||||||
background_color: .2, .9, 1, 1
|
background_color: .2, .9, 1, 1
|
||||||
height: '40dp'
|
height: '48dp'
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
|
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
height: '32dp'
|
height: '48dp'
|
||||||
#size: 120, 250
|
|
||||||
pos: (0, 0)
|
pos: (0, 0)
|
||||||
show_arrow: False
|
show_arrow: False
|
||||||
|
arrow_pos: 'top_mid'
|
||||||
padding: 0
|
padding: 0
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
size_hint: 1, 1
|
size_hint: 1, 1
|
||||||
height: '40dp'
|
height: '48dp'
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
id: buttons
|
id: buttons
|
||||||
''')
|
''')
|
||||||
|
|
|
@ -24,6 +24,8 @@ from electrum.plugins import run_hook
|
||||||
|
|
||||||
from context_menu import ContextMenu
|
from context_menu import ContextMenu
|
||||||
|
|
||||||
|
from electrum.paymentrequest import PR_UNPAID, PR_PAID, PR_UNKNOWN, PR_EXPIRED
|
||||||
|
|
||||||
|
|
||||||
class CScreen(Factory.Screen):
|
class CScreen(Factory.Screen):
|
||||||
|
|
||||||
|
@ -74,14 +76,14 @@ class CScreen(Factory.Screen):
|
||||||
|
|
||||||
def hide_menu(self):
|
def hide_menu(self):
|
||||||
if self.context_menu:
|
if self.context_menu:
|
||||||
self.screen.remove_widget(self.context_menu)
|
self.remove_widget(self.context_menu)
|
||||||
self.context_menu = None
|
self.context_menu = None
|
||||||
|
|
||||||
def show_menu(self, obj):
|
def show_menu(self, obj):
|
||||||
if self.context_menu is None:
|
if self.context_menu is None:
|
||||||
self.context_menu = ContextMenu(obj, self.menu_actions)
|
self.context_menu = ContextMenu(obj, self.menu_actions)
|
||||||
self.screen.remove_widget(self.context_menu)
|
self.remove_widget(self.context_menu)
|
||||||
self.screen.add_widget(self.context_menu)
|
self.add_widget(self.context_menu)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,15 +145,14 @@ class HistoryScreen(CScreen):
|
||||||
# repopulate History Card
|
# repopulate History Card
|
||||||
history_card.clear_widgets()
|
history_card.clear_widgets()
|
||||||
history_add = history_card.add_widget
|
history_add = history_card.add_widget
|
||||||
RecentActivityItem = Factory.RecentActivityItem
|
|
||||||
count = 0
|
count = 0
|
||||||
for item in history:
|
for item in history:
|
||||||
count += 1
|
count += 1
|
||||||
conf, icon, date_time, address, value, tx, quote_text = item
|
conf, icon, date_time, message, value, tx, quote_text = item
|
||||||
ri = RecentActivityItem()
|
ri = Factory.HistoryItem()
|
||||||
ri.icon = icon
|
ri.icon = icon
|
||||||
ri.date = date_time
|
ri.date = date_time
|
||||||
ri.address = address
|
ri.message = message
|
||||||
ri.value = value
|
ri.value = value
|
||||||
ri.quote_text = quote_text
|
ri.quote_text = quote_text
|
||||||
ri.confirmations = conf
|
ri.confirmations = conf
|
||||||
|
@ -377,7 +378,14 @@ class InvoicesScreen(CScreen):
|
||||||
ci.requestor = pr.get_requestor()
|
ci.requestor = pr.get_requestor()
|
||||||
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())
|
||||||
#ci.status = self.invoices.get_status(key)
|
status = self.app.invoices.get_status(ci.key)
|
||||||
|
if status == PR_PAID:
|
||||||
|
icon = "atlas://gui/kivy/theming/light/confirmed"
|
||||||
|
elif status == PR_EXPIRED:
|
||||||
|
icon = "atlas://gui/kivy/theming/light/important"
|
||||||
|
else:
|
||||||
|
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
|
||||||
|
@ -406,11 +414,17 @@ class RequestsScreen(CScreen):
|
||||||
expiration = req.get('exp', None)
|
expiration = req.get('exp', None)
|
||||||
status = req.get('status')
|
status = req.get('status')
|
||||||
signature = req.get('sig')
|
signature = req.get('sig')
|
||||||
|
|
||||||
ci = Factory.RequestItem()
|
ci = Factory.RequestItem()
|
||||||
ci.address = req['address']
|
ci.address = req['address']
|
||||||
ci.memo = req.get('memo', '')
|
ci.memo = req.get('memo', '')
|
||||||
#ci.status = req.get('status')
|
status = req.get('status')
|
||||||
|
if status == PR_PAID:
|
||||||
|
icon = "atlas://gui/kivy/theming/light/confirmed"
|
||||||
|
elif status == PR_EXPIRED:
|
||||||
|
icon = "atlas://gui/kivy/theming/light/important"
|
||||||
|
else:
|
||||||
|
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
|
||||||
|
|
|
@ -5,23 +5,9 @@
|
||||||
#:set mbtc_symbol unichr(187)
|
#:set mbtc_symbol unichr(187)
|
||||||
|
|
||||||
|
|
||||||
<Card@GridLayout>
|
|
||||||
cols: 1
|
|
||||||
padding: '12dp' , '22dp', '12dp' , '12dp'
|
|
||||||
spacing: '12dp'
|
|
||||||
size_hint: 1, None
|
|
||||||
height: max(100, self.minimum_height)
|
|
||||||
canvas.before:
|
|
||||||
Color:
|
|
||||||
rgba: 1, 1, 1, 1
|
|
||||||
BorderImage:
|
|
||||||
border: 18, 18, 18, 18
|
|
||||||
source: 'atlas://gui/kivy/theming/light/card'
|
|
||||||
size: self.size
|
|
||||||
pos: self.pos
|
|
||||||
|
|
||||||
<CardLabel@Label>
|
<CardLabel@Label>
|
||||||
color: 0.45, 0.45, 0.45, 1
|
color: 0.95, 0.95, 0.95, 1
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
text: ''
|
text: ''
|
||||||
text_size: self.width, None
|
text_size: self.width, None
|
||||||
|
@ -29,21 +15,13 @@
|
||||||
halign: 'left'
|
halign: 'left'
|
||||||
valign: 'top'
|
valign: 'top'
|
||||||
|
|
||||||
<CardButton@Button>
|
|
||||||
background_normal: 'atlas://gui/kivy/theming/light/card_btn'
|
|
||||||
bold: True
|
|
||||||
font_size: '10sp'
|
|
||||||
color: 0.699, 0.699, 0.699, 1
|
|
||||||
size_hint: None, None
|
|
||||||
size: self.texture_size[0] + dp(32), self.texture_size[1] + dp(7)
|
|
||||||
|
|
||||||
|
<HistoryItem@CardItem>
|
||||||
<RecentActivityItem@CardItem>
|
|
||||||
icon: 'atlas://gui/kivy/theming/light/important'
|
icon: 'atlas://gui/kivy/theming/light/important'
|
||||||
address: 'no address set'
|
message: ''
|
||||||
value: 0
|
value: 0
|
||||||
amount: app.format_amount(self.value, True) if self.value is not None else '--'
|
amount: app.format_amount(self.value, True) if self.value is not None else '--'
|
||||||
amount_color: '#DB3627' if self.value < 0 else '#2EA442'
|
amount_color: '#FF6657' if self.value < 0 else '#2EA442'
|
||||||
confirmations: 0
|
confirmations: 0
|
||||||
date: '0/0/0'
|
date: '0/0/0'
|
||||||
quote_text: '.'
|
quote_text: '.'
|
||||||
|
@ -62,26 +40,26 @@
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
Widget
|
Widget
|
||||||
CardLabel:
|
|
||||||
shorten: True
|
|
||||||
text: root.address
|
|
||||||
markup: False
|
|
||||||
text_size: self.size
|
|
||||||
CardLabel:
|
CardLabel:
|
||||||
color: .699, .699, .699, 1
|
color: .699, .699, .699, 1
|
||||||
text: root.date
|
text: root.date
|
||||||
font_size: '12sp'
|
font_size: '14sp'
|
||||||
|
CardLabel:
|
||||||
|
shorten: True
|
||||||
|
text: root.message
|
||||||
|
markup: False
|
||||||
|
text_size: self.size
|
||||||
Widget
|
Widget
|
||||||
CardLabel:
|
CardLabel:
|
||||||
halign: 'right'
|
halign: 'right'
|
||||||
font_size: '13sp'
|
font_size: '15sp'
|
||||||
size_hint: None, 1
|
size_hint: None, 1
|
||||||
width: '110sp'
|
width: '110sp'
|
||||||
markup: True
|
markup: True
|
||||||
font_name: font_light
|
font_name: font_light
|
||||||
text:
|
text:
|
||||||
u'[color={amount_color}]{sign}{amount} {unit}[/color]\n'\
|
u'[color={amount_color}]{sign}{amount} {unit}[/color]\n'\
|
||||||
u'[color=#B2B3B3][size=12sp]{qt}[/size]'\
|
u'[color=#B2B3B3][size=13sp]{qt}[/size]'\
|
||||||
u'[/color]'.format(amount_color=root.amount_color,\
|
u'[/color]'.format(amount_color=root.amount_color,\
|
||||||
amount=root.amount[1:], qt=root.quote_text, sign=root.amount[0],\
|
amount=root.amount[1:], qt=root.quote_text, sign=root.amount[0],\
|
||||||
unit=app.base_unit)
|
unit=app.base_unit)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<InvoicesLabel@Label>
|
<InvoicesLabel@Label>
|
||||||
#color: .305, .309, .309, 1
|
#color: .305, .309, .309, 1
|
||||||
text_size: self.size
|
text_size: self.width, None
|
||||||
halign: 'left'
|
halign: 'left'
|
||||||
valign: 'middle'
|
valign: 'top'
|
||||||
|
|
||||||
<InvoiceItem@CardItem>
|
<InvoiceItem@CardItem>
|
||||||
requestor: ''
|
requestor: ''
|
||||||
|
@ -10,11 +10,32 @@
|
||||||
amount: ''
|
amount: ''
|
||||||
status: ''
|
status: ''
|
||||||
date: ''
|
date: ''
|
||||||
|
icon: 'atlas://gui/kivy/theming/light/important'
|
||||||
|
Image:
|
||||||
|
id: icon
|
||||||
|
source: root.icon
|
||||||
|
size_hint: None, 1
|
||||||
|
width: self.height *.54
|
||||||
|
mipmap: True
|
||||||
|
BoxLayout:
|
||||||
|
spacing: '8dp'
|
||||||
|
height: '32dp'
|
||||||
|
orientation: 'vertical'
|
||||||
|
Widget
|
||||||
|
InvoicesLabel:
|
||||||
|
text: root.requestor
|
||||||
|
shorten: True
|
||||||
|
InvoicesLabel:
|
||||||
|
text: root.memo
|
||||||
|
color: .699, .699, .699, 1
|
||||||
|
font_size: '13sp'
|
||||||
|
shorten: True
|
||||||
|
Widget
|
||||||
InvoicesLabel:
|
InvoicesLabel:
|
||||||
text: root.requestor
|
halign: 'right'
|
||||||
InvoicesLabel:
|
font_size: '15sp'
|
||||||
text: root.memo
|
size_hint: None, 1
|
||||||
InvoicesLabel:
|
width: '80sp'
|
||||||
text: root.amount
|
text: root.amount
|
||||||
|
|
||||||
InvoicesScreen:
|
InvoicesScreen:
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<RequestLabel@Label>
|
<RequestLabel@Label>
|
||||||
#color: .305, .309, .309, 1
|
#color: .305, .309, .309, 1
|
||||||
text_size: self.size
|
text_size: self.width, None
|
||||||
halign: 'left'
|
halign: 'left'
|
||||||
valign: 'middle'
|
valign: 'top'
|
||||||
|
|
||||||
<RequestItem@CardItem>
|
<RequestItem@CardItem>
|
||||||
address: ''
|
address: ''
|
||||||
|
@ -10,15 +10,33 @@
|
||||||
amount: ''
|
amount: ''
|
||||||
status: ''
|
status: ''
|
||||||
date: ''
|
date: ''
|
||||||
|
icon: 'atlas://gui/kivy/theming/light/important'
|
||||||
|
Image:
|
||||||
|
id: icon
|
||||||
|
source: root.icon
|
||||||
|
size_hint: None, 1
|
||||||
|
width: self.height *.54
|
||||||
|
mipmap: True
|
||||||
|
BoxLayout:
|
||||||
|
spacing: '8dp'
|
||||||
|
height: '32dp'
|
||||||
|
orientation: 'vertical'
|
||||||
|
Widget
|
||||||
|
RequestLabel:
|
||||||
|
text: root.address
|
||||||
|
shorten: True
|
||||||
|
RequestLabel:
|
||||||
|
text: root.memo
|
||||||
|
color: .699, .699, .699, 1
|
||||||
|
font_size: '13sp'
|
||||||
|
shorten: True
|
||||||
|
Widget
|
||||||
RequestLabel:
|
RequestLabel:
|
||||||
text: root.address
|
halign: 'right'
|
||||||
font_size: '13dp'
|
font_size: '15sp'
|
||||||
RequestLabel:
|
size_hint: None, 1
|
||||||
text: root.memo
|
width: '80sp'
|
||||||
RequestLabel:
|
|
||||||
text: root.amount
|
text: root.amount
|
||||||
#InvoicesLabel:
|
|
||||||
# text: root.status
|
|
||||||
|
|
||||||
|
|
||||||
RequestsScreen:
|
RequestsScreen:
|
||||||
|
|
Loading…
Add table
Reference in a new issue