Created a common method for empty screen label

This commit is contained in:
shekhar-cis 2022-04-22 12:26:55 +05:30
parent d195784554
commit 69961335bf
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7
2 changed files with 5 additions and 23 deletions

View File

@ -26,7 +26,7 @@ import state
from bitmessagekivy.get_platform import platform
from bitmessagekivy import kivy_helper_search
from bitmessagekivy.baseclass.common import (
avatarImageFirstLetter, toast,
avatarImageFirstLetter, toast, empty_screen_label,
ThemeClsColor, SwipeToDeleteItem
)
from bitmessagekivy.baseclass.popup import AddbookDetailPopup
@ -42,6 +42,8 @@ class AddressBook(Screen, HelperAddressBook):
has_refreshed = True
address_label = StringProperty()
address = StringProperty()
label_str = "No contact Address found yet......"
no_search_res_found = "No search result found"
def __init__(self, *args, **kwargs):
"""Getting AddressBook Details"""
@ -71,7 +73,7 @@ class AddressBook(Screen, HelperAddressBook):
self.set_mdList(0, 20)
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
else:
self.ids.ml.add_widget(self.default_label_when_empty())
self.ids.ml.add_widget(empty_screen_label(self.label_str, self.no_search_res_found))
def set_mdList(self, start_index, end_index):
"""Creating the mdList"""

View File

@ -6,31 +6,11 @@ Addressbook widgets are here.
from kivymd.uix.button import MDRaisedButton
from kivymd.uix.dialog import MDDialog
from kivymd.uix.label import MDLabel
import state
no_address_found = "No contact found yet......"
empty_search_label = "No contact found!"
# pylint: disable=no-init, old-style-class
class DefaultLabelMixin:
"""Common label on blank screen"""
@staticmethod
def default_label_when_empty():
"""This function returns default message while no address is there."""
content = MDLabel(
font_style='Caption',
theme_text_color='Primary',
# FIXME: searching_text supposed to be inside kivy_sate.py, typo and need to create a PR for kivy_state.py
text=empty_search_label if state.searching_text else no_address_found,
halign='center', size_hint_y=None, valign='top')
return content
class HelperAddressBook(DefaultLabelMixin):
class HelperAddressBook(object):
"""Widget used in Addressbook are here"""
@staticmethod