Skip to content

Conversation

ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Aug 7, 2025

Closes #5469

Test Code

def main(page: ft.Page):
    page.vertical_alignment = page.horizontal_alignment = "center"
    page.add(
        ft.IconButton(icon=ft.Icons.ADD),
        ft.FilledIconButton(icon=ft.Icons.ADD),
        ft.FilledTonalIconButton(icon=ft.Icons.ADD),
        ft.OutlinedIconButton(icon=ft.Icons.ADD),
    )

Summary by Sourcery

Introduce Material 3 icon button variants and update both Python SDK and Dart control implementations to support filled, filled tonal, and outlined IconButtons, while refining style handling and documentation for IconButton properties.

New Features:

  • Add FilledIconButton, FilledTonalIconButton, and OutlinedIconButton classes in Python SDK
  • Support new icon button variants in Dart control and FletCoreExtension
  • Expose new icon button variants in module exports

Enhancements:

  • Merge bgcolor and visual_density into ButtonStyle via before_update hook
  • Switch Dart IconButtonControl to use variant-specific constructors for filled, tonal, outlined styles
  • Add assertion to enforce positive splash_radius and refine AppBar/ElevatedButton before_update validations

Documentation:

  • Clarify IconButton property descriptions and docstrings for color, style, and toggle behavior
  • Document new icon button variants with usage guidance

Summary by Sourcery

Introduce Material 3 icon button variants and a unified URL handling mechanism, refine style merging and validations, extend platform brightness event support, and update documentation, examples, and tests accordingly.

New Features:

  • Add FilledIconButton, FilledTonalIconButton, and OutlinedIconButton variants in Python SDK and Dart control.
  • Introduce a Url type and update launch_url APIs across Python and Dart SDKs.
  • Add PlatformBrightnessChangeEvent in Python Page and propagate the event on platform brightness changes.

Enhancements:

  • Merge bgcolor, visual_density, and mouse_cursor into ButtonStyle in IconButton.before_update and add splash_radius validation.
  • Switch Dart IconButtonControl to use variant-specific constructors and normalize canvas PathElement type naming.
  • Refactor flet_app fixtures for integration tests setup.

Documentation:

  • Clarify docstrings for IconButton and other button controls and document the new icon button variants.
  • Update tutorials, examples, and navigation in mkdocs to reflect new parameter names and color values.

Tests:

  • Add integration tests for all icon button variants in different states.
  • Revamp alert dialog tests with fixture-based setup and update body update scenario.

Copy link

cloudflare-workers-and-pages bot commented Aug 7, 2025

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: bb8b967
Status: ✅  Deploy successful!
Preview URL: https://9c8812e3.flet-docs.pages.dev
Branch Preview URL: https://v1-icon-button-variants.flet-docs.pages.dev

View logs

@ndonkoHenri ndonkoHenri marked this pull request as ready for review August 7, 2025 21:58
@ndonkoHenri ndonkoHenri requested a review from Copilot August 7, 2025 21:58
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

Copilot

This comment was marked as outdated.



@pytest.mark.asyncio(loop_scope="module")
async def test_button_1(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app.assert_control_screenshot(
request.node.name,
ft.Button("Click me"),
control=ft.Button("Click me"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

control in that method is a normal, positional, required parameter. Why using it by name here?

@ndonkoHenri ndonkoHenri requested a review from Copilot August 9, 2025 17:06
Copilot

This comment was marked as outdated.

@ndonkoHenri ndonkoHenri marked this pull request as draft August 10, 2025 19:13
Refactored IconButton control to support filled, filled tonal, and outlined variants with dedicated constructors. Updated Python integration tests and golden image filenames to match new variant naming. Cleaned up API usage and removed unnecessary parameters and code in both Dart and Python implementations.
Deleted the inspect_golden_images.py script from integration test utilities. This script was used to check for mismatches between test functions and golden images, but is no longer needed.
Introduces a Python example for IconButton variants, including normal, disabled, and toggle states. Expands integration tests to cover disabled, selected, and unselected states for standard, filled, filled tonal, and outlined icon buttons, with corresponding golden images for macOS. Minor code cleanups and docstring updates are also included.
@@ -253,28 +253,6 @@ class _ViewControlState extends State<ViewControl> {
child: scaffold);
}

if (pageData?.widgetsDesign == PageDesign.material) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this hack as it messes really bad with the styling.
Removing this could affect some material controls when page.platform = ft.PagePlatform.MACOS or IOS is set. I don't know which controls though - we need to add tests for that.

Merged alert dialog body test into test_alert_dialog.py and removed test_alert_dialog_body.py. Updated screenshot assets and renamed files for consistency. Enhanced conftest.py with reusable app creation and added function-scoped fixture for tests. Added docstring to close_in_app_web_view method in url_launcher.py.
@FeodorFitsner FeodorFitsner marked this pull request as ready for review August 16, 2025 20:28
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@ndonkoHenri ndonkoHenri requested a review from Copilot August 16, 2025 21:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces Material 3 icon button variants and a unified URL handling mechanism. The changes add support for filled, filled tonal, and outlined icon button variants, enhance URL handling with a new Url type, and improve documentation throughout the codebase.

  • Add FilledIconButton, FilledTonalIconButton, and OutlinedIconButton classes
  • Introduce unified URL handling with Url type across Python and Dart SDKs
  • Enhance icon button styling with proper before_update hooks and validation

Reviewed Changes

Copilot reviewed 56 out of 78 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sdk/python/packages/flet/src/flet/controls/material/icon_button.py Adds new icon button variants and improves style handling with before_update validation
sdk/python/packages/flet/src/flet/controls/types.py Introduces new Url dataclass for consistent URL handling
packages/flet/lib/src/controls/icon_button.dart Updates Dart implementation to support icon button variants with proper constructors
sdk/python/packages/flet/src/flet/controls/services/url_launcher.py Refactors URL launching to use new Url type with improved parameter naming
sdk/python/packages/flet/integration_tests/controls/test_icon_button.py Adds comprehensive integration tests for all icon button variants

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Replaced references to 'web' with 'web mode' across documentation, examples, and service classes for consistency and clarity. This affects user-facing messages, docstrings, and error handling in file picker and storage paths services.
Changed the assertion in IconButton.before_update to compare splash_radius against 0 instead of 0.0, ensuring the value is greater than zero regardless of type.
@FeodorFitsner FeodorFitsner merged commit 35794a0 into main Aug 17, 2025
5 checks passed
@FeodorFitsner FeodorFitsner deleted the v1-icon-button-variants branch August 17, 2025 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v1: Add "variants" to IconButton: FilledIconButton, FilledTonalIconButton, OutlinedIconButton
2 participants