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
|
||||
)
|
||||
from bitmessagekivy.baseclass.popup import AddbookDetailPopup
|
||||
|
||||
from bitmessagekivy.baseclass.addressbook_widgets import HelperAddressBook
|
||||
|
||||
class AddressBook(Screen):
|
||||
"""AddressBook Screen class for kivy Ui"""
|
||||
|
@ -58,15 +58,26 @@ class AddressBook(Screen):
|
|||
self.set_mdList(0, 20)
|
||||
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
||||
else:
|
||||
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')
|
||||
self.ids.ml.add_widget(content)
|
||||
# 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')
|
||||
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):
|
||||
"""Creating the mdList"""
|
||||
|
@ -116,32 +127,34 @@ class AddressBook(Screen):
|
|||
if instance.state == 'closed':
|
||||
instance.ids.delete_msg.disabled = True
|
||||
if instance.open_progress == 0.0:
|
||||
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.set_normal_height()
|
||||
self.addbook_popup.auto_dismiss = False
|
||||
self.addbook_popup.open()
|
||||
HelperAddressBook.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.set_normal_height()
|
||||
# self.addbook_popup = HelperAddressBook.address_detail_popup(self)
|
||||
# self.addbook_popup.auto_dismiss = False
|
||||
# self.addbook_popup.open()
|
||||
else:
|
||||
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
|
||||
elevation_normal: 8
|
||||
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()
|
||||
|
||||
|
||||
|
|
|
@ -25,4 +25,4 @@
|
|||
MDRaisedButton:
|
||||
height: dp(38)
|
||||
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"
|
||||
text: app.tr._("Proceed Next")
|
||||
on_release:
|
||||
app.root.ids.scr_mngr.current = 'random'
|
||||
app.root.set_screen('random')
|
||||
on_press:
|
||||
app.root.ids.sc7.reset_address_label()
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
icon: 'qrcode-scan'
|
||||
pos_hint: {'center_x': 0.95, 'y': 0.6}
|
||||
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()
|
||||
on_press:
|
||||
app.root.ids.sc23.get_screen('composer')
|
||||
|
|
|
@ -153,7 +153,7 @@
|
|||
MDRaisedButton:
|
||||
size_hint: 1.5, None
|
||||
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)
|
||||
MDLabel:
|
||||
font_style: 'H6'
|
||||
|
|
|
@ -246,6 +246,9 @@ class NavigateApp(MDApp):
|
|||
return Builder.load_file(
|
||||
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):
|
||||
"""Running the widgets"""
|
||||
kivyuisignaler.release()
|
||||
|
|
|
@ -310,7 +310,7 @@ class Main(object):
|
|||
asyncoreThread = BMNetworkThread()
|
||||
asyncoreThread.daemon = True
|
||||
asyncoreThread.start()
|
||||
for i in range(config.safeGet('threads', 'receive')):
|
||||
for i in range(config.safeGetInt('threads', 'receive')):
|
||||
receiveQueueThread = ReceiveQueueThread(i)
|
||||
receiveQueueThread.daemon = True
|
||||
receiveQueueThread.start()
|
||||
|
|
Reference in New Issue
Block a user