Skip to content

Commit a31481d

Browse files
0.12.1 fixes (#2083)
* Dismiss drawers on page change * Fixed routing regression Fix #2082 * ViewControl * Bottom sheet to use control state Fix #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 #2087 * Fixed: close currently opened AlertDialog before opening a new one Fix #1670 * Added `BottomSheet.maintain_bottom_view_insets_padding` property Close #2010
1 parent 349b8b0 commit a31481d

File tree

11 files changed

+273
-209
lines changed

11 files changed

+273
-209
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Flet changelog
22

3+
# 0.12.1
4+
5+
* 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)).
6+
* `BottomSheet.maintain_bottom_view_insets_padding` to avoid obstructing controls with on-screen keyboard ([#2010](https://github.com/flet-dev/flet/issues/2010)).
7+
* Fixed: `NavigationDrawer` disappears when you move the window and is not opening again ([#2062](https://github.com/flet-dev/flet/issues/2062)).
8+
* Fixed: alert dialog doesn't close ([#2011](https://github.com/flet-dev/flet/issues/2011)).
9+
* Fixed: Resizing app's window with an opened BottomSheet triggers new addition to Overlay ([#2075](https://github.com/flet-dev/flet/issues/2075)).
10+
* Fixed: on_window_event isnt handled after page navigation ([#2081](https://github.com/flet-dev/flet/issues/2081)).
11+
* Fixed: Routing is not working in 0.12.0 ([#2082](https://github.com/flet-dev/flet/issues/2082)).
12+
* Fixed: routing regression.
13+
* Fixed: Multiple dialogs (AlertDialog) will create a ghost dialog ([#1670](https://github.com/flet-dev/flet/issues/1670)).
14+
315
# 0.12.0
416

517
* `NavigationDrawer` control ([docs](https://flet.dev/docs/controls/navigationdrawer)).

client/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ packages:
183183
path: "../package"
184184
relative: true
185185
source: path
186-
version: "0.12.0"
186+
version: "0.12.1"
187187
flutter:
188188
dependency: "direct main"
189189
description: flutter

package/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# 0.12.1
2+
3+
* 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)).
4+
* `BottomSheet.maintain_bottom_view_insets_padding` to avoid obstructing controls with on-screen keyboard ([#2010](https://github.com/flet-dev/flet/issues/2010)).
5+
* Fixed: `NavigationDrawer` disappears when you move the window and is not opening again ([#2062](https://github.com/flet-dev/flet/issues/2062)).
6+
* Fixed: alert dialog doesn't close ([#2011](https://github.com/flet-dev/flet/issues/2011)).
7+
* Fixed: Resizing app's window with an opened BottomSheet triggers new addition to Overlay ([#2075](https://github.com/flet-dev/flet/issues/2075)).
8+
* Fixed: on_window_event isnt handled after page navigation ([#2081](https://github.com/flet-dev/flet/issues/2081)).
9+
* Fixed: Routing is not working in 0.12.0 ([#2082](https://github.com/flet-dev/flet/issues/2082)).
10+
* Fixed: routing regression.
11+
* Fixed: Multiple dialogs (AlertDialog) will create a ghost dialog ([#1670](https://github.com/flet-dev/flet/issues/1670)).
12+
113
# 0.12.0
214

315
* `NavigationDrawer` control ([docs](https://flet.dev/docs/controls/navigationdrawer)).

package/lib/src/controls/alert_dialog.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ class _AlertDialogControlState extends State<AlertDialogControl> {
9494
return dialog;
9595
}
9696

97+
// close previous dialog
98+
if (ModalRoute.of(context)?.isCurrent != true) {
99+
Navigator.pop(context);
100+
}
101+
97102
widget.control.state["open"] = open;
98103

99104
WidgetsBinding.instance.addPostFrameCallback((_) {

package/lib/src/controls/bottom_sheet.dart

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,77 +30,94 @@ class BottomSheetControl extends StatefulWidget {
3030
}
3131

3232
class _BottomSheetControlState extends State<BottomSheetControl> {
33-
bool _open = false;
34-
35-
Widget _createBottomSheet() {
36-
bool disabled = widget.control.isDisabled || widget.parentDisabled;
37-
var contentCtrls = widget.children.where((c) => c.name == "content");
38-
39-
if (contentCtrls.isEmpty) {
40-
return const ErrorControl("BottomSheet does not have a content.");
41-
}
42-
43-
return createControl(widget.control, contentCtrls.first.id, disabled);
44-
}
45-
4633
@override
4734
Widget build(BuildContext context) {
4835
debugPrint("BottomSheet build: ${widget.control.id}");
4936

37+
var server = FletAppServices.of(context).server;
38+
39+
bool lastOpen = widget.control.state["open"] ?? false;
40+
bool disabled = widget.control.isDisabled || widget.parentDisabled;
41+
5042
var open = widget.control.attrBool("open", false)!;
5143
//var modal = widget.control.attrBool("modal", true)!;
5244
var dismissible = widget.control.attrBool("dismissible", true)!;
5345
var enableDrag = widget.control.attrBool("enableDrag", false)!;
5446
var showDragHandle = widget.control.attrBool("showDragHandle", false)!;
5547
var useSafeArea = widget.control.attrBool("useSafeArea", true)!;
48+
var isScrollControlled =
49+
widget.control.attrBool("isScrollControlled", false)!;
50+
var maintainBottomViewInsetsPadding =
51+
widget.control.attrBool("maintainBottomViewInsetsPadding", true)!;
5652

5753
void resetOpenState() {
5854
List<Map<String, String>> props = [
5955
{"i": widget.control.id, "open": "false"}
6056
];
6157
widget.dispatch(
6258
UpdateControlPropsAction(UpdateControlPropsPayload(props: props)));
63-
FletAppServices.of(context).server.updateControlProps(props: props);
59+
server.updateControlProps(props: props);
6460
}
6561

66-
if (!open && _open) {
67-
_open = false;
68-
resetOpenState();
69-
Navigator.pop(context);
70-
} else if (open && !_open) {
71-
var bottomSheet = _createBottomSheet();
72-
if (bottomSheet is ErrorControl) {
73-
return bottomSheet;
74-
}
75-
76-
_open = open;
62+
if (open && !lastOpen) {
63+
widget.control.state["open"] = open;
7764

7865
WidgetsBinding.instance.addPostFrameCallback((_) {
7966
showModalBottomSheet<void>(
8067
context: context,
8168
builder: (context) {
82-
return bottomSheet;
69+
var contentCtrls =
70+
widget.children.where((c) => c.name == "content");
71+
72+
if (contentCtrls.isEmpty) {
73+
return const ErrorControl(
74+
"BottomSheet does not have a content.");
75+
}
76+
77+
var content = createControl(
78+
widget.control, contentCtrls.first.id, disabled);
79+
80+
if (content is ErrorControl) {
81+
return content;
82+
}
83+
84+
if (maintainBottomViewInsetsPadding) {
85+
var bottomPadding =
86+
MediaQuery.of(context).viewInsets.bottom;
87+
debugPrint("bottomPadding: $bottomPadding");
88+
content = Padding(
89+
padding: EdgeInsets.only(
90+
bottom: MediaQuery.of(context).viewInsets.bottom),
91+
child: content,
92+
);
93+
}
94+
95+
return content;
8396
},
8497
isDismissible: dismissible,
98+
isScrollControlled: isScrollControlled,
8599
enableDrag: enableDrag,
86100
showDragHandle: showDragHandle,
87101
useSafeArea: useSafeArea)
88102
.then((value) {
89-
debugPrint("BottomSheet dismissed: $_open");
90-
bool shouldDismiss = _open;
91-
_open = false;
103+
lastOpen = widget.control.state["open"] ?? false;
104+
debugPrint("BottomSheet dismissed: $lastOpen");
105+
bool shouldDismiss = lastOpen;
106+
widget.control.state["open"] = false;
92107

93108
if (shouldDismiss) {
94109
resetOpenState();
95-
FletAppServices.of(context).server.sendPageEvent(
110+
server.sendPageEvent(
96111
eventTarget: widget.control.id,
97112
eventName: "dismiss",
98113
eventData: "");
99114
}
100115
});
101116
});
117+
} else if (open != lastOpen && lastOpen) {
118+
Navigator.pop(context);
102119
}
103120

104-
return widget.nextChild ?? const SizedBox.shrink();
121+
return const SizedBox.shrink();
105122
}
106123
}

0 commit comments

Comments
 (0)