You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -21,7 +25,10 @@ FletNavigator - Simple and fast navigator (router) for Flet (Python) that allows
21
25
Installation is quite easy: ```pip install flet_navigator```
22
26
23
27
> [!WARNING]
24
-
> FletNavigator is in active development phase + only one developer works on this project. Please, be patient and report all bugs.
28
+
> ~FletNavigator is in active development phase + only one developer works on this project. Please, be patient and report all bugs.~
29
+
30
+
> [!NOTE]
31
+
> Starting from `v2.7.5` FletNavigator is production-stable and almost completely ready to use. Any bug reports are very appreciated.
25
32
26
33
**FletNavigator Features**:
27
34
-**✨ Simple installation and very simple using.**
@@ -111,33 +118,25 @@ Homepage is main page, that you can set with `set_homepage`, and navigate with `
111
118
-`get_route_data(route: str) -> Any` - Get route data. More <ahref="https://github.com/xzripper/flet_navigator/issues/4#issuecomment-1817908000">detailed</a>.
112
119
-`set_homepage(self, homepage: str) -> None` - Set homepage (main page). More <ahref="https://github.com/xzripper/flet_navigator/issues/4#issuecomment-1817908000">detailed</a>.
113
120
121
+
-`@property virtual() -> bool[True]` - Is navigator virtual? Used in `PageData`.
122
+
114
123
Using example:
115
124
116
125
```python
117
-
from flet import app, Page, Text, FilledButton
126
+
from flet import app, Text
118
127
119
-
from flet_navigator importVirtualFletNavigator, PageData, ROUTE_404, route
128
+
from flet_navigator importPageData, render, anon, route
120
129
121
130
122
131
@route('/')
123
132
defmain_page(pg: PageData) -> None:
124
-
pg.add(FilledButton('Navigate to second page.', on_click=lambda_: pg.navigator.navigate('second_page', pg.page)))
-`navigate(route: str, page: Page, args: Arguments=None, parameters: dict=None) -> None` - Navigate to specific route. Specify `args` to transfer arguments to other page. Specify `parameters` to add URL parameters.
-`navigate(route: str, page: Page, args: Arguments=None, parameters: dict[str, Any]=None) -> None` - Navigate to specific route. Specify `args` to transfer arguments to other page. Specify `parameters` to add URL parameters.
-`render(page: Page, args: tuple[Any]=None, route_parameters: dict[str, Any]={}) -> None` - Render current route. If there is no route like that throw ROUTE-404 (if specified). Should be called only one time.
161
160
-`set_route_data(route: str, data: Any) -> int` - Set route data (cookies-like mechanism). Returns success/fail. More <ahref="https://github.com/xzripper/flet_navigator/issues/4#issuecomment-1817908000">detailed</a>.
162
161
-`get_route_data(route: str) -> Any` - Get route data. More <ahref="https://github.com/xzripper/flet_navigator/issues/4#issuecomment-1817908000">detailed</a>.
163
162
-`set_homepage(homepage: str) -> None` - Set homepage (main page). More <ahref="https://github.com/xzripper/flet_navigator/issues/4#issuecomment-1817908000">detailed</a>.
164
163
164
+
-`@property virtual() -> bool[False]` - Is navigator virtual? Used in `PageData`.
165
+
165
166
Using example:
166
167
167
168
```python
168
-
from flet import app, Page, Text, FilledButton, WEB_BROWSER
169
+
from flet import app, Text
169
170
170
-
from flet_navigator importFletNavigator, PageData, ROUTE_404, route
171
+
from flet_navigator importPageData, render, anon, route
171
172
172
173
173
174
@route('/')
174
175
defmain_page(pg: PageData) -> None:
175
-
pg.add(FilledButton('Navigate to second page.', on_click=lambda_: pg.navigator.navigate('second_page', pg.page)))
176
+
pg.add(Text('Main Page!')) # or `pg.page.add`.
176
177
177
178
@route('second_page')
178
179
defsecond_page(pg: PageData) -> None:
179
180
...# Second page content.
180
181
181
-
# Specify 404 page (since v2.6.5 it's optional).
182
-
# @route(ROUTE_404)
183
-
# def route_404(pg: PageData) -> None:
184
-
# ... # 404 Page Content.
185
-
186
-
# Main function.
187
-
defmain(page: Page) -> None:
188
-
# Initialize navigator and render page.
189
-
FletNavigator(page).render(page)
190
-
191
-
app(main, view=WEB_BROWSER)
182
+
app(anon(render))
192
183
```
193
184
194
185
<hr>
@@ -204,7 +195,9 @@ app(main, view=WEB_BROWSER)
204
195
-`page_id: int = None` - Page ID.<br><br>
205
196
206
197
-`set_appbar(appbar: Control) -> None` - Set appbar for current page. More <ahref="https://github.com/xzripper/flet_navigator/issues/4#issuecomment-1817908000">detailed</a>.
207
-
-`add(self, *controls: Control) -> None` - Append control(s) to page. Works as same as `Page.add`.
198
+
-`add(*controls: Control) -> None` - Append control(s) to page. Works as same as `Page.add`.
199
+
-`navigate(route: str, args: Arguments=None, parameters: dict[str, Any]=None) -> None` - Navigate to specific route. Parameters aren't used if navigator is virtual. Works as same as `PageData.navigator.navigate`.
200
+
-`navigate_homepage(args: Arguments=None, parameters: dict[str, Any]=None) -> None` - Navigate to homepage. Parameters aren't used if navigator is virtual. Works as same as `PageData.navigator.navigate_homepage`.
Used to render template. More <ahref="https://github.com/xzripper/flet_navigator/issues/4#issuecomment-1817908000">detailed</a>.<br>
321
328
322
-
Used to render template. More <ahref="https://github.com/xzripper/flet_navigator/issues/4#issuecomment-1817908000">detailed</a>. Example:<br>
329
+
In `v2.7.5` template features are extended: added global templates. Now you can use `@global_template` to register template and call template just by it's name.
pg.page.add(FilledButton(args[0], on_click=lambda_: pg.navigator.navigate(args[1], pg.page, args[2]))) # Or return FilledButton so we can do things with button later.
@global_template# or use @global_template(%TEMPLATE_NAME%) for custom name. So now template with name `my_global_template` is registered in global templates.
template(go_to_button, pg, ('Go to second page.', 'second_page', None)) # Out is FilledButton with text 'Go to second page.', and on click redirect to `second_page` happens.
@global_template# or use @global_template(%TEMPLATE_NAME%) for custom name. So now template with name `my_global_template` is registered in global templates.
0 commit comments