Exemplo n.º 1
0
        internal virtual void OnSwipe(NSIndexPath path, UITableViewCell cell)
        {
            MenuHostElement = TweetElementFromPath(path);
            if (MenuHostElement != null)
            {
                var frame = cell.ContentView.Frame;
                TableView.ScrollEnabled = false;

                if (swipeMenuImages == null)
                {
                    swipeMenuImages = new UIImage [] {
                        UIImage.FromBundle("Images/swipe-reply.png"),
                        UIImage.FromBundle("Images/swipe-retweet.png"),
                        UIImage.FromBundle("Images/swipe-profile.png"),
                        UIImage.FromBundle("Images/swipe-star-off.png"),
                        UIImage.FromBundle("Images/swipe-star-on.png"),
                    };

                    onImages = new UIImage [] {
                        swipeMenuImages [0], swipeMenuImages [1], swipeMenuImages [2], swipeMenuImages [4]
                    };
                    offImages = new UIImage [] {
                        swipeMenuImages [0], swipeMenuImages [1], swipeMenuImages [2], swipeMenuImages [3]
                    };
                }

                var menu = new SwipeMenuView(this, MenuHostElement.Tweet.Favorited ? onImages : offImages, frame);
                menu.Selected += idx => {
                    switch (idx)
                    {
                    case 0:
                        AppDelegate.MainAppDelegate.Reply(this, MenuHostElement.Tweet);
                        break;

                    case 1:
                        AppDelegate.MainAppDelegate.Retweet(this, MenuHostElement.Tweet);
                        break;

                    case 2:
                        ActivateController(new FullProfileView(MenuHostElement.Tweet.UserId));
                        break;

                    case 3:
                        AppDelegate.MainAppDelegate.ToggleFavorite(MenuHostElement.Tweet);
                        break;
                    }
                };
                ShowMenu(menu, cell);
            }
        }
Exemplo n.º 2
0
        bool HideMenu()
        {
            if (menuCell == null)
            {
                return(false);
            }

            float offset = menuCell.ContentView.Frame.Width;


            UIView.BeginAnimations("Foo");
            UIView.SetAnimationDuration(hideDelay);
            UIView.SetAnimationCurve(UIViewAnimationCurve.EaseInOut);

            var animation = MakeBounceAnimation(Math.Abs(offset), "position.x");

            foreach (var view in menuCell.ContentView.Subviews)
            {
                if (view == currentMenuView)
                {
                    continue;
                }

                view.SetNeedsDisplay();
                AnimateBack(view, animation);
            }
            AnimateBack(menuCell.SelectedBackgroundView, animation);

            UIView.CommitAnimations();

            // Pass the currentMenuView as the view to remove, as it is a global that can be overwritten by
            // another menu showing up.
            var copy = currentMenuView;

            NSTimer.CreateScheduledTimer(hideDelay + 0.1, delegate {
                copy.RemoveFromSuperview();
                copy.Dispose();
            });

            menuCell        = null;
            MenuHostElement = null;
            currentMenuView = null;
            return(true);
        }
Exemplo n.º 3
0
        internal virtual void OnSwipe(NSIndexPath path, UITableViewCell cell)
        {
            MenuHostElement = TweetElementFromPath (path);
            if (MenuHostElement != null){
                var frame = cell.ContentView.Frame;
                TableView.ScrollEnabled = false;

                if (swipeMenuImages == null){
                    swipeMenuImages = new UIImage [] {
                        UIImage.FromBundle ("Images/swipe-reply.png"),
                        UIImage.FromBundle ("Images/swipe-retweet.png"),
                        UIImage.FromBundle ("Images/swipe-profile.png"),
                        UIImage.FromBundle ("Images/swipe-star-off.png"),
                        UIImage.FromBundle ("Images/swipe-star-on.png"),
                    };

                    onImages = new UIImage [] {
                        swipeMenuImages [0], swipeMenuImages [1], swipeMenuImages [2], swipeMenuImages [4]
                    };
                    offImages = new UIImage [] {
                        swipeMenuImages [0], swipeMenuImages [1], swipeMenuImages [2], swipeMenuImages [3]
                    };
                }

                var menu = new SwipeMenuView (this, MenuHostElement.Tweet.Favorited ? onImages : offImages, frame);
                menu.Selected += idx => {
                    switch (idx){
                    case 0:
                        AppDelegate.MainAppDelegate.Reply (this, MenuHostElement.Tweet);
                        break;

                    case 1:
                        AppDelegate.MainAppDelegate.Retweet (this, MenuHostElement.Tweet);
                        break;

                    case 2:
                        ActivateController (new FullProfileView (MenuHostElement.Tweet.UserId));
                        break;

                    case 3:
                        AppDelegate.MainAppDelegate.ToggleFavorite (MenuHostElement.Tweet);
                        break;
                    }
                };
                ShowMenu (menu, cell);
            }
        }
