Update NavigationApp helper module

This commit is contained in:
shekhar-cis 2022-08-19 21:43:41 +05:30
parent 885c7f5de5
commit afb53f4d71
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7

View File

@ -1,5 +1,5 @@
# pylint: disable=no-name-in-module, too-few-public-methods, import-error, unused-argument
# pylint: disable=attribute-defined-outside-init, global-variable-not-assigned, unused-variable
# pylint: disable=no-name-in-module, too-few-public-methods, import-error, unused-argument, unused-import
# pylint: disable=attribute-defined-outside-init, global-variable-not-assigned, unused-variable, too-many-ancestors
"""
Bitmessage android(mobile) interface
@ -26,13 +26,21 @@ from kivy.core.window import Window
from kivymd.app import MDApp
from kivymd.uix.label import MDLabel
from kivymd.uix.list import (
OneLineAvatarIconListItem,
OneLineListItem
IRightBodyTouch,
)
from kivymd.uix.bottomsheet import MDCustomBottomSheet
from pybitmessage.bitmessagekivy.kivy_state import KivyStateVariables
from pybitmessage.bitmessagekivy.base_navigation import (
BaseLanguage, BaseNavigationItem, BaseNavigationDrawerDivider,
BaseNavigationDrawerSubheader, BaseContentNavigationDrawer,
BaseCustomSpinner
)
from pybitmessage.bmconfigparser import config
logger = logging.getLogger('default')
@ -63,92 +71,39 @@ def get_identity_list():
)
return identity_list
class Lang(Observable):
class Lang(BaseLanguage):
"""UI Language"""
observers = []
lang = None
def __init__(self, defaultlang):
super(Lang, self).__init__()
self.ugettext = None
self.lang = defaultlang
@staticmethod
def _(text):
return text
class NavigationItem(BaseNavigationItem):
"""NavigationItem class for kivy Ui"""
class NavigationItem(OneLineAvatarIconListItem):
"""UI for NavigationItem class on Side Navigation bar"""
badge_text = StringProperty()
icon = StringProperty()
active = BooleanProperty(False)
def currentlyActive(self):
"""Currenly active"""
for nav_obj in self.parent.children:
nav_obj.active = False
self.active = True
class NavigationDrawerDivider(OneLineListItem):
class NavigationDrawerDivider(BaseNavigationDrawerDivider):
"""
A small full-width divider line for Side Navigation bar
A small full-width divider that can be placed
in the :class:`MDNavigationDrawer`
"""
disabled = True
divider = None
_txt_top_pad = NumericProperty(dp(8))
_txt_bot_pad = NumericProperty(dp(8))
def __init__(self, **kwargs):
# pylint: disable=bad-super-call
super(OneLineListItem, self).__init__(**kwargs)
self.height = dp(16)
class NavigationDrawerSubheader(OneLineListItem):
class NavigationDrawerSubheader(BaseNavigationDrawerSubheader):
"""
A subheader for separating content in :class:`MDNavigationDrawer`
Works well alongside :class:`NavigationDrawerDivider`
"""
disabled = True
divider = None
theme_text_color = 'Secondary'
class ContentNavigationDrawer(BaseContentNavigationDrawer):
"""ContentNavigationDrawer class for kivy Uir"""
class ContentNavigationDrawer(BoxLayout):
"""Helper for Side navigation bar which contains screen names"""
def __init__(self, *args, **kwargs):
"""Method used for to initialize side navbar"""
super(ContentNavigationDrawer, self).__init__(*args, **kwargs)
Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0):
"""Clock Schdule for class contentNavigationDrawer"""
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
def check_scroll_y(self, instance, somethingelse):
"""show data on scroll down"""
if self.ids.identity_dropdown.is_open:
self.ids.identity_dropdown.is_open = False
class BadgeText(IRightBodyTouch, MDLabel):
"""BadgeText class for kivy Ui"""
class CustomSpinner(Spinner):
"""
A Dropdown on side navigation bar which hold the identity and can switch to other identity
"""
def __init__(self, *args, **kwargs):
"""Method used for setting size of spinner"""
super(CustomSpinner, self).__init__(*args, **kwargs)
self.dropdown_cls.max_height = Window.size[1] / 3
self.values = list(addr for addr in config.addresses()
if config.getboolean(str(addr), 'enabled'))
class CustomSpinner(BaseCustomSpinner):
"""CustomSpinner class for kivy Ui"""
class NavigateApp(MDApp):