Skip to content

Commit 082b478

Browse files
authored
ReadMe.
ReadMe.
1 parent 803ab41 commit 082b478

File tree

1 file changed

+17
-68
lines changed

1 file changed

+17
-68
lines changed

README.md

Lines changed: 17 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,41 @@
1-
<h1 align="center">FletNavigator V2.0.1</h1>
1+
<h1 align="center">FletNavigator V2.1.1</h1>
22
<i><p align="center">Simple and fast navigator (router) for Flet (Python) that allows you to create multi-page applications! [<code>pip install flet_navigator</code>].<br><b>[<a href="https://github.com/xzripper/flet_navigator/blob/main/flet-navigator-docs.md">DOCUMENTATION</a>].</b></p>
33
<p align="center">Using Example:
44

55
```python
6-
from flet import app, Page, Text, FilledButton, TextThemeStyle
6+
from flet import app, Page
77

8-
from flet_navigator import VirtualFletNavigator, Any, ROUTE_404
8+
from flet_navigator import VirtualFletNavigator, PageData, Any, ROUTE_404
99

10-
from random import randint
10+
def main_page(pg: PageData) -> None:
11+
... # Main page content.
1112

13+
def second_page(pg: PageData) -> None:
14+
... # Second page content.
1215

13-
# Main page content.
14-
# page - Current page,
15-
# navigator - With this you can navigate to other pages,
16-
# args - Arguments sent from other page.
17-
# Using these all typehints is optional.
18-
def main_page(page: Page, navigator: VirtualFletNavigator, args: tuple[Any]) -> None:
19-
page.add(Text('Main Page!', style=TextThemeStyle.DISPLAY_MEDIUM))
16+
def route_404(pg: PageData) -> None:
17+
... # 404 Page Content.
2018

21-
if args:
22-
page.add(Text(f'Message from {args[0]}: {args[1]}.'))
23-
24-
page.add(
25-
FilledButton(
26-
'Navigate to second page!',
27-
28-
on_click=lambda _: navigator.navigate('second_page', page, ('main page', 'Hello from main page!')) # Navigate to 'second_page', and send greetings from main page as arguments!
29-
)
30-
)
31-
32-
page.add(
33-
FilledButton(
34-
'Navigate to really_non_existent_page!',
35-
36-
on_click=lambda _: navigator.navigate('really_non_existent_page', page) # Navigate to non-existent page. Will result route_404.
37-
)
38-
)
39-
40-
# Second page content.
41-
def second_page(page: Page, navigator: VirtualFletNavigator, args: tuple[Any]) -> None:
42-
page.add(Text('Second Page!', style=TextThemeStyle.DISPLAY_SMALL))
43-
44-
page.add(Text(f'Message from {args[0]}: {args[1]}'))
45-
46-
page.add(
47-
FilledButton(
48-
'Navigate to main page!',
49-
50-
on_click=lambda _: navigator.navigate('/', page, ('second page', randint(1, 100))) # Navigate to main page, and send random number as arguments!
51-
)
52-
)
53-
54-
# 404 page content.
55-
def route_404(page: Page, navigator: VirtualFletNavigator, args: tuple[Any]) -> None:
56-
page.add(Text('How did you get here? There is no page like this registered in routes...'))
57-
58-
page.add(
59-
FilledButton(
60-
'Navigate to the main page until it is too late...',
61-
62-
on_click=lambda _: navigator.navigate('/', page) # Navigate to main page.
63-
)
64-
)
65-
66-
# Main function. Being used only for routing.
6719
def main(page: Page) -> None:
6820
# Initialize navigator.
6921
flet_navigator = VirtualFletNavigator(
7022
{
71-
'/': main_page, # Specify main page,
72-
'second_page': second_page, # Specify second page,
73-
ROUTE_404: route_404 # Specify 404 page (optional).
74-
}, lambda route: print(f'Route changed!: {route}') # On route changed handler (optional).
23+
'/': main_page, # Main page route.
24+
'second_page': second_page, # Second page route.
25+
ROUTE_404: route_404 # 404 page route.
26+
}, lambda route: print(f'Route changed!: {route}') # Route change handler (optional).
7527
)
7628

77-
flet_navigator.render(page) # Render main page.
29+
flet_navigator.render(page) # Render current page.
7830

79-
app(target=main) # Run main fuction.
31+
app(target=main)
8032
```
8133

8234
</p>
8335

84-
<p align="center"><img src="example.gif" width=600></p>
85-
86-
~~There is no documentation, or more examples, because you can use FletNavigator just by researching this small example! Also every function, and class field has own docstring.<br>
87-
This example will be updated in next releases to keep everything up to date.~~
36+
<p align="center"><img src="example.gif" width=500></p>
8837

8938
See the difference between ```VirtualFletNavigator``` and ```FletNavigator```, and more <a href="https://github.com/xzripper/flet_navigator/blob/main/flet-navigator-docs.md">here</a> (<- documentation).
9039

9140
<hr>
92-
<p align="center">FletNavigator v2.0.1.</p></i>
41+
<p align="center">FletNavigator v2.1.1.</p></i>

0 commit comments

Comments
 (0)