mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 17:01:34 +00:00
kivy: simplify fee dialog
This commit is contained in:
parent
721dc8cdb9
commit
2e594d2d7a
1 changed files with 33 additions and 41 deletions
|
@ -11,13 +11,26 @@ Builder.load_string('''
|
||||||
title: _('Transaction Fees')
|
title: _('Transaction Fees')
|
||||||
size_hint: 0.8, 0.8
|
size_hint: 0.8, 0.8
|
||||||
pos_hint: {'top':0.9}
|
pos_hint: {'top':0.9}
|
||||||
|
method: 0
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
size_hint: 1, 0.5
|
size_hint: 1, 0.5
|
||||||
Label:
|
Label:
|
||||||
text: (_('Target') if dynfees.active else _('Fixed rate')) + ':'
|
text: _('Method') + ':'
|
||||||
|
Button:
|
||||||
|
text: _('Mempool based') if root.method == 2 else _('ETA based') if root.method == 1 else _('Static')
|
||||||
|
background_color: (0,0,0,0)
|
||||||
|
on_release:
|
||||||
|
root.method = (root.method + 1) % 3
|
||||||
|
root.update_slider()
|
||||||
|
root.update_text()
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'horizontal'
|
||||||
|
size_hint: 1, 0.5
|
||||||
|
Label:
|
||||||
|
text: _('Target') + ':'
|
||||||
Label:
|
Label:
|
||||||
id: fee_target
|
id: fee_target
|
||||||
text: ''
|
text: ''
|
||||||
|
@ -25,7 +38,7 @@ Builder.load_string('''
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
size_hint: 1, 0.5
|
size_hint: 1, 0.5
|
||||||
Label:
|
Label:
|
||||||
text: (_('Current rate') if dynfees.active else _('Estimate')) + ':'
|
text: (_('Current rate') if root.method > 0 else _('Estimate')) + ':'
|
||||||
Label:
|
Label:
|
||||||
id: fee_estimate
|
id: fee_estimate
|
||||||
text: ''
|
text: ''
|
||||||
|
@ -34,22 +47,6 @@ Builder.load_string('''
|
||||||
range: 0, 4
|
range: 0, 4
|
||||||
step: 1
|
step: 1
|
||||||
on_value: root.on_slider(self.value)
|
on_value: root.on_slider(self.value)
|
||||||
BoxLayout:
|
|
||||||
orientation: 'horizontal'
|
|
||||||
size_hint: 1, 0.5
|
|
||||||
Label:
|
|
||||||
text: _('Dynamic Fees')
|
|
||||||
CheckBox:
|
|
||||||
id: dynfees
|
|
||||||
on_active: root.on_dynfees(self.active)
|
|
||||||
BoxLayout:
|
|
||||||
orientation: 'horizontal'
|
|
||||||
size_hint: 1, 0.5
|
|
||||||
Label:
|
|
||||||
text: _('Use mempool')
|
|
||||||
CheckBox:
|
|
||||||
id: mempool
|
|
||||||
on_active: root.on_mempool(self.active)
|
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 1
|
size_hint: 1, 1
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
|
@ -77,10 +74,9 @@ class FeeDialog(Factory.Popup):
|
||||||
self.config = config
|
self.config = config
|
||||||
self.fee_rate = self.config.fee_per_kb()
|
self.fee_rate = self.config.fee_per_kb()
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.mempool = self.config.use_mempool_fees()
|
mempool = self.config.use_mempool_fees()
|
||||||
self.dynfees = self.config.is_dynfee()
|
dynfees = self.config.is_dynfee()
|
||||||
self.ids.mempool.active = self.mempool
|
self.method = (2 if mempool else 1) if dynfees else 0
|
||||||
self.ids.dynfees.active = self.dynfees
|
|
||||||
self.update_slider()
|
self.update_slider()
|
||||||
self.update_text()
|
self.update_text()
|
||||||
|
|
||||||
|
@ -90,28 +86,34 @@ class FeeDialog(Factory.Popup):
|
||||||
self.ids.fee_target.text = target
|
self.ids.fee_target.text = target
|
||||||
self.ids.fee_estimate.text = estimate
|
self.ids.fee_estimate.text = estimate
|
||||||
|
|
||||||
|
def get_method(self):
|
||||||
|
dynfees = self.method > 0
|
||||||
|
mempool = self.method == 2
|
||||||
|
return dynfees, mempool
|
||||||
|
|
||||||
def update_slider(self):
|
def update_slider(self):
|
||||||
slider = self.ids.slider
|
slider = self.ids.slider
|
||||||
maxp, pos, fee_rate = self.config.get_fee_slider(self.dynfees, self.mempool)
|
dynfees, mempool = self.get_method()
|
||||||
|
maxp, pos, fee_rate = self.config.get_fee_slider(dynfees, mempool)
|
||||||
slider.range = (0, maxp)
|
slider.range = (0, maxp)
|
||||||
slider.step = 1
|
slider.step = 1
|
||||||
slider.value = pos
|
slider.value = pos
|
||||||
|
|
||||||
def get_fee_text(self, pos):
|
def get_fee_text(self, pos):
|
||||||
dyn = self.dynfees
|
dynfees, mempool = self.get_method()
|
||||||
mempool = self.mempool
|
if dynfees:
|
||||||
if dyn:
|
|
||||||
fee_rate = self.config.depth_to_fee(pos) if mempool else self.config.eta_to_fee(pos)
|
fee_rate = self.config.depth_to_fee(pos) if mempool else self.config.eta_to_fee(pos)
|
||||||
else:
|
else:
|
||||||
fee_rate = self.config.static_fee(pos)
|
fee_rate = self.config.static_fee(pos)
|
||||||
return self.config.get_fee_text(pos, dyn, mempool, fee_rate)
|
return self.config.get_fee_text(pos, dynfees, mempool, fee_rate)
|
||||||
|
|
||||||
def on_ok(self):
|
def on_ok(self):
|
||||||
value = int(self.ids.slider.value)
|
value = int(self.ids.slider.value)
|
||||||
self.config.set_key('dynamic_fees', self.dynfees, False)
|
dynfees, mempool = self.get_method()
|
||||||
self.config.set_key('mempool_fees', self.mempool, False)
|
self.config.set_key('dynamic_fees', dynfees, False)
|
||||||
if self.dynfees:
|
self.config.set_key('mempool_fees', mempool, False)
|
||||||
if self.mempool:
|
if dynfees:
|
||||||
|
if mempool:
|
||||||
self.config.set_key('depth_level', value, True)
|
self.config.set_key('depth_level', value, True)
|
||||||
else:
|
else:
|
||||||
self.config.set_key('fee_level', value, True)
|
self.config.set_key('fee_level', value, True)
|
||||||
|
@ -121,13 +123,3 @@ class FeeDialog(Factory.Popup):
|
||||||
|
|
||||||
def on_slider(self, value):
|
def on_slider(self, value):
|
||||||
self.update_text()
|
self.update_text()
|
||||||
|
|
||||||
def on_dynfees(self, b):
|
|
||||||
self.dynfees = b
|
|
||||||
self.update_slider()
|
|
||||||
self.update_text()
|
|
||||||
|
|
||||||
def on_mempool(self, b):
|
|
||||||
self.mempool = b
|
|
||||||
self.update_slider()
|
|
||||||
self.update_text()
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue