I didn't say [share] code because I am just trying, I know what I have done us crappy. I have touched on ui.animate a few times, but never got in to it. But I know it's very powerful. I am surprised I don't see more ui examples here using it. What I have put below is crap. Just to spark some ideas. Should be possible to make a single function with all sort of presentation permutations for a subview.
```python
'''
Pythonista Forum - @Phuket2
'''
import ui, editor
def slide_up(p, v, reverse = False, delay = 1.0 ):
v.y = p.height if not reverse else -p.height
def animation():
v.y = 0
ui.animate(animation, delay)
def slide_in(p, v, reverse = False, delay = 1.0 ):
v.x = p.width if not reverse else -p.width
def animation():
v.x = 0
ui.animate(animation, delay)
class MyClass2(ui.View):
def init(self, args, kwargs):
super().init(args, **kwargs)
self.bg_color = 'deeppink'
btn = ui.Button(frame=(30, 30, 100, 100))
btn.title = 'hit me'
btn.border_width =2
btn.border_color = 'white'
btn.corner_radius = btn.width / 2
self.add_subview(btn)
def draw(self):
# do a draw, just to see how it works
r = ui.Rect(*self.bounds).inset(20, 20)
s = ui.Path.rect(*r)
s.line_width = 10
ui.set_color('blue')
s.stroke()
class MyClass(ui.View):
def init(self, args, kwargs):
super().init(args, **kwargs)
def add_view(self, v):
self.add_subview(v)
# comment out either line below for 1 effect
slide_up(self, v, reverse=False, delay = 3)
slide_in(self, v, reverse=False, delay=.8)
if name == 'main':
_use_theme = True
w, h = 540, 540
f = ui.Rect(0, 0, w, h)
style='sheet'
mc = MyClass(frame=f, bg_color='white')
if not _use_theme:
mc.present(style = style, animated=False)
else:
editor.present_themed(mc, theme_name='Oceanic', style=style, animated=False)
mc2 = MyClass2(frame = f)
mc.add_view(mc2)
```python