Skip to content

Commit 7d51823

Browse files
authored
Merge pull request #2 from flet-dev/v1
flet-permission-handler v1
2 parents 4ead86b + 4cf91a5 commit 7d51823

26 files changed

+1063
-325
lines changed

.github/workflows/docs.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'LICENSE'
9+
- 'CHANGELOG.md'
10+
- 'docs/**'
11+
- 'mkdocs.yml'
12+
- 'pyproject.toml'
13+
- '.github/workflows/docs.yml'
14+
- 'src/flet_permission_handler/**'
15+
- 'examples/permission_handler_example/src/**'
16+
17+
workflow_dispatch: # Allow manual trigger from the GitHub Actions UI
18+
19+
concurrency:
20+
group: "docs" # Prevent multiple overlapping deploys
21+
cancel-in-progress: false # Allow in-progress deploys to finish
22+
23+
permissions:
24+
contents: write # Required to push to the gh-pages branch
25+
26+
env:
27+
GH_TOKEN: ${{ secrets.GH_TOKEN }} # Token used by mkdocs for pushing
28+
UV_SYSTEM_PYTHON: 1 # Use system Python interpreter with uv
29+
30+
jobs:
31+
deploy:
32+
name: Deploy Documentation
33+
runs-on: ubuntu-latest
34+
if: github.repository == github.event.repository.full_name # don't run on forks
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
39+
- name: Configure Git for mkdocs
40+
run: |
41+
git config user.name github-actions[bot]
42+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
43+
44+
- name: Install uv
45+
uses: astral-sh/setup-uv@v6
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version-file: "pyproject.toml" # Match Python version with project config
51+
52+
- name: Install dependencies
53+
run: |
54+
uv pip install -e .
55+
uv pip install --group docs
56+
57+
- name: Deploy to GitHub Pages
58+
run: uv run mkdocs gh-deploy --force

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
build/
33
develop-eggs/
44
dist/
5-
.DS_store
5+
.DS_store
6+
.venv/

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
repos:
2+
- repo: https://github.com/pycqa/isort
3+
rev: 5.13.2
4+
hooks:
5+
- id: isort
6+
- repo: https://github.com/ambv/black
7+
rev: 22.12.0
8+
hooks:
9+
- id: black

CHANGELOG.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7+
8+
## [0.2.0] - 2025-06-26
9+
10+
## Added
11+
12+
- Deployed online documentation: https://flet-dev.github.io/flet-permissionhandler/
13+
- `PermissionHandler` control new methods:
14+
- `get_status_async`
15+
- `request_async`
16+
- `open_app_settings_async`
17+
18+
### Changed
19+
20+
- Refactored `PermissionHandler` control to use `@ft.control` dataclass-style definition and switched to `Service` control type
21+
22+
### Breaking Changes
23+
24+
- Enum `PermissionType` renamed to `Permission`
25+
- `PermissionHandler` method `check_permission_async` renamed to `get_status_async`, with parameters changed:
26+
- `of``permission` (type: `PermissionType``Permission`)
27+
- `wait_timeout``timeout`
28+
- `PermissionHandler` method `request_permission_async` renamed to `request_async`, with parameters changed:
29+
- `of``permission` (type: `PermissionType``Permission`)
30+
- `wait_timeout``timeout`
31+
- `PermissionHandler` method `open_app_settings_async` parameter `wait_timeout` renamed to `timeout` (type: `Optional[float]``int`)
32+
- Removed sync methods from `PermissionHandler`:
33+
- `check_permission` → use `get_status_async` instead
34+
- `request_permission` → use `request_async` instead
35+
- `open_app_settings` → use `open_app_settings_async` instead
36+
- `PermissionHandler` must now be added to `Page.services` before being used instead of `Page.overlay`.
37+
- `PermissionHandler` can now only be used on the following platforms: Windows, iOS, Android, and Web. A `FletUnimplementedPlatformEception` will be raised if used on unsupported platforms.
38+
39+
## [0.1.0] - 2025-01-15
40+
41+
Initial release.
42+
43+
44+
[0.2.0]: https://github.com/flet-dev/flet-permission-handler/compare/0.1.0...0.2.0
45+
[0.1.0]: https://github.com/flet-dev/flet-permission-handler/releases/tag/0.1.0

README.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
# PermissionHandler control for Flet
1+
# flet-permission-handler
22

