Skip to main content

FlowViewFt es una libreria para crear aplicaciones con Flet sinplificando las rutas y el manejo de estados.

Project description

📦 FlowViewFt - Enrutador dinámico para Flet

FlowViewFt es una librería modular diseñada para simplificar la creación, organización y navegación entre vistas en proyectos desarrollados con Flet. Su enfoque está basado en el concepto de "flujo" (Flow), permitiendo transiciones naturales y estructuradas entre páginas, lo que facilita el mantenimiento y la escalabilidad del código.


🚀 Instalación

pip install FlowViewFt

🧠 Conceptos Clave

  • FlowViewFtParams: Encapsula los parámetros que se pueden pasar entre rutas.
  • FlowViewFtState: Maneja el estado de una vista o componente de forma organizada.
  • FlowViewFtView: Clase base para construir vistas reutilizables e independientes.

⚙️ Uso básico

main.py

import flet as ft
from FlowViewFt import FlowViewFt, route
from view.home_view import HomeView
from view.counter_view import CounterView

def main(page: ft.Page):
    page.title = "Counter App"

    FlowViewFt(
        page=page,
        routes=[
            route("/", HomeView),
            route("/counter", CounterView),
        ],
        init_route="/",
    )

ft.app(target=main)

state/CounterState.py

from FlowViewFt.core import FlowViewFtState
import flet as ft
class counter_state(FlowViewFtState):
    def __init__(self, page):
        super().__init__(page)
        self.txt_number = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)

    def minus_click(self,e):
        if self.txt_number.value is not None:
            self.txt_number.value = str(int(self.txt_number.value) - 1)
        self.update()

    def plus_click(self,e):
        if self.txt_number.value is not None:
            self.txt_number.value = str(int(self.txt_number.value) + 1)
        self.update()

view/home_view.py

import flet as ft
from FlowViewFt.core import FlowViewFtView

class HomeView(FlowViewFtView):
    def build(self):
        return ft.View(
            controls=[
                ft.Text("Welcome to CounterApp", size=30),
                ft.ElevatedButton(
                    "Go to Counter", 
                    on_click=lambda _: self.page.go("/counter")
                ),
            ]
        )

view/counter_view.py

import flet as ft
from FlowViewFt.core import FlowViewFtView
from state.CounterState import counter_state

class CounterView(FlowViewFtView):
    def __init__(self, page):
        super().__init__(page)
        self.state = counter_state(self.page)

    def build(self):
        return ft.View(
            horizontal_alignment=ft.CrossAxisAlignment.CENTER,
            vertical_alignment=ft.MainAxisAlignment.CENTER,
            controls=[
                ft.Row(
                    controls=[
                        ft.IconButton(ft.Icons.REMOVE, on_click=self.state.minus_click),
                        self.state.txt_number,
                        ft.IconButton(ft.Icons.ADD, on_click=self.state.plus_click),
                    ],
                    alignment=ft.MainAxisAlignment.CENTER,
                ),
                ft.ElevatedButton(
                    "Go to Home",
                    on_click=lambda _: self.pop_go("/"),
                ),
            ]
        )

🤝 Contribuciones

¡Las contribuciones son bienvenidas! Puedes enviar pull requests o sugerencias abriendo un issue en el repositorio de GitHub.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flowviewft-0.1.2.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flowviewft-0.1.2-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file flowviewft-0.1.2.tar.gz.

File metadata

  • Download URL: flowviewft-0.1.2.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for flowviewft-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f1cb255b53743ba4982561c9fe55816029fddc21a59d6412536ca44f517f7d44
MD5 bd823c6be5af12111db991e5c5aaadb2
BLAKE2b-256 e97f8fab286c5bb14c8fc991ec92683275eed4c67c7995e363f7a86d85547189

See more details on using hashes here.

File details

Details for the file flowviewft-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: flowviewft-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for flowviewft-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fd41739b2835ac37233c10be1ae79592fbe98bdae71fe8324a64f03f727e1347
MD5 45c3c1232970022aed6ebee615a195c7
BLAKE2b-256 ec362e783a49a97be1a30eb9d9909d2a4418ff044ac0e2e92adec431cd37e69b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page