diff --git a/examples/1/main.py b/examples/1/main.py index 2182c82..6528a29 100644 --- a/examples/1/main.py +++ b/examples/1/main.py @@ -1,7 +1,7 @@ import asyncio import flet as ft from fletx.app import FletXApp -from routes import routes +from routes import MyAppRouter def main(page: ft.Page): # Configuration de la page @@ -24,7 +24,6 @@ def main(page: ft.Page): # Initialisation de l'application FletX app = FletXApp( - routes = routes, initial_route = "/login", debug = True ) diff --git a/fletx/app.py b/fletx/app.py index bf63f93..ae99393 100644 --- a/fletx/app.py +++ b/fletx/app.py @@ -19,7 +19,6 @@ class FletXApp: def __init__( self, - routes: Optional[Dict[str, Type[FletXPage]]] = None, initial_route: str = "/", theme_mode: ft.ThemeMode = ft.ThemeMode.SYSTEM, debug: bool = False @@ -34,7 +33,6 @@ def __init__( debug: Debug mode """ - self.routing_module = routes or {} self.initial_route = initial_route self.theme_mode = theme_mode self.debug = debug diff --git a/fletx/cli/templates/project/README.md.tpl b/fletx/cli/templates/project/README.md.tpl index 104dad1..60c75a4 100644 --- a/fletx/cli/templates/project/README.md.tpl +++ b/fletx/cli/templates/project/README.md.tpl @@ -1,4 +1,4 @@ -# {{ project_name }} +# {{ project_name | pascal_case }} {{ description }} diff --git a/fletx/cli/templates/project/app/__init__.py.tpl b/fletx/cli/templates/project/app/__init__.py.tpl index e3e2b1a..cfc9511 100644 --- a/fletx/cli/templates/project/app/__init__.py.tpl +++ b/fletx/cli/templates/project/app/__init__.py.tpl @@ -1,5 +1,5 @@ """ -{{ project_name }} - A FletX Application +{{ project_name | pascal_case }} - A FletX Application This package contains the main application components. """ diff --git a/fletx/cli/templates/project/app/components/__init__.py.tpl b/fletx/cli/templates/project/app/components/__init__.py.tpl index 8803af1..4f1428b 100644 --- a/fletx/cli/templates/project/app/components/__init__.py.tpl +++ b/fletx/cli/templates/project/app/components/__init__.py.tpl @@ -1,5 +1,5 @@ """ -{{ project_name }} Application Components module. +{{ project_name | pascal_case }} Application Components module. This module contains reusable widgets and components Version: {{ version }} diff --git a/fletx/cli/templates/project/app/controllers/__init__.py.tpl b/fletx/cli/templates/project/app/controllers/__init__.py.tpl index db24c9c..f737271 100644 --- a/fletx/cli/templates/project/app/controllers/__init__.py.tpl +++ b/fletx/cli/templates/project/app/controllers/__init__.py.tpl @@ -1,10 +1,10 @@ """ -Controllers package for {{ project_name }}. +Controllers package for {{ project_name | pascal_case }}. Controllers contain the business logic and manage application state. """ -from counter import CounterController +from .counter import CounterController __all__ = [ 'CounterController' diff --git a/fletx/cli/templates/project/app/models/__ini__.py.tpl b/fletx/cli/templates/project/app/models/__ini__.py.tpl index 2fbc51a..4af91b3 100644 --- a/fletx/cli/templates/project/app/models/__ini__.py.tpl +++ b/fletx/cli/templates/project/app/models/__ini__.py.tpl @@ -1,5 +1,5 @@ """ -{{ project_name }} Application Models module. +{{ project_name | pascal_case }} Application Models module. This module contains data models. Version: {{ version }} diff --git a/fletx/cli/templates/project/app/pages/__init__.py.tpl b/fletx/cli/templates/project/app/pages/__init__.py.tpl index 719b083..7ef37c8 100644 --- a/fletx/cli/templates/project/app/pages/__init__.py.tpl +++ b/fletx/cli/templates/project/app/pages/__init__.py.tpl @@ -1,11 +1,11 @@ """ -{{ project_name }} Application Pages module. +{{ project_name | pascal_case }} Application Pages module. This module contains the application Pages. Version: {{ version }} """ -from counter import CounterPage +from .counter import CounterPage __all__ = [ 'CounterPage' diff --git a/fletx/cli/templates/project/app/pages/counter.py.tpl b/fletx/cli/templates/project/app/pages/counter.py.tpl index f7e1c04..bb1c5d8 100644 --- a/fletx/cli/templates/project/app/pages/counter.py.tpl +++ b/fletx/cli/templates/project/app/pages/counter.py.tpl @@ -18,7 +18,7 @@ class CounterPage(FletXPage): horizontal_alignment = ft.CrossAxisAlignment.CENTER, controls = [ ft.Text( - "{{ project_name }} Counter", + "{{ project_name | pascal_case }} Counter", size = 20, weight = ft.FontWeight.BOLD ), diff --git a/fletx/cli/templates/project/app/routes.py.tpl b/fletx/cli/templates/project/app/routes.py.tpl index 45c03bb..098e357 100644 --- a/fletx/cli/templates/project/app/routes.py.tpl +++ b/fletx/cli/templates/project/app/routes.py.tpl @@ -5,9 +5,27 @@ Version: {{ version }} # Import your pages here +from fletx.navigation import ( + ModuleRouter, TransitionType, RouteTransition +) +from fletx.decorators import register_router + from .pages.counter import CounterPage -# Define {{ project_name }} routes here -routes = { - '/': CounterPage -} \ No newline at end of file +# Define {{ project_name | pascal_case }} routes here +routes = [ + { + 'path': '/', + 'component': CounterPage, + }, +] + +@register_router +class {{ project_name | pascal_case }}Router(ModuleRouter): + """{{ project_name }} Routing Module.""" + + name = '{{ project_name }}' + base_path = '/' + is_root = True + routes = routes + sub_routers = [] diff --git a/fletx/cli/templates/project/main.py.tpl b/fletx/cli/templates/project/main.py.tpl index 21cc05b..c3e7cb0 100644 --- a/fletx/cli/templates/project/main.py.tpl +++ b/fletx/cli/templates/project/main.py.tpl @@ -8,7 +8,7 @@ Version: {{ version }} import flet as ft from fletx.app import FletXApp -from app.routes import routes +from app.routes import {{ project_name | pascal_case }}Router def main(page: ft.Page): """Main entry point for the Flet application.""" @@ -32,7 +32,6 @@ def main(page: ft.Page): # FletX Application Initialization app = FletXApp( - routes = routes, initial_route = "/", debug = True )