Metadata-Version: 2.3
Name: flet-model
Version: 0.1.3
Summary: A Model-based router for Flet applications that simplifies the creation of multi-page applications
Project-URL: Homepage, https://github.com/fasilwdr/Flet-Model
Project-URL: Documentation, https://github.com/fasilwdr/Flet-Model#readme
Project-URL: Repository, https://github.com/fasilwdr/Flet-Model.git
Project-URL: Issues, https://github.com/fasilwdr/Flet-Model/issues
Project-URL: Changelog, https://github.com/fasilwdr/Flet-Model/releases
Author-email: Fasil <fasilwdr@hotmail.com>
License: MIT License
        
        Copyright (c) 2024 Fasil
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Keywords: flet,framework,gui,model,mvc,navigation,router,ui
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: User Interfaces
Requires-Python: >=3.7
Requires-Dist: flet>=0.10.0
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: build; extra == 'dev'
Requires-Dist: flake8; extra == 'dev'
Requires-Dist: isort; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: sphinx; extra == 'dev'
Requires-Dist: sphinx-rtd-theme; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Description-Content-Type: text/markdown

# Flet Model

A Model-based router for Flet applications that simplifies the creation of multi-page applications.

## Installation

```bash
pip install flet-model
```

## Usage

Here's a simple example of how to use Flet Model:

```python
import flet as ft
from flet_model import Model, Router


class First(Model):
    route = 'first'
    vertical_alignment = ft.MainAxisAlignment.CENTER
    horizontal_alignment = ft.CrossAxisAlignment.CENTER

    appbar = ft.AppBar(
        title=ft.Text("First View"),
        center_title=True,
        bgcolor=ft.Colors.SURFACE)
    controls = [
        ft.ElevatedButton("Go to Second Page", on_click="go_second")
    ]

    def go_second(self, e):
        self.page.go('/first/second')


class Second(Model):
    route = 'second'
    title = "Test"
    vertical_alignment = ft.MainAxisAlignment.CENTER
    horizontal_alignment = ft.CrossAxisAlignment.CENTER

    appbar = ft.AppBar(
        title=ft.Text("Second View"),
        center_title=True,
        bgcolor=ft.Colors.SURFACE)
    controls = [
        ft.ElevatedButton("Go to First", on_click="go_first")
    ]

    def go_first(self, e):
        self.page.go('first')


def main(page: ft.Page):
    page.title = "Title"
    page.theme_mode = "light"
    # Initialize router with route mappings
    Router(
        {'first': First(page)},
        {'second': Second(page)}
    )

    page.go(page.route)


ft.app(target=main)
```

## Features

- Model-based view definition
- Automatic route handling
- Event binding
- Support for nested routes
- Easy navigation between views
- View caching for improved performance
- Comprehensive UI component configuration (AppBar, BottomAppBar, FAB, etc.)
- Auto-binding of event handlers with caching
- Thread-safe initialization hooks (init and post_init)
- Support for overlay controls
- Customizable layout properties (alignment, padding, spacing)
- Keyboard event handling
- Scroll event handling
- Flexible control definition (static list or callable)
- Built-in view state management
- Navigation drawer support (both start and end)
- Built-in support for fullscreen dialogs

## License

This project is licensed under the MIT License.