Skip to content
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

fix: Switch's height and width properties not respected when label is set #3998

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ndonkoHenri
Copy link
Collaborator

@ndonkoHenri ndonkoHenri commented Sep 16, 2024

Description

Fixes #3997

Continuation of #3670

Test Code

import flet as ft


def main(page: ft.Page):
    page.add(
        ft.Switch(
            label="Switch 50",
            value=True,
            on_change=lambda e: print(e.value),
            height=50,
        ),
        ft.Switch(
            label="Switch 100",
            value=True,
            on_change=lambda e: print(e.value),
            height=100,
            label_position=ft.LabelPosition.LEFT,
        ),
    )


ft.app(target=main)

Summary by Sourcery

Fix the issue where the Switch component's height and width properties were not respected when a label was set, ensuring proper layout and functionality.

Bug Fixes:

  • Ensure the Switch component respects the height and width properties when a label is set.

Copy link
Contributor

sourcery-ai bot commented Sep 16, 2024

Reviewer's Guide by Sourcery

This pull request addresses an issue where the Switch control's height and width properties were not being respected when a label was set. The fix involves restructuring the widget tree to ensure proper sizing and layout of the Switch control with its label.

File-Level Changes

Change Details Files
Restructured the widget tree for the Switch control with label
  • Wrapped the existing Switch and label widgets in a Row with MainAxisSize.min
  • Moved the MergeSemantics widget to encompass the entire Row
  • Adjusted the order of widgets in the Row based on label position
packages/flet/lib/src/controls/switch.dart

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

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.

Hey @ndonkoHenri - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider renaming the 'result' variable when it's reassigned to avoid potential confusion, as it's used in different contexts within the same function.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

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.

Switch's height and width properties not respected when label is set
1 participant