From e8805ce19c834f8f5d46f9bb12c8a4bdcf8f19a5 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Wed, 30 Mar 2022 18:35:15 +0530 Subject: [PATCH] Constant for empty screen label --- src/bitmessagekivy/baseclass/addressbook.py | 6 +++-- .../baseclass/addressbook_widgets.py | 25 ++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/bitmessagekivy/baseclass/addressbook.py b/src/bitmessagekivy/baseclass/addressbook.py index b0ec16af..7fcff0f6 100644 --- a/src/bitmessagekivy/baseclass/addressbook.py +++ b/src/bitmessagekivy/baseclass/addressbook.py @@ -13,6 +13,7 @@ from kivymd.uix.label import MDLabel from kivy.uix.screenmanager import Screen import state +import os from debug import logger from bitmessagekivy.baseclass.common import ( @@ -83,8 +84,9 @@ class AddressBook(Screen, HelperAddressBook): # listItem.add_widget(AvatarSampleWidget( # source=state.imageDir + '/text_images/{}.png'.format( # avatarImageFirstLetter(item[0].strip())))) - image = state.imageDir + "/text_images/{}.png".format( - avatarImageFirstLetter(item[0].strip())) + image = os.path.join( + state.imageDir, "text_images", "{}.png".format(avatarImageFirstLetter(item[0].strip())) + ) message_row.ids.avater_img.source = image listItem.bind(on_release=partial( self.addBook_detail, item[1], item[0], message_row)) diff --git a/src/bitmessagekivy/baseclass/addressbook_widgets.py b/src/bitmessagekivy/baseclass/addressbook_widgets.py index fac856b0..3b5560d1 100644 --- a/src/bitmessagekivy/baseclass/addressbook_widgets.py +++ b/src/bitmessagekivy/baseclass/addressbook_widgets.py @@ -8,19 +8,26 @@ from kivymd.uix.label import MDLabel from bitmessagekivy.baseclass.popup import AddbookDetailPopup +no_address_found = "No contact found yet...??..." +empty_search_label = "No contact found!??" -class HelperAddressBook(object): - """Widget used in Addressbook are here""" + + +class DefaultLabelMixin(object): @staticmethod def default_label_when_empty(): - content = MDLabel( - font_style='Caption', - theme_text_color='Primary', - # TODO: searcing_text(typo) need to create a kivy_state.py and add kivy related variables - text="No contact found!" if state.searcing_text - else "No contact found yet...... ", halign='center', size_hint_y=None, valign='top') - return content + content = MDLabel( + font_style='Caption', + theme_text_color='Primary', + # TODO: searcing_text(typo) need to create a kivy_state.py and add kivy related variables + text=empty_search_label if state.searcing_text else no_address_found, + halign='center', size_hint_y=None, valign='top') + return content + + +class HelperAddressBook(DefaultLabelMixin): + """Widget used in Addressbook are here""" @staticmethod def address_detail_popup(obj, send_message, update_address, close_popup, width):