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
140 changes: 140 additions & 0 deletions docs/controls/dismissible.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
---
title: Dismissible
sidebar_label: Dismissible
slug: dismissible
---

A control that can be dismissed by dragging in the indicated `dismiss_direction`.
When dragged or flung in the specified `dismiss_direction`, it's content smoothly slides out of view.

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

## Examples

[//]: # ([Live example](https://flet-controls-gallery.fly.dev/controls/dismissible))

### Dismissible ListView Tiles

<Tabs groupId="language">
<TabItem value="python" label="Python" default>

```python
import flet as ft


def main(page):
page.window_height, page.window_width = 370, 150

def handle_dismiss(e):
lv.controls.remove(e.control)
page.update()

def handle_update(e):
print("update")

def handle_resize(e):
print("resize")

page.add(
lv := ft.ListView(
controls=[
ft.Dismissible(
content=ft.ListTile(title=ft.Text(f"Item {i}")),
dismiss_direction=ft.DismissDirection.HORIZONTAL,
background=ft.Container(bgcolor=ft.colors.GREEN),
secondary_background=ft.Container(bgcolor=ft.colors.RED),
on_dismiss=handle_dismiss,
on_update=handle_update,
on_resize=handle_resize,
dismiss_thresholds={
ft.DismissDirection.HORIZONTAL: 0.1,
ft.DismissDirection.START_TO_END: 0.1
}
)
for i in range(5)
]
)
)


ft.app(target=main)
```
</TabItem>
</Tabs>

<img src="/img/docs/controls/dismissible/dismissible-listview.gif" className="screenshot-40"/>

## Properties

### `background`

A Control that is stacked behind the `content`.

If `secondary_background` is also specified, then this control only appears when the content has been dragged down or to the right.

### `content`

A child Control contained by the Dismissible.

### `cross_axis_end_offset`

Specifies the end offset along the main axis once the card has been dismissed.

If non-zero value is given then widget moves in cross direction depending on whether it is positive or negative.

### `direction`

The direction in which the control can be dismissed. Specified using the `DismissDirection` enum:

- `DismissDirection.UP`
- `DismissDirection.DOWN`
- `DismissDirection.LEFT`
- `DismissDirection.RIGHT`
- `DismissDirection.START_TO_END`
- `DismissDirection.END_TO_START`

### `dismiss_thresholds`

The offset threshold the item has to be dragged in order to be considered dismissed.

Ex: a threshold of `0.4` (the default) means that the item has to be dragged _at least_ 40% in order for it to be dismissed.

It is specified as a dictionary where the key is of type `DismissDirection` and the value is the threshold(fractional/decimal value between `0.0` and `1.0`).:

```python
ft.Dismissible(
# ...
dismiss_thresholds={
ft.DismissDirection.VERTICAL: 0.1,
ft.DismissDirection.START_TO_END: 0.7
}
)
```

### `movement_duration`

The duration for card to dismiss or to come back to original position if not dismissed.

### `resize_duration`

The amount of time the control will spend contracting before `on_dismiss` is called.

### `secondary_background`

A control that is stacked behind the `content` and is exposed when the `content` has been dragged up or to the left.
It may only be specified when `background` has also been specified.

## Events

### `on_dismiss`

Fires when this control has been dismissed, after finishing resizing.

### `on_resize`

Fires when this control changes size, for example, when contracting before being dismissed.

### `on_update`

Fires when this control has been dragged.
29 changes: 28 additions & 1 deletion docs/controls/switch.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ To configure thumb color for all Material states set `thumb_color` value to a li
sw.thumb_color=ft.colors.GREEN
```

To configure thumb color for specific Material states set its value to a dictionary where the key is state name. For example, to configure different fill colors for `HOVERED` and `FOCUSED` states and another color for all other states:
To configure thumb's color for specific Material states set its value to a dictionary where the key is state name. For example, to configure different fill colors for `HOVERED` and `FOCUSED` states and another color for all other states:

```python
sw.thumb_color={
Expand All @@ -142,6 +142,33 @@ sw.thumb_color={
}
```

### `thumb_icon`

The icon of this Switch's thumb.

Resolved in the following `MaterialState` states:

* `SELECTED`
* `HOVERED`
* `FOCUSED`
* `DISABLED`
* `DEFAULT` - fallback state, meaning "all other states".

To configure thumb color for all Material states set `thumb_icon` value to a literal, for example:

```python
sw.thumb_icon=ft.icons.CHECK
```

To configure thumb's icon for specific Material states set its value to a dictionary where the key is state name. For example, to configure different icons for `SELECTED` and `DISABLED` states and another icon for all other states:

```python
sw.thumb_icon={
ft.MaterialState.SELECTED: ft.icons.CHECK,
ft.MaterialState.DISABLED: ft.icons.CLOSE,
}
```

### `track_color`

The [color](/docs/guides/python/colors) of this Switch's track.
Expand Down
2 changes: 1 addition & 1 deletion docs/controls/transparentpointer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_label: TransparentPointer
slug: transparentpointer
---

TransparentPointer is the solution to ["How to pass trough all gestures between two widgets in Stack"](https://stackoverflow.com/questions/65269190/pass-trough-all-gestures-between-two-widgets-in-stack) problem.
TransparentPointer is the solution to ["How to pass through all gestures between two widgets in Stack"](https://stackoverflow.com/questions/65269190/pass-trough-all-gestures-between-two-widgets-in-stack) problem.

For example, if there is an `ElevatedButton` inside `Container` with `GestureDetector` then tapping on a button won't be "visible" to a gesture detector behind it. With `TransparentPointer` a tapping event doesn't stop on a button, but goes up to the parent, similar to event bubbling in HTML/JS.

Expand Down
2 changes: 1 addition & 1 deletion src/pages/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ New controls:
* [Location](https://github.com/flet-dev/flet/issues/66)
* [Map](https://github.com/flet-dev/flet/issues/1193)
* [Google Mobile Ads](https://github.com/flet-dev/flet/issues/286)
* [Dismissable](https://github.com/flet-dev/flet/issues/482)
* :white_check_mark: [Dismissible](https://github.com/flet-dev/flet/issues/482)
* [InAppPurchase](https://github.com/flet-dev/flet/issues/853)
* [TreeView](https://github.com/flet-dev/flet/issues/961)
* [DropdownMenu](https://github.com/flet-dev/flet/issues/1088)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.