Skip to content

Commit

Permalink
0.12.1 fixes (flet-dev#2083)
Browse files Browse the repository at this point in the history
* Dismiss drawers on page change

* Fixed routing regression

Fix flet-dev#2082

* ViewControl

* Bottom sheet to use control state

Fix flet-dev#2075

* AnimatedTransitionPage

* Remove old animated pages

* Flet version bumped to 0.12.1

* Added `BottomSheet. is_scroll_controlled` property

Allows expanding bottom sheet on the entire screen.
Close flet-dev#2087

* Fixed: close currently opened AlertDialog before opening a new one

Fix flet-dev#1670

* Added `BottomSheet.maintain_bottom_view_insets_padding` property

Close flet-dev#2010
  • Loading branch information
FeodorFitsner authored and zrr1999 committed Jul 17, 2024
1 parent 9094bc9 commit ae8ec2e
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 209 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Flet changelog

# 0.12.1

* Ability to expand `ButtomSheet` to the top of the screen with `BottomSheet.is_scroll_controlled` property ([#2087](https://github.com/flet-dev/flet/issues/2087)).
* `BottomSheet.maintain_bottom_view_insets_padding` to avoid obstructing controls with on-screen keyboard ([#2010](https://github.com/flet-dev/flet/issues/2010)).
* Fixed: `NavigationDrawer` disappears when you move the window and is not opening again ([#2062](https://github.com/flet-dev/flet/issues/2062)).
* Fixed: alert dialog doesn't close ([#2011](https://github.com/flet-dev/flet/issues/2011)).
* Fixed: Resizing app's window with an opened BottomSheet triggers new addition to Overlay ([#2075](https://github.com/flet-dev/flet/issues/2075)).
* Fixed: on_window_event isnt handled after page navigation ([#2081](https://github.com/flet-dev/flet/issues/2081)).
* Fixed: Routing is not working in 0.12.0 ([#2082](https://github.com/flet-dev/flet/issues/2082)).
* Fixed: routing regression.
* Fixed: Multiple dialogs (AlertDialog) will create a ghost dialog ([#1670](https://github.com/flet-dev/flet/issues/1670)).

# 0.12.0

* `NavigationDrawer` control ([docs](https://flet.dev/docs/controls/navigationdrawer)).
Expand Down
2 changes: 1 addition & 1 deletion client/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ packages:
path: "../package"
relative: true
source: path
version: "0.12.0"
version: "0.12.1"
flutter:
dependency: "direct main"
description: flutter
Expand Down
12 changes: 12 additions & 0 deletions package/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 0.12.1

* Ability to expand `ButtomSheet` to the top of the screen with `BottomSheet.is_scroll_controlled` property ([#2087](https://github.com/flet-dev/flet/issues/2087)).
* `BottomSheet.maintain_bottom_view_insets_padding` to avoid obstructing controls with on-screen keyboard ([#2010](https://github.com/flet-dev/flet/issues/2010)).
* Fixed: `NavigationDrawer` disappears when you move the window and is not opening again ([#2062](https://github.com/flet-dev/flet/issues/2062)).
* Fixed: alert dialog doesn't close ([#2011](https://github.com/flet-dev/flet/issues/2011)).
* Fixed: Resizing app's window with an opened BottomSheet triggers new addition to Overlay ([#2075](https://github.com/flet-dev/flet/issues/2075)).
* Fixed: on_window_event isnt handled after page navigation ([#2081](https://github.com/flet-dev/flet/issues/2081)).
* Fixed: Routing is not working in 0.12.0 ([#2082](https://github.com/flet-dev/flet/issues/2082)).
* Fixed: routing regression.
* Fixed: Multiple dialogs (AlertDialog) will create a ghost dialog ([#1670](https://github.com/flet-dev/flet/issues/1670)).

# 0.12.0

* `NavigationDrawer` control ([docs](https://flet.dev/docs/controls/navigationdrawer)).
Expand Down
5 changes: 5 additions & 0 deletions package/lib/src/controls/alert_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ class _AlertDialogControlState extends State<AlertDialogControl> {
return dialog;
}

// close previous dialog
if (ModalRoute.of(context)?.isCurrent != true) {
Navigator.pop(context);
}

widget.control.state["open"] = open;

WidgetsBinding.instance.addPostFrameCallback((_) {
Expand Down
79 changes: 48 additions & 31 deletions package/lib/src/controls/bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,77 +30,94 @@ class BottomSheetControl extends StatefulWidget {
}

class _BottomSheetControlState extends State<BottomSheetControl> {
bool _open = false;

Widget _createBottomSheet() {
bool disabled = widget.control.isDisabled || widget.parentDisabled;
var contentCtrls = widget.children.where((c) => c.name == "content");

if (contentCtrls.isEmpty) {
return const ErrorControl("BottomSheet does not have a content.");
}

return createControl(widget.control, contentCtrls.first.id, disabled);
}

@override
Widget build(BuildContext context) {
debugPrint("BottomSheet build: ${widget.control.id}");

var server = FletAppServices.of(context).server;

bool lastOpen = widget.control.state["open"] ?? false;
bool disabled = widget.control.isDisabled || widget.parentDisabled;

var open = widget.control.attrBool("open", false)!;
//var modal = widget.control.attrBool("modal", true)!;
var dismissible = widget.control.attrBool("dismissible", true)!;
var enableDrag = widget.control.attrBool("enableDrag", false)!;
var showDragHandle = widget.control.attrBool("showDragHandle", false)!;
var useSafeArea = widget.control.attrBool("useSafeArea", true)!;
var isScrollControlled =
widget.control.attrBool("isScrollControlled", false)!;
var maintainBottomViewInsetsPadding =
widget.control.attrBool("maintainBottomViewInsetsPadding", true)!;

void resetOpenState() {
List<Map<String, String>> props = [
{"i": widget.control.id, "open": "false"}
];
widget.dispatch(
UpdateControlPropsAction(UpdateControlPropsPayload(props: props)));
FletAppServices.of(context).server.updateControlProps(props: props);
server.updateControlProps(props: props);
}

if (!open && _open) {
_open = false;
resetOpenState();
Navigator.pop(context);
} else if (open && !_open) {
var bottomSheet = _createBottomSheet();
if (bottomSheet is ErrorControl) {
return bottomSheet;
}

_open = open;
if (open && !lastOpen) {
widget.control.state["open"] = open;

WidgetsBinding.instance.addPostFrameCallback((_) {
showModalBottomSheet<void>(
context: context,
builder: (context) {
return bottomSheet;
var contentCtrls =
widget.children.where((c) => c.name == "content");

if (contentCtrls.isEmpty) {
return const ErrorControl(
"BottomSheet does not have a content.");
}

var content = createControl(
widget.control, contentCtrls.first.id, disabled);

if (content is ErrorControl) {
return content;
}

if (maintainBottomViewInsetsPadding) {
var bottomPadding =
MediaQuery.of(context).viewInsets.bottom;
debugPrint("bottomPadding: $bottomPadding");
content = Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom),
child: content,
);
}

return content;
},
isDismissible: dismissible,
isScrollControlled: isScrollControlled,
enableDrag: enableDrag,
showDragHandle: showDragHandle,
useSafeArea: useSafeArea)
.then((value) {
debugPrint("BottomSheet dismissed: $_open");
bool shouldDismiss = _open;
_open = false;
lastOpen = widget.control.state["open"] ?? false;
debugPrint("BottomSheet dismissed: $lastOpen");
bool shouldDismiss = lastOpen;
widget.control.state["open"] = false;

if (shouldDismiss) {
resetOpenState();
FletAppServices.of(context).server.sendPageEvent(
server.sendPageEvent(
eventTarget: widget.control.id,
eventName: "dismiss",
eventData: "");
}
});
});
} else if (open != lastOpen && lastOpen) {
Navigator.pop(context);
}

return widget.nextChild ?? const SizedBox.shrink();
return const SizedBox.shrink();
}
}
Loading

0 comments on commit ae8ec2e

Please sign in to comment.