From 929d9af94556b28571d84e9dff5d0f05e2a0d378 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Wed, 16 Nov 2022 18:26:40 +0530 Subject: [PATCH] Refactor mpybit and add msg_composer dropdown --- src/bitmessagekivy/kv/msg_composer.kv | 1 + src/bitmessagekivy/main.kv | 1 + src/bitmessagekivy/mpybit.py | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/bitmessagekivy/kv/msg_composer.kv b/src/bitmessagekivy/kv/msg_composer.kv index aeb7063a..e6b71f05 100644 --- a/src/bitmessagekivy/kv/msg_composer.kv +++ b/src/bitmessagekivy/kv/msg_composer.kv @@ -38,6 +38,7 @@ id: btn background_color: app.theme_cls.primary_dark values: app.identity_list + on_text: root.auto_fill_fromaddr() if self.text != 'Select' else '' option_cls: Factory.get("ComposerSpinnerOption") background_normal: '' background_color: app.theme_cls.primary_color diff --git a/src/bitmessagekivy/main.kv b/src/bitmessagekivy/main.kv index dd9eaf9b..06963eac 100644 --- a/src/bitmessagekivy/main.kv +++ b/src/bitmessagekivy/main.kv @@ -292,6 +292,7 @@ MDNavigationLayout: elevation_normal: 8 md_bg_color: [0.941, 0, 0,1] on_press: app.root.ids.scr_mngr.current = 'create' + on_press: app.clear_composer() : diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 4f0b363b..57df8395 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -309,6 +309,28 @@ class NavigateApp(MDApp): AppClosingPopup().open() return True + def clear_composer(self): + """If slow down, the new composer edit screen""" + self.set_navbar_for_composer() + composer_obj = self.root.ids.id_create.children[1].ids + composer_obj.ti.text = '' + composer_obj.composer_dropdown.text = 'Select' + composer_obj.txt_input.text = '' + composer_obj.subject.text = '' + composer_obj.body.text = '' + self.kivy_state_obj.in_composer = True + self.kivy_state_obj = False + + def set_navbar_for_composer(self): + """Clearing toolbar data when composer open""" + self.root.ids.toolbar.left_action_items = [ + ['arrow-left', lambda x: self.back_press()]] + self.root.ids.toolbar.right_action_items = [ + ['refresh', + lambda x: self.root.ids.id_create.children[1].reset_composer()], + ['send', + lambda x: self.root.ids.id_create.children[1].send(self)]] + def set_identicon(self, text): """Show identicon in address spinner""" img = identiconGeneration.generate(text)