private async void SwipeOnOpenEvent(SwipeLayout sender) { Debug.WriteLine($"Attempting swipe for {ViewModel.Title}"); if (_swipeCooldown) { return; } _swipeCooldown = true; var edge = sender.GetDragEdge(); if (edge == SwipeLayout.DragEdge.Right) { ViewModel.IncrementWatchedCommand.Execute(null); } else if (edge == SwipeLayout.DragEdge.Left) { ViewModel.DecrementWatchedCommand.Execute(null); } await Task.Delay(500); sender.Close(); _swipeCooldown = false; }
public void SetUndoState() { // Show Undo layout for selected ViewHolder UndoLayout.Visibility = ViewStates.Visible; PreUndoLayout.Visibility = ViewStates.Gone; SwipeLayout.Visibility = ViewStates.Gone; SwipeLayout.SetX(ItemView.Width); }
private void ConfigureSwipe(ConnectionManager connectionManager) { _swipeLayout = FindViewById <SwipeLayout>(Resource.Id.swipeLayout); _swipeLayout.SetShowMode(SwipeLayout.ShowMode.PullOut); var addFavoriteView = FindViewById(Resource.Id.leftBottomWrapper); _swipeLayout.AddDrag(SwipeLayout.DragEdge.Left, addFavoriteView); var removeFavoriteView = FindViewById(Resource.Id.rightBottomWrapper); _swipeLayout.AddDrag(SwipeLayout.DragEdge.Right, removeFavoriteView); View backgroundView = FindViewById <Button>(Resource.Id.addToFavorite); _swipeLayout.Opened += (sender, e) => { if (_swipeLayout.CurrentBottomView.FindViewById <Button>(Resource.Id.addToFavorite) != null) { _favoriteView.SetImageResource(Resource.Drawable.Star); backgroundView = FindViewById <Button>(Resource.Id.addToFavorite); connectionManager.MarkFavorite(true, _article.ID); _article.Favorite = true; } else { _favoriteView.SetImageResource(Resource.Drawable.EmptyStar); backgroundView = FindViewById <Button>(Resource.Id.removeFromFavorite); connectionManager.MarkFavorite(false, _article.ID); _article.Favorite = false; } backgroundView.SetBackgroundColor(Color.Green); _swipeLayout.Close(); }; _swipeLayout.Closed += (sender, e) => { backgroundView.SetBackgroundColor(Color.Transparent); }; _swipeLayout.Hover += (sender, e) => { _swipeLayout.Close(); }; _swipeLayout.Click += delegate { string swipeStatus = _swipeLayout.OpenStatus.ToString(); if (!swipeStatus.Equals("Open") && !swipeStatus.Equals("Middle")) { Intent intent = new Intent(Context, typeof(ArticleActivity)); intent.PutExtra("sourceUri", _article.Link); _activity.StartActivity(intent); } _swipeLayout.Close(); }; }
public SwipeActionViewHolder(SwipeLayout itemView) : base(itemView) { position = itemView.FindViewById <TextView>(ZC.Xamarin.Android.SwipeAction.Resource.Id.swipePosition); //textValue1 = itemView.FindViewById<TextView>(ZC.Xamarin.Android.SwipeAction.Resource.Id.textValue1); //textValue2 = itemView.FindViewById<RelativeLayout>(ZC.Xamarin.Android.SwipeAction.Resource.Id.SwipeRelativeLayoutContent); //textValue3 = itemView.FindViewById<TextView>(ZC.Xamarin.Android.SwipeAction.Resource.Id.textValue3); swipeLayout = itemView; swipe_content = itemView.FindViewById <LinearLayout>(ZC.Xamarin.Android.SwipeAction.Resource.Id.swipe_content); }
public SimpleViewHolder(View itemView) : base(itemView) { SwipeLayout = itemView.FindViewById <SwipeLayout> (Resource.Id.swipe); TextViewPos = itemView.FindViewById <TextView> (Resource.Id.position); TextViewData = itemView.FindViewById <TextView> (Resource.Id.text_data); ButtonDelete = itemView.FindViewById <Button> (Resource.Id.delete); itemView.Click += (sender, e) => { Toast.MakeText(ItemView.Context, "OnItemSelected: " + TextViewData.Text, ToastLength.Short).Show(); }; }
public SimpleViewHolder (View itemView) : base (itemView) { SwipeLayout = itemView.FindViewById<SwipeLayout> (Resource.Id.swipe); TextViewPos = itemView.FindViewById<TextView> (Resource.Id.position); TextViewData = itemView.FindViewById<TextView> (Resource.Id.text_data); ButtonDelete = itemView.FindViewById<Button> (Resource.Id.delete); itemView.Click += (sender, e) => { Toast.MakeText (ItemView.Context, "OnItemSelected: " + TextViewData.Text, ToastLength.Short).Show (); }; }
public void SetNormalState(bool animated = false) { SwipeLayout.Visibility = ViewStates.Visible; if (animated) { SwipeLayout.Animate().TranslationX(0).SetDuration(150); } else { SwipeLayout.SetX(0); } PreUndoLayout.Visibility = ViewStates.Visible; UndoLayout.Visibility = ViewStates.Gone; }
public override View GetView(int position, View convertView, ViewGroup parent) { var swipeableView = convertView as SwipeLayout; if (swipeableView == null) { swipeableView = new SwipeLayout(context); } var topView = swipeableView.SetTopView(Resource.Layout.RowLayout); //RatingBar ratingbar = topView.FindViewById<RatingBar>(Resource.Id.ratingBar); //ratingbar.Visibility = ViewStates.Gone; //ratingbar.Rating = sessionsRating[position]; TextView textView = topView.FindViewById <TextView>(Resource.Id.textView); textView.Text = array[position]; if (activeSessionsPosition.Contains(position)) { topView.SetBackgroundColor(ColorHelper.Completed); //myButton.SetBackgroundColor(ColorHelper.Completed); swipeableView.SetClipToPadding(true); swipeableView.SetOnlyRightSwipe().EnablePossibleSwipeAnimationOnClick(true).AddSwipeButton(new ButtonBuilder(() => ViewSession(position), ColorHelper.Purple) .SetTitle(" VIEW ") .SetForegroundColor(Color.White) .SetButtonSize(ButtonSize.Wrap), SwipeDirection.Right).SetBackgroundColor(Color.DarkGreen);; } else { topView.SetBackgroundColor(ColorHelper.Inactive); swipeableView.SetBothWaysSwipe().EnablePossibleSwipeAnimationOnClick(true).AddSwipeButton(new ButtonBuilder(() => DeleteSession(position), ColorHelper.Red) .SetTitle(" DELETE ? ") .SetForegroundColor(Color.White) .SetButtonSize(ButtonSize.Wrap), SwipeDirection.Left).AddSwipeButton(new ButtonBuilder(() => ShowEditDetails(position), ColorHelper.Green) .SetTitle(" EDIT ") .SetForegroundColor(Color.White) .SetButtonSize(ButtonSize.Wrap), SwipeDirection.Right); } return(swipeableView); }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.main); //sample1 sample1 = FindViewById<SwipeLayout> (Resource.Id.sample1); sample1.SetShowMode (SwipeLayout.ShowMode.PullOut); sample1.AddDrag (SwipeLayout.DragEdge.Left, sample1.FindViewById (Resource.Id.bottom_wrapper)); sample1.AddDrag (SwipeLayout.DragEdge.Right, sample1.FindViewById (Resource.Id.bottom_wrapper_2)); sample1.AddDrag (SwipeLayout.DragEdge.Top, sample1.FindViewById (Resource.Id.starbott)); sample1.AddDrag (SwipeLayout.DragEdge.Bottom, sample1.FindViewById (Resource.Id.starbott)); sample1.AddRevealListener (Resource.Id.delete, (sender, e) => { }); sample1.SurfaceView.Click += (sender, e) => { Toast.MakeText (this, "Click on surface", ToastLength.Short).Show (); }; sample1.SurfaceView.LongClick += (sender, e) => { Toast.MakeText (this, "longClick on surface", ToastLength.Short).Show (); e.Handled = true; }; sample1.FindViewById (Resource.Id.star2).Click += (sender, e) => { Toast.MakeText (this, "Star", ToastLength.Short).Show (); }; sample1.FindViewById (Resource.Id.trash2).Click += (sender, e) => { Toast.MakeText (this, "Trash Bin", ToastLength.Short).Show (); }; sample1.FindViewById (Resource.Id.magnifier2).Click += (sender, e) => { Toast.MakeText (this, "Magnifier", ToastLength.Short).Show (); }; sample1.AddRevealListener (Resource.Id.starbott, (sender, e) => { View star = e.Child.FindViewById (Resource.Id.star); float d = e.Child.Height / 2 - star.Height / 2; ViewHelper.SetTranslationY (star, d * e.Fraction); ViewHelper.SetScaleX (star, e.Fraction + 0.6f); ViewHelper.SetScaleY (star, e.Fraction + 0.6f); }); //sample2 sample2 = FindViewById<SwipeLayout> (Resource.Id.sample2); sample2.SetShowMode (SwipeLayout.ShowMode.LayDown); sample2.AddDrag (SwipeLayout.DragEdge.Right, sample2.FindViewWithTag ("Bottom2")); sample2.FindViewById (Resource.Id.star).Click += (sender, e) => { Toast.MakeText (this, "Star", ToastLength.Short).Show (); }; sample2.FindViewById (Resource.Id.trash).Click += (sender, e) => { Toast.MakeText (this, "Trash Bin", ToastLength.Short).Show (); }; sample2.FindViewById (Resource.Id.magnifier).Click += (sender, e) => { Toast.MakeText (this, "Magnifier", ToastLength.Short).Show (); }; sample2.FindViewById (Resource.Id.click).Click += (sender, e) => { Toast.MakeText (this, "Yo!", ToastLength.Short).Show (); }; sample2.SurfaceView.Click += (sender, e) => { Toast.MakeText (this, "Click on surface", ToastLength.Short).Show (); }; //sample3 sample3 = FindViewById<SwipeLayout> (Resource.Id.sample3); sample3.AddDrag (SwipeLayout.DragEdge.Top, sample3.FindViewWithTag ("Bottom3")); sample3.AddRevealListener (Resource.Id.bottom_wrapper_child1, (sender, e) => { View star = e.Child.FindViewById (Resource.Id.star); float d = e.Child.Height / 2 - star.Height / 2; ViewHelper.SetTranslationY (star, d * e.Fraction); ViewHelper.SetScaleX (star, e.Fraction + 0.6f); ViewHelper.SetScaleY (star, e.Fraction + 0.6f); Color c = Evaluate (e.Fraction, Color.ParseColor ("#dddddd"), Color.ParseColor ("#4C535B")); e.Child.SetBackgroundColor (c); }); sample3.FindViewById (Resource.Id.bottom_wrapper_child1).Click += (sender, e) => { Toast.MakeText (this, "Yo!", ToastLength.Short).Show (); }; sample3.SurfaceView.Click += (sender, e) => { Toast.MakeText (this, "Click on surface", ToastLength.Short).Show (); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.main); //sample1 sample1 = FindViewById <SwipeLayout> (Resource.Id.sample1); sample1.SetShowMode(SwipeLayout.ShowMode.PullOut); sample1.AddDrag(SwipeLayout.DragEdge.Left, sample1.FindViewById(Resource.Id.bottom_wrapper)); sample1.AddDrag(SwipeLayout.DragEdge.Right, sample1.FindViewById(Resource.Id.bottom_wrapper_2)); sample1.AddDrag(SwipeLayout.DragEdge.Top, sample1.FindViewById(Resource.Id.starbott)); sample1.AddDrag(SwipeLayout.DragEdge.Bottom, sample1.FindViewById(Resource.Id.starbott)); sample1.AddRevealListener(Resource.Id.delete, (sender, e) => { }); sample1.SurfaceView.Click += (sender, e) => { Toast.MakeText(this, "Click on surface", ToastLength.Short).Show(); }; sample1.SurfaceView.LongClick += (sender, e) => { Toast.MakeText(this, "longClick on surface", ToastLength.Short).Show(); e.Handled = true; }; sample1.FindViewById(Resource.Id.star2).Click += (sender, e) => { Toast.MakeText(this, "Star", ToastLength.Short).Show(); }; sample1.FindViewById(Resource.Id.trash2).Click += (sender, e) => { Toast.MakeText(this, "Trash Bin", ToastLength.Short).Show(); }; sample1.FindViewById(Resource.Id.magnifier2).Click += (sender, e) => { Toast.MakeText(this, "Magnifier", ToastLength.Short).Show(); }; sample1.AddRevealListener(Resource.Id.starbott, (sender, e) => { View star = e.Child.FindViewById(Resource.Id.star); float d = e.Child.Height / 2 - star.Height / 2; ViewHelper.SetTranslationY(star, d * e.Fraction); ViewHelper.SetScaleX(star, e.Fraction + 0.6f); ViewHelper.SetScaleY(star, e.Fraction + 0.6f); }); //sample2 sample2 = FindViewById <SwipeLayout> (Resource.Id.sample2); sample2.SetShowMode(SwipeLayout.ShowMode.LayDown); sample2.AddDrag(SwipeLayout.DragEdge.Right, sample2.FindViewWithTag("Bottom2")); sample2.FindViewById(Resource.Id.star).Click += (sender, e) => { Toast.MakeText(this, "Star", ToastLength.Short).Show(); }; sample2.FindViewById(Resource.Id.trash).Click += (sender, e) => { Toast.MakeText(this, "Trash Bin", ToastLength.Short).Show(); }; sample2.FindViewById(Resource.Id.magnifier).Click += (sender, e) => { Toast.MakeText(this, "Magnifier", ToastLength.Short).Show(); }; sample2.FindViewById(Resource.Id.click).Click += (sender, e) => { Toast.MakeText(this, "Yo!", ToastLength.Short).Show(); }; sample2.SurfaceView.Click += (sender, e) => { Toast.MakeText(this, "Click on surface", ToastLength.Short).Show(); }; //sample3 sample3 = FindViewById <SwipeLayout> (Resource.Id.sample3); sample3.AddDrag(SwipeLayout.DragEdge.Top, sample3.FindViewWithTag("Bottom3")); sample3.AddRevealListener(Resource.Id.bottom_wrapper_child1, (sender, e) => { View star = e.Child.FindViewById(Resource.Id.star); float d = e.Child.Height / 2 - star.Height / 2; ViewHelper.SetTranslationY(star, d * e.Fraction); ViewHelper.SetScaleX(star, e.Fraction + 0.6f); ViewHelper.SetScaleY(star, e.Fraction + 0.6f); Color c = Evaluate(e.Fraction, Color.ParseColor("#dddddd"), Color.ParseColor("#4C535B")); e.Child.SetBackgroundColor(c); }); sample3.FindViewById(Resource.Id.bottom_wrapper_child1).Click += (sender, e) => { Toast.MakeText(this, "Yo!", ToastLength.Short).Show(); }; sample3.SurfaceView.Click += (sender, e) => { Toast.MakeText(this, "Click on surface", ToastLength.Short).Show(); }; }
public void OnUpdate(SwipeLayout p0, int p1, int p2) { IsSwiping = true; OnUpdateAction?.Invoke(p0, p1, p2); }
public void OnStartOpen(SwipeLayout p0) { IsSwiping = true; }
public void OnStartClose(SwipeLayout p0) { }
public void OnOpen(SwipeLayout p0) { OnOpenAction?.Invoke(p0); }
public void OnHandRelease(SwipeLayout p0, float p1, float p2) { OnReleaseAction?.Invoke(p0, p1, p2); }
public void OnClose(SwipeLayout p0) { IsSwiping = false; }