mirror of
https://github.com/markqvist/Sideband.git
synced 2025-09-27 20:01:22 -04:00
Updated build system for Kivy 2.2.1
This commit is contained in:
parent
23e6b6e0c6
commit
67a8f61af8
126 changed files with 9967 additions and 4279 deletions
|
@ -15,7 +15,7 @@
|
|||
canvas:
|
||||
Clear
|
||||
Color:
|
||||
rgba: root.theme_cls.primary_dark
|
||||
rgba: root.circle_color
|
||||
Ellipse:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
|
@ -24,4 +24,4 @@
|
|||
id: spinner
|
||||
size_hint: None, None
|
||||
size: dp(30), dp(30)
|
||||
color: 1, 1, 1, 1
|
||||
color: root.spinner_color
|
||||
|
|
|
@ -43,6 +43,8 @@ Example
|
|||
id: refresh_layout
|
||||
refresh_callback: app.refresh_callback
|
||||
root_layout: root
|
||||
spinner_color: "brown"
|
||||
circle_color: "white"
|
||||
|
||||
MDGridLayout:
|
||||
id: box
|
||||
|
@ -66,6 +68,8 @@ Example
|
|||
y = 15
|
||||
|
||||
def build(self):
|
||||
self.theme_cls.theme_style = "Dark"
|
||||
self.theme_cls.primary_palette = "Orange"
|
||||
self.screen = Factory.Example()
|
||||
self.set_list()
|
||||
|
||||
|
@ -81,8 +85,10 @@ Example
|
|||
asynckivy.start(set_list())
|
||||
|
||||
def refresh_callback(self, *args):
|
||||
'''A method that updates the state of your application
|
||||
while the spinner remains on the screen.'''
|
||||
'''
|
||||
A method that updates the state of your application
|
||||
while the spinner remains on the screen.
|
||||
'''
|
||||
|
||||
def refresh_callback(interval):
|
||||
self.screen.ids.box.clear_widgets()
|
||||
|
@ -110,7 +116,12 @@ from kivy.core.window import Window
|
|||
from kivy.effects.dampedscroll import DampedScrollEffect
|
||||
from kivy.lang import Builder
|
||||
from kivy.metrics import dp
|
||||
from kivy.properties import ColorProperty, NumericProperty, ObjectProperty
|
||||
from kivy.properties import (
|
||||
ColorProperty,
|
||||
NumericProperty,
|
||||
ObjectProperty,
|
||||
StringProperty,
|
||||
)
|
||||
from kivy.uix.floatlayout import FloatLayout
|
||||
|
||||
from kivymd import uix_path
|
||||
|
@ -150,7 +161,16 @@ class _RefreshScrollEffect(DampedScrollEffect):
|
|||
return False
|
||||
|
||||
|
||||
class MDScrollViewRefreshLayout(MDScrollView):
|
||||
class MDScrollViewRefreshLayout(ThemableBehavior, MDScrollView):
|
||||
"""
|
||||
Refresh layout class.
|
||||
|
||||
For more information, see in the
|
||||
:class:`~kivymd.theming.ThemableBehavior` and
|
||||
:class:`~kivymd.uix.scrollview.MDScrollView`
|
||||
class documentation.
|
||||
"""
|
||||
|
||||
root_layout = ObjectProperty()
|
||||
"""
|
||||
The spinner will be attached to this layout.
|
||||
|
@ -168,8 +188,70 @@ class MDScrollViewRefreshLayout(MDScrollView):
|
|||
and defaults to `None`.
|
||||
"""
|
||||
|
||||
spinner_color = ColorProperty([1, 1, 1, 1])
|
||||
"""
|
||||
Color of the spinner in (r, g, b, a) or string format.
|
||||
|
||||
.. versionadded:: 1.2.0
|
||||
|
||||
:attr:`spinner_color` is a :class:`~kivy.properties.ColorProperty`
|
||||
and defaults to `[1, 1, 1, 1]`.
|
||||
"""
|
||||
|
||||
circle_color = ColorProperty(None)
|
||||
"""
|
||||
Color of the ellipse around the spinner in (r, g, b, a) or string format.
|
||||
|
||||
.. versionadded:: 1.2.0
|
||||
|
||||
:attr:`circle_color` is a :class:`~kivy.properties.ColorProperty`
|
||||
and defaults to `None`.
|
||||
"""
|
||||
|
||||
show_transition = StringProperty("out_elastic")
|
||||
"""
|
||||
Transition of the spinner's opening.
|
||||
|
||||
.. versionadded:: 1.2.0
|
||||
|
||||
:attr:`show_transition` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to `'out_elastic'`.
|
||||
"""
|
||||
|
||||
show_duration = NumericProperty(0.8)
|
||||
"""
|
||||
Duration of the spinner display.
|
||||
|
||||
.. versionadded:: 1.2.0
|
||||
|
||||
:attr:`show_duration` is a :class:`~kivy.properties.NumericProperty`
|
||||
and defaults to `0.8`.
|
||||
"""
|
||||
|
||||
hide_transition = StringProperty("out_elastic")
|
||||
"""
|
||||
Transition of hiding the spinner.
|
||||
|
||||
.. versionadded:: 1.2.0
|
||||
|
||||
:attr:`hide_transition` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to `'out_elastic'`.
|
||||
"""
|
||||
|
||||
hide_duration = NumericProperty(0.8)
|
||||
"""
|
||||
Duration of hiding the spinner.
|
||||
|
||||
.. versionadded:: 1.2.0
|
||||
|
||||
:attr:`hide_duration` is a :class:`~kivy.properties.NumericProperty`
|
||||
and defaults to `0.8`.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if not self.circle_color:
|
||||
self.circle_color = self.theme_cls.primary_dark
|
||||
self.effect_cls = _RefreshScrollEffect
|
||||
self._work_spinner = False
|
||||
self._did_overscroll = False
|
||||
|
@ -180,7 +262,15 @@ class MDScrollViewRefreshLayout(MDScrollView):
|
|||
if self.refresh_callback:
|
||||
self.refresh_callback()
|
||||
if not self.refresh_spinner:
|
||||
self.refresh_spinner = RefreshSpinner(_refresh_layout=self)
|
||||
self.refresh_spinner = RefreshSpinner(
|
||||
_refresh_layout=self,
|
||||
spinner_color=self.spinner_color,
|
||||
circle_color=self.circle_color,
|
||||
show_transition=self.show_transition,
|
||||
show_duration=self.show_duration,
|
||||
hide_transition=self.hide_transition,
|
||||
hide_duration=self.hide_duration,
|
||||
)
|
||||
self.root_layout.add_widget(self.refresh_spinner)
|
||||
self.refresh_spinner.start_anim_spinner()
|
||||
self._work_spinner = True
|
||||
|
@ -195,13 +285,18 @@ class MDScrollViewRefreshLayout(MDScrollView):
|
|||
|
||||
|
||||
class RefreshSpinner(ThemableBehavior, FloatLayout):
|
||||
# Color of the spinner in (r, g, b, a) or string format.
|
||||
spinner_color = ColorProperty([1, 1, 1, 1])
|
||||
"""
|
||||
Color of spinner.
|
||||
|
||||
:attr:`spinner_color` is a :class:`~kivy.properties.ColorProperty`
|
||||
and defaults to `[1, 1, 1, 1]`.
|
||||
"""
|
||||
# Color of the ellipse around the spinner in (r, g, b, a) or string format.
|
||||
circle_color = ColorProperty()
|
||||
# Transition of the spinner's opening.
|
||||
show_transition = StringProperty()
|
||||
# The duration of the spinner display.
|
||||
show_duration = NumericProperty(0.8)
|
||||
# Transition of hiding the spinner.
|
||||
hide_transition = StringProperty()
|
||||
# Duration of hiding the spinner.
|
||||
hide_duration = NumericProperty(0.8)
|
||||
|
||||
# kivymd.refreshlayout.MDScrollViewRefreshLayout object
|
||||
_refresh_layout = ObjectProperty()
|
||||
|
@ -210,13 +305,15 @@ class RefreshSpinner(ThemableBehavior, FloatLayout):
|
|||
spinner = self.ids.body_spinner
|
||||
Animation(
|
||||
y=spinner.y - self.theme_cls.standard_increment * 2 + dp(10),
|
||||
d=0.8,
|
||||
t="out_elastic",
|
||||
d=self.show_duration,
|
||||
t=self.show_transition,
|
||||
).start(spinner)
|
||||
|
||||
def hide_anim_spinner(self) -> None:
|
||||
spinner = self.ids.body_spinner
|
||||
anim = Animation(y=Window.height, d=0.8, t="out_elastic")
|
||||
anim = Animation(
|
||||
y=Window.height, d=self.hide_duration, t=self.hide_transition
|
||||
)
|
||||
anim.bind(on_complete=self.set_spinner)
|
||||
anim.start(spinner)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue