Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Xamarin.Forms.SwipeView Spec #3171

Closed
hartez opened this issue Jun 27, 2018 · 2 comments
Closed

Xamarin.Forms.SwipeView Spec #3171

hartez opened this issue Jun 27, 2018 · 2 comments
Assignees
Labels
a/swipeview e/5 🕔 5 in-progress This issue has an associated pull request that may resolve it! roadmap t/enhancement ➕

Comments

@hartez
Copy link
Contributor

hartez commented Jun 27, 2018

SwipeView

Swiping on an element to reveal or execute contextual commands is an increasingly common paradigm, especially when working with lists. This view provides support for that interaction.

Note: Nothing in this specification is guaranteed to be final; all features, implementations, and interfaces are subject to change.

SwipeItem

Represents an individual command in a SwipeView.

public class SwipeItem : ContextItem
{
	public static readonly BindableProperty BackgroundColorProperty;
	public Color BackgroundColor { get; set; }
}

SwipeItems

Represents a collection of SwipeItem objects

public class SwipeItems : IList<SwipeItem>
{
	public static SwipeMode Mode { get; set; }
}

Properties

API Description
SwipeMode Gets or sets the SwipeMode of the item.

Properties

API Description
BackgroundColor Gets or sets the background color of the item.

SwipeMode

Defines the possible swipe interactions

public enum SwipeMode 
{
	Reveal, // Display additional context items which may be selected
	Execute // Immediately execute the associated command
}

SwipeView

Represents a container that provides access to contextual commands through touch interactions.

public class SwipeView : ContentView
{
	public static readonly BindableProperty LeftItems;
	public SwipeItems LeftItems { get; set; }

	public static readonly BindableProperty RightItems;
	public SwipeItems RightItems { get; set; }	

	public static readonly BindableProperty TopItems;
	public SwipeItems TopItems { get; set; }
	
	public static readonly BindableProperty BottomItems;	
	public SwipeItems BottomItems { get; set; }  
}

Properties

API Description
LeftItems Gets or sets the items that can be invoked when the control is swiped from the left side.
RightItems Gets or sets the items that can be invoked when the control is swiped from the right side.
TopItems Gets or sets the items that can be invoked when the control is swiped from the top.
BottomItems Gets or sets the items that can be invoked when the control is swiped from the bottom.

Examples

<SwipeView>
	<SwipeView.LeftItems>
		<SwipeItems Mode="Reveal">
			<SwipeItem Text="Favorite" Command="{Binding Favorite}">
				<SwipeItem.Icon>
					<FontIconSource Glyph="&#xE734;"/>
				</SwipeItem.Icon>
			</SwipeItem>
			<SwipeItem Text="Share" Command="{Binding Share}">
				<SwipeItem.Icon>
					<FontIconSource Glyph="&#xE27D;"/>
				</SwipeItem.Icon>
			</SwipeItem>
		</SwipeItems>
	</SwipeView.LeftItems>

	<SwipeView.RightItems>
		<SwipeItems Mode="Execute">
			<SwipeItem Text="Delete" Command="{Binding Delete}">
				<SwipeItem.Icon>
					<FontIconSource Glyph="&#xE74D;"/>
				</SwipeItem.Icon>
			</SwipeItem>
		</SwipeItems>
	</SwipeView.LeftItems>

	<!-- Swipeable content -->
	<Frame>
		<Label Text="Foo" />
	</Frame>
</SwipeView>

In this example, the Frame and its contents can be swiped left or right. Swiping to the right will immediately execute the bound "Delete" command. Swiping to the left will reveal two options: "Share" and "Favorite". Tapping on those items will execute their respective commands.

@PureWeen PureWeen added the e/5 🕔 5 label Oct 15, 2018
@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! labels Jul 4, 2019
@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested and removed inactive Issue is older than 6 months and needs to be retested labels Aug 5, 2019
@jsuarezruiz jsuarezruiz self-assigned this Aug 26, 2019
@jsuarezruiz jsuarezruiz mentioned this issue Sep 20, 2019
2 tasks
@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Oct 2, 2019
@jsuarezruiz
Copy link
Contributor

We have the implementation of this Spec in: #7603

After implementing the Spec I have several ideas that would improve the possibilities of the SwipeView.

Right now each SwipeItem allows basic customization; the background color, text, icon, etc. It would be nice to have a more customizable SwipeItem, using a View.

public interface ISwipeItem
{
     ICommand Command { get; set; }
     object CommandParameter { get; set; }

     event EventHandler<SwipeItemInvokedEventArgs> Invoked;
}

public class SwipeItem : ContextItem, ISwipeItem
{

}

public class CustomSwipeItem : ContentView, ISwipeItem
{

}

NOTE: I have a small prototype of this on a branch.

There may be cases where want to open (or close) the SwipeView programmatically. To do this, I propose to add a new property to the SwipeView, IsOpen.

If custom SwipeItem is included, I would also add a new event, SwipeThresholdChanged. In this way, you can obtain the value of swipeThreshold to, for example, apply animations to the Custom SwipeItems, etc.

@samhouts samhouts removed help wanted We welcome community contributions to any issue, but these might be a good place to start! inactive Issue is older than 6 months and needs to be retested up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! labels Nov 26, 2019
@samhouts
Copy link
Member

samhouts commented Dec 6, 2019

closed by #7603

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/swipeview e/5 🕔 5 in-progress This issue has an associated pull request that may resolve it! roadmap t/enhancement ➕
Projects
None yet
Development

No branches or pull requests

4 participants