xzripper / flet_navigator

🌟 Navigator (Router) for Flet. 🐍
https://github.com/xzripper/flet_navigator
MIT License
36 stars 1 forks source link

Can you add more transitions? #15

Closed CoderMaximus closed 4 months ago

CoderMaximus commented 4 months ago

Is it possible to add more animations and transitions?

xzripper commented 4 months ago

Do you want to create your own animations and apply them or do you want me to add new ones?

CoderMaximus commented 4 months ago

1st. Can i create my own animation? 2nd. If you may plz add some. BTW i love flet-navigator cuz it is really easier than using flet's built in routing. Thanks

xzripper commented 4 months ago

Thanks so much for your support! I don't think it'll be too tricky to add custom animations. I'm planning to release a new version of Flet-Navigator tomorrow (UTC +3:00) with that feature. It would also be great if you could give me some ideas for animations you'd like to see in the navigator.

CoderMaximus commented 4 months ago

I recommend a sliding page from right to left when entering a new page and the opposite when going back, flipping tiles is another thing that would be nice, and many more!

xzripper commented 4 months ago
def my_animation(control: Control, mult: float, smoothess: float) -> None:
    for angle in range(0, randint(80, 140), smoothess + 1):
        control.rotate = angle

        control.scale = mult

anim = NavigatorAnimation(NavigatorAnimation.CUSTOM, NavigatorAnimation.SMOOTHNESS_10);
anim.set_custom_animation(my_animation)

flet_navigator = VirtualFletNavigator(navigator_animation=anim)

Reimplementation of built-in ROTATION animation.

What do you think? Isn't it complicated for newcomers?

xzripper commented 4 months ago
def my_animation(control: Control, mult: float, smoothess: float) -> None:
    control.scale = Scale(scale=control.scale.scale if control.scale else 1)

    control.scale.scale += mult * 0.1

anim = NavigatorAnimation(NavigatorAnimation.CUSTOM, NavigatorAnimation.SMOOTHNESS_10);
anim.set_custom_animation(my_animation)

flet_navigator = VirtualFletNavigator(navigator_animation=anim)

Another fun custom animation.

Aj4vj0s68N

xzripper commented 4 months ago

V2.8.5 is released! Implemented custom animations (check documentation), fixed some animation issues, etc. Also I failed to implement sliding page or flipping tiles, because its impossible, here is why:

  1. Can't implement sliding page because navigator has no ability to make IN animation after page loaded.
  2. Can't implement sliding page because controls (widgets) position can be changed only in Stack.
  3. Can't implement flipping tiles because Flet has no ability to rotate controls by other axis than Y (or P if we are using HPR).

But its not over thought, you still can implement sliding page via custom animations, see Flet absolute positioning: https://flet.dev/docs/controls/stack/#absolute-positioning-inside-stack

Also FletNavigator is archived, i.e development is halted. But you can still push new issue and ask for help. Good luck!

xzripper commented 4 months ago

You can re-open this issue if you want.