Update NavigationApp helper module
This commit is contained in:
parent
885c7f5de5
commit
afb53f4d71
|
@ -1,5 +1,5 @@
|
||||||
# pylint: disable=no-name-in-module, too-few-public-methods, import-error, unused-argument
|
# 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
|
# pylint: disable=attribute-defined-outside-init, global-variable-not-assigned, unused-variable, too-many-ancestors
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Bitmessage android(mobile) interface
|
Bitmessage android(mobile) interface
|
||||||
|
@ -26,13 +26,21 @@ from kivy.core.window import Window
|
||||||
|
|
||||||
|
|
||||||
from kivymd.app import MDApp
|
from kivymd.app import MDApp
|
||||||
|
from kivymd.uix.label import MDLabel
|
||||||
from kivymd.uix.list import (
|
from kivymd.uix.list import (
|
||||||
OneLineAvatarIconListItem,
|
OneLineAvatarIconListItem,
|
||||||
OneLineListItem
|
IRightBodyTouch,
|
||||||
)
|
)
|
||||||
|
|
||||||
from kivymd.uix.bottomsheet import MDCustomBottomSheet
|
from kivymd.uix.bottomsheet import MDCustomBottomSheet
|
||||||
|
|
||||||
from pybitmessage.bitmessagekivy.kivy_state import KivyStateVariables
|
from pybitmessage.bitmessagekivy.kivy_state import KivyStateVariables
|
||||||
|
from pybitmessage.bitmessagekivy.base_navigation import (
|
||||||
|
BaseLanguage, BaseNavigationItem, BaseNavigationDrawerDivider,
|
||||||
|
BaseNavigationDrawerSubheader, BaseContentNavigationDrawer,
|
||||||
|
BaseCustomSpinner
|
||||||
|
)
|
||||||
|
|
||||||
from pybitmessage.bmconfigparser import config
|
from pybitmessage.bmconfigparser import config
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
@ -63,92 +71,39 @@ def get_identity_list():
|
||||||
)
|
)
|
||||||
return identity_list
|
return identity_list
|
||||||
|
|
||||||
|
class Lang(BaseLanguage):
|
||||||
class Lang(Observable):
|
|
||||||
"""UI Language"""
|
"""UI Language"""
|
||||||
|
|
||||||
observers = []
|
|
||||||
lang = None
|
|
||||||
|
|
||||||
def __init__(self, defaultlang):
|
class NavigationItem(BaseNavigationItem):
|
||||||
super(Lang, self).__init__()
|
"""NavigationItem class for kivy Ui"""
|
||||||
self.ugettext = None
|
|
||||||
self.lang = defaultlang
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _(text):
|
|
||||||
return text
|
|
||||||
|
|
||||||
|
|
||||||
class NavigationItem(OneLineAvatarIconListItem):
|
class NavigationDrawerDivider(BaseNavigationDrawerDivider):
|
||||||
"""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):
|
|
||||||
"""
|
"""
|
||||||
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):
|
class NavigationDrawerSubheader(BaseNavigationDrawerSubheader):
|
||||||
# pylint: disable=bad-super-call
|
|
||||||
super(OneLineListItem, self).__init__(**kwargs)
|
|
||||||
self.height = dp(16)
|
|
||||||
|
|
||||||
|
|
||||||
class NavigationDrawerSubheader(OneLineListItem):
|
|
||||||
"""
|
"""
|
||||||
A subheader for separating content in :class:`MDNavigationDrawer`
|
A subheader for separating content in :class:`MDNavigationDrawer`
|
||||||
|
|
||||||
Works well alongside :class:`NavigationDrawerDivider`
|
Works well alongside :class:`NavigationDrawerDivider`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
disabled = True
|
|
||||||
divider = None
|
class ContentNavigationDrawer(BaseContentNavigationDrawer):
|
||||||
theme_text_color = 'Secondary'
|
"""ContentNavigationDrawer class for kivy Uir"""
|
||||||
|
|
||||||
|
|
||||||
class ContentNavigationDrawer(BoxLayout):
|
class BadgeText(IRightBodyTouch, MDLabel):
|
||||||
"""Helper for Side navigation bar which contains screen names"""
|
"""BadgeText class for kivy Ui"""
|
||||||
|
|
||||||
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 CustomSpinner(Spinner):
|
class CustomSpinner(BaseCustomSpinner):
|
||||||
"""
|
"""CustomSpinner class for kivy Ui"""
|
||||||
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 NavigateApp(MDApp):
|
class NavigateApp(MDApp):
|
||||||
|
|
Reference in New Issue
Block a user