Skip to content

Commit 2a56423

Browse files
authored
v1: Remove _async suffix from all methods, remove fire-n-forget counterparts, code improvements (#5)
* remove fire-and-forget methods | remove _async in methods name * updates
1 parent 23ce2b7 commit 2a56423

File tree

14 files changed

+70
-42
lines changed

14 files changed

+70
-42
lines changed

.ci/patch_pubspec_version.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# /// script
2+
# dependencies = ["pyyaml"]
3+
# ///
4+
15
import os
26
import pathlib
37
import sys
@@ -17,7 +21,7 @@
1721
"flet",
1822
]
1923

20-
with open(pubspec_path, "r") as f:
24+
with open(pubspec_path) as f:
2125
data = yaml.safe_load(f)
2226

2327
# patch version

.ci/patch_toml_version.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# /// script
2+
# dependencies = ["tomlkit"]
3+
# ///
4+
15
import os
26
import pathlib
37
import sys
@@ -14,7 +18,7 @@
1418
print(f"Patching TOML file {toml_path} to {ver}")
1519

1620
# read
17-
with open(toml_path, "r") as f:
21+
with open(toml_path) as f:
1822
t = tomlkit.parse(f.read())
1923

2024
# patch version

.docstr.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
paths: src/flet_permission_handler
2+
badge: ./docs/assets/badges/docs-coverage.svg
3+
skip_file_doc: True
4+
skip_private: False
5+
ignore_patterns: # Dict with key/value pairs of file-pattern/node-pattern
6+
.*: __post_init__ # Ignore __post_init__ in all files
7+
fail_under: 50

.github/workflows/docs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
- dev
87
paths:
98
- 'LICENSE'
109
- 'CHANGELOG.md'

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ This package supports the following platforms:
3030
| Android ||
3131
| Web ||
3232

33-
## Installation
33+
## Usage
34+
35+
### Installation
3436

3537
To install the `flet-permission-handler` package and add it to your project dependencies:
3638

