Skip to content

Commit 48044f9

Browse files
Images and code for Control descriptions (#5691)
* Update checkbox docs and tests to use PNG images Replaced GIF images with PNGs in checkbox documentation and updated references accordingly. Added new PNG screenshot for handling events. Refactored test functions in button and checkbox integration tests to use function-scoped fixtures and renamed parameters for clarity. Commented out handling_events test in checkbox tests. * Add Card integration tests and update docs Introduced integration tests for the Card control with golden images for documentation. Updated Card and Checkbox docstrings with code examples, improved Card documentation to use new screenshots, and made music_info.py executable as a script. * Update Card example and test with ListTile content Replaces the Card example and integration test to use a ListTile with icon and title, updates styling properties, and refreshes the golden image for documentation. This improves the demonstration of Card usage and aligns the test with the new example. * Enable and test checkbox event handling in integration tests Uncommented and activated the test for checkbox event handling in test_checkbox.py, updated the golden screenshot for event handling, and ensured the test app pumps and settles after app initialization for more reliable UI state in tests. * Update checkbox example and docs with submit action Refactored the checkbox example to improve message formatting and updated the documentation images with captions reflecting the state after clicking Submit. Integration test now simulates clicking the Submit button before taking a screenshot to match the updated documentation. * Update TextField docs and add integration test Updated the TextField documentation to use a new example image and clarified image paths. Added a screenshot integration test and corresponding image for documentation purposes. Also included a code example in the TextField class docstring for better usage clarity. * Update Text control docs and add integration test Updated the Text control documentation to use a new example image and clarified image/media paths. Added a code example to the Text class docstring. Introduced an integration test and corresponding golden image for the Text control. * Update Chip docs and add integration test Updated chip.md to improve example image references and captions. Added a new screenshot image and integration test for Chip control. Enhanced Chip class docstring with a code example. * Update CircleAvatar docs and add integration test Improved documentation for CircleAvatar by updating example images and captions, and added a code example to the class docstring. Introduced an integration test and corresponding golden image for CircleAvatar to ensure visual correctness. * Update Column docs and add integration test Updated the Column documentation to use a new example image and clarified image/media paths. Added an integration test and golden image for the Column control. Improved the Column class docstring with a code example for better clarity. * Update CupertinoButton docs and add integration test Updated documentation for CupertinoButton to include a new example image and improved example references. Added an integration test and golden image for documentation purposes. Also included a code snippet in the class docstring for better usage clarity. * Add docs and tests for CupertinoCheckbox Updated CupertinoCheckbox documentation with new example image and code snippet. Added integration test and golden image for documentation purposes. * Add example and test for CupertinoFilledButton Updated documentation to include a basic usage example and image for CupertinoFilledButton. Added an integration test to generate the screenshot used in docs, and included the corresponding golden image. Minor doc improvements for clarity. * Add CupertinoRadio example and integration test Updated documentation to include a new example image and code snippet for CupertinoRadio. Added an integration test to generate the example screenshot and included the corresponding image file. * Add example and test for CupertinoSegmentedButton Updated documentation to include a code example and image for CupertinoSegmentedButton. Added a screenshot test and corresponding golden image for integration testing. * Add example and test for CupertinoSlider docs Updated CupertinoSlider documentation to include a new example image and code snippet. Added a screenshot test and image for documentation purposes, and improved image/media references in the markdown file. * Add example and test for CupertinoSlidingSegmentedButton Updated documentation to include a screenshot and code example for CupertinoSlidingSegmentedButton. Added an integration test to generate the image used in docs and improved doc references to example images and media. * Add example and test for CupertinoSwitch control Updated documentation for CupertinoSwitch to include a new example image and code snippet. Added a golden image and integration test for the control to improve test coverage and documentation clarity. * Add example and test for CupertinoTextField docs Updated CupertinoTextField documentation to include a new example image and code snippet. Added a golden image and integration test to verify the visual appearance of the control. Minor doc improvements for clarity. * Add example and test for CupertinoTintedButton Updated documentation for CupertinoTintedButton to include a usage example and image. Added an integration test and corresponding golden image for the button. Enhanced docstring with a code snippet for clarity. * Add example and test for CupertinoListTile Updated documentation for CupertinoListTile to include a new example image and code snippet. Added an integration test to generate the example screenshot and included the corresponding image file for documentation purposes. * Add DataTable doc image and example test Added a screenshot image for DataTable documentation and an integration test to generate it. Updated documentation to reference the new image and improved example references. Also included a code example in the DataTable class docstring. * Add Divider control example and integration test Updated Divider documentation to include a new example image and code snippet. Added an integration test for the Divider control and included a corresponding golden image for screenshot comparison. * Add example and test for Dropdown control Updated Dropdown documentation to include a new example image and code snippet. Added a screenshot test for the Dropdown control and included the corresponding golden image. Improved clarity and demonstration of basic Dropdown usage. * Update DropdownM2 docs and add integration test Updated the DropdownM2 documentation to use a new example image and clarified image/media paths. Added a screenshot integration test and example image for documentation. Included a basic usage example in the DropdownM2 class docstring. * Add ExpansionPanel example and test Updated ExpansionPanel documentation to include a code example and image. Added a screenshot test and golden image for ExpansionPanel to integration tests. The example demonstrates basic usage with two panels, one expanded by default. * Add ExpansionPanelList doc image and test Added a screenshot image and integration test for ExpansionPanelList documentation. Updated the markdown to reference the new image and improved the example code in the class docstring. * Add ExpansionTile example and test image Updated ExpansionTile documentation to include a new example image and code snippet. Added a screenshot test and image for documentation purposes, and adjusted image references in the docs for clarity. * Update FilledButton docs and add integration test Improved FilledButton documentation with updated example images and a new screenshot for docs. Added an integration test for FilledButton and included a code example in the class docstring. * Add FilledIconButton example and integration test Updated documentation for FilledIconButton with a new example image and code snippet. Added an integration test and corresponding golden image for visual regression testing. * Add screenshot test and update FilledTonalButton docs Added a screenshot test and image for FilledTonalButton in integration tests. Updated documentation to reference the new image and improved example references. Also included a code snippet in the FilledTonalButton class docstring. * Add FilledTonalIconButton example and test Updated documentation for FilledTonalIconButton with a new example image and code snippet. Added an integration test and corresponding golden image for the example. * Refactor text style and value handling in DropdownM2 Improves text style logic by separating font size, color, and focused color handling for clarity and correctness. Replaces 'value' with 'initialValue' in DropdownButtonFormField to match updated API usage. * Add FloatingActionButton doc image and test Updated documentation for FloatingActionButton to include a new example image and code snippet. Added a screenshot test and corresponding image for documentation purposes. * Update dropdown material test image Replaces the golden image for the macOS dropdown material integration test to reflect updated UI or documentation requirements. * Add GridView example and integration test Updated GridView documentation to include a new example image and code snippet. Added an integration test for GridView and the corresponding golden image for screenshot testing. * Update Icon docs and add integration test Improves the Icon documentation with a new example image and code snippet. Adds an integration test and corresponding golden image for the Icon control to verify its appearance. * Add example and test for IconButton documentation Updated IconButton documentation to include a new example image and code snippet. Added a screenshot test and corresponding image for documentation purposes. * Add image example and update documentation Added a new image example and corresponding assets for documentation and integration tests. Updated image.md to reference new example images and included a code snippet in image.py for clarity. * Enable image tests and update golden images Re-enabled previously skipped image and image_base64 integration tests by removing skip decorators. Updated macOS golden images and added pump_times and pump_duration parameters to improve test reliability. * Update image test to use online image source Removed local sample_image.jpg and updated test_image.py to use an online image for testing. Adjusted image properties and screenshot parameters for improved reliability. Updated golden image to reflect new test output. * Update Image control example in docstring Revised the example in the Image control docstring to use a remote image URL, adjusted width and height to 100, and added the fit property for clarity. * Add ListTile doc image and example test Added a new screenshot image for ListTile documentation and an integration test to generate it. Updated the ListTile documentation to reference the new image and improved the example section. Also included a code snippet in the ListTile class docstring for clarity. --------- Co-authored-by: Feodor Fitsner <[email protected]>
1 parent f5e1581 commit 48044f9

File tree

149 files changed

+1178
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+1178
-174
lines changed

client/pubspec.lock

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -682,10 +682,10 @@ packages:
682682
dependency: transitive
683683
description:
684684
name: logger
685-
sha256: "55d6c23a6c15db14920e037fe7e0dc32e7cdaf3b64b4b25df2d541b5b6b81c0c"
685+
sha256: a7967e31b703831a893bbc3c3dd11db08126fe5f369b5c648a36f821979f5be3
686686
url: "https://pub.dev"
687687
source: hosted
688-
version: "2.6.1"
688+
version: "2.6.2"
689689
logging:
690690
dependency: transitive
691691
description:
@@ -730,18 +730,18 @@ packages:
730730
dependency: transitive
731731
description:
732732
name: media_kit
733-
sha256: "48c10c3785df5d88f0eef970743f8c99b2e5da2b34b9d8f9876e598f62d9e776"
733+
sha256: "52a8e989babc431db0aa242f32a4a08e55f60662477ea09759a105d7cd6410da"
734734
url: "https://pub.dev"
735735
source: hosted
736-
version: "1.2.0"
736+
version: "1.2.1"
737737
media_kit_libs_android_video:
738738
dependency: transitive
739739
description:
740740
name: media_kit_libs_android_video
741-
sha256: adff9b571b8ead0867f9f91070f8df39562078c0eb3371d88b9029a2d547d7b7
741+
sha256: "3f6274e5ab2de512c286a25c327288601ee445ed8ac319e0ef0b66148bd8f76c"
742742
url: "https://pub.dev"
743743
source: hosted
744-
version: "1.3.7"
744+
version: "1.3.8"
745745
media_kit_libs_ios_video:
746746
dependency: transitive
747747
description:
@@ -770,10 +770,10 @@ packages:
770770
dependency: transitive
771771
description:
772772
name: media_kit_libs_video
773-
sha256: "958cc55e7065d9d01f52a2842dab2a0812a92add18489f1006d864fb5e42a3ef"
773+
sha256: "2b235b5dac79c6020e01eef5022c6cc85fedc0df1738aadc6ea489daa12a92a9"
774774
url: "https://pub.dev"
775775
source: hosted
776-
version: "1.0.6"
776+
version: "1.0.7"
777777
media_kit_libs_windows_video:
778778
dependency: transitive
779779
description:
@@ -786,10 +786,10 @@ packages:
786786
dependency: transitive
787787
description:
788788
name: media_kit_video
789-
sha256: a656a9463298c1adc64c57f2d012874f7f2900f0c614d9545a3e7b8bb9e2137b
789+
sha256: "813858c3fe84eb46679eb698695f60665e2bfbef757766fac4d2e683f926e15a"
790790
url: "https://pub.dev"
791791
source: hosted
792-
version: "1.3.0"
792+
version: "1.3.1"
793793
meta:
794794
dependency: transitive
795795
description:
@@ -1026,18 +1026,18 @@ packages:
10261026
dependency: transitive
10271027
description:
10281028
name: record_android
1029-
sha256: "854627cd78d8d66190377f98477eee06ca96ab7c9f2e662700daf33dbf7e6673"
1029+
sha256: f05677eeed074898327f890f232f9eb49cd99d1c20d0daaf22b5612f4b2301bb
10301030
url: "https://pub.dev"
10311031
source: hosted
1032-
version: "1.4.2"
1032+
version: "1.4.3"
10331033
record_ios:
10341034
dependency: transitive
10351035
description:
10361036
name: record_ios
1037-
sha256: "13e241ed9cbc220534a40ae6b66222e21288db364d96dd66fb762ebd3cb77c71"
1037+
sha256: "765b42ac1be019b1674ddd809b811fc721fe5a93f7bb1da7803f0d16772fd6d7"
10381038
url: "https://pub.dev"
10391039
source: hosted
1040-
version: "1.1.2"
1040+
version: "1.1.4"
10411041
record_linux:
10421042
dependency: transitive
10431043
description:
@@ -1050,10 +1050,10 @@ packages:
10501050
dependency: transitive
10511051
description:
10521052
name: record_macos
1053-
sha256: "2849068bb59072f300ad63ed146e543d66afaef8263edba4de4834fc7c8d4d35"
1053+
sha256: "842ea4b7e95f4dd237aacffc686d1b0ff4277e3e5357865f8d28cd28bc18ed95"
10541054
url: "https://pub.dev"
10551055
source: hosted
1056-
version: "1.1.1"
1056+
version: "1.1.2"
10571057
record_platform_interface:
10581058
dependency: transitive
10591059
description:

packages/flet/lib/src/controls/dropdownm2.dart

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,23 @@ class _DropdownM2ControlState extends State<DropdownM2Control> {
7070

7171
var textStyle = widget.control
7272
.getTextStyle("text_style", Theme.of(context), const TextStyle())!;
73-
if (textSize != null || color != null || focusedColor != null) {
73+
74+
if (textSize != null) {
75+
textStyle = textStyle.copyWith(fontSize: textSize);
76+
}
77+
78+
if (focusedColor != null) {
7479
textStyle = textStyle.copyWith(
75-
fontSize: textSize,
76-
color: (_focused ? (focusedColor ?? color) : color) ??
77-
Theme.of(context).colorScheme.onSurface);
80+
color: _focused ? focusedColor : (color ?? textStyle.color));
81+
}
82+
83+
if (color != null) {
84+
textStyle = textStyle.copyWith(color: color);
85+
}
86+
87+
if (textStyle.color == null) {
88+
textStyle =
89+
textStyle.copyWith(color: Theme.of(context).colorScheme.onSurface);
7890
}
7991

8092
var items = widget.control
@@ -113,7 +125,7 @@ class _DropdownM2ControlState extends State<DropdownM2Control> {
113125
style: textStyle,
114126
autofocus: widget.control.getBool("autofocus", false)!,
115127
focusNode: _focusNode,
116-
value: _value,
128+
initialValue: _value,
117129
dropdownColor: widget.control.getColor("bgcolor", context),
118130
enableFeedback: widget.control.getBool("enable_feedback"),
119131
elevation: widget.control.getInt("elevation", 8)!,

sdk/python/examples/controls/card/__init__.py

Whitespace-only changes.

sdk/python/examples/controls/card/music_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ def main(page: ft.Page):
3535
)
3636

3737

38-
ft.run(main)
38+
if __name__ == "__main__":
39+
ft.run(main)

sdk/python/examples/controls/checkbox/basic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
def main(page: ft.Page):
55
def handle_button_click(e: ft.Event[ft.Button]):
6-
message.value = f"Checkboxes values are: {c1.value}, {c2.value}, {c3.value}, "
7-
f"{c4.value}, {c5.value}."
6+
message.value = (
7+
f"Checkboxes values are: {c1.value}, {c2.value}, {c3.value}, "
8+
f"{c4.value}, {c5.value}."
9+
)
810
page.update()
911

1012
page.add(
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
class_name: flet.Card
33
examples: ../../examples/controls/card
4-
example_images: ../examples/controls/card/media
4+
example_images: ../test-images/examples/material/golden/macos/card
55
---
66

7-
{{ class_summary(class_name) }}
7+
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic card") }}
88

99
## Examples
1010

@@ -14,7 +14,7 @@ example_images: ../examples/controls/card/media
1414
--8<-- "{{ examples }}/music_info.py"
1515
```
1616

17-
{{ image(example_images + "/music_info.gif", alt="music-info", width="80%") }}
17+
{{ image(example_images + "/music_info.png", alt="music-info", width="50%") }}
1818

1919

2020
{{ class_members(class_name) }}

sdk/python/packages/flet/docs/controls/checkbox.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ example_images: ../test-images/examples/material/golden/macos/checkbox
1616
--8<-- "{{ examples }}/basic.py"
1717
```
1818

19-
{{ image(example_images + "/basic.gif", alt="basic", width="50%") }}
19+
{{ image(example_images + "/basic.png", alt="basic", width="50%", caption="After clicking Submit") }}
2020

2121

2222
### Handling events
@@ -25,7 +25,7 @@ example_images: ../test-images/examples/material/golden/macos/checkbox
2525
--8<-- "{{ examples }}/handling_events.py"
2626
```
2727

28-
{{ image(example_images + "/handling_events.gif", alt="handling-events", width="50%") }}
28+
{{ image(example_images + "/handling_events.png", alt="handling-events", width="50%", caption="After three clicks") }}
2929

3030

3131
### Styled checkboxes
@@ -34,6 +34,6 @@ example_images: ../test-images/examples/material/golden/macos/checkbox
3434
--8<-- "{{ examples }}/styled.py"
3535
```
3636

37-
{{ image(example_images + "/styled_checkboxes.gif", alt="Styled checkboxes", width="50%") }}
37+
{{ image(example_images + "/styled_checkboxes.png", alt="Styled checkboxes", width="50%") }}
3838

3939
{{ class_members(class_name) }}

sdk/python/packages/flet/docs/controls/chip.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
class_name: flet.Chip
33
examples: ../../examples/controls/chip
4-
example_images: ../examples/controls/chip/media
4+
example_images: ../test-images/examples/material/golden/macos/chip
5+
example_media: ../examples/controls/chip/media
56
---
67

7-
{{ class_summary(class_name) }}
8+
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic Chip") }}
89

910
## Examples
1011

@@ -22,7 +23,7 @@ An alternative to assist chips are [buttons](buttons/index.md), which should app
2223
--8<-- "{{ examples }}/assist_chips.py"
2324
```
2425

25-
{{ image(example_images + "/assist_chips.png", alt="assist-chips", width="80%") }}
26+
{{ image(example_media + "/assist_chips.png", alt="assist-chips", width="80%") }}
2627

2728

2829
### Filter chips
@@ -36,7 +37,7 @@ They can be a good alternative to switches or checkboxes.
3637
--8<-- "{{ examples }}/filter_chips.py"
3738
```
3839

39-
{{ image(example_images + "/filter_chips.png", alt="filter-chips", width="80%") }}
40+
{{ image(example_media + "/filter_chips.png", alt="filter-chips", width="80%") }}
4041

4142

4243
{{ class_members(class_name) }}

sdk/python/packages/flet/docs/controls/circleavatar.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
class_name: flet.CircleAvatar
33
examples: ../../examples/controls/circle_avatar
4-
example_images: ../examples/controls/circle_avatar/media
4+
example_images: ../test-images/examples/material/golden/macos/circle_avatar
5+
example_media: ../examples/controls/circle_avatar/media
56
---
67

7-
{{ class_summary(class_name) }}
8+
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic CircleAvatar") }}
89

910
## Examples
1011

@@ -16,7 +17,7 @@ example_images: ../examples/controls/circle_avatar/media
1617
--8<-- "{{ examples }}/user_avatars.py"
1718
```
1819

19-
{{ image(example_images + "/user_avatars.png", alt="user-avatars", width="80%") }}
20+
{{ image(example_media + "/user_avatars.png", alt="user-avatars", width="80%") }}
2021

2122

2223
{{ class_members(class_name) }}

sdk/python/packages/flet/docs/controls/column.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
class_name: flet.Column
33
examples: ../../examples/controls/column
4-
example_images: ../examples/controls/column/media
4+
example_images: ../test-images/examples/material/golden/macos/column
5+
example_media: ../examples/controls/column/media
56
---
67

7-
{{ class_summary(class_name) }}
8+
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic Column with Text controls") }}
89

910
## Examples
1011

@@ -16,7 +17,7 @@ example_images: ../examples/controls/column/media
1617
--8<-- "{{ examples }}/spacing.py"
1718
```
1819

19-
{{ image(example_images + "/spacing.gif", alt="spacing", width="80%") }}
20+
{{ image(example_media + "/spacing.gif", alt="spacing", width="80%") }}
2021

2122

2223
### Column wrapping
@@ -25,7 +26,7 @@ example_images: ../examples/controls/column/media
2526
--8<-- "{{ examples }}/wrap.py"
2627
```
2728

28-
{{ image(example_images + "/wrap.gif", alt="wrap", width="80%") }}
29+
{{ image(example_media + "/wrap.gif", alt="wrap", width="80%") }}
2930

3031

3132
### Column vertical alignments
@@ -34,7 +35,7 @@ example_images: ../examples/controls/column/media
3435
--8<-- "{{ examples }}/alignment.py"
3536
```
3637

37-
{{ image(example_images + "/alignment.png", alt="alignment", width="80%") }}
38+
{{ image(example_media + "/alignment.png", alt="alignment", width="80%") }}
3839

3940

4041
### Column horizontal alignments
@@ -43,7 +44,7 @@ example_images: ../examples/controls/column/media
4344
--8<-- "{{ examples }}/horizontal_alignment.py"
4445
```
4546

46-
{{ image(example_images + "/horizontal_alignment.png", alt="horizontal-alignment", width="80%") }}
47+
{{ image(example_media + "/horizontal_alignment.png", alt="horizontal-alignment", width="80%") }}
4748

4849

4950
### Infinite scrolling
@@ -63,7 +64,7 @@ This example shows how to use [`scroll_to()`][flet.Column.scroll_to] to programm
6364
--8<-- "{{ examples }}/programmatic_scroll.py"
6465
```
6566

66-
{{ image(example_images + "/programmatic_scroll.png", alt="programmatic-scroll", width="80%") }}
67+
{{ image(example_media + "/programmatic_scroll.png", alt="programmatic-scroll", width="80%") }}
6768

6869

6970
[//]: # (### Custom scrollbar)

0 commit comments

Comments
 (0)