add amount keyboard

This commit is contained in:
ThomasV 2015-10-14 11:44:01 +02:00
parent 3e8cbdfba2
commit 2f543d2ad8
5 changed files with 125 additions and 24 deletions

View File

@ -803,6 +803,15 @@ class ElectrumWindow(App):
info_bubble.show(pos, duration, width, modal=modal, exit=exit) info_bubble.show(pos, duration, width, modal=modal, exit=exit)
def amount_dialog(self, label, callback):
popup = Builder.load_file('gui/kivy/uix/ui_screens/amount.kv')
popup.ids.amount_label.text = label.text
def cb():
label.text = popup.ids.amount_label.text
callback()
popup.on_dismiss = cb
popup.open()
def password_dialog(self, f, args): def password_dialog(self, f, args):
if self.wallet.use_encryption: if self.wallet.use_encryption:
popup = Builder.load_file('gui/kivy/uix/ui_screens/password.kv') popup = Builder.load_file('gui/kivy/uix/ui_screens/password.kv')

View File

@ -249,11 +249,31 @@ class SendScreen(CScreen):
class ReceiveScreen(CScreen): class ReceiveScreen(CScreen):
kvname = 'receive' kvname = 'receive'
@profiler
def update(self): def update(self):
addr = self.app.wallet.get_unused_address(None) addr = self.app.wallet.get_unused_address(None)
address_label = self.screen.ids.get('address')
address_label.text = addr
self.update_qr()
def amount_callback(self, popup):
amount_label = self.screen.ids.get('amount')
amount_label.text = popup.ids.amount_label.text
self.update_qr()
@profiler
def update_qrtt(self):
raise
def update_qr(self):
address_label = self.screen.ids.get('address')
address = address_label.text
amount_label = self.screen.ids.get('amount')
amount = amount_label.text
qr = self.screen.ids.get('qr') qr = self.screen.ids.get('qr')
qr.set_data(addr) uri = 'bitcoin:'+ address + '?amount='+amount if address and amount else address
qr.set_data(uri)
class ContactsScreen(CScreen): class ContactsScreen(CScreen):

View File

@ -0,0 +1,66 @@
<KButton@Button>:
size_hint: 1, None
height: '38dp'
Popup:
id: popup
title: _('Amount')
BoxLayout:
orientation: 'vertical'
halign: 'center'
Label:
id: amount_label
text: ''
GridLayout:
cols: 3
size_hint: 0.5, 1
KButton:
text: '1'
on_release: amount_label.text += self.text
KButton:
text: '2'
on_release: amount_label.text += self.text
KButton:
text: '3'
on_release: amount_label.text += self.text
KButton:
text: '4'
on_release: amount_label.text += self.text
KButton:
text: '5'
on_release: amount_label.text += self.text
KButton:
text: '6'
on_release: amount_label.text += self.text
KButton:
text: '7'
on_release: amount_label.text += self.text
KButton:
text: '8'
on_release: amount_label.text += self.text
KButton:
text: '9'
on_release: amount_label.text += self.text
KButton:
text: '.'
on_release: amount_label.text += self.text
KButton:
text: '0'
on_release: amount_label.text += self.text
KButton:
text: '<'
on_release: amount_label.text = amount_label.text[:-1]
Button:
size_hint: 0.5, None
height: '48dp'
text: _('OK')
on_release: popup.dismiss()
Widget:
size_hint: 1, None

View File

@ -9,14 +9,12 @@
ReceiveScreen: ReceiveScreen:
id: receive_screen id: receive_screen
name: 'receive' name: 'receive'
mode: 'qr'
on_mode: if args[1] == 'nfc': from electrum_gui.kivy.nfc_scanner import NFCScanner
BoxLayout BoxLayout
padding: '12dp', '12dp', '12dp', '12dp' padding: '12dp', '12dp', '12dp', '12dp'
spacing: '12dp' spacing: '12dp'
mode: 'qr'
orientation: 'vertical' orientation: 'vertical'
size_hint: 1, 1
FloatLayout: FloatLayout:
id: bl id: bl
@ -31,14 +29,32 @@ ReceiveScreen:
GridLayout: GridLayout:
id: grid id: grid
cols: 1 cols: 2
Label:
text: 'Address'
size_hint: 0.5, None
height: '38dp'
AddressSelector:
id: address
size_hint: 0.5, None
height: '38dp'
Label:
text: 'Amount'
size_hint: 0.5, None
height: '38dp'
Button: Button:
text: 'Amount: None' id: amount
size_hint_y: None text: ''
size_hint: 0.5, None
height: '38dp'
on_release: app.amount_dialog(amount, receive_screen.parent.update_qr)
Label:
text: 'Description'
size_hint: 0.5, None
height: '48dp' height: '48dp'
on_release: receive_screen.set_amount_dialog() TextInput:
Button: text: ''
text: 'Message: None' on_text: receive_screen.parent.update_qr
size_hint_y: None multiline: False
height: '48dp' size_hint: 0.5, None
height: '38dp'

View File

@ -192,16 +192,6 @@ SendScreen:
on_text_validate: on_text_validate:
anim = Factory.Animation(opacity=1, height=blue_bottom.item_height) anim = Factory.Animation(opacity=1, height=blue_bottom.item_height)
anim.start(wallet_selection) anim.start(wallet_selection)
#anim.start(address_selection)
CardSeparator
opacity: address_selection.opacity
color: blue_bottom.foreground_color
AddressSelector:
id: address_selection
foreground_color: blue_bottom.foreground_color
opacity: 1
size_hint: 1, None
height: blue_bottom.item_height
Button: Button:
#background_color: (1, 1, 1, 1) if self.disabled else ((.258, .80, .388, 1) if self.state == 'normal' else (.203, .490, .741, 1)) #background_color: (1, 1, 1, 1) if self.disabled else ((.258, .80, .388, 1) if self.state == 'normal' else (.203, .490, .741, 1))
text: _('Send') text: _('Send')