Skip to content

Commit

Permalink
implement loading as kivy animation rather as gif
Browse files Browse the repository at this point in the history
  • Loading branch information
LupaDevStudio committed May 31, 2024
1 parent a4a4fbb commit 15226c7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ version.filename = tools/constants.py
# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = python3, kivy, Pillow, olefile
requirements = python3, kivy
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
Expand Down
Binary file removed resources/images/loading.gif
Binary file not shown.
Binary file added resources/images/loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 19 additions & 8 deletions screens/custom_widgets/popup/loading_popup.kv
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,22 @@
color: (0,0,0,1)
halign: "center"
valign: "middle"

Image:
id: loading_image
size_hint: (0.8,0.7)
pos_hint: {"center_x":0.5,"center_y":0.6}
fit_mode: "contain"
source: PATH_IMAGES + "loading.gif"
anim_delay: 0.04

RelativeLayout:
size_hint: (0.7, 0.6)
pos_hint: {"center_x":0.5, "center_y": 0.6}

canvas.before:
PushMatrix
Rotate:
angle: root.angle
axis: 0, 0, 1
origin: self.width/2, self.height/2
canvas.after:
PopMatrix

Image:
id: loading_image
source: PATH_IMAGES + "loading.png"
size_hint: (1, 1)
pos_hint: {'center_x': 0.5, "center_y": 0.5}
20 changes: 19 additions & 1 deletion screens/custom_widgets/popup/loading_popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
### Kivy imports ###

from kivy.properties import (
ObjectProperty,
NumericProperty,
StringProperty
)
from kivy.animation import Animation, AnimationTransition

### Local imports ###

Expand All @@ -28,8 +29,25 @@ class LoadingPopup(CustomPopup):

title = StringProperty()
center_text = StringProperty()
angle = NumericProperty(0)

def __init__(self, **kwargs):
super().__init__(**kwargs)
self.center_text = "Loading in progress..."
self.title = "Loading"

anim1 = Animation(angle=360, duration=2,
t=AnimationTransition.linear)
anim2 = Animation(angle=360, duration=2,
t=AnimationTransition.linear)
self.sequence = anim1 + anim2
self.sequence.repeat = True
self.sequence.start(self)

def on_dismiss(self):
self.sequence.stop(self)
return super().on_dismiss()

def on_angle(self, item, angle):
if angle >= 360:
item.angle = angle - 360

0 comments on commit 15226c7

Please sign in to comment.