From 0ec38b43f833902ece948ac20f34300537beca00 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Thu, 17 Mar 2022 18:25:31 +0530 Subject: [PATCH] Created a UI independent function --- src/bitmessagekivy/baseclass/addressbook.py | 8 +------- .../baseclass/addressbook_widgets.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/bitmessagekivy/baseclass/addressbook.py b/src/bitmessagekivy/baseclass/addressbook.py index 6b289c43..98b1ef56 100644 --- a/src/bitmessagekivy/baseclass/addressbook.py +++ b/src/bitmessagekivy/baseclass/addressbook.py @@ -162,11 +162,5 @@ class AddressBook(Screen, HelperAddressBook): def send_message_to(self, instance): """Method used to fill to_address of composer autofield""" state.kivyapp.set_navbar_for_composer() - window_obj = state.kivyapp.root.ids - window_obj.sc3.children[1].ids.txt_input.text = self.address - window_obj.sc3.children[1].ids.ti.text = '' - window_obj.sc3.children[1].ids.btn.text = 'Select' - window_obj.sc3.children[1].ids.subject.text = '' - window_obj.sc3.children[1].ids.body.text = '' - window_obj.scr_mngr.current = 'create' + self.compose_message(None, self.address) self.addbook_popup.dismiss() diff --git a/src/bitmessagekivy/baseclass/addressbook_widgets.py b/src/bitmessagekivy/baseclass/addressbook_widgets.py index 3eb139e1..ed7e6196 100644 --- a/src/bitmessagekivy/baseclass/addressbook_widgets.py +++ b/src/bitmessagekivy/baseclass/addressbook_widgets.py @@ -50,3 +50,17 @@ class HelperAddressBook(object): ], ) return show_dialogue + + @staticmethod + def compose_message(from_addr=None, to_addr=None): + """This UI independent method for message sending to reciever""" + window_obj = state.kivyapp.root.ids + if to_addr: + window_obj.sc3.children[1].ids.txt_input.text = to_addr + if from_addr: + window_obj.sc3.children[1].ids.txt_input.text = from_addr + window_obj.sc3.children[1].ids.ti.text = '' + window_obj.sc3.children[1].ids.btn.text = 'Select' + window_obj.sc3.children[1].ids.subject.text = '' + window_obj.sc3.children[1].ids.body.text = '' + window_obj.scr_mngr.current = 'create'