@@ -50,6 +52,6 @@ To install the `flet-permission-handler` package and add it to your project depe
5052
poetry add flet-permission-handler
5153
```
5254

53-
## Examples
55+
### Examples
5456

55-
For examples, see [this](./examples)
57+
For examples, see [these](./examples).

appveyor.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,20 @@ image: ubuntu
33
version: '0.1.{build}'
44

55
environment:
6+
PYTHON_VERSION: 3.12
67
UV_PUBLISH_TOKEN:
78
secure: 174ncAbF5IjSIkmioPt62jeSnzmTlRNchUkE4QdjDWH8xK1olYtySXLJpo2q95HcP7lWJky1hv4APESiRRHnBWoY0XRFafzM/mbCDMzG1tZXiXZmpP1qzHAtRP2QSCIg18xh1TMktraUdTi7sbJnjjRhqzgbW1k0kLBxKw79MPFBhYQ/TiGcmaYWZbWVZNY3HCUCb6Dt7bG1OE2Ul9rD1gvs55xwO9Oq9FOVA1VnMYw=
89

9-
stack:
10-
- python 3.12
11-
1210
install:
1311
- source .ci/update_build_version.sh
14-
- python --version
15-
- python -m ensurepip --upgrade
16-
- pip3 install --upgrade tomlkit pyyaml
1712
- curl -LsSf https://astral.sh/uv/install.sh | sh
18-
- export PATH=$HOME/.local/bin:$PATH
13+
- export PATH="$HOME/.local/bin:$PATH"
14+
- uv python install $PYTHON_VERSION
15+
- uv python pin $PYTHON_VERSION
1916

2017
build_script:
21-
- python .ci/patch_toml_version.py pyproject.toml $PYPI_VER
22-
- python .ci/patch_pubspec_version.py src/flutter/flet_*/pubspec.yaml $PKG_VER
18+
- uv run .ci/patch_toml_version.py pyproject.toml $PYPI_VER
19+
- uv run .ci/patch_pubspec_version.py src/flutter/flet_*/pubspec.yaml $PKG_VER
2320
- (cd src/flutter/* && dart pub get && dart analyze && cd -)
2421
- uv build
2522

@@ -32,4 +29,4 @@ deploy_script:
3229
artifacts:
3330
- path: dist/*.whl
3431

35-
test: off
32+
test: off

docs/index.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ To install the `flet-permission-handler` package and add it to your project depe
5151

5252
### Declaring Permissions
5353

54-
Ensure that your app has the necessary [permissions declared](https://flet.dev/docs/publish#permissions).
54+
On mobile platforms, while the permissions are being requested during runtime,
55+
you'll still need to tell the respective OS which permissions your app
56+
might potentially use.
5557

56-
## Example
58+
See [this guide](https://flet.dev/docs/publish#permissions) on how to declare permissions.
5759

58-
```python title="main.py"
59-
--8<-- "examples/permission_handler_example/src/main.py"
60-
```
60+
### Examples
6161

62-
1. The [`PermissionHandler`][flet_permission_handler.permission_handler.PermissionHandler] instance must be added to the
63-
[`Page.services`][flet.Page.services] list to work properly.
62+
See [these](permission_handler.md#examples).

docs/permission_handler.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
::: flet_permission_handler.permission_handler.PermissionHandler
1+
## Examples
2+
3+
### Example 1
4+
5+
```python title="example_1.py"
6+
--8<-- "examples/permission_handler_example/src/example_1.py"
7+
```
8+
9+
1. The [`PermissionHandler`][flet_permission_handler.permission_handler.PermissionHandler] instance must be added to the
10+
[`Page.services`][flet.Page.services] list to work properly.
11+
12+
::: flet_permission_handler.permission_handler.PermissionHandler

examples/permission_handler_example/src/main.py renamed to examples/permission_handler_example/src/example_1.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ def show_snackbar(message: str):
1010
page.show_dialog(ft.SnackBar(ft.Text(message)))
1111

1212
async def get_permission_status(e: ft.Event[ft.OutlinedButton]):
13-
status = await p.get_status_async(fph.Permission.MICROPHONE)
13+
status = await p.get_status(fph.Permission.MICROPHONE)
1414
show_snackbar(f"Microphone permission status: {status.name}")
1515

1616
async def request_permission(e: ft.Event[ft.OutlinedButton]):
17-
status = await p.request_async(fph.Permission.MICROPHONE)
17+
status = await p.request(fph.Permission.MICROPHONE)
1818
show_snackbar(f"Requested microphone permission: {status.name}")
1919

2020
async def open_app_settings(e: ft.Event[ft.OutlinedButton]):
2121
show_snackbar("Opening app settings...")
22-
await p.open_app_settings_async()
22+
await p.open_app_settings()
2323

2424
p = fph.PermissionHandler()
2525
page.services.append(p) # (1)!

mkdocs.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ plugins:
109109
alias_type: symlink
110110
- glightbox
111111
- section-index
112+
- external-images:
113+
mappings:
114+
- source_dir: examples
115+
target_url_path: examples
116+
include_exts: [ ".png", ".gif", ".svg" ]
112117
- mkdocstrings:
113118
default_handler: python_xref
114119
handlers:
@@ -134,7 +139,6 @@ plugins:
134139
preload_modules: [ flet ]
135140
filters:
136141
- "!^_" # Exclude private members starting with only one underscore
137-
- "!get_event_field_type"
138142
extensions:
139143
- griffe_modernized_annotations
140144
- griffe_warnings_deprecated
@@ -185,3 +189,4 @@ markdown_extensions:
185189
- pymdownx.tasklist:
186190
custom_checkbox: true
187191
- pymdownx.tilde
192+
- pymdownx.blocks.caption

0 commit comments

Comments
 (0)