Exemplo n.º 4
0
        bool HideMenu()
        {
            if (menuCell == null)
                return false;

            float offset = menuCell.ContentView.Frame.Width;

            // Pass the currentMenuView as the view to remove, as it is a global that can be overwritten by
            // another menu showing up.
            var copy = currentMenuView;
            var gch = GCHandle.Alloc (copy);
            UIView.BeginAnimations ("Foo", GCHandle.ToIntPtr (gch));
            UIView.SetAnimationDuration (hideDelay);
            UIView.SetAnimationDidStopSelector (new Selector ("animationDidStop:finished:context:"));
            UIView.SetAnimationDelegate (this);
            UIView.SetAnimationCurve (UIViewAnimationCurve.EaseInOut);

            var animation = MakeBounceAnimation (Math.Abs (offset));

            menuCell.Selected = false;
            foreach (var view in menuCell.ContentView.Subviews){
                if (view == currentMenuView)
                    continue;

                view.SetNeedsDisplay ();
                AnimateBack (view, animation);
            }
            AnimateBack (menuCell.SelectedBackgroundView, animation);

            UIView.CommitAnimations ();
            menuCell = null;
            DisableSelection = false;
            MenuHostElement = null;
            currentMenuView = null;
            return true;
        }
Exemplo n.º 5
0
		bool HideMenu ()
		{
			if (menuCell == null)
				return false;
			
			float offset = menuCell.ContentView.Frame.Width;
			

			UIView.BeginAnimations ("Foo");
			UIView.SetAnimationDuration (hideDelay);
			UIView.SetAnimationCurve (UIViewAnimationCurve.EaseInOut);			

			var animation = MakeBounceAnimation (Math.Abs (offset), "position.x");
			
			foreach (var view in menuCell.ContentView.Subviews){
				if (view == currentMenuView)
					continue;

				view.SetNeedsDisplay ();
				AnimateBack (view, animation);
			}
			AnimateBack (menuCell.SelectedBackgroundView, animation);

			UIView.CommitAnimations ();
			
			// Pass the currentMenuView as the view to remove, as it is a global that can be overwritten by
			// another menu showing up.
			var copy = currentMenuView;
			NSTimer.CreateScheduledTimer (hideDelay + 0.1, delegate {
				copy.RemoveFromSuperview ();
				copy.Dispose ();
			});
	
			menuCell = null;
			MenuHostElement = null;
			currentMenuView = null;
			return true;
		}
