Metadata-Version: 2.1
Name: flet-django
Version: 0.2.2
Summary: Django Flutter Framework.
Home-page: https://marysia.app
License: MIT
Author: beret
Author-email: beret@hipisi.org.pl
Maintainer: Marysia Software Limited
Maintainer-email: office@marysia.app
Requires-Python: >=3.10,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: MacOS X
Classifier: Environment :: Web Environment
Classifier: Environment :: WebAssembly
Classifier: Environment :: Win32 (MS Windows)
Classifier: Environment :: X11 Applications
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.0
Classifier: Framework :: Django :: 4.1
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Other
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Desktop Environment
Requires-Dist: django (>=4.0,<5.0)
Requires-Dist: flet
Requires-Dist: flet-core
Project-URL: Documentation, https://github.com/Marysia-Software-Limited/flet-django
Project-URL: Repository, https://github.com/Marysia-Software-Limited/flet-django
Description-Content-Type: text/markdown

# Just married!!!
# Django and Flutter.

## Rapid developing db based app. Zero boilerplate code.

I hate boilerplate code. I hated it all my life. I made so many steps to remove this mental parasites far from me. And now, with Flet and Django I'm so close to get my ideal. For this moment I made as PoC a clone of a standard Flet ToDo application. All what i change is write all directly inside of Django. Flet code is run directly on the backend, so we not need any dedicated communication layer. Next what I done is generic data table control. This is a simple control able to create a data table for any Django model. All with searching and sorting.

## Roadmap:
* [x] Create package for a framework
* [x] Create environment for generic Flutter app
  * [x] GenericApp class for a new Flutter application
  * [x] GenericPage class for a new Flutter application instance
  * [x] GenericView class to easily create routed Flutter views
  * [x] Generic middleware class for flexible management of Flutter view routing process
  * [x] UrlsMiddleware class for implementing Django urls based routing
  * [x] Generic navigation mechanism
* [ ] Create authorisation and permissions middleware
  * [ ] AuthApp for apps with authorization
  * [ ] AuthMiddleware for authorisation management
* [ ] Create generic list view for any Django model
  * [x] Generic model's, data table based, control
  * [ ] Generic form based on Django forms
* [ ] Create generic form for any Django model
* [ ] Manage relations between models
* [ ] Documentation!!!

## Instalation
- Install python package:

        $ pip install flet-django
- Add 'flet_django' to INSTALLED_APPS in settings.py:
        `INSTALLED_APPS += ['flet_django']`


## Run and usage

- Create main function in file main_app.py
    ```python
    import flet as ft
    from flet_django.pages import GenericApp

    ...

    main = GenericApp(controls=[ft.Text("Hello World!")])
    ```
- GenericApp instance is a GenericPage instances factory, can be use directly as main function for flet application.
- To run function __main__ from file __main_app.py__ use django command:

        $ python manage.py run_app

## Flutter view

- A framework based on flutter views. Flutter view is a function which takes page as a first argument, and returns instance of flet.View class.
- For simplicity we can use ft_view factory
- Let create a simple flutter view example in file main_app.py:
    ```python
    import flet as ft
    from flet_django.views import ft_view

    def home(page):
        return ft_view(
            page,
            controls=[ft.Text("Hello World!")],
            app_bar_params=dict(title="ToDo app")
        )
    ```
- Flutter view can be assigned to route by Generic App's urls parameter, or as a target for navigation:
    ```python
    import flet as ft
    from django.urls import path
    from flet_django.views import ft_view
    from flet_django.pages import GenericApp
    from flet_django.navigation import Fatum

    def home(page):
        return ft_view(
            page,
            controls=[ft.Text("Hello World!")],
            app_bar_params=dict(title="ToDo app")
        )

    destinations = [
        Fatum(
            route="/",
            icon=ft.icons.HOME,
            selected_icon=ft.icons.HOME_OUTLINED,
            label="home",
            nav_bar=True,
            action=True,
            nav_rail=False
        ),
    ]

    urlpatterns = [
        path('', home, name="home")
    ]

    main = GenericApp(
        destinations=destinations,
        urls=urlpatterns,
        init_route="/"
    )

    ```
- To run application on other devices you need establish server and build client, based on Flutter frontend project from repository
- To run app as server use --view parameter:
    ```bash
    python manage.py run_app --view flet_app_hidden
    ```
- Server will be avaible as http server, for example:
    ```bash
      open http://ala.hipisi.org.pl:8085
    ```
- Compile ./frontend futter app to have separate ready to install application:
    ```bash
      cd frontend
      flutter run --dart-entrypoint-args http://94.23.247.130:8085
    ```
- You can use simple script to run separate flutter application:
    ```bash
      python run.py
    ```

## Demo
You can run repository's project as example of usage.
Working demo [is here](http://ala.hipisi.org.pl:8085).

## Screenshots

![Android app](./todo_pixel4.png)

![iOS app](./todo_iphone14.png)

