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
58 changes: 58 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: docs

on:
push:
branches:
- main
paths:
- 'LICENSE'
- 'CHANGELOG.md'
- 'docs/**'
- 'mkdocs.yml'
- 'pyproject.toml'
- '.github/workflows/docs.yml'
- 'src/flet_flashlight/**'
- 'examples/flashlight_example/src/**'

workflow_dispatch: # Allow manual trigger from the GitHub Actions UI

concurrency:
group: "docs" # Prevent multiple overlapping deploys
cancel-in-progress: false # Allow in-progress deploys to finish

permissions:
contents: write # Required to push to the gh-pages branch

env:
GH_TOKEN: ${{ secrets.GH_TOKEN }} # Token used by mkdocs for pushing
UV_SYSTEM_PYTHON: 1 # Use system Python interpreter with uv

jobs:
deploy:
name: Deploy Documentation
runs-on: ubuntu-latest
if: github.repository == github.event.repository.full_name # don't run on forks
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Configure Git for mkdocs
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml" # Match Python version with project config

- name: Install dependencies
run: |
uv pip install -e .
uv pip install --group docs

- name: Deploy to GitHub Pages
run: uv run mkdocs gh-deploy --force
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
build/
develop-eggs/
dist/
.DS_store
.DS_store
.venv/
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/ambv/black
rev: 22.12.0
hooks:
- id: black
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.2.0] - 2025-06-26

## Added

- Deployed online documentation: https://flet-dev.github.io/flet-flashlight/
- `Flashlight` control new properties: `on`, `on_error`
- `Flashlight` control new methods: `is_available_async`
- New exception classes:
- `FlashlightException`
- `FlashlightEnableExistentUserException`
- `FlashlightEnableNotAvailableException`
- `FlashlightEnableException`
- `FlashlightDisableExistentUserException`
- `FlashlightDisableNotAvailableException`
- `FlashlightDisableException`

### Changed

- Refactored `Flashlight` control to use `@ft.control` dataclass-style definition and switched to `Service` control type.
- `Flashlight` must now be added to `Page.services` instead of `Page.overlay` due to control type change.

## [0.1.0] - 2025-01-15

Initial release.


[0.2.0]: https://github.com/flet-dev/flet-flashlight/compare/0.1.0...0.2.0
[0.1.0]: https://github.com/flet-dev/flet-flashlight/releases/tag/0.1.0
53 changes: 37 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
# Flashlight control for Flet
# flet-flashlight