Exemplo n.º 6
0
        internal virtual void OnSwipe(NSIndexPath path, UITableViewCell cell)
        {
            MenuHostElement = TweetElementFromPath(path);
            if (MenuHostElement != null)
            {
                var frame = cell.ContentView.Frame;
                TableView.ScrollEnabled = false;

                if (swipeMenuImages == null)
                {
                    swipeMenuImages = new UIImage [] {
                        UIImage.FromBundle("Images/swipe-reply.png"),
                        UIImage.FromBundle("Images/swipe-retweet.png"),
                        UIImage.FromBundle("Images/swipe-profile.png"),
                        UIImage.FromBundle("Images/swipe-star-off.png"),
                        UIImage.FromBundle("Images/swipe-star-on.png"),
                        UIImage.FromBundle("Images/swipe-clip.png"),
                        UIImage.FromBundle("Images/swipe-clipdark.png"),
                    };

                    onImages = new UIImage [] {
                        swipeMenuImages [0], swipeMenuImages [1], swipeMenuImages [2], swipeMenuImages [4], swipeMenuImages [5]
                    };
                    offImages = new UIImage [] {
                        swipeMenuImages [0], swipeMenuImages [1], swipeMenuImages [2], swipeMenuImages [3], swipeMenuImages [5]
                    };
                }
                var imageSet = MenuHostElement.Tweet.Favorited ? onImages : offImages;
                imageSet [4] = MenuHostElement.Tweet.ContainsUrl ? swipeMenuImages [5] : swipeMenuImages [6];

                var menu = new SwipeMenuView(this, imageSet, frame);
                menu.Selected += idx => {
                    switch (idx)
                    {
                    case 0:
                        AppDelegate.MainAppDelegate.Reply(this, MenuHostElement.Tweet);
                        break;

                    case 1:
                        AppDelegate.MainAppDelegate.Retweet(this, MenuHostElement.Tweet);
                        break;

                    case 2:
                        ActivateController(new FullProfileView(MenuHostElement.Tweet.UserId));
                        break;

                    case 3:
                        AppDelegate.MainAppDelegate.ToggleFavorite(MenuHostElement.Tweet);
                        break;

                    case 4:
                        // Instapaper
                        var bookmarkTweet = MenuHostElement.Tweet;

                        if (!UrlBookmark.Bookmarker.LoggedIn)
                        {
                            UrlBookmark.Bookmarker.SignIn(this, x => {
                                if (!x)
                                {
                                    return;
                                }

                                BookmarkUrls(bookmarkTweet);
                            });
                        }
                        else
                        {
                            BookmarkUrls(bookmarkTweet);
                        }
                        break;
                    }
                };
                ShowMenu(menu, cell);
            }
        }
Exemplo n.º 7
0
		internal virtual void OnSwipe (NSIndexPath path, UITableViewCell cell)
		{
			MenuHostElement = TweetElementFromPath (path);
			if (MenuHostElement != null){
				var frame = cell.ContentView.Frame;				
				TableView.ScrollEnabled = false;
				
				if (swipeMenuImages == null){
					swipeMenuImages = new UIImage [] {
						UIImage.FromBundle ("Images/swipe-reply.png"),
						UIImage.FromBundle ("Images/swipe-retweet.png"),
						UIImage.FromBundle ("Images/swipe-profile.png"),
						UIImage.FromBundle ("Images/swipe-star-off.png"),
						UIImage.FromBundle ("Images/swipe-star-on.png"),
						UIImage.FromBundle ("Images/swipe-clip.png"),
						UIImage.FromBundle ("Images/swipe-clipdark.png"),
					};

					onImages = new UIImage [] {
						swipeMenuImages [0], swipeMenuImages [1], swipeMenuImages [2], swipeMenuImages [4], swipeMenuImages [5]
					};
					offImages = new UIImage [] {
						swipeMenuImages [0], swipeMenuImages [1], swipeMenuImages [2], swipeMenuImages [3], swipeMenuImages [5]
					};
				}
				var imageSet = MenuHostElement.Tweet.Favorited ? onImages : offImages;
				imageSet [4] = MenuHostElement.Tweet.ContainsUrl ? swipeMenuImages [5] : swipeMenuImages [6];
				
				var menu = new SwipeMenuView (this, imageSet, frame);
				menu.Selected += idx => {
					switch (idx){
					case 0:
						AppDelegate.MainAppDelegate.Reply (this, MenuHostElement.Tweet);
						break;
						
					case 1:
						AppDelegate.MainAppDelegate.Retweet (this, MenuHostElement.Tweet);
						break;
						
					case 2:
						ActivateController (new FullProfileView (MenuHostElement.Tweet.UserId));
						break;
						
					case 3:
						AppDelegate.MainAppDelegate.ToggleFavorite (MenuHostElement.Tweet);
						break;
						
					case 4:
						// Instapaper
						var bookmarkTweet = MenuHostElement.Tweet;
						
						if (!UrlBookmark.Bookmarker.LoggedIn){
							UrlBookmark.Bookmarker.SignIn (this, x=> {
								if (!x) return;
							
								BookmarkUrls (bookmarkTweet);
							});
						} else 
							BookmarkUrls (bookmarkTweet);
						break;
					}
				};
				ShowMenu (menu, cell);
			}
		}