question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: add a CanSwipe bool property to the SwipeControl type

See original GitHub issue

Proposal: Add a CanSwipe bool property to the SwipeControl type

Summary

I’d like to have a bool CanSwipe { get; set; } property to the SwipeControl so that swipe can be turned off and on easily.

Rationale

When using the SwipeControl in a ListView there could be situations were swipe actions are disabled for particular read-only items.

Today this is possible by having an ItemTemplateSelector that switches between 2 datatemplates: one with the SwipeControl, one without.

Having a bool CanSwipe { get; set; } property to the SwipeControl would make this super easy.

Functional Requirements

  • The CanSwipe property should support databinding (e.g. be a dependency property)
  • The CanSwipe property should have a default value of true
  • When the property changes, the swipe capability must be updated accordingly

Important Notes

I did some prototyping and I think the implementation shouldn’t too hard. Here is what I did:

  • add a new bool dependency property
  • update the InitializeInteractionTracker method to setup the interaction tracker according to the value of the CanSwipe property
    if (CanSwipe())
    {
        m_visualInteractionSource.get().ManipulationRedirectionMode(winrt::VisualInteractionSourceRedirectionMode::CapableTouchpadOnly);
        m_visualInteractionSource.get().PositionXSourceMode(m_isHorizontal ? winrt::InteractionSourceMode::EnabledWithInertia : winrt::InteractionSourceMode::Disabled);
        m_visualInteractionSource.get().PositionYSourceMode(!m_isHorizontal ? winrt::InteractionSourceMode::EnabledWithInertia : winrt::InteractionSourceMode::Disabled);
    }
    else
    {
        m_visualInteractionSource.get().ManipulationRedirectionMode(winrt::VisualInteractionSourceRedirectionMode::Off);
        m_visualInteractionSource.get().PositionXSourceMode(winrt::InteractionSourceMode::Disabled);
        m_visualInteractionSource.get().PositionYSourceMode(winrt::InteractionSourceMode::Disabled);
    }

When the DP changes, if the m_visualInteractionSource is defined, update the interaction mode as well.

Open Questions

None at the moment.

  • Maybe we would like to disable only swipe left and/or swipe right. In that case we might want to have 2 properties CanSwipeLeft and CanSwipeRight or having a new Mode = None instead of Reveal and Execute.

Misc

This has been discussed offline with @kikisaints. I’m happy to submit a PR if that’s easier to discuss.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
lukasfcommented, Feb 27, 2019

I’d say, if the dev sets CanSwipe to false, he doesn’t want the user to be able to access those swipe commands. So if the user has already opened the control, it should immediately close when CanSwipe is switched to false. At least for me, that would be the logical behavior.

It would also seem like a glitch if the control stays open, can be closed, and then cannot be opened again. Also if it stays open not interactable, it would seem broken, caught in some intermediary state.

0reactions
hansmbakkercommented, Oct 9, 2020

To add to this, I would expect that this would be possible to enable / disable individual SwipeItems using the CanExecute property of the already existing SwipeControl.Command --> by indicating that the command cannot execute, you disable the SwipeItem

Read more comments on GitHub >

github_iconTop Results From Across the Web

DEVONthink To Go
The document kind was labeled 'Type' in the view options. Fixed. Trying to insert a photo annotation into a PDF opened the camera...
Read more >
Human-Powered Smartphone Assistance for Blind People
In this section, we describe how this type of solutions has been previously leveraged on the web and on mobile devices to the...
Read more >
Swapnil Project | PDF | Mobile App | Software Testing
We learned how to write a project srs. We learn how to work with the android studio to develop an application. We learn...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found