Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# FletX 🚀
**The open-source GetX-inspired Python Framework for Building Reactive, Cross-Platform Apps with Flet**

[![PyPI Version](https://img.shields.io/pypi/v/fletx)](https://pypi.org/project/FletXr/)
[![PyPI Version](https://img.shields.io/pypi/v/FletXr)](https://pypi.org/project/FletXr/)
[![Downloads](https://static.pepy.tech/badge/FletXr)](https://pepy.tech/project/FletXr)
[![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
[![Discord](https://img.shields.io/discord/v6trjD8m)](https://discord.gg/v6trjD8m)

Expand Down Expand Up @@ -313,7 +314,7 @@ We welcome contributions from the community! Please see the [CONTRIBUTING.md](CO

## License 📜

MIT © 2023 AllDotPy
MIT © 2025 AllDotPy

```bash
# Happy coding!
Expand Down
3 changes: 2 additions & 1 deletion examples/1/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from fletx.app import FletXApp
import asyncio
import flet as ft
from fletx.app import FletXApp
from routes import routes

def main(page: ft.Page):
Expand Down
4 changes: 2 additions & 2 deletions examples/1/pages/auth/guards.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from fletx.core.navigation.guards import RouteGuard
from fletx.core.types import RouteInfo
from fletx.core.routing.guards import RouteGuard
from fletx.core.routing.models import RouteInfo


class AuthGuard(RouteGuard):
Expand Down
4 changes: 2 additions & 2 deletions examples/1/pages/auth/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ..shared.components import ReactivePasswordField
from fletx import FletX
from fletx.core.page import FletXPage
from fletx.core.router import FletXRouter
from fletx.navigation import navigate
from fletx.core.state import RxBool
from .controller import AuthController
from .guards import AuthGuard
Expand Down Expand Up @@ -317,6 +317,6 @@ def on_login(self, e):
self.controller.login(
self.email_field.value,
self.password_field.value,
on_success=lambda: FletXRouter.to("/dashboard"),
on_success=lambda: navigate("/dashboard"),
on_failure=lambda: print("Échec de connexion")
)
2 changes: 1 addition & 1 deletion examples/1/pages/dashboard/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import flet as ft
from fletx.core.page import FletXPage
from fletx.decorators.controllers import page_controller
from fletx.core.router import FletXRouter
from fletx.core.routing.router import FletXRouter
from .controller import DashboardController

@page_controller
Expand Down
58 changes: 53 additions & 5 deletions examples/1/routes.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,59 @@
from fletx.navigation import (
ModuleRouter, TransitionType, RouteTransition
)
from fletx.decorators import register_router

from pages.auth.login import LoginPage
from pages.dashboard.home import DashboardHomePage
from pages.dashboard.settings import DashboardSettingsPage

routes = {
"/login": LoginPage,
"/dashboard": DashboardHomePage,
"/dashboard/settings": DashboardSettingsPage,
}

routes = [
{
'path': '/login',
'component': LoginPage,
'meta':{
'transition': RouteTransition(
transition_type = TransitionType.ZOOM_IN,
duration = 350
)
}
},
{
'path': '/dashboard',
'component': DashboardHomePage,
'meta':{
'transition': RouteTransition(
transition_type = TransitionType.FLIP_HORIZONTAL,
duration = 350
)
}
},
{
'path': '/dashboard/settings',
'component': DashboardSettingsPage
}
]

@register_router
class MyAppRouter(ModuleRouter):
"""My Application Routing Module."""

name = 'MyAppRouter'
base_path = '/'
is_root = True
routes = routes
sub_routers = []




# MyAppRouter.add_routes(routes = routes)

# {
# "/login": LoginPage,
# "/dashboard": DashboardHomePage,
# "/dashboard/settings": DashboardSettingsPage,
# }

# DashboardHomePage().build()
16 changes: 8 additions & 8 deletions fletx/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

import flet as ft
from typing import Dict, Type, Optional
from fletx.core.router import FletXRouter
from fletx.core.route_config import RouteConfig
from fletx.core.routing.router import FletXRouter
from fletx.core.page import FletXPage
from fletx.core.factory import FletXWidgetRegistry
# from fletx.core.factory import FletXWidgetRegistry
from fletx.utils.logger import SharedLogger
from fletx.utils.context import AppContext
from fletx.utils.exceptions import FletXError


####
## FLETX APPLICATION
#####
class FletXApp:
"""Main application class"""

Expand All @@ -32,7 +34,7 @@ def __init__(
debug: Debug mode
"""

self.routes = routes or {}
self.routing_module = routes or {}
self.initial_route = initial_route
self.theme_mode = theme_mode
self.debug = debug
Expand All @@ -44,8 +46,6 @@ def __init__(
)
self.logger = SharedLogger.get_logger(__name__)

# Configure routes
RouteConfig.register_routes(self.routes)

def run(self, **kwargs):
"""Deprecated method – use only in controlled environments"""
Expand Down Expand Up @@ -73,7 +73,7 @@ def _main(self, page: ft.Page):
AppContext.set_data("logger", self.logger)

# FletX Router Initialization
FletXRouter.initialize(page, self.initial_route)
FletXRouter.initialize(page, initial_route = self.initial_route)

self.logger.info("FletX Application initialized with success")

Expand Down
2 changes: 1 addition & 1 deletion fletx/cli/templates/project/pyproject.toml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ readme = "README.md"
authors = [{ name = "{{ author }}", email = "" }]
requires-python = ">={{ python_version }}"
dependencies = [
"fletx",
"fletxr",
"flet[all]",
]
2 changes: 1 addition & 1 deletion fletx/cli/templates/project/requirements.txt.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Core dependencies
flet>=0.21.0
fletx>={{ fletx_version }}
fletxr>={{ fletx_version }}

# Development dependencies
pytest>=7.0.0
Expand Down
9 changes: 4 additions & 5 deletions fletx/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
from fletx.core.controller import FletXController
from fletx.core.effects import EffectManager, Effect
from fletx.core.page import FletXPage
from fletx.core.route_config import RouteConfig
from fletx.core.router import FletXRouter
from fletx.core.route_config import RouteConfig # Deprecated
from fletx.core.state import (
ReactiveDependencyTracker, Observer,
Reactive, Computed, RxBool, RxDict, RxInt, RxList, RxStr
)
from fletx.core.types import (
RouteInfo, BindingConfig, BindingType,
BindingConfig, BindingType,
ComputedBindingConfig, FormFieldValidationRule
)
from fletx.core.router import FletXRouter
from fletx.core.widget import FletXWidget

__all__ = [
'FletXController',
'EffectManager',
'Effect',
'FletXPage',
'RouteConfig',
'RouteConfig', # Deprecated
'FletXRouter',
'ReactiveDependencyTracker',
'Observer',
Expand All @@ -34,5 +34,4 @@
'BindingType',
'ComputedBindingConfig',
'FormFieldValidationRule',
'FletXWidget'
]
62 changes: 62 additions & 0 deletions fletx/core/concurency/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from enum import Enum
from dataclasses import dataclass, field
from typing import (
TypeVar, Generic, Callable, Any, Optional, Dict, List,
Union, Protocol, runtime_checkable
)

# GENERIC TYPES
T = TypeVar('T')

####
## WORKER STATE
#####
class WorkerState(Enum):
"""Possible state of a worker"""

PENDING = "pending"
RUNNING = "running"
COMPLETED = "completed"
FAILED = "failed"
CANCELLED = "cancelled"


####
## EXECUTION PRIORITY
#####
class Priority(Enum):
"""Task execution priority"""

LOW = 1
NORMAL = 2
HIGH = 3
CRITICAL = 4


####
## WORKER RESULT
#####
@dataclass
class WorkerResult(Generic[T]):
"""Worker execution result"""

worker_id: str
state: WorkerState
result: Optional[T] = None
error: Optional[Exception] = None
execution_time: float = 0.0
metadata: Dict[str, Any] = field(default_factory=dict)


####
## WORKER POOL CONFIGURATION
#####
@dataclass
class WorkerPoolConfig:
"""Worker Pool Configuration."""

max_workers: int = 4
queue_size: int = 100
enable_priority: bool = True
timeout: Optional[float] = None
auto_shutdown: bool = True
Loading