Skip to content

Inesa/v1 docstrings for material controls #5290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3a35254
removed example
InesaFitsner May 7, 2025
0413cd2
NavigationRailDestination
InesaFitsner May 7, 2025
20f6917
NavigationRail
InesaFitsner May 7, 2025
557e225
removed example
InesaFitsner May 7, 2025
1cc579b
Update outlined_button.py
InesaFitsner May 7, 2025
055ad75
PopupMenuButton docstrings and removed text property
InesaFitsner May 7, 2025
7d83b24
ProgressBar docstrings
InesaFitsner May 7, 2025
8a979e4
deleted example
InesaFitsner May 7, 2025
5252aed
ProgressRing properties
InesaFitsner May 7, 2025
56dec99
removed example
InesaFitsner May 7, 2025
39dddd4
RadioGroup docstrings
InesaFitsner May 7, 2025
6409c0c
removed example
InesaFitsner May 7, 2025
1fef74c
Radio docstrings
InesaFitsner May 7, 2025
83ed008
asserts for RangeSlider
InesaFitsner May 7, 2025
0e25f52
RangeSlider docstrings
InesaFitsner May 7, 2025
fa44ef3
Control docstring
InesaFitsner May 7, 2025
9dd7900
ReorderableListView docstrings
InesaFitsner May 7, 2025
f05c058
SearchBar Control docstrings
InesaFitsner May 7, 2025
6bea206
SearchBar docstrings
InesaFitsner May 7, 2025
f2b5f98
formatted for ruf
InesaFitsner May 7, 2025
99dd368
asserts for SegmentedButton
InesaFitsner May 7, 2025
f069846
SegmentedButton docstrings
InesaFitsner May 7, 2025
29b50f3
SelectionArea docstrings
InesaFitsner May 7, 2025
aa70b33
removed example
InesaFitsner May 7, 2025
7472a09
Slider docstrings
InesaFitsner May 7, 2025
bc5ae8d
removed example
InesaFitsner May 7, 2025
2b75c71
SnackBar docstrings
InesaFitsner May 7, 2025
1831e84
SubmenuButton docstrings
InesaFitsner May 7, 2025
b40a91a
Switch docstrings
InesaFitsner May 7, 2025
e301863
Tab docstrings, fixed SegmentedButton
InesaFitsner May 7, 2025
2af5a25
Tab docstrings
InesaFitsner May 7, 2025
5d231ee
TextButton description
InesaFitsner May 8, 2025
2911664
TextButton docstrings
InesaFitsner May 8, 2025
be18770
InputFilter docstrings
InesaFitsner May 8, 2025
d91ca55
TextField description
InesaFitsner May 8, 2025
61235ba
TextField docstrings
InesaFitsner May 8, 2025
db27941
FormFieldControl docstrings
InesaFitsner May 8, 2025
6918f8c
TimePicker description
InesaFitsner May 8, 2025
c714f2e
TimePicker docstrings
InesaFitsner May 8, 2025
8a934d1
Tooltip description
InesaFitsner May 8, 2025
490d6b9
Tooltip docstrings
InesaFitsner May 8, 2025
ee163f3
TextField docstrings
InesaFitsner May 8, 2025
4b126d4
VerticalDivider docstrings
InesaFitsner May 8, 2025
505ff39
AlertDialog docstrings formatting
InesaFitsner May 8, 2025
b439d75
docstrings for all Material Controls formatted
InesaFitsner May 8, 2025
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
24 changes: 10 additions & 14 deletions packages/flet/lib/src/controls/popup_menu_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import '../utils/box.dart';
import '../utils/buttons.dart';
import '../utils/colors.dart';
import '../utils/edge_insets.dart';
import '../utils/icons.dart';
import '../utils/misc.dart';
import '../utils/mouse.dart';
import '../utils/numbers.dart';
Expand All @@ -23,7 +22,7 @@ class PopupMenuButtonControl extends StatelessWidget {
Widget build(BuildContext context) {
debugPrint("PopupMenuButton build: ${control.id}");

var content = control.buildWidget("content");
var content = control.buildTextOrWidget("content");

var popupMenuButton = PopupMenuButton<String>(
enabled: !control.disabled,
Expand Down Expand Up @@ -57,27 +56,24 @@ class PopupMenuButtonControl extends StatelessWidget {
.children("items")
.where((i) => i.type == "PopupMenuItem")
.map((item) {
var itemIcon = item.getIcon("icon");
var text = item.getString("text", "")!;
var checked = item.getBool("checked");
var height = item.getDouble("height", 48.0)!;
var padding = item.getPadding("padding");
var content = item.buildWidget("content");
var itemContent = item.buildTextOrWidget("content");
var itemIcon = item.buildIconOrWidget("icon");
var mouseCursor = item.getMouseCursor("mouse_cursor");

Widget? child;
if (content != null) {
// custom content
child = content;
} else if (itemIcon != null && text != "") {
// icon and text
if (itemContent != null && itemIcon == null) {
child = itemContent;
} else if (itemContent == null && itemIcon != null) {
child = itemIcon;
} else if (itemContent != null && itemIcon != null) {
child = Row(children: [
Icon(itemIcon),
itemIcon,
const SizedBox(width: 8),
Text(text)
itemContent
]);
} else if (text != "") {
child = Text(text);
}

var result = checked != null
Expand Down
4 changes: 2 additions & 2 deletions packages/flet/lib/src/controls/segmented_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class _SegmentedButtonControlState extends State<SegmentedButtonControl>
value: segment.getString("value")!,
enabled: !segment.disabled,
tooltip: segment.disabled ? null : segment.getString("tooltip"),
icon: segment.buildWidget("icon"),
label: segment.buildWidget("label"));
icon: segment.buildIconOrWidget("icon"),
label: segment.buildTextOrWidget("label"));
}).toList());

return ConstrainedControl(control: widget.control, child: segmentedButton);
Expand Down
79 changes: 50 additions & 29 deletions sdk/python/packages/flet/src/flet/controls/material/alert_dialog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import field
from typing import List, Optional
from typing import Optional

from flet.controls.alignment import Alignment
from flet.controls.base_control import control
Expand All @@ -22,14 +22,18 @@
@control("AlertDialog")
class AlertDialog(DialogControl):
"""
An alert dialog informs the user about situations that require acknowledgement. An alert dialog has an optional title and an optional list of actions. The title is displayed above the content and the actions are displayed below the content.
An alert dialog informs the user about situations that require acknowledgement. An
alert dialog has an optional title and an optional list of actions. The title is
displayed above the content and the actions are displayed below the content.

Online docs: https://flet.dev/docs/controls/alertdialog
"""

content: Optional[Control] = None
"""
The (optional) content of the dialog is displayed in the center of the dialog in a lighter font. Typically this is a [`Column`](https://flet.dev/docs/controls/column) that contains the dialog's [`Text`](https://flet.dev/docs/controls/text) message.
The (optional) content of the dialog is displayed in the center of the dialog in a
lighter font. Typically this is a [`Column`](https://flet.dev/docs/controls/column)
that contains the dialog's [`Text`](https://flet.dev/docs/controls/text) message.

Value is of type `Control`.
"""
Expand All @@ -43,21 +47,24 @@ class AlertDialog(DialogControl):

title: Optional[StrOrControl] = None
"""
The (optional) title of the dialog is displayed in a large font at the top of the dialog.
The (optional) title of the dialog is displayed in a large font at the top of the
dialog.

Typically a [`Text`](https://flet.dev/docs/controls/text) control.
"""

actions: List[Control] = field(default_factory=list)
actions: list[Control] = field(default_factory=list)
"""
The (optional) set of actions that are displayed at the bottom of the dialog.

Typically this is a list of [`TextButton`](https://flet.dev/docs/controls/textbutton) controls.
Typically this is a list of [`TextButton`](https://flet.dev/docs/controls/textbutton)
controls.
"""

bgcolor: OptionalColorValue = None
"""
The background [color](https://flet.dev/docs/reference/colors) of the dialog's surface.
The background [color](https://flet.dev/docs/reference/colors) of the dialog's
surface.
"""

elevation: OptionalNumber = None
Expand All @@ -69,7 +76,8 @@ class AlertDialog(DialogControl):

icon: Optional[Control] = None
"""
A control that is displayed at the top of the dialog. Typically a [`Icon`](https://flet.dev/docs/controls/icon) control.
A control that is displayed at the top of the dialog. Typically a [`Icon`](https://flet.dev/docs/controls/icon)
control.
"""

title_padding: OptionalPaddingValue = None
Expand All @@ -80,16 +88,20 @@ class AlertDialog(DialogControl):

Value is of type [`PaddingValue`](https://flet.dev/docs/reference/types/aliases#paddingvalue).

Defaults to providing `24` pixels on the top, left, and right of the title. If the `content` is not `None`, then no
bottom padding is provided (but see [`content_padding`](https://flet.dev/docs/reference/types/aliases#paddingvalue)).
If it is not set, then an extra `20` pixels of bottom padding is added to separate the title from the actions.
Defaults to providing `24` pixels on the top, left, and right of the title. If the
`content` is not `None`, then no bottom padding is provided (but see [`content_padding`](https://flet.dev/docs/reference/types/aliases#paddingvalue)).
If it is not set, then an extra `20` pixels of bottom padding is added to separate
the title from the actions.
"""

content_padding: OptionalPaddingValue = None
"""
Padding around the content.

If there is no content, no padding will be provided. Otherwise, padding of 20 pixels is provided above the content to separate the content from the title, and padding of 24 pixels is provided on the left, right, and bottom to separate the content from the other edges of the dialog.
If there is no content, no padding will be provided. Otherwise, padding of 20
pixels is provided above the content to separate the content from the title, and
padding of 24 pixels is provided on the left, right, and bottom to separate the
content from the other edges of the dialog.

Value is of type [`PaddingValue`](https://flet.dev/docs/reference/types/aliases#paddingvalue).
"""
Expand All @@ -98,9 +110,11 @@ class AlertDialog(DialogControl):
"""
Padding around the set of actions at the bottom of the dialog.

Typically used to provide padding to the button bar between the button bar and the edges of the dialog.
Typically used to provide padding to the button bar between the button bar and the
edges of the dialog.

If are no actions, then no padding will be included. The padding around the button bar defaults to zero.
If are no actions, then no padding will be included. The padding around the button
bar defaults to zero.

Value is of type [`PaddingValue`](https://flet.dev/docs/reference/types/aliases#paddingvalue).
"""
Expand All @@ -109,15 +123,16 @@ class AlertDialog(DialogControl):
"""
Defines the horizontal layout of the actions.

Value is of type [`MainAxisAlignment`](https://flet.dev/docs/reference/types/mainaxisalignment) and defaults to `MainAxisAlignment.END`.
Value is of type [`MainAxisAlignment`](https://flet.dev/docs/reference/types/mainaxisalignment)
and defaults to `MainAxisAlignment.END`.
"""

shape: Optional[OutlinedBorder] = None
"""
The shape of the dialog.

Value is of type [`OutlinedBorder`](https://flet.dev/docs/reference/types/outlinedborder) and defaults
to `RoundedRectangleBorder(radius=4.0)`.
Value is of type [`OutlinedBorder`](https://flet.dev/docs/reference/types/outlinedborder)
and defaults to `RoundedRectangleBorder(radius=4.0)`.
"""

inset_padding: OptionalPaddingValue = None
Expand All @@ -126,8 +141,8 @@ class AlertDialog(DialogControl):

Value is of type [`PaddingValue`](https://flet.dev/docs/reference/types/aliases#paddingvalue).

Defaults to `padding.symmetric(vertical=40, horizontal=24)` - 40 pixels horizontally and 24 pixels vertically outside of
the dialog box.
Defaults to `padding.symmetric(vertical=40, horizontal=24)` - 40 pixels
horizontally and 24 pixels vertically outside of the dialog box.
"""

icon_padding: OptionalPaddingValue = None
Expand All @@ -146,13 +161,14 @@ class AlertDialog(DialogControl):

surface_tint_color: OptionalColorValue = None
"""
The [color](https://flet.dev/docs/reference/colors) used as a surface tint overlay on the dialog's background color, which reflects the
dialog's elevation.
The [color](https://flet.dev/docs/reference/colors) used as a surface tint overlay
on the dialog's background color, which reflects the dialog's elevation.
"""

shadow_color: OptionalColorValue = None
"""
The [color](https://flet.dev/docs/reference/colors) used to paint a drop shadow under the dialog, which reflects the dialog's elevation.
The [color](https://flet.dev/docs/reference/colors) used to paint a drop shadow
under the dialog, which reflects the dialog's elevation.
"""

icon_color: OptionalColorValue = None
Expand Down Expand Up @@ -189,28 +205,33 @@ class AlertDialog(DialogControl):
"""
Controls how the contents of the dialog are clipped (or not) to the given `shape`.

Value is of type [`ClipBehavior`](https://flet.dev/docs/reference/types/clipbehavior) and defaults to `ClipBehavior.NONE`.
Value is of type [`ClipBehavior`](https://flet.dev/docs/reference/types/clipbehavior)
and defaults to `ClipBehavior.NONE`.
"""

semantics_label: Optional[str] = None
"""
The semantic label of the dialog used by accessibility frameworks to announce screen transitions when the dialog is opened and closed.
The semantic label of the dialog used by accessibility frameworks to announce
screen transitions when the dialog is opened and closed.

In iOS, if this label is not provided, a semantic label will be inferred from the `title` if it is not null.
In iOS, if this label is not provided, a semantic label will be inferred from the
`title` if it is not null.

Value is of type `str`.
"""

barrier_color: OptionalColorValue = None
"""
The [color](https://flet.dev/docs/reference/colors) of the modal barrier that darkens everything below the dialog.
The [color](https://flet.dev/docs/reference/colors) of the modal barrier that
darkens everything below the dialog.

If `None`, the [`DialogTheme.barrier_color`](https://flet.dev/docs/reference/types/dialogtheme#barrier_color) is used.
If it is also `None`, then `Colors.BLACK_54` is used.
If `None`, the [`DialogTheme.barrier_color`](https://flet.dev/docs/reference/types/dialogtheme#barrier_color)
is used. If it is also `None`, then `Colors.BLACK_54` is used.
"""

def before_update(self):
super().before_update()
assert (
self.title or self.content or self.actions
), "AlertDialog has nothing to display. Provide at minimum one of the following: title, content, actions"
), "AlertDialog has nothing to display. Provide at minimum one of the "
"following: title, content, actions"
Loading