`Flashlight` control for Flet.
[![pypi](https://img.shields.io/pypi/v/flet-flashlight.svg)](https://pypi.python.org/pypi/flet-flashlight)
[![downloads](https://static.pepy.tech/badge/flet-flashlight/month)](https://pepy.tech/project/flet-flashlight)
[![license](https://img.shields.io/github/license/flet-dev/flet-flashlight.svg)](https://github.com/flet-dev/flet-flashlight/blob/main/LICENSE)

## Usage
A [Flet](https://flet.dev) extension to manage the device torch/flashlight.

Add `flet-flashlight` as dependency (`pyproject.toml` or `requirements.txt`) to your Flet project.
It is based on the [flashlight](https://pub.dev/packages/flashlight) Flutter package.

## Example
## Documentation

```py
Detailed documentation to this package can be found [here](https://flet-dev.github.io/flet-flashlight/).

import flet as ft
## Platform Support

import flet_flashlight as ffl
This package supports the following platforms:

def main(page: ft.Page):
flashlight = ffl.Flashlight()
page.overlay.append(flashlight)
page.add(
ft.TextButton("toggle", on_click=lambda _: flashlight.toggle())
)
| Platform | Supported |
|----------|:---------:|
| Windows | ❌ |
| macOS | ❌ |
| Linux | ❌ |
| iOS | ✅ |
| Android | ✅ |
| Web | ❌ |

ft.app(main)
```
## Installation

To install the `flet-flashlight` package and add it to your project dependencies:

- Using `uv`:
```bash
uv add flet-flashlight
```

- Using `pip`:
```bash
pip install flet-flashlight
```
After this, you will have to manually add this package to your `requirements.txt` or `pyproject.toml`.

- Using `poetry`:
```bash
poetry add flet-flashlight
```
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Changelog
---

--8<-- "CHANGELOG.md"
1 change: 1 addition & 0 deletions docs/exceptions/flashlight_disable_exception.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: flet_flashlight.exceptions.FlashlightDisableException
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: flet_flashlight.exceptions.FlashlightDisableExistentUserException
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: flet_flashlight.exceptions.FlashlightDisableNotAvailableException
1 change: 1 addition & 0 deletions docs/exceptions/flashlight_enable_exception.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: flet_flashlight.exceptions.FlashlightEnableException
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: flet_flashlight.exceptions.FlashlightEnableExistentUserException
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: flet_flashlight.exceptions.FlashlightEnableNotAvailableException
1 change: 1 addition & 0 deletions docs/exceptions/flashlight_exception.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: flet_flashlight.exceptions.FlashlightException
1 change: 1 addition & 0 deletions docs/flashlight.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: flet_flashlight.flashlight.Flashlight
Binary file added docs/images/favicon.ico
Binary file not shown.
19 changes: 19 additions & 0 deletions docs/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# flet-flashlight

[![pypi](https://img.shields.io/pypi/v/flet-flashlight.svg)](https://pypi.python.org/pypi/flet-flashlight)
[![downloads](https://static.pepy.tech/badge/flet-flashlight/month)](https://pepy.tech/project/flet-flashlight)
[![license](https://img.shields.io/github/license/flet-dev/flet-flashlight.svg)](https://github.com/flet-dev/flet-flashlight/blob/main/LICENSE)

A [Flet](https://flet.dev) extension to manage the device torch/flashlight.

It is based on the [flashlight](https://pub.dev/packages/flashlight) Flutter package.

## Platform Support

This package supports the following platforms:

| Platform | Supported |
|----------|:---------:|
| Windows | ❌ |
| macOS | ❌ |
| Linux | ❌ |
| iOS | ✅ |
| Android | ✅ |
| Web | ❌ |

## Usage

### Installation

To install the `flet-flashlight` package and add it to your project dependencies:

=== "uv"
```bash
uv add flet-flashlight
```

=== "pip"
```bash
pip install flet-flashlight # (1)!
```

1. After this, you will have to manually add this package to your `requirements.txt` or `pyproject.toml`.

=== "poetry"
```bash
poetry add flet-flashlight
```


## Example

```python title="main.py"
--8<-- "examples/flashlight_example/src/main.py"
```
3 changes: 3 additions & 0 deletions docs/license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```
--8<-- "LICENSE"
```
28 changes: 8 additions & 20 deletions examples/flashlight_example/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
[project]
name = "flashlight_example"
name = "flet-flashlight-example"
version = "1.0.0"
description = ""
description = "flet-flashlight-example"
readme = "README.md"
requires-python = ">=3.8"
license = "Apache-2.0"
requires-python = ">=3.10"
dependencies = [
"flet-flashlight @ git+https://github.com/flet-dev/flet-flashlight.git",
"flet>=0.25.2",
"flet-flashlight",
"flet",
]


# Docs: https://flet.dev/docs/publish
[tool.flet]
# org name in reverse domain name notation, e.g. "com.mycompany".
# Combined with project.name to build bundle ID for iOS and Android apps
org = "com.mycompany"

# project display name that is used as an app title on Android and iOS home screens,
# shown in window titles and about app dialogs on desktop.
product = "Flet Flashlight Example"

# company name to display in about app dialogs
product = "flet-flashlight-example"
company = "Flet"

# copyright text to display in about app dialogs
copyright = "Copyright (C) 2024 by Flet"

[tool.flet.app]
path = "src"

[tool.uv]
dev-dependencies = [
"flet[all]>=0.25.2",
]
11 changes: 6 additions & 5 deletions examples/flashlight_example/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import flet_flashlight as ffl


def main(page: ft.Page):
flashlight = ffl.Flashlight()
page.overlay.append(flashlight)
page.add(
ft.TextButton("toggle", on_click=lambda _: flashlight.toggle())
)
page.services.append(flashlight)

page.add(ft.TextButton("toggle", on_click=lambda _: flashlight.toggle()))


ft.app(main)
ft.run(main)
Loading