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: Drag with mouse switch #195

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

bazzadazza72
Copy link
Contributor

Pull Request Description

Previously, the "Drag with mouse" switch in the settings would turn on the "AMOLED black" switch and would not respond to input unless the latter switch was turned off.

Now, it works as it should and responds correctly to users enabling the setting.

Issue Being Fixed

Resolves #194

Screenshots / Recordings

No screenshots/recordings required

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.

Copy link

sourcery-ai bot commented Jan 2, 2025

Reviewer's Guide by Sourcery

This pull request fixes a bug where the "Drag with mouse" switch would activate the "AMOLED black" switch and become unresponsive unless the "AMOLED black" switch was deactivated. The fix updates the onChanged callback of the "Drag with mouse" switch to correctly toggle the mouseDragSupport setting, resolving the conflict with the "AMOLED black" setting.

Sequence diagram for fixed mouse drag switch interaction

sequenceDiagram
    actor User
    participant Switch as Mouse Drag Switch
    participant Settings as Client Settings Provider

    Note over User, Settings: Before Fix
    User->>Switch: Toggle switch
    Switch->>Settings: setAmoledBlack(value)
    Settings-->>Switch: Update AMOLED setting (incorrect)

    Note over User, Settings: After Fix
    User->>Switch: Toggle switch
    Switch->>Settings: update(mouseDragSupport: !current)
    Settings-->>Switch: Update mouse drag setting (correct)
Loading

State diagram for mouse drag switch behavior

stateDiagram-v2
    [*] --> MouseDragOff: Initial State
    MouseDragOff --> MouseDragOn: Toggle Switch
    MouseDragOn --> MouseDragOff: Toggle Switch

    note right of MouseDragOff
        Fixed: Now correctly toggles
        mouseDragSupport instead of
        AMOLED setting
    end note
Loading

File-Level Changes

Change Details Files
Update "Drag with mouse" switch behavior
  • Modified the onChanged callback to update the mouseDragSupport setting instead of the AMOLED black setting.
lib/screens/settings/client_settings_page.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#194 Ensure 'Drag with mouse' switch works independently and does not automatically turn on 'AMOLED black' switch
#194 Fix the switch's behavior to respond correctly when enabled

Possibly linked issues


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

Overall Comments:

  • Consider extracting the duplicate state update logic into a single function to avoid repetition between the ListTile and Switch widgets
  • The Switch's onChanged callback receives the new value as a parameter - consider using this directly instead of reading the current state and negating it
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 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.

@@ -498,7 +498,9 @@ class _ClientSettingsPageState extends ConsumerState<ClientSettingsPage> {
.update((current) => current.copyWith(mouseDragSupport: !clientSettings.mouseDragSupport)),
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): The Switch's onChanged callback should use the provided 'value' parameter instead of negating the current value

This could cause incorrect behavior if the switch is toggled rapidly. Use 'value' directly: .update((current) => current.copyWith(mouseDragSupport: value))

Copy link
Collaborator

@PartyDonut PartyDonut left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for finding and fixing this 👍🏼

@PartyDonut PartyDonut added the bug Something isn't working label Jan 2, 2025
@PartyDonut PartyDonut changed the title Fix Drag with mouse switch fix: Drag with mouse switch Jan 2, 2025
@PartyDonut PartyDonut merged commit ae4707d into DonutWare:develop Jan 2, 2025
1 check passed
@bazzadazza72 bazzadazza72 deleted the bug/drag-with-mouse branch January 2, 2025 11:16
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.

🐛 Drag with mouse switch turns on AMOLED black switch
2 participants