public DetailTweetView(RectangleF rect, Tweet tweet, TweetView.TappedEvent tapped, TweetView.TappedEvent tapAndHold, DialogViewController parent) : base(rect) { var tweetRect = rect; if (tweet.Kind != TweetKind.Direct) { tweetRect.Width -= 30; } BackgroundColor = UIColor.Clear; tweetView = new TweetView(tweetRect, tweet.Text, tapped, tapAndHold) { BackgroundColor = UIColor.Clear, }; AddSubview(tweetView); float y = tweetView.Frame.Height + PadY; string thumbUrl, previewUrl; var picUrl = PicDetect.FindPicUrl(tweet.Text, out thumbUrl, out previewUrl); if (picUrl != null) { borderAt = y; SetupImagePreview(parent, y, picUrl, thumbUrl, previewUrl); y += 90; } rect.Y = y; rect.Height = smallSize; AddSubview(new UILabel(rect) { Text = Locale.Format("{0} ago from {1}", Util.FormatTime(new TimeSpan(DateTime.UtcNow.Ticks - tweet.CreatedAt)), tweet.Source), TextColor = UIColor.Gray, BackgroundColor = UIColor.Clear, Font = UIFont.SystemFontOfSize(smallSize) }); y += PadY; var f = Frame; f.Y += PadY; f.Height = y + PadY + smallSize + 2; Frame = f; if (tweet.Kind != TweetKind.Direct) { // Now that we now our size, center the button buttonView = UIButton.FromType(UIButtonType.Custom); buttonView.Frame = new RectangleF(tweetRect.X + tweetRect.Width, (f.Height - 38) / 2 - 4, 38, 38); UpdateButtonImage(tweet.Favorited); buttonView.TouchDown += delegate { UpdateButtonImage(!tweet.Favorited); AppDelegate.MainAppDelegate.ToggleFavorite(tweet); }; AddSubview(buttonView); } }
public DetailTweetView(RectangleF rect, Tweet tweet, TweetView.TappedEvent handler, DialogViewController parent) : base(rect) { var tweetRect = rect; if (tweet.Kind != TweetKind.Direct) tweetRect.Width -= 30; BackgroundColor = UIColor.Clear; tweetView = new TweetView (tweetRect, tweet.Text){ BackgroundColor = UIColor.Clear, }; if (handler != null) tweetView.Tapped += handler; AddSubview (tweetView); float y = tweetView.Frame.Height + PadY; string thumbUrl, previewUrl; var picUrl = PicDetect.FindPicUrl (tweet.Text, out thumbUrl, out previewUrl); if (picUrl != null){ borderAt = y; SetupImagePreview (parent, y, picUrl, thumbUrl, previewUrl); y += 90; } rect.Y = y; rect.Height = smallSize; AddSubview (new UILabel (rect) { Text = Util.FormatTime (new TimeSpan (DateTime.UtcNow.Ticks - tweet.CreatedAt)) + " ago from " + tweet.Source, TextColor = UIColor.Gray, Font = UIFont.SystemFontOfSize (smallSize) }); y += PadY; var f = Frame; f.Y += PadY; f.Height = y + PadY + smallSize + 2; Frame = f; if (tweet.Kind != TweetKind.Direct){ // Now that we now our size, center the button buttonView = UIButton.FromType (UIButtonType.Custom); buttonView.Frame = new RectangleF (tweetRect.X + tweetRect.Width, (f.Height-38)/2-4, 38, 38); UpdateButtonImage (tweet); buttonView.TouchDown += delegate { tweet.Favorited = !tweet.Favorited; Util.MainAppDelegate.FavoriteChanged (tweet); TwitterAccount.CurrentAccount.Post (String.Format ("http://api.twitter.com/1/favorites/{0}/{1}.json", tweet.Favorited ? "create" : "destroy", tweet.Id),""); UpdateButtonImage (tweet); tweet.Replace (Database.Main); }; AddSubview (buttonView); } }
public DetailTweetView(RectangleF rect, Tweet tweet, TweetView.TappedEvent tapped, TweetView.TappedEvent tapAndHold, DialogViewController parent) : base(rect) { var tweetRect = rect; if (tweet.Kind != TweetKind.Direct) tweetRect.Width -= 30; BackgroundColor = UIColor.Clear; tweetView = new TweetView (tweetRect, tweet.Text, tapped, tapAndHold){ BackgroundColor = UIColor.Clear, }; AddSubview (tweetView); float y = tweetView.Frame.Height + PadY; string thumbUrl, previewUrl; var picUrl = PicDetect.FindPicUrl (tweet.Text, out thumbUrl, out previewUrl); if (picUrl != null){ borderAt = y; SetupImagePreview (parent, y, picUrl, thumbUrl, previewUrl); y += 90; } rect.Y = y; rect.Height = smallSize; AddSubview (new UILabel (rect) { Text = Locale.Format ("{0} ago from {1}", Util.FormatTime (new TimeSpan (DateTime.UtcNow.Ticks - tweet.CreatedAt)), tweet.Source), TextColor = UIColor.Gray, BackgroundColor = UIColor.Clear, Font = UIFont.SystemFontOfSize (smallSize) }); y += PadY; var f = Frame; f.Y += PadY; f.Height = y + PadY + smallSize + 2; Frame = f; if (tweet.Kind != TweetKind.Direct){ // Now that we now our size, center the button buttonView = UIButton.FromType (UIButtonType.Custom); buttonView.Frame = new RectangleF (tweetRect.X + tweetRect.Width, (f.Height-38)/2-4, 38, 38); UpdateButtonImage (tweet.Favorited); buttonView.TouchDown += delegate { UpdateButtonImage (!tweet.Favorited); AppDelegate.MainAppDelegate.ToggleFavorite (tweet); }; AddSubview (buttonView); } }