Add set_screen() to set dynamic screen, created separate helper method for widget calling for addressbook
This commit is contained in:
parent
4b3f45ec5f
commit
b2fd30c338
|
@ -20,7 +20,7 @@ from bitmessagekivy.baseclass.common import (
|
||||||
ThemeClsColor, SwipeToDeleteItem
|
ThemeClsColor, SwipeToDeleteItem
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.popup import AddbookDetailPopup
|
from bitmessagekivy.baseclass.popup import AddbookDetailPopup
|
||||||
|
from bitmessagekivy.baseclass.addressbook_widgets import HelperAddressBook
|
||||||
|
|
||||||
class AddressBook(Screen):
|
class AddressBook(Screen):
|
||||||
"""AddressBook Screen class for kivy Ui"""
|
"""AddressBook Screen class for kivy Ui"""
|
||||||
|
@ -58,15 +58,26 @@ class AddressBook(Screen):
|
||||||
self.set_mdList(0, 20)
|
self.set_mdList(0, 20)
|
||||||
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
||||||
else:
|
else:
|
||||||
content = MDLabel(
|
# content = MDLabel(
|
||||||
font_style='Caption',
|
# font_style='Caption',
|
||||||
theme_text_color='Primary',
|
# theme_text_color='Primary',
|
||||||
text="No contact found!" if state.searcing_text
|
# text="No contact found!" if state.searcing_text
|
||||||
else "No contact found yet...... ",
|
# else "No contact found yet...... ",
|
||||||
halign='center',
|
# halign='center',
|
||||||
size_hint_y=None,
|
# size_hint_y=None,
|
||||||
valign='top')
|
# valign='top')
|
||||||
self.ids.ml.add_widget(content)
|
self.ids.ml.add_widget(HelperAddressBook.default_label_while_empty())
|
||||||
|
|
||||||
|
# def show_default_content(self):
|
||||||
|
# content = MDLabel(
|
||||||
|
# font_style='Caption',
|
||||||
|
# theme_text_color='Primary',
|
||||||
|
# text="No contact found!" if state.searcing_text
|
||||||
|
# else "No contact found yet...... ",
|
||||||
|
# halign='center',
|
||||||
|
# size_hint_y=None,
|
||||||
|
# valign='top')
|
||||||
|
# return content
|
||||||
|
|
||||||
def set_mdList(self, start_index, end_index):
|
def set_mdList(self, start_index, end_index):
|
||||||
"""Creating the mdList"""
|
"""Creating the mdList"""
|
||||||
|
@ -116,32 +127,34 @@ class AddressBook(Screen):
|
||||||
if instance.state == 'closed':
|
if instance.state == 'closed':
|
||||||
instance.ids.delete_msg.disabled = True
|
instance.ids.delete_msg.disabled = True
|
||||||
if instance.open_progress == 0.0:
|
if instance.open_progress == 0.0:
|
||||||
obj = AddbookDetailPopup()
|
HelperAddressBook.address_detail_popup(self, address, label, instance)
|
||||||
self.address_label = obj.address_label = label
|
# obj = AddbookDetailPopup()
|
||||||
self.address = obj.address = address
|
# self.address_label = obj.address_label = label
|
||||||
width = .9 if platform == 'android' else .8
|
# self.address = obj.address = address
|
||||||
self.addbook_popup = MDDialog(
|
# width = .9 if platform == 'android' else .8
|
||||||
type="custom",
|
# self.addbook_popup = MDDialog(
|
||||||
size_hint=(width, .25),
|
# type="custom",
|
||||||
content_cls=obj,
|
# size_hint=(width, .25),
|
||||||
buttons=[
|
# content_cls=obj,
|
||||||
MDRaisedButton(
|
# buttons=[
|
||||||
text="Send message to",
|
# MDRaisedButton(
|
||||||
on_release=self.send_message_to,
|
# text="Send message to",
|
||||||
),
|
# on_release=self.send_message_to,
|
||||||
MDRaisedButton(
|
# ),
|
||||||
text="Save",
|
# MDRaisedButton(
|
||||||
on_release=self.update_addbook_label,
|
# text="Save",
|
||||||
),
|
# on_release=self.update_addbook_label,
|
||||||
MDRaisedButton(
|
# ),
|
||||||
text="Cancel",
|
# MDRaisedButton(
|
||||||
on_release=self.close_pop,
|
# text="Cancel",
|
||||||
),
|
# on_release=self.close_pop,
|
||||||
],
|
# ),
|
||||||
)
|
# ],
|
||||||
# self.addbook_popup.set_normal_height()
|
# )
|
||||||
self.addbook_popup.auto_dismiss = False
|
# # self.addbook_popup.set_normal_height()
|
||||||
self.addbook_popup.open()
|
# self.addbook_popup = HelperAddressBook.address_detail_popup(self)
|
||||||
|
# self.addbook_popup.auto_dismiss = False
|
||||||
|
# self.addbook_popup.open()
|
||||||
else:
|
else:
|
||||||
instance.ids.delete_msg.disabled = False
|
instance.ids.delete_msg.disabled = False
|
||||||
|
|
||||||
|
|
48
src/bitmessagekivy/baseclass/addressbook_widgets.py
Normal file
48
src/bitmessagekivy/baseclass/addressbook_widgets.py
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
import state
|
||||||
|
|
||||||
|
from bitmessagekivy.get_platform import platform
|
||||||
|
|
||||||
|
from kivymd.uix.button import MDRaisedButton
|
||||||
|
from kivymd.uix.dialog import MDDialog
|
||||||
|
from kivymd.uix.label import MDLabel
|
||||||
|
|
||||||
|
from bitmessagekivy.baseclass.popup import AddbookDetailPopup
|
||||||
|
|
||||||
|
class HelperAddressBook:
|
||||||
|
def default_label_while_empty():
|
||||||
|
content = MDLabel(
|
||||||
|
font_style='Caption',
|
||||||
|
theme_text_color='Primary',
|
||||||
|
text="No contact found!" if state.searcing_text
|
||||||
|
else "No contact found yet...... ",
|
||||||
|
halign='center',
|
||||||
|
size_hint_y=None,
|
||||||
|
valign='top')
|
||||||
|
return content
|
||||||
|
|
||||||
|
def address_detail_popup(self, address, label, instance):
|
||||||
|
obj = AddbookDetailPopup()
|
||||||
|
self.address_label = obj.address_label = label
|
||||||
|
self.address = obj.address = address
|
||||||
|
width = .9 if platform == 'android' else .8
|
||||||
|
self.addbook_popup = MDDialog(
|
||||||
|
type="custom",
|
||||||
|
size_hint=(width, .25),
|
||||||
|
content_cls=obj,
|
||||||
|
buttons=[
|
||||||
|
MDRaisedButton(
|
||||||
|
text="Send message to",
|
||||||
|
on_release=self.send_message_to,
|
||||||
|
),
|
||||||
|
MDRaisedButton(
|
||||||
|
text="Save",
|
||||||
|
on_release=self.update_addbook_label,
|
||||||
|
),
|
||||||
|
MDRaisedButton(
|
||||||
|
text="Cancel",
|
||||||
|
on_release=self.close_pop,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
self.addbook_popup.auto_dismiss = False
|
||||||
|
self.addbook_popup.open()
|
|
@ -40,7 +40,7 @@
|
||||||
opposite_colors: True
|
opposite_colors: True
|
||||||
elevation_normal: 8
|
elevation_normal: 8
|
||||||
md_bg_color: [0.941, 0, 0,1]
|
md_bg_color: [0.941, 0, 0,1]
|
||||||
on_press: app.root.ids.scr_mngr.current = 'create'
|
on_press: app.root.set_screen('create')
|
||||||
on_press: app.clear_composer()
|
on_press: app.clear_composer()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,4 +25,4 @@
|
||||||
MDRaisedButton:
|
MDRaisedButton:
|
||||||
height: dp(38)
|
height: dp(38)
|
||||||
text: app.tr._("+Add more credits")
|
text: app.tr._("+Add more credits")
|
||||||
on_press: app.root.ids.scr_mngr.current = 'payment'
|
on_press: app.root.set_screen('payment')
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
icon: "chevron-double-right"
|
icon: "chevron-double-right"
|
||||||
text: app.tr._("Proceed Next")
|
text: app.tr._("Proceed Next")
|
||||||
on_release:
|
on_release:
|
||||||
app.root.ids.scr_mngr.current = 'random'
|
app.root.set_screen('random')
|
||||||
on_press:
|
on_press:
|
||||||
app.root.ids.sc7.reset_address_label()
|
app.root.ids.sc7.reset_address_label()
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
icon: 'qrcode-scan'
|
icon: 'qrcode-scan'
|
||||||
pos_hint: {'center_x': 0.95, 'y': 0.6}
|
pos_hint: {'center_x': 0.95, 'y': 0.6}
|
||||||
on_release:
|
on_release:
|
||||||
if root.is_camara_attached(): app.root.ids.scr_mngr.current = 'scanscreen'
|
if root.is_camara_attached(): app.root.set_screen('scanscreen')
|
||||||
else: root.camera_alert()
|
else: root.camera_alert()
|
||||||
on_press:
|
on_press:
|
||||||
app.root.ids.sc23.get_screen('composer')
|
app.root.ids.sc23.get_screen('composer')
|
||||||
|
|
|
@ -153,7 +153,7 @@
|
||||||
MDRaisedButton:
|
MDRaisedButton:
|
||||||
size_hint: 1.5, None
|
size_hint: 1.5, None
|
||||||
height: dp(40)
|
height: dp(40)
|
||||||
on_press: app.root.ids.scr_mngr.current = 'showqrcode'
|
on_press: app.set_screen('showqrcode')
|
||||||
on_press: app.root.ids.sc15.qrdisplay(root, root.address)
|
on_press: app.root.ids.sc15.qrdisplay(root, root.address)
|
||||||
MDLabel:
|
MDLabel:
|
||||||
font_style: 'H6'
|
font_style: 'H6'
|
||||||
|
|
|
@ -246,6 +246,9 @@ class NavigateApp(MDApp):
|
||||||
return Builder.load_file(
|
return Builder.load_file(
|
||||||
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
||||||
|
|
||||||
|
def set_screen(self, screen_name):
|
||||||
|
self.root.ids.scr_mngr.current = screen_name
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Running the widgets"""
|
"""Running the widgets"""
|
||||||
kivyuisignaler.release()
|
kivyuisignaler.release()
|
||||||
|
|
|
@ -310,7 +310,7 @@ class Main(object):
|
||||||
asyncoreThread = BMNetworkThread()
|
asyncoreThread = BMNetworkThread()
|
||||||
asyncoreThread.daemon = True
|
asyncoreThread.daemon = True
|
||||||
asyncoreThread.start()
|
asyncoreThread.start()
|
||||||
for i in range(config.safeGet('threads', 'receive')):
|
for i in range(config.safeGetInt('threads', 'receive')):
|
||||||
receiveQueueThread = ReceiveQueueThread(i)
|
receiveQueueThread = ReceiveQueueThread(i)
|
||||||
receiveQueueThread.daemon = True
|
receiveQueueThread.daemon = True
|
||||||
receiveQueueThread.start()
|
receiveQueueThread.start()
|
||||||
|
|
Reference in New Issue
Block a user