Code Monkey home page Code Monkey logo

Comments (5)

xzripper avatar xzripper commented on June 12, 2024 1

Its not hard to implement, I'll add opportunity to display AppBar only is selected pages.

from flet_navigator.

Plumpplump avatar Plumpplump commented on June 12, 2024 1

Also, it would be helpful if you could have examples
to show how to :
(1) use functions in actual actions like:
Define_ page
render
set_route_data
get_route_data
set_homepage
(2) what if Homepage, second_page, third_page … are in separate py files.

Thanks again. I find this package is very intuitive and easy to use to beginners.

from flet_navigator.

xzripper avatar xzripper commented on June 12, 2024 1

Thanks a lot, much appreciated! In the v2.3.5 release the problem with the AppBar is fixed by hooking each AppBar to the page ID. (pip install flet_navigator --upgrade)

def main_page(pg: PageData) -> None:
    pg.page.set_appbar(my_appbar) # Appbar is going to be displayed.

def second_page(pg: PageData) -> None:
    ... # Appbar isn't going to be displayed.

def third_appbar(pg: PageData) -> None:
    pg.page.set_appbar(my_appbar) # If you don't wanna copy & paste AppBar each time, you can write AppBar template and use it everywhere. # Appbar is going to be displayed.

define_page

Documentation:
https://github.com/xzripper/flet_navigator/blob/main/flet-navigator-docs.md#define_page

define_page used to import page from other .py file.

flet_navigator = FletNavigator(page,
    {
        '/': main_page,
        'second_page': define_page('second_page') # Auto imports `second_page` function from `second_page.py`.
    })

second_page.py

# from flet import 

from flet_navigator import PageData


def second_page(pg: PageData) -> None:
    ... # Second page content.

render

render function shouldn't be called by user.

set_route_data

Save server data on route. Its similar to Flet session (but data saved for this route is global, for all users).

users_visited_main_page = pg.navigator.get_route_data('/')

if users_visited_main_page == None:
    users_visited_main_page = 1

else:
    users_visited_main_page += 1

pg.navigator.set_route_data('/', users_visited_main_page)

get_route_data

Get server data on route. Returns data saved on this route.

pg.page.add(Text(f'Users visited this page: {pg.navigator.get_route_data("/")}.'))

set_homepage

You can set homepage with this function (pg.navigator.set_homepage('/')), and later instead of using pg.navigator.navigate(home_page, pg.page), you can use pg.navigator.navigate_homepage(pg.page)

I also updated documentation: https://github.com/xzripper/flet_navigator/blob/main/flet-navigator-docs.md

from flet_navigator.

xzripper avatar xzripper commented on June 12, 2024

Thanks for reporting! I'll release patch that fixes this issue in the near future!

from flet_navigator.

Plumpplump avatar Plumpplump commented on June 12, 2024

But in some cases, appbar again needs to be displayed in other pages anyway. So it would be better to have an option? That might make things a bit complicated.

from flet_navigator.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.