working condition
This commit is contained in:
parent
417e54da96
commit
511e0b0379
517 changed files with 29187 additions and 32696 deletions
Binary file not shown.
Binary file not shown.
|
@ -1,5 +1,4 @@
|
|||
#:import ScrollEffect kivy.effects.scroll.ScrollEffect
|
||||
#:import get_color_from_hex kivy.utils.get_color_from_hex
|
||||
|
||||
|
||||
<MDSliverAppbar>
|
||||
|
@ -13,7 +12,7 @@
|
|||
rgba:
|
||||
root.background_color \
|
||||
if root.background_color else \
|
||||
root.theme_cls.primary_color
|
||||
root.theme_cls.primaryColor
|
||||
a: root._opacity
|
||||
Rectangle:
|
||||
pos: self.pos
|
||||
|
@ -31,11 +30,20 @@
|
|||
on_scroll_start:
|
||||
if not root._scroll_was_moving: root._scroll_was_moving = True
|
||||
|
||||
MDBoxLayout:
|
||||
BoxLayout:
|
||||
id: scroll_box
|
||||
adaptive_height: True
|
||||
orientation: "vertical"
|
||||
size_hint_y: None
|
||||
height: self.minimum_height
|
||||
|
||||
BoxLayout:
|
||||
size_hint_y: None
|
||||
height: root.max_height
|
||||
|
||||
|
||||
<MDSliverAppbarContent>
|
||||
adaptive_height: True
|
||||
md_bg_color:
|
||||
self.theme_cls.surfaceColor \
|
||||
if self.theme_bg_color == "Primary" else \
|
||||
self.md_bg_color
|
||||
|
|
|
@ -6,7 +6,10 @@ Components/SliverAppbar
|
|||
|
||||
.. rubric:: MDSliverAppbar is a Material Design widget in KivyMD which gives
|
||||
scrollable or collapsible
|
||||
`MDTopAppBar <https://kivymd.readthedocs.io/en/latest/components/toolbar/>`_
|
||||
`MDTopAppBar <https://kivymd.readthedocs.io/en/latest/components/appbar/>`_
|
||||
|
||||
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/sliver-appbar-preview.gif
|
||||
:align: center
|
||||
|
||||
.. note:: This widget is a modification of the
|
||||
`silverappbar.py <https://github.com/kivymd-extensions/akivymd/blob/main/kivymd_extensions/akivymd/uix/silverappbar.py>`_ module.
|
||||
|
@ -20,15 +23,21 @@ Usage
|
|||
|
||||
MDSliverAppbar:
|
||||
|
||||
MDTopAppBar:
|
||||
[...]
|
||||
|
||||
MDSliverAppbarHeader:
|
||||
|
||||
# Custom content.
|
||||
...
|
||||
[...]
|
||||
|
||||
# Custom list.
|
||||
MDSliverAppbarContent:
|
||||
|
||||
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/sliver-app-bar-usage.png
|
||||
Anatomy
|
||||
-------
|
||||
|
||||
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/sliver-appbar-anatomy.png
|
||||
:align: center
|
||||
|
||||
Example
|
||||
|
@ -39,84 +48,139 @@ Example
|
|||
from kivy.lang.builder import Builder
|
||||
|
||||
from kivymd.app import MDApp
|
||||
from kivymd.uix.card import MDCard
|
||||
from kivymd.uix.list import MDListItem
|
||||
|
||||
KV = '''
|
||||
<CardItem>
|
||||
size_hint_y: None
|
||||
height: "86dp"
|
||||
padding: "4dp"
|
||||
radius: 12
|
||||
<GuitarItem>
|
||||
theme_bg_color: "Custom"
|
||||
md_bg_color: "2d4a50"
|
||||
|
||||
FitImage:
|
||||
source: "avatar.jpg"
|
||||
radius: root.radius
|
||||
size_hint_x: None
|
||||
width: root.height
|
||||
MDListItemLeadingAvatar
|
||||
source: "avatar.png"
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "vertical"
|
||||
adaptive_height: True
|
||||
spacing: "6dp"
|
||||
padding: "12dp", 0, 0, 0
|
||||
pos_hint: {"center_y": .5}
|
||||
MDListItemHeadlineText:
|
||||
text: "Ibanez"
|
||||
|
||||
MDLabel:
|
||||
text: "Title text"
|
||||
font_style: "H5"
|
||||
bold: True
|
||||
adaptive_height: True
|
||||
MDListItemSupportingText:
|
||||
text: "GRG121DX-BKF"
|
||||
|
||||
MDLabel:
|
||||
text: "Subtitle text"
|
||||
theme_text_color: "Hint"
|
||||
adaptive_height: True
|
||||
MDListItemTertiaryText:
|
||||
text: "$445,99"
|
||||
|
||||
MDListItemTrailingIcon:
|
||||
icon: "guitar-electric"
|
||||
|
||||
|
||||
MDScreen:
|
||||
|
||||
MDSliverAppbar:
|
||||
background_color: "2d4a50"
|
||||
hide_appbar: True
|
||||
|
||||
MDTopAppBar:
|
||||
type: "medium"
|
||||
|
||||
MDTopAppBarLeadingButtonContainer:
|
||||
|
||||
MDActionTopAppBarButton:
|
||||
icon: "arrow-left"
|
||||
|
||||
MDTopAppBarTitle:
|
||||
text: "Sliver toolbar"
|
||||
|
||||
MDTopAppBarTrailingButtonContainer:
|
||||
|
||||
MDActionTopAppBarButton:
|
||||
icon: "attachment"
|
||||
|
||||
MDActionTopAppBarButton:
|
||||
icon: "calendar"
|
||||
|
||||
MDActionTopAppBarButton:
|
||||
icon: "dots-vertical"
|
||||
|
||||
MDSliverAppbarHeader:
|
||||
|
||||
MDRelativeLayout:
|
||||
|
||||
FitImage:
|
||||
source: "bg.jpg"
|
||||
FitImage:
|
||||
source: "bg.jpg"
|
||||
|
||||
MDSliverAppbarContent:
|
||||
id: content
|
||||
orientation: "vertical"
|
||||
padding: "12dp"
|
||||
spacing: "12dp"
|
||||
adaptive_height: True
|
||||
theme_bg_color: "Custom"
|
||||
md_bg_color: "2d4a50"
|
||||
'''
|
||||
|
||||
|
||||
class CardItem(MDCard):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.elevation = 1
|
||||
class GuitarItem(MDListItem):
|
||||
...
|
||||
|
||||
|
||||
class Example(MDApp):
|
||||
def build(self):
|
||||
self.theme_cls.theme_style = "Dark"
|
||||
return Builder.load_string(KV)
|
||||
|
||||
def on_start(self):
|
||||
for x in range(10):
|
||||
self.root.ids.content.add_widget(CardItem())
|
||||
self.root.ids.content.add_widget(GuitarItem())
|
||||
|
||||
|
||||
Example().run()
|
||||
|
||||
API break
|
||||
=========
|
||||
|
||||
1.2.0 version
|
||||
-------------
|
||||
|
||||
.. code-block:: kv
|
||||
|
||||
#:import SliverToolbar __main__.SliverToolbar
|
||||
|
||||
Root:
|
||||
|
||||
MDSliverAppbar:
|
||||
[...]
|
||||
|
||||
MDSliverAppbarHeader:
|
||||
|
||||
[...]
|
||||
|
||||
MDSliverAppbarContent:
|
||||
[...]
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class SliverToolbar(MDTopAppBar):
|
||||
[...]
|
||||
|
||||
2.0.0 version
|
||||
-------------
|
||||
|
||||
.. code-block:: kv
|
||||
|
||||
Root:
|
||||
|
||||
MDSliverAppbar:
|
||||
[...]
|
||||
|
||||
MDTopAppBar:
|
||||
[...]
|
||||
|
||||
MDSliverAppbarHeader:
|
||||
|
||||
[...]
|
||||
|
||||
MDSliverAppbarContent:
|
||||
[...]
|
||||
"""
|
||||
|
||||
|
||||
__all__ = ("MDSliverAppbar", "MDSliverAppbarHeader", "MDSliverAppbarContent")
|
||||
|
||||
import os
|
||||
from typing import Union
|
||||
|
||||
from kivy.clock import Clock
|
||||
from kivy.core.window import Window
|
||||
|
@ -125,13 +189,15 @@ from kivy.properties import (
|
|||
BooleanProperty,
|
||||
ColorProperty,
|
||||
NumericProperty,
|
||||
ObjectProperty,
|
||||
VariableListProperty,
|
||||
ObjectProperty,
|
||||
)
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
|
||||
from kivymd import uix_path
|
||||
from kivymd.theming import ThemableBehavior
|
||||
from kivymd.uix.boxlayout import MDBoxLayout
|
||||
from kivymd.uix.toolbar import MDTopAppBar
|
||||
from kivymd.uix.appbar import MDTopAppBar
|
||||
|
||||
with open(
|
||||
os.path.join(uix_path, "sliverappbar", "sliverappbar.kv"), encoding="utf-8"
|
||||
|
@ -151,167 +217,33 @@ class MDSliverAppbarContent(MDBoxLayout):
|
|||
:class:`~kivymd.uix.boxlayout.MDBoxLayout` class documentation.
|
||||
"""
|
||||
|
||||
md_bg_color = ColorProperty([0, 0, 0, 0])
|
||||
"""
|
||||
See :attr:`~kivymd.uix.sliverappbar.sliverappbar.MDSliverAppbar.background_color`.
|
||||
|
||||
:attr:`md_bg_color` is an :class:`~kivy.properties.ColorProperty`
|
||||
and defaults to `[0, 0, 0, 0]`.
|
||||
"""
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
Clock.schedule_once(self.set_bg_color)
|
||||
|
||||
def set_bg_color(self, interval: Union[int, float]) -> None:
|
||||
if self.md_bg_color == [0, 0, 0, 0]:
|
||||
self.md_bg_color = self.theme_cls.bg_normal
|
||||
|
||||
|
||||
class MDSliverAppbarHeader(MDBoxLayout):
|
||||
class MDSliverAppbarHeader(BoxLayout):
|
||||
"""
|
||||
Sliver app bar header class.
|
||||
|
||||
For more information, see in the
|
||||
:class:`~kivymd.uix.boxlayout.MDBoxLayout` class documentation.
|
||||
:class:`~kivy.uix.boxlayout.BoxLayout` class documentation.
|
||||
"""
|
||||
|
||||
|
||||
class MDSliverAppbar(MDBoxLayout):
|
||||
class MDSliverAppbar(ThemableBehavior, BoxLayout):
|
||||
"""
|
||||
Sliver app bar class.
|
||||
Sliver appbar class.
|
||||
|
||||
For more information, see in the
|
||||
:class:`~kivymd.uix.boxlayout.MDBoxLayout` class documentation.
|
||||
:class:`~kivymd.theming.ThemableBehavior` and
|
||||
:class:`~kivy.uix.boxlayout.BoxLayout`
|
||||
classes documentation.
|
||||
|
||||
:Events:
|
||||
:attr:`on_scroll_content`
|
||||
Called when the list of custom content is being scrolled.
|
||||
"""
|
||||
|
||||
toolbar_cls = ObjectProperty()
|
||||
"""
|
||||
Must be an object of the :class:`~kivymd.uix.toolbar.toolbar.MDTopAppBar' class.
|
||||
See :class:`~kivymd.uix.toolbar.toolbar.MDTopAppBar` class documentation
|
||||
for more information.
|
||||
|
||||
By default, MDSliverAppbar widget uses the MDTopAppBar class with no
|
||||
parameters.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from kivy.lang.builder import Builder
|
||||
|
||||
from kivymd.uix.card import MDCard
|
||||
from kivymd.uix.toolbar import MDTopAppBar
|
||||
|
||||
KV = '''
|
||||
#:import SliverToolbar __main__.SliverToolbar
|
||||
|
||||
|
||||
<CardItem>
|
||||
size_hint_y: None
|
||||
height: "86dp"
|
||||
padding: "4dp"
|
||||
radius: 12
|
||||
|
||||
FitImage:
|
||||
source: "avatar.jpg"
|
||||
radius: root.radius
|
||||
size_hint_x: None
|
||||
width: root.height
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "vertical"
|
||||
adaptive_height: True
|
||||
spacing: "6dp"
|
||||
padding: "12dp", 0, 0, 0
|
||||
pos_hint: {"center_y": .5}
|
||||
|
||||
MDLabel:
|
||||
text: "Title text"
|
||||
font_style: "H5"
|
||||
bold: True
|
||||
adaptive_height: True
|
||||
|
||||
MDLabel:
|
||||
text: "Subtitle text"
|
||||
theme_text_color: "Hint"
|
||||
adaptive_height: True
|
||||
|
||||
|
||||
MDScreen:
|
||||
|
||||
MDSliverAppbar:
|
||||
background_color: "2d4a50"
|
||||
toolbar_cls: SliverToolbar()
|
||||
|
||||
MDSliverAppbarHeader:
|
||||
|
||||
MDRelativeLayout:
|
||||
|
||||
FitImage:
|
||||
source: "bg.jpg"
|
||||
|
||||
MDSliverAppbarContent:
|
||||
id: content
|
||||
orientation: "vertical"
|
||||
padding: "12dp"
|
||||
spacing: "12dp"
|
||||
adaptive_height: True
|
||||
'''
|
||||
|
||||
|
||||
class CardItem(MDCard):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.elevation = 1
|
||||
|
||||
|
||||
class SliverToolbar(MDTopAppBar):
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.shadow_color = (0, 0, 0, 0)
|
||||
self.type_height = "medium"
|
||||
self.headline_text = "Headline medium"
|
||||
self.left_action_items = [["arrow-left", lambda x: x]]
|
||||
self.right_action_items = [
|
||||
["attachment", lambda x: x],
|
||||
["calendar", lambda x: x],
|
||||
["dots-vertical", lambda x: x],
|
||||
]
|
||||
|
||||
|
||||
class Example(MDApp):
|
||||
def build(self):
|
||||
self.theme_cls.material_style = "M3"
|
||||
return Builder.load_string(KV)
|
||||
|
||||
def on_start(self):
|
||||
for x in range(10):
|
||||
self.root.ids.content.add_widget(CardItem())
|
||||
|
||||
|
||||
Example().run()
|
||||
|
||||
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/sliver-app-bar-toolbar-cls.gif
|
||||
:align: center
|
||||
|
||||
:attr:`toolbar_cls` is an :class:`~kivy.properties.ObjectProperty`
|
||||
and defaults to `None`.
|
||||
Fired when the list of custom content is being scrolled.
|
||||
"""
|
||||
|
||||
background_color = ColorProperty(None)
|
||||
"""
|
||||
Background color of toolbar in (r, g, b, a) or string format.
|
||||
|
||||
.. code-block:: kv
|
||||
|
||||
MDSliverAppbar:
|
||||
background_color: "2d4a50"
|
||||
|
||||
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/sliver-app-bar-background-color.png
|
||||
:align: center
|
||||
Background color of appbar in (r, g, b, a) or string format.
|
||||
|
||||
:attr:`background_color` is an :class:`~kivy.properties.ColorProperty`
|
||||
and defaults to `None`.
|
||||
|
@ -326,34 +258,40 @@ class MDSliverAppbar(MDBoxLayout):
|
|||
MDSliverAppbar:
|
||||
max_height: "200dp"
|
||||
|
||||
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/sliver-app-bar-max-height.png
|
||||
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/sliver-appbar-max-height.png
|
||||
:align: center
|
||||
|
||||
:attr:`max_height` is an :class:`~kivy.properties.NumericProperty`
|
||||
and defaults to `Window.height / 2`.
|
||||
"""
|
||||
|
||||
hide_toolbar = BooleanProperty(True)
|
||||
hide_appbar = BooleanProperty(None)
|
||||
"""
|
||||
Whether to hide the toolbar when scrolling through a list
|
||||
Whether to hide the appbar when scrolling through a list
|
||||
of custom content.
|
||||
|
||||
.. versionchanged:: 2.0.0
|
||||
|
||||
Rename `hide_toolbar` to `hide_appbar` attribute.
|
||||
|
||||
.. code-block:: kv
|
||||
|
||||
MDSliverAppbar:
|
||||
hide_toolbar: False
|
||||
hide_appbar: False
|
||||
|
||||
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/sliver-app-bar-hide-toolbar.gif
|
||||
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/sliver-appbar-hide-appbar-false.gif
|
||||
:align: center
|
||||
|
||||
.. code-block:: kv
|
||||
|
||||
MDSliverAppbar:
|
||||
hide_toolbar: True
|
||||
hide_appbar: True
|
||||
|
||||
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/sliver-app-bar-hide-toolbar-true.gif
|
||||
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/sliver-appbar-hide-appbar-true.gif
|
||||
:align: center
|
||||
|
||||
:attr:`hide_toolbar` is an :class:`~kivy.properties.BooleanProperty`
|
||||
and defaults to `True`.
|
||||
:attr:`hide_appbar` is an :class:`~kivy.properties.BooleanProperty`
|
||||
and defaults to `None`.
|
||||
"""
|
||||
|
||||
radius = VariableListProperty([20], length=4)
|
||||
|
@ -395,72 +333,51 @@ class MDSliverAppbar(MDBoxLayout):
|
|||
_opacity = NumericProperty()
|
||||
_scroll_was_moving = BooleanProperty(False)
|
||||
_last_scroll_y_pos = 0.0
|
||||
_appbar = ObjectProperty()
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.register_event_type("on_scroll_content")
|
||||
|
||||
def on_hide_appbar(self, instance, value) -> None:
|
||||
"""Fired when the `hide_appbar` value changes."""
|
||||
|
||||
if not value:
|
||||
self.background_color = self.theme_cls.transparentColor
|
||||
|
||||
def on_scroll_content(
|
||||
self,
|
||||
instance_sliverappbar: object = None,
|
||||
instance: object = None,
|
||||
value: float = 1.0,
|
||||
direction: str = "up",
|
||||
):
|
||||
"""
|
||||
Called when the list of custom content is being scrolled.
|
||||
Fired when the list of custom content is being scrolled.
|
||||
|
||||
:param instance_sliverappbar: :class:`~MDSliverAppbar`
|
||||
:param instance: :class:`~MDSliverAppbar`
|
||||
:param value: see :attr:`~kivy.uix.scrollview.ScrollView.scroll_y`
|
||||
:param direction: scroll direction: 'up/down'
|
||||
"""
|
||||
|
||||
def on_background_color(
|
||||
self, instance_sliver_appbar, color_value: list
|
||||
) -> None:
|
||||
if self.toolbar_cls:
|
||||
self.toolbar_cls.md_bg_color = color_value
|
||||
def on_background_color(self, instance, color) -> None:
|
||||
"""Fired when the `background_color` value changes."""
|
||||
|
||||
def on_toolbar_cls(
|
||||
self, instance_sliver_appbar, instance_toolbar_cls: MDTopAppBar
|
||||
) -> None:
|
||||
"""Called when a value is set to the :attr:`toolbar_cls` parameter."""
|
||||
|
||||
def on_toolbar_cls(*args):
|
||||
# If an MDTopAppBar object is already in use, delete it
|
||||
# before adding a new MDTopAppBar object.
|
||||
for widget in self.ids.float_box.children:
|
||||
if issubclass(widget.__class__, MDTopAppBar):
|
||||
self.ids.float_box.remove_widget(widget)
|
||||
|
||||
# Adding a custom MDTopAppBar object.
|
||||
if issubclass(instance_toolbar_cls.__class__, MDTopAppBar):
|
||||
instance_toolbar_cls.pos_hint = {"top": 1}
|
||||
instance_toolbar_cls.elevation = 0
|
||||
self.ids.float_box.add_widget(instance_toolbar_cls)
|
||||
else:
|
||||
raise MDSliverAppbarException(
|
||||
"The `toolbar_cls` parameter must be an object of the "
|
||||
"`kivymd.uix.toolbar.MDTopAppBar class`"
|
||||
)
|
||||
|
||||
# Schedule using for declarative style.
|
||||
# Otherwise get AttributeError exception.
|
||||
Clock.schedule_once(on_toolbar_cls)
|
||||
if self._appbar:
|
||||
self._appbar.canvas.get_group("md-top-app-bar-color")[
|
||||
0
|
||||
].rgba = color
|
||||
|
||||
def on_vbar(self) -> None:
|
||||
if not self.background_color:
|
||||
self.background_color = self.theme_cls.primary_color
|
||||
|
||||
if not self.toolbar_cls:
|
||||
self.toolbar_cls = self.get_default_toolbar()
|
||||
self.background_color = self.theme_cls.primaryColor
|
||||
|
||||
scroll_box = self.ids.scroll_box
|
||||
vbar = self.ids.scroll.vbar
|
||||
toolbar_percent = (self.toolbar_cls.height / scroll_box.height) * 100
|
||||
appbar_percent = (self._appbar.height / scroll_box.height) * 100
|
||||
current_percent = (vbar[0] + vbar[1]) * 100
|
||||
percent_min = (
|
||||
1 - self.max_height / scroll_box.height
|
||||
) * 100 + toolbar_percent
|
||||
) * 100 + appbar_percent
|
||||
|
||||
if self._scroll_was_moving:
|
||||
direction = self._get_direction_swipe(self.ids.scroll.scroll_y)
|
||||
|
@ -469,38 +386,47 @@ class MDSliverAppbar(MDBoxLayout):
|
|||
"on_scroll_content", self.ids.scroll.scroll_y, direction
|
||||
)
|
||||
|
||||
if self.hide_toolbar:
|
||||
if self.hide_appbar:
|
||||
if percent_min <= current_percent:
|
||||
opacity = (current_percent - percent_min) / (100 - percent_min)
|
||||
self._opacity = self.max_opacity * (1 - opacity)
|
||||
self.background_color = self.background_color[0:3] + [
|
||||
1 - opacity
|
||||
]
|
||||
self.toolbar_cls._hard_shadow_a = 1 - opacity
|
||||
self.toolbar_cls._soft_shadow_a = 1 - opacity
|
||||
else:
|
||||
self.background_color = self.background_color[0:3] + [1]
|
||||
|
||||
def get_default_toolbar(self) -> MDTopAppBar:
|
||||
"""Called if no value is passed for the toolbar_cls attribute."""
|
||||
|
||||
return MDTopAppBar(
|
||||
pos_hint={"top": 1}, md_bg_color=self.background_color
|
||||
)
|
||||
|
||||
def add_widget(self, widget, index=0, canvas=None):
|
||||
if issubclass(widget.__class__, MDSliverAppbarContent):
|
||||
if isinstance(widget, MDSliverAppbarContent):
|
||||
Clock.schedule_once(lambda x: self._set_radius(widget))
|
||||
self.ids.scroll_box.add_widget(widget)
|
||||
elif issubclass(widget.__class__, MDSliverAppbarHeader):
|
||||
elif isinstance(widget, MDSliverAppbarHeader):
|
||||
self.ids.header.add_widget(widget)
|
||||
elif isinstance(widget, MDTopAppBar):
|
||||
self._appbar = widget
|
||||
widget.pos_hint = {"top": 1}
|
||||
self.ids.float_box.add_widget(widget)
|
||||
else:
|
||||
super().add_widget(widget, index=index, canvas=canvas)
|
||||
|
||||
def _set_radius(self, instance: MDSliverAppbarContent) -> None:
|
||||
def on__appbar(self, instance, value):
|
||||
def set_rgba_appbar(*args):
|
||||
if self.hide_appbar:
|
||||
value.theme_elevation_level = "Custom"
|
||||
value.elevation_level = 0
|
||||
value.theme_shadow_color = "Custom"
|
||||
value.shadow_color = self.theme_cls.transparentColor
|
||||
value.md_bg_color = self.theme_cls.transparentColor
|
||||
value.canvas.get_group("md-top-app-bar-color")[
|
||||
0
|
||||
].rgba = self.theme_cls.transparentColor
|
||||
|
||||
Clock.schedule_once(set_rgba_appbar, 0.5)
|
||||
|
||||
def _set_radius(self, instance: MDSliverAppbarContent):
|
||||
instance.radius = self.radius
|
||||
|
||||
def _get_direction_swipe(self, current_percent: float) -> str:
|
||||
def _get_direction_swipe(self, current_percent: float):
|
||||
if self._last_scroll_y_pos > current_percent:
|
||||
direction = "up"
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue