diff --git a/src/bitmessagekivy/baseclass/inbox.py b/src/bitmessagekivy/baseclass/inbox.py new file mode 100644 index 00000000..11b60e3e --- /dev/null +++ b/src/bitmessagekivy/baseclass/inbox.py @@ -0,0 +1,58 @@ +# pylint: disable=unused-import, too-many-public-methods, unused-variable, too-many-ancestors +# pylint: disable=no-name-in-module, too-few-public-methods, import-error, unused-argument, too-many-arguments +# pylint: disable=attribute-defined-outside-init, global-variable-not-assigned, too-many-instance-attributes + +""" +Kivy UI for inbox screen +""" +from kivy.clock import Clock +from kivy.properties import ( + ListProperty, + StringProperty +) +from kivy.app import App +from kivy.uix.screenmanager import Screen + +from pybitmessage.bitmessagekivy.baseclass.common import kivy_state_variables, load_image_path + + +class Inbox(Screen): + """Inbox Screen class for kivy Ui""" + + queryreturn = ListProperty() + has_refreshed = True + account = StringProperty() + no_search_res_found = "No search result found" + label_str = "Yet no message for this account!" + + def __init__(self, *args, **kwargs): + """Initialize kivy variables""" + super(Inbox, self).__init__(*args, **kwargs) + self.kivy_running_app = App.get_running_app() + self.kivy_state = kivy_state_variables() + self.image_dir = load_image_path() + Clock.schedule_once(self.init_ui, 0) + + def set_defaultAddress(self): + """Set default address""" + if self.kivy_state.association == "": + if self.kivy_running_app.identity_list: + self.kivy_state.association = self.kivy_running_app.identity_list[0] + + def init_ui(self, dt=0): + """loadMessagelist() call at specific interval""" + + def refresh_callback(self, *args): + """Load inbox messages while wating-loader spins & called in inbox.kv""" + + def refresh_on_scroll_down(interval): + """Reset fields and load data on scrolling upside down""" + self.kivy_state.searching_text = "" + self.children[2].children[1].ids.search_field.text = "" + self.ids.ml.clear_widgets() + self.loadMessagelist(self.kivy_state.association) + self.has_refreshed = True + self.ids.refresh_layout.refresh_done() + self.tick = 0 + + Clock.schedule_once(refresh_on_scroll_down, 1) diff --git a/src/bitmessagekivy/baseclass/maildetail.py b/src/bitmessagekivy/baseclass/maildetail.py index 34a62a70..e98f8206 100644 --- a/src/bitmessagekivy/baseclass/maildetail.py +++ b/src/bitmessagekivy/baseclass/maildetail.py @@ -154,7 +154,7 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes self.parent.screens[2].ids.ml.clear_widgets() self.parent.screens[2].loadSent(self.kivy_state.association) elif self.kivy_state.detail_page_type == 'inbox': - App.get_running_app().root.ids.sc1.ids.inbox_search.ids.search_field.text = '' + App.get_running_app().root.ids.id_inbox.ids.inbox_search.ids.search_field.text = '' trash(self.kivy_state.mail_id) msg_count_objs.inbox_cnt.ids.badge_txt.text = str( int(self.kivy_state.inbox_count) - 1) diff --git a/src/bitmessagekivy/main.kv b/src/bitmessagekivy/main.kv index 4f5de8cf..f23a03e1 100644 --- a/src/bitmessagekivy/main.kv +++ b/src/bitmessagekivy/main.kv @@ -220,6 +220,8 @@ MDNavigationLayout: id:id_payment Create: id:id_create + Inbox: + id:id_inbox MDNavigationDrawer: id: nav_drawer diff --git a/src/bitmessagekivy/screens_data.json b/src/bitmessagekivy/screens_data.json index 81a3ce70..709851d1 100644 --- a/src/bitmessagekivy/screens_data.json +++ b/src/bitmessagekivy/screens_data.json @@ -1,4 +1,9 @@ { + "Inbox": { + "kv_string": "inbox", + "name_screen": "inbox", + "Import": "from pybitmessage.bitmessagekivy.baseclass.inbox import Inbox" + }, "Login": { "kv_string": "login", "Import": "from pybitmessage.bitmessagekivy.baseclass.login import *"