3-
`PermissionHandler` control for Flet.
3+
[![pypi](https://img.shields.io/pypi/v/flet-permission-handler.svg)](https://pypi.python.org/pypi/flet-permission-handler)
4+
[![downloads](https://static.pepy.tech/badge/flet-permission-handler/month)](https://pepy.tech/project/flet-permission-handler)
5+
[![license](https://img.shields.io/github/license/flet-dev/flet-permission-handler.svg)](https://github.com/flet-dev/flet-permission-handler/blob/main/LICENSE)
46

5-
## Usage
7+
A [Flet](https://flet.dev) extension that simplifies working with device permissions.
68

7-
Add `flet-permission-handler` as dependency (`pyproject.toml` or `requirements.txt`) to your Flet project.
9+
It is based on the [permission_handler](https://pub.dev/packages/permission_handler) Flutter package
10+
and brings similar functionality to Flet, including:
811

9-
## Example
12+
- Requesting permissions at runtime
13+
- Checking the current permission status (e.g., granted, denied)
14+
- Redirecting users to system settings to manually grant permissions
1015

11-
```py
16+
## Documentation
1217

13-
import flet as ft
18+
Detailed documentation to this package can be found [here](https://flet-dev.github.io/flet-permission-handler/).
1419

15-
import flet_permission_handler as fph
20+
## Platform Support
1621

22+
This package supports the following platforms:
1723

18-
def main(page: ft.Page):
19-
page.scroll = ft.ScrollMode.ADAPTIVE
20-
page.appbar = ft.AppBar(title=ft.Text("PermissionHandler Tests"))
21-
ph = fph.PermissionHandler()
22-
page.overlay.append(ph)
24+
| Platform | Supported |
25+
|----------|:---------:|
26+
| Windows ||
27+
| macOS ||
28+
| Linux ||
29+
| iOS ||
30+
| Android ||
31+
| Web ||
2332

24-
def check_permission(e):
25-
o = ph.check_permission(e.control.data)
26-
page.add(ft.Text(f"Checked {e.control.data.name}: {o}"))
33+
## Installation
2734

28-
def request_permission(e):
29-
o = ph.request_permission(e.control.data)
30-
page.add(ft.Text(f"Requested {e.control.data.name}: {o}"))
35+
To install the `flet-permission-handler` package and add it to your project dependencies:
3136

32-
def open_app_settings(e):
33-
o = ph.open_app_settings()
34-
page.add(ft.Text(f"App Settings: {o}"))
37+
- Using `uv`:
38+
```bash
39+
uv add flet-permission-handler
40+
```
3541

36-
page.add(
37-
ft.OutlinedButton(
38-
"Check Microphone Permission",
39-
data=fph.PermissionType.MICROPHONE,
40-
on_click=check_permission,
41-
),
42-
ft.OutlinedButton(
43-
"Request Microphone Permission",
44-
data=fph.PermissionType.MICROPHONE,
45-
on_click=request_permission,
46-
),
47-
ft.OutlinedButton(
48-
"Open App Settings",
49-
on_click=open_app_settings,
50-
),
51-
)
42+
- Using `pip`:
43+
```bash
44+
pip install flet-permission-handler
45+
```
46+
After this, you will have to manually add this package to your `requirements.txt` or `pyproject.toml`.
5247

48+
- Using `poetry`:
49+
```bash
50+
poetry add flet-permission-handler
51+
```
5352

54-
ft.app(main)
55-
```
53+
## Examples
54+
55+
For examples, see [this](./examples)

docs/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Changelog
3+
---
4+
5+
--8<-- "CHANGELOG.md"

docs/images/favicon.ico

15 KB
Binary file not shown.

docs/images/logo.svg

Lines changed: 19 additions & 0 deletions
Loading

docs/index.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# flet-permission-handler
2+
3+
[![pypi](https://img.shields.io/pypi/v/flet-permission-handler.svg)](https://pypi.python.org/pypi/flet-permission-handler)
4+
[![downloads](https://static.pepy.tech/badge/flet-permission-handler/month)](https://pepy.tech/project/flet-permission-handler)
5+
[![license](https://img.shields.io/github/license/flet-dev/flet-permission-handler.svg)](https://github.com/flet-dev/flet-permission-handler/blob/main/LICENSE)
6+
7+
A [Flet](https://flet.dev) extension that simplifies working with device permissions.
8+
9+
It is based on the [permission_handler](https://pub.dev/packages/permission_handler) Flutter package
10+
and brings similar functionality to Flet, including:
11+
12+
- Requesting permissions at runtime
13+
- Checking the current permission status (e.g., granted, denied)
14+
- Redirecting users to system settings to manually grant permissions
15+
16+
## Platform Support
17+
18+
This package supports the following platforms:
19+
20+
| Platform | Supported |
21+
|----------|:---------:|
22+
| Windows ||
23+
| macOS ||
24+
| Linux ||
25+
| iOS ||
26+
| Android ||
27+
| Web ||
28+
29+
## Usage
30+
31+
### Installation
32+
33+
To install the `flet-permission-handler` package and add it to your project dependencies:
34+
35+
=== "uv"
36+
```bash
37+
uv add flet-permission-handler
38+
```
39+
40+
=== "pip"
41+
```bash
42+
pip install flet-permission-handler # (1)!
43+
```
44+
45+
1. After this, you will have to manually add this package to your `requirements.txt` or `pyproject.toml`.
46+
47+
=== "poetry"
48+
```bash
49+
poetry add flet-permission-handler
50+
```
51+
52+
### Declaring Permissions
53+
54+
Ensure that your app has the necessary [permissions declared](https://flet.dev/docs/publish#permissions).
55+
56+
## Example
57+
58+
```python title="main.py"
59+
--8<-- "examples/permission_handler_example/src/main.py"
60+
```
61+
62+
1. The [`PermissionHandler`][(p).] instance must be added to the
63+
[`Page.services`](https://flet.dev/docs/controls/page#services) list to work properly.

docs/license.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```
2+
--8<-- "LICENSE"
3+
```

0 commit comments

Comments
 (0)