electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 1526768cd668b9b6da1ea902627b8f289395ad0a
parent f863e7c7a8524c319339fd65ab6917628dbf3549
Author: ThomasV <thomasv@electrum.org>
Date:   Sat,  3 Mar 2018 11:32:38 +0100

kivy: simplify history screen, display either fiat or btc

Diffstat:
Mgui/kivy/main.kv | 2+-
Mgui/kivy/main_window.py | 6++++--
Mgui/kivy/uix/screens.py | 13++++++-------
Mgui/kivy/uix/ui_screens/address.kv | 18+-----------------
Mgui/kivy/uix/ui_screens/history.kv | 46++++++++++++++++++----------------------------
Mlib/exchange_rate.py | 4++++
6 files changed, 34 insertions(+), 55 deletions(-)

diff --git a/gui/kivy/main.kv b/gui/kivy/main.kv @@ -239,7 +239,7 @@ self.screen.show_menu(args[0]) if self.state == 'down' else self.screen.hide_menu() canvas.before: Color: - rgba: (0.192, .498, 0.745, 1) if self.state == 'down' else (0.3, 0.3, 0.3, 1) + rgba: (0.192, .498, 0.745, 1) if self.state == 'down' else (0.15, 0.15, 0.17, 1) Rectangle: size: self.size pos: self.pos diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -84,6 +84,8 @@ class ElectrumWindow(App): blockchain_name = StringProperty('') fee_status = StringProperty('Fee') balance = StringProperty('') + fiat_balance = StringProperty('') + is_fiat = BooleanProperty(False) blockchain_checkpoint = NumericProperty(0) auto_connect = BooleanProperty(False) @@ -644,8 +646,8 @@ class ElectrumWindow(App): # balance c, u, x = self.wallet.get_balance() text = self.format_amount(c+x+u) - self.balance = str(text.strip() + ' ' + self.base_unit) - #fiat_balance = self.fx.format_amount_and_units(c+u+x) or '' + self.balance = str(text.strip()) + ' [size=22dp]%s[/size]'% self.base_unit + self.fiat_balance = self.fx.format_amount(c+u+x) + ' [size=22dp]%s[/size]'% self.fx.ccy def get_max_amount(self): inputs = self.wallet.get_spendable_coins(None, self.electrum_config) diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py @@ -143,14 +143,13 @@ class HistoryScreen(CScreen): ri.icon = icon ri.date = status_str ri.message = label - ri.value = value or 0 - ri.amount = self.app.format_amount(value, True) if value is not None else '--' ri.confirmations = conf - if self.app.fiat_unit and date: - rate = self.app.fx.history_rate(date) - if rate: - s = self.app.fx.value_str(value, rate) - ri.quote_text = '' if s is None else s + ' ' + self.app.fiat_unit + if value is not None: + ri.is_mine = value < 0 + if value < 0: value = - value + ri.amount = self.app.format_amount_and_units(value) + if self.app.fiat_unit and date: + ri.quote_text = self.app.fx.historical_value_str(value, date) + ' ' + self.app.fx.ccy return ri def update(self, see_all=False): diff --git a/gui/kivy/uix/ui_screens/address.kv b/gui/kivy/uix/ui_screens/address.kv @@ -24,26 +24,11 @@ shorten: True Widget AddressLabel: - text: root.memo + text: (root.amount if root.status == 'Funded' else root.status) + ' ' + root.memo color: .699, .699, .699, 1 font_size: '13sp' shorten: True Widget - BoxLayout: - spacing: '8dp' - height: '32dp' - orientation: 'vertical' - Widget - AddressLabel: - text: root.amount - halign: 'right' - font_size: '15sp' - Widget - AddressLabel: - text: root.status - halign: 'right' - font_size: '13sp' - color: .699, .699, .699, 1 AddressScreen: id: addr_screen @@ -103,4 +88,3 @@ AddressScreen: id: search_container size_hint_y: None height: self.minimum_height - spacing: '2dp' diff --git a/gui/kivy/uix/ui_screens/history.kv b/gui/kivy/uix/ui_screens/history.kv @@ -19,44 +19,34 @@ <HistoryItem@CardItem> icon: 'atlas://gui/kivy/theming/light/important' message: '' - value: 0 + is_mine: True amount: '--' - amount_color: '#FF6657' if self.value < 0 else '#2EA442' + action: _('Sent') if self.is_mine else _('Received') + amount_color: '#FF6657' if self.is_mine else '#2EA442' confirmations: 0 date: '' quote_text: '' - spacing: '9dp' Image: id: icon source: root.icon size_hint: None, 1 - width: self.height *.54 + width: self.height mipmap: True BoxLayout: orientation: 'vertical' Widget CardLabel: - text: root.date - font_size: '14sp' + text: + u'[color={color}]{s}[/color]'.format(s='<<' if root.is_mine else '>>', color=root.amount_color)\ + + ' ' + root.action + ' ' + (root.quote_text if app.is_fiat else root.amount) + font_size: '15sp' CardLabel: color: .699, .699, .699, 1 - font_size: '13sp' + font_size: '14sp' shorten: True - text: root.message + text: root.date + ' ' + root.message Widget - CardLabel: - halign: 'right' - font_size: '15sp' - size_hint: None, 1 - width: '110sp' - markup: True - font_name: font_light - text: - u'[color={amount_color}]{sign}{amount} {unit}[/color]\n'\ - u'[color=#B2B3B3][size=13sp]{qt}[/size]'\ - u'[/color]'.format(amount_color=root.amount_color,\ - amount=root.amount[1:], qt=root.quote_text, sign=root.amount[0],\ - unit=app.base_unit) + HistoryScreen: @@ -64,21 +54,21 @@ HistoryScreen: content: content BoxLayout: orientation: 'vertical' - Label: - text: app.balance - color: .699, .699, .699, 1 - font_size: '22dp' + Button: + background_color: 0, 0, 0, 0 + text: app.fiat_balance if app.is_fiat else app.balance + markup: True + color: .9, .9, .9, 1 + font_size: '30dp' bold: True size_hint: 1, 0.25 + on_release: app.is_fiat = not app.is_fiat ScrollView: id: content do_scroll_x: False size_hint: 1, 0.75 - #height: self.minimum_height GridLayout id: history_container cols: 1 size_hint: 1, None height: self.minimum_height - padding: '12dp' - spacing: '2dp' diff --git a/lib/exchange_rate.py b/lib/exchange_rate.py @@ -505,6 +505,10 @@ class FxThread(ThreadJob): return Decimal('NaN') return Decimal(rate) + def format_amount(self, btc_balance): + rate = self.exchange_rate() + return '' if rate.is_nan() else "%s" % self.value_str(btc_balance, rate) + def format_amount_and_units(self, btc_balance): rate = self.exchange_rate() return '' if rate.is_nan() else "%s %s" % (self.value_str(btc_balance, rate), self.ccy)