Skip to content
Open
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
18 changes: 13 additions & 5 deletions packages/flet/lib/src/controls/bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class _BottomSheetControlState extends State<BottomSheetControl> {

var maintainBottomViewInsetsPadding =
widget.control.getBool("maintain_bottom_view_insets_padding", true)!;
final fullscreen = widget.control.getBool("fullscreen", false)!;
final scrollable =
fullscreen || widget.control.getBool("scrollable", false)!;
final draggable = widget.control.getBool("draggable", false)!;

if (open && !lastOpen) {
widget.control.updateProperties({"_open": open}, python: false);
Expand All @@ -53,19 +57,23 @@ class _BottomSheetControlState extends State<BottomSheetControl> {
);
}

if (fullscreen) {
content = SizedBox.expand(child: content);
}

return content;
},
isDismissible: widget.control.getBool("dismissible", true)!,
backgroundColor: widget.control.getColor("bgcolor", context),
elevation: widget.control.getDouble("elevation"),
isScrollControlled:
widget.control.getBool("scroll_controlled", false)!,
enableDrag: widget.control.getBool("enable_drag", false)!,
isScrollControlled: scrollable,
enableDrag: draggable,
barrierColor: widget.control.getColor("barrier_color", context),
sheetAnimationStyle:
widget.control.getAnimationStyle("animation_style"),
constraints:
widget.control.getBoxConstraints("size_constraints"),
constraints: fullscreen
? null
: widget.control.getBoxConstraints("size_constraints"),
showDragHandle:
widget.control.getBool("show_drag_handle", false)!,
clipBehavior: widget.control.getClipBehavior("clip_behavior"),
Expand Down
22 changes: 17 additions & 5 deletions packages/flet/lib/src/controls/cupertino_activity_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,23 @@ class CupertinoActivityIndicatorControl extends StatelessWidget {
@override
Widget build(BuildContext context) {
debugPrint("CupertinoActivityIndicatorControl build: ${control.id}");
final activityIndicator = CupertinoActivityIndicator(
radius: control.getDouble("radius", 10)!,
animating: control.getBool("animating", true)!,
color: control.getColor("color", context),
);
final radius = control.getDouble("radius", 10)!;
final color = control.getColor("color", context);
final progress = control.getDouble("progress");
final bool animating =
progress == null ? control.getBool("animating", true)! : false;

final activityIndicator = progress != null
? CupertinoActivityIndicator.partiallyRevealed(
radius: radius,
color: color,
progress: progress,
)
: CupertinoActivityIndicator(
radius: radius,
animating: animating,
color: color,
);
return LayoutControl(control: control, child: activityIndicator);
}
}
2 changes: 1 addition & 1 deletion packages/flet/lib/src/controls/date_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class _DatePickerControlState extends State<DatePickerControl> {
initialCalendarMode: widget.control
.getDatePickerMode("date_picker_mode", DatePickerMode.day)!,
initialEntryMode: widget.control.getDatePickerEntryMode(
"date_picker_entry_mode", DatePickerEntryMode.calendar)!,
"entry_mode", DatePickerEntryMode.calendar)!,
fieldHintText: widget.control.getString("field_hint_text"),
fieldLabelText: widget.control.getString("field_label_text"),
onDatePickerModeChange: (DatePickerEntryMode mode) {
Expand Down
2 changes: 1 addition & 1 deletion packages/flet/lib/src/controls/date_range_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class _DateRangePickerControlState extends State<DateRangePickerControl> {
keyboardType: parseTextInputType(
widget.control.getString("keyboard_type"), TextInputType.text)!,
initialEntryMode: widget.control.getDatePickerEntryMode(
"date_picker_entry_mode", DatePickerEntryMode.calendar)!,
"entry_mode", DatePickerEntryMode.calendar)!,
switchToCalendarEntryModeIcon: switchToCalendarEntryModeIcon != null
? Icon(switchToCalendarEntryModeIcon)
: null,
Expand Down
Empty file.
5 changes: 3 additions & 2 deletions sdk/python/examples/controls/bottom_sheet/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def handle_sheet_dismissal(e: ft.Event[ft.BottomSheet]):
),
),
)
page.overlay.append(sheet)

page.add(
ft.Button(
content="Display bottom sheet",
Expand All @@ -31,4 +31,5 @@ def handle_sheet_dismissal(e: ft.Event[ft.BottomSheet]):
)


ft.run(main)
if __name__ == "__main__":
ft.run(main)
35 changes: 35 additions & 0 deletions sdk/python/examples/controls/bottom_sheet/fullscreen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import flet as ft


def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER

def handle_switch_change(e: ft.Event[ft.Switch]):
sheet.fullscreen = e.control.value

sheet = ft.BottomSheet(
fullscreen=True,
show_drag_handle=True,
content=ft.Container(
padding=ft.Padding.all(10),
content=ft.Column(
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
controls=[
ft.Text("This is bottom sheet's content!"),
ft.Button("Close bottom sheet", on_click=lambda: page.pop_dialog()),
],
),
),
)

page.add(
ft.Button(
content="Display bottom sheet",
on_click=lambda e: page.show_dialog(sheet),
),
ft.Switch(value=True, label="Fullscreen", on_change=handle_switch_change),
)


if __name__ == "__main__":
ft.run(main)
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import flet as ft


async def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.spacing = 20

def handle_progress_change(e: ft.Event[ft.Slider]):
indicator.progress = e.control.value

page.add(
indicator := ft.CupertinoActivityIndicator(progress=1.0, radius=40),
ft.Slider(
min=0.0,
value=indicator.progress,
max=1.0,
divisions=10,
round=1,
label="Progress = {value}",
width=400,
on_change=handle_progress_change,
),
)


ft.run(main)
2 changes: 1 addition & 1 deletion sdk/python/examples/controls/date_range_picker/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def handle_change(e: ft.Event[ft.DateRangePicker]):
ft.Text(f"End Date changed: {e.control.end_value.strftime('%m/%d/%Y')}"),
)

def handle_dismissal(e: ft.Event[ft.DialogControl]):
def handle_dismissal(e: ft.Event[ft.DateRangePicker]):
page.add(ft.Text("DatePicker dismissed"))

page.add(
Expand Down
10 changes: 8 additions & 2 deletions sdk/python/packages/flet/docs/controls/bottomsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
class_name: flet.BottomSheet
examples: ../../examples/controls/bottom_sheet
example_images: ../test-images/examples/material/golden/macos/bottom_sheet
example_media: ../examples/controls/bottom_sheet/media
---

{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic BottomSheet") }}
Expand All @@ -17,7 +16,14 @@ example_media: ../examples/controls/bottom_sheet/media
--8<-- "{{ examples }}/basic.py"
```

{{ image(example_media + "/basic.gif", alt="basic", width="80%") }}
{{ image(example_images + "/basic.gif", width="60%") }}

### Fullscreen

```python
--8<-- "{{ examples }}/fullscreen.py"
```
{{ image(example_images + "/fullscreen.gif", width="60%") }}


{{ class_members(class_name) }}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pytest

import flet as ft
import flet.testing as ftt


@pytest.mark.asyncio(loop_scope="module")
async def test_basic(flet_app: ftt.FletTestApp, request):
await flet_app.assert_control_screenshot(
request.node.name,
ft.CupertinoActivityIndicator(
radius=30,
color=ft.CupertinoColors.DARK_BACKGROUND_GRAY,
animating=False,
),
)


@pytest.mark.asyncio(loop_scope="module")
async def test_progress(flet_app: ftt.FletTestApp, request):
await flet_app.assert_control_screenshot(
request.node.name,
ft.CupertinoActivityIndicator(
radius=30,
color=ft.CupertinoColors.DARK_BACKGROUND_GRAY,
progress=0.5,
),
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@


@pytest.mark.asyncio(loop_scope="module")
async def test_bottom_sheet_basic(flet_app: ftt.FletTestApp, request):
bs = ft.BottomSheet(
async def test_basic(flet_app: ftt.FletTestApp, request):
flet_app.page.enable_screenshots = True
flet_app.resize_page(400, 600)

sheet = ft.BottomSheet(
content=ft.Container(
padding=50,
content=ft.Column(
Expand All @@ -19,14 +22,43 @@ async def test_bottom_sheet_basic(flet_app: ftt.FletTestApp, request):
),
),
)
flet_app.page.show_dialog(sheet)
flet_app.page.update()
await flet_app.tester.pump_and_settle()

flet_app.assert_screenshot(
request.node.name,
await flet_app.page.take_screenshot(
pixel_ratio=flet_app.screenshots_pixel_ratio
),
)


@pytest.mark.asyncio(loop_scope="module")
async def test_fullscreen(flet_app: ftt.FletTestApp, request):
flet_app.page.enable_screenshots = True
flet_app.resize_page(400, 600)
flet_app.page.show_dialog(bs)

sheet = ft.BottomSheet(
fullscreen=True,
content=ft.Container(
padding=50,
content=ft.Column(
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
tight=True,
controls=[
ft.Text("Here is a bottom sheet!"),
ft.Button("Dismiss", on_click=lambda _: flet_app.page.pop_dialog()),
],
),
),
)
flet_app.page.show_dialog(sheet)
flet_app.page.update()
await flet_app.tester.pump_and_settle()

flet_app.assert_screenshot(
"bottom_sheet_basic",
request.node.name,
await flet_app.page.take_screenshot(
pixel_ratio=flet_app.screenshots_pixel_ratio
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def test_properties1(flet_app: ftt.FletTestApp, request):
modal=False,
barrier_color=ft.Colors.RED,
keyboard_type=ft.KeyboardType.EMAIL,
# date_picker_entry_mode=ft.DatePickerEntryMode.CALENDAR,
# entry_mode=ft.DatePickerEntryMode.CALENDAR,
)
flet_app.page.enable_screenshots = True
flet_app.resize_page(400, 600)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@
"""

md = ft.Markdown(
value=sample1,
selectable=True,
extension_set=ft.MarkdownExtensionSet.GITHUB_WEB,
)


@pytest.mark.asyncio(loop_scope="module")
async def test_md_1(flet_app: ftt.FletTestApp, request):
md.value = sample1
await flet_app.assert_control_screenshot(
request.node.name,
md,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading