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

Window destroy on android and iOS #3733

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bl1nch
Copy link
Contributor

@bl1nch bl1nch commented Jul 29, 2024

Description

This PR should provide window destroy (app exit) function for Android and IOS platforms

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • I signed the CLA.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing tests pass locally with my changes
  • I have made corresponding changes to the documentation (if applicable)

Summary by Sourcery

This pull request introduces a new feature that allows the application to destroy the window (exit the app) on Android and iOS platforms. The implementation checks the platform and performs the appropriate action to close the app.

  • New Features:
    • Added window destroy functionality for Android and iOS platforms.

Copy link
Contributor

sourcery-ai bot commented Jul 29, 2024

Reviewer's Guide by Sourcery

This pull request introduces a new feature that allows the application to destroy the window (exit the app) on Android and iOS platforms. The implementation checks the platform and calls the appropriate method to exit the app. Significant changes include importing necessary libraries and modifying the 'destroyWindow' function to handle mobile platforms.

File-Level Changes

Files Changes
packages/flet/lib/src/utils/desktop.dart Enhanced the 'destroyWindow' function to support window destruction (app exit) on both Android and iOS platforms by adding platform-specific exit logic.

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 @bl1nch - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using a more graceful shutdown method for iOS instead of exit(0), which may not allow for proper cleanup.
  • The logic could be simplified by removing the redundant isDesktop() check and potentially adding a default case for unknown platforms.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 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.

Comment on lines -247 to 248
if (isDesktop()) {
if (isDesktop() || isMobile()) {
debugPrint("destroyWindow()");
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Remove redundant platform check as all cases are handled specifically.

The isDesktop() || isMobile() check is no longer necessary since all platforms are handled in the subsequent conditions. Consider removing this check and keeping only the debug print statement outside of any condition.

Suggested change
if (isDesktop()) {
if (isDesktop() || isMobile()) {
debugPrint("destroyWindow()");
debugPrint("destroyWindow()");

@bl1nch bl1nch marked this pull request as draft July 29, 2024 10:26
@bl1nch bl1nch marked this pull request as ready for review July 29, 2024 10:50
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 @bl1nch - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding unit tests to ensure the window destroy functionality works correctly across all platforms.
  • Using exit(0) for iOS might be too abrupt. Consider implementing a more graceful shutdown process that allows for proper cleanup.
  • Research and implement platform-specific best practices for app termination on mobile platforms to improve user experience.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 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.

packages/flet/lib/src/utils/desktop.dart Show resolved Hide resolved
Comment on lines 248 to +251
Future destroyWindow() async {
if (isDesktop()) {
if (isDesktop() || isMobile()) {
debugPrint("destroyWindow()");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Consider renaming the function to reflect its expanded functionality

The destroyWindow() function now handles application exit for both desktop and mobile platforms. Consider renaming it to something more general like exitApplication() or terminateApp() to accurately reflect its broader purpose.

Suggested change
Future destroyWindow() async {
if (isDesktop()) {
if (isDesktop() || isMobile()) {
debugPrint("destroyWindow()");
}
Future terminateApp() async {
if (isDesktop() || isMobile()) {
debugPrint("terminateApp()");
}

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.

2 participants