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: Disabling switching router layouts after init #191

Merged
merged 1 commit into from
Dec 27, 2024

Conversation

PartyDonut
Copy link
Collaborator

@PartyDonut PartyDonut commented Dec 27, 2024

Pull Request Description

This disables switching routers when the size/layout has already been decided.

Issue Being Fixed

Resolves #174

Checklist

  • If a new package was added, did you ensure it works for all supported platforms? Is the package well maintained
  • Check that any changes are related to the issue at hand.

@PartyDonut PartyDonut added the bug Something isn't working label Dec 27, 2024
Copy link

sourcery-ai bot commented Dec 27, 2024

Reviewer's Guide by Sourcery

This PR disables switching router layouts after the size/layout has been set. This addresses issue #174 by ensuring the router layout is only initialized once and prevents it from being re-initialized when the screen size or layout changes.

Class diagram showing AdaptiveLayoutBuilder changes

classDiagram
    class AdaptiveLayoutBuilder {
        <<ConsumerStatefulWidget>>
    }
    class _AdaptiveLayoutBuilderState {
        -LayoutState layout
        -ScreenLayout size
        -AutoRouter? router
        -TargetPlatform currentPlatform
        -ScrollController controller
        +updateSize()
        +build()
    }
    note for _AdaptiveLayoutBuilderState "Router is now nullable and initialized only once"
    AdaptiveLayoutBuilder --> _AdaptiveLayoutBuilderState
Loading

State diagram for router layout initialization behavior

stateDiagram-v2
    [*] --> Uninitialized: App starts
    Uninitialized --> Initialized: First layout/size setting
    Initialized --> Initialized: Screen size changes
    note right of Initialized: Router layout remains fixed
    note left of Uninitialized: router is null
Loading

File-Level Changes

Change Details Files
Prevents re-initialization of the router layout
  • Removed the re-assignment of the router variable inside the _updateLayout method.
  • Initialized the router variable lazily using the null-aware assignment operator (??=).
  • Changed the type of the router variable from AutoRouter to AutoRouter? (nullable).
lib/util/adaptive_layout.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#174 Fix app resetting to home screen when auto-rotating while playing media

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

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

Overall Comments:

  • Consider adding tests to verify the router initialization behavior and ensure it doesn't get recreated after the initial setup.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Review instructions: 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 and I'll use the feedback to improve your reviews.

@PartyDonut PartyDonut merged commit 473e817 into develop Dec 27, 2024
1 check passed
@PartyDonut PartyDonut deleted the bugfix/only-allow-size-changes-web branch December 27, 2024 13:37
@PartyDonut PartyDonut changed the title fix: Disabling switching router layouts after setting fix: Disabling switching router layouts after init Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Auto rotation of the app resets the app to homescreen
1 participant