kivy: channels list improvements
This commit is contained in:
@@ -130,7 +130,7 @@ Builder.load_string(r'''
|
|||||||
short_channel_id: '<channelId not set>'
|
short_channel_id: '<channelId not set>'
|
||||||
status: ''
|
status: ''
|
||||||
is_backup: False
|
is_backup: False
|
||||||
balances: ''
|
capacity: ''
|
||||||
node_alias: ''
|
node_alias: ''
|
||||||
_chan: None
|
_chan: None
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
@@ -140,14 +140,15 @@ Builder.load_string(r'''
|
|||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
Widget
|
Widget
|
||||||
CardLabel:
|
CardLabel:
|
||||||
color: (.5,.5,.5,1) if not root.active else (1,1,1,1)
|
|
||||||
text: root.short_channel_id
|
|
||||||
font_size: '15sp'
|
font_size: '15sp'
|
||||||
|
text: root.node_alias
|
||||||
|
shorten: True
|
||||||
|
color: (.5,.5,.5,1) if not root.active else (1,1,1,1)
|
||||||
Widget
|
Widget
|
||||||
CardLabel:
|
CardLabel:
|
||||||
font_size: '13sp'
|
font_size: '13sp'
|
||||||
shorten: True
|
text: root.short_channel_id
|
||||||
text: root.node_alias
|
color: (.5,.5,.5,1)
|
||||||
Widget
|
Widget
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
size_hint: 0.3, None
|
size_hint: 0.3, None
|
||||||
@@ -159,11 +160,13 @@ Builder.load_string(r'''
|
|||||||
text: root.status
|
text: root.status
|
||||||
font_size: '13sp'
|
font_size: '13sp'
|
||||||
halign: 'right'
|
halign: 'right'
|
||||||
|
color: (.5,.5,.5,1) if not root.active else (1,1,1,1)
|
||||||
Widget
|
Widget
|
||||||
CardLabel:
|
CardLabel:
|
||||||
text: root.balances if not root.is_backup else ''
|
text: root.capacity
|
||||||
font_size: '13sp'
|
font_size: '13sp'
|
||||||
halign: 'right'
|
halign: 'right'
|
||||||
|
color: (.5,.5,.5,1)
|
||||||
Widget
|
Widget
|
||||||
|
|
||||||
<LightningChannelsDialog@Popup>:
|
<LightningChannelsDialog@Popup>:
|
||||||
@@ -180,14 +183,14 @@ Builder.load_string(r'''
|
|||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
spacing: '2dp'
|
spacing: '2dp'
|
||||||
padding: '12dp'
|
padding: '12dp'
|
||||||
|
TopLabel:
|
||||||
|
text: root.num_channels_text
|
||||||
BoxLabel:
|
BoxLabel:
|
||||||
text: _('You can send') + ':'
|
text: _('You can send') + ':'
|
||||||
value: root.can_send
|
value: root.can_send
|
||||||
BoxLabel:
|
BoxLabel:
|
||||||
text: _('You can receive') + ':'
|
text: _('You can receive') + ':'
|
||||||
value: root.can_receive
|
value: root.can_receive
|
||||||
TopLabel:
|
|
||||||
text: root.num_channels_text
|
|
||||||
ScrollView:
|
ScrollView:
|
||||||
GridLayout:
|
GridLayout:
|
||||||
cols: 1
|
cols: 1
|
||||||
@@ -598,29 +601,11 @@ class LightningChannelsDialog(Factory.Popup):
|
|||||||
p = ChannelDetailsPopup(chan, self.app)
|
p = ChannelDetailsPopup(chan, self.app)
|
||||||
p.open()
|
p.open()
|
||||||
|
|
||||||
def format_fields(self, chan):
|
|
||||||
labels = {}
|
|
||||||
for subject in (REMOTE, LOCAL):
|
|
||||||
bal_minus_htlcs = chan.balance_minus_outgoing_htlcs(subject)//1000
|
|
||||||
label = self.app.format_amount(bal_minus_htlcs)
|
|
||||||
other = subject.inverted()
|
|
||||||
bal_other = chan.balance(other)//1000
|
|
||||||
bal_minus_htlcs_other = chan.balance_minus_outgoing_htlcs(other)//1000
|
|
||||||
if bal_other != bal_minus_htlcs_other:
|
|
||||||
label += ' (+' + self.app.format_amount(bal_other - bal_minus_htlcs_other) + ')'
|
|
||||||
labels[subject] = label
|
|
||||||
closed = chan.is_closed()
|
|
||||||
return [
|
|
||||||
'n/a' if closed else labels[LOCAL],
|
|
||||||
'n/a' if closed else labels[REMOTE],
|
|
||||||
]
|
|
||||||
|
|
||||||
def update_item(self, item):
|
def update_item(self, item):
|
||||||
chan = item._chan
|
chan = item._chan
|
||||||
item.status = chan.get_state_for_GUI()
|
item.status = chan.get_state_for_GUI()
|
||||||
item.short_channel_id = chan.short_id_for_GUI()
|
item.short_channel_id = chan.short_id_for_GUI()
|
||||||
l, r = self.format_fields(chan)
|
item.capacity = self.app.format_amount_and_units(chan.get_capacity())
|
||||||
item.balances = l + '/' + r
|
|
||||||
self.update_can_send()
|
self.update_can_send()
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user