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

feat: wrap Views into a background container #3820

Merged
merged 4 commits into from
Aug 18, 2024
Merged

Conversation

ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Aug 16, 2024

Description

Closes #3743

Test Code

import flet as ft


def main(page: ft.Page):
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
    page.vertical_alignment = ft.MainAxisAlignment.CENTER
    
    page.bgcolor = ft.colors.TRANSPARENT
    page.decoration = ft.BoxDecoration(
        gradient=ft.LinearGradient(
            colors=[ft.colors.RED, ft.colors.BLUE],
            begin=ft.alignment.top_left,
            end=ft.alignment.bottom_right,
            stops=[0.0, 1.0],
        ),
        image=ft.DecorationImage(
            src="https://images.unsplash.com/photo-1547721064-da6cfb341d50",
            fit=ft.ImageFit.COVER,
            opacity=0.2,
        ),
    )

    page.add(ft.Text("Hello, World!", size=55),)


ft.app(main)

Screenshots (if applicable):

image

Summary by Sourcery

Add support for background and foreground decorations in View and Container components, enabling more flexible UI designs. Enhance border radius parsing with default values and update macOS client code to use modern Swift attributes.

New Features:

  • Introduce background and foreground decoration properties to the View and Container components, allowing for more customizable UI elements.

Enhancements:

  • Enhance the borderRadiusFromJSON function to accept a default value, improving flexibility in border radius parsing.
  • Update the AppDelegate in the macOS client to use the @main attribute, modernizing the Swift code.

Copy link
Contributor

sourcery-ai bot commented Aug 16, 2024

Reviewer's Guide by Sourcery

This pull request introduces a new feature to wrap Views into a background container. The changes primarily affect the View and Page classes in the Python SDK, as well as corresponding Dart implementations. The main additions include new properties for decoration and foreground_decoration, which allow for more customization of the background and foreground of views and pages.

File-Level Changes

Files Changes
sdk/python/packages/flet-core/src/flet_core/view.py Added decoration and foreground_decoration properties to the View class
sdk/python/packages/flet-core/src/flet_core/page.py Added decoration and foreground_decoration properties to the Page class
packages/flet/lib/src/controls/page.dart Implemented background and foreground decoration parsing and application in the Dart ViewControl class
packages/flet/lib/src/utils/borders.dart Modified borderRadiusFromJSON function to accept a default value
sdk/python/packages/flet-core/src/flet_core/container.py
packages/flet/lib/src/controls/container.dart
Added foreground_decoration property to the Container class
packages/flet/lib/src/utils/theme.dart Updated parseTabBarTheme function to use the modified borderRadiusFromJSON
packages/flet/lib/src/controls/canvas.dart Modified FletCustomPainter class to use the updated borderRadiusFromJSON function
client/macos/Runner/AppDelegate.swift Updated MacOS AppDelegate annotation from @NSApplicationMain to @main

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:

  • The change in client/macos/Runner/AppDelegate.swift from @NSApplicationMain to @main seems unrelated to the main purpose of this PR. Could you explain the reasoning behind this change?
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 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.

@ndonkoHenri
Copy link
Contributor Author

The change in client/macos/Runner/AppDelegate.swift from @NSApplicationMain to @main seems unrelated to the main purpose of this PR. Could you explain the reasoning behind this change?

Yes sir! 🙂
Running the above test code in my dev-environment, Flutter notified me (see below) that NSApplicationMain in AppDelegate.swift was deprecated, and it automatically made the appropriate modification.

macos/Runner/AppDelegate.swift uses the deprecated @NSApplicationMain attribute, updating.

@FeodorFitsner FeodorFitsner merged commit e76da0e into main Aug 18, 2024
3 checks passed
@FeodorFitsner FeodorFitsner deleted the background-container branch August 20, 2024 18:03
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.

Add properties gradient, image_src for View
2 participants