public PostViewController(Post post, CellSizeHelper size, BasePostPresenter presenter) { _post = post; _presenter = presenter; _size = size; _presenter.SourceChanged += (obj) => { _cell.UpdateCell(_post, _size); }; }
public nfloat UpdateCell(Post post, CellSizeHelper variables) { _currentPost = post; likesMargin = leftMargin; _avatarImage?.RemoveFromSuperview(); _avatarImage = new UIImageView(new CGRect(leftMargin, 20, 30, 30)); _avatarImage.Layer.CornerRadius = _avatarImage.Frame.Size.Width / 2; _avatarImage.ClipsToBounds = true; _avatarImage.ContentMode = UIViewContentMode.ScaleAspectFill; _contentView.AddSubview(_avatarImage); _scheduledWorkAvatar?.Cancel(); if (!string.IsNullOrEmpty(_currentPost.Avatar)) { _scheduledWorkAvatar = ImageService.Instance.LoadUrl(_currentPost.Avatar, TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .FadeAnimation(false) .DownSample(200) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Normal) .Into(_avatarImage); } else { _avatarImage.Image = UIImage.FromBundle("ic_noavatar"); } _author.Text = _currentPost.Author; _timestamp.Text = _currentPost.Created.ToPostTime(); _photoScroll.Frame = new CGRect(0, _avatarImage.Frame.Bottom + 20, UIScreen.MainScreen.Bounds.Width, variables.PhotoHeight); _photoScroll.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width * _currentPost.Media.Length, variables.PhotoHeight); foreach (var subview in _photoScroll.Subviews) { subview.RemoveFromSuperview(); } for (int i = 0; i < _scheduledWorkBody.Length; i++) { _scheduledWorkBody[i]?.Cancel(); } _scheduledWorkBody = new IScheduledWork[_currentPost.Media.Length]; _bodyImage = new UIImageView[_currentPost.Media.Length]; for (int i = 0; i < _currentPost.Media.Length; i++) { _bodyImage[i] = new UIImageView(); _bodyImage[i].ClipsToBounds = true; _bodyImage[i].UserInteractionEnabled = true; _bodyImage[i].ContentMode = UIViewContentMode.ScaleAspectFill; _bodyImage[i].Frame = new CGRect(UIScreen.MainScreen.Bounds.Width * i, 0, UIScreen.MainScreen.Bounds.Width, variables.PhotoHeight); _photoScroll.AddSubview(_bodyImage[i]); _scheduledWorkBody[i] = ImageService.Instance.LoadUrl(_currentPost.Media[i].Url) .Retry(2) .FadeAnimation(false) .WithCache(FFImageLoading.Cache.CacheType.All) .WithPriority(LoadingPriority.Highest) /* .DownloadProgress((f)=> * { * })*/ .Into(_bodyImage[i]); } if (_currentPost.TopLikersAvatars.Any() && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[0])) { _firstLikerImage?.RemoveFromSuperview(); _firstLikerImage = new UIImageView(); _contentView.AddSubview(_firstLikerImage); _firstLikerImage.Layer.CornerRadius = likersCornerRadius; _firstLikerImage.ClipsToBounds = true; _firstLikerImage.ContentMode = UIViewContentMode.ScaleAspectFill; _firstLikerImage.Frame = new CGRect(leftMargin, _photoScroll.Frame.Bottom + likersY, likersImageSide, likersImageSide); _scheduledWorkfirst?.Cancel(); _scheduledWorkfirst = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[0], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .DownSample(width: 100) .FadeAnimation(false) .WithPriority(LoadingPriority.Lowest) .Into(_firstLikerImage); likesMargin = _firstLikerImage.Frame.Right + likesMarginConst; } else if (_firstLikerImage != null) { _firstLikerImage.Hidden = true; } if (_currentPost.TopLikersAvatars.Count() >= 2 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[1])) { _secondLikerImage?.RemoveFromSuperview(); _secondLikerImage = new UIImageView(); _contentView.AddSubview(_secondLikerImage); _secondLikerImage.Layer.CornerRadius = likersCornerRadius; _secondLikerImage.ClipsToBounds = true; _secondLikerImage.ContentMode = UIViewContentMode.ScaleAspectFill; _secondLikerImage.Frame = new CGRect(_firstLikerImage.Frame.Right - likersMargin, _photoScroll.Frame.Bottom + likersY, likersImageSide, likersImageSide); _scheduledWorksecond?.Cancel(); _scheduledWorksecond = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[1], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Lowest) .DownSample(width: 100) .FadeAnimation(false) .Into(_secondLikerImage); likesMargin = _secondLikerImage.Frame.Right + likesMarginConst; } else if (_secondLikerImage != null) { _secondLikerImage.Hidden = true; } if (_currentPost.TopLikersAvatars.Count() >= 3 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[2])) { _thirdLikerImage?.RemoveFromSuperview(); _thirdLikerImage = new UIImageView(); _contentView.AddSubview(_thirdLikerImage); _thirdLikerImage.Layer.CornerRadius = likersCornerRadius; _thirdLikerImage.ClipsToBounds = true; _thirdLikerImage.ContentMode = UIViewContentMode.ScaleAspectFill; _thirdLikerImage.Frame = new CGRect(_secondLikerImage.Frame.Right - likersMargin, _photoScroll.Frame.Bottom + likersY, likersImageSide, likersImageSide); _scheduledWorkthird?.Cancel(); _scheduledWorkthird = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[2], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Lowest) .DownSample(width: 100) .FadeAnimation(false) .Into(_thirdLikerImage); likesMargin = _thirdLikerImage.Frame.Right + likesMarginConst; } else if (_thirdLikerImage != null) { _thirdLikerImage.Hidden = true; } nfloat flagMargin = 0; if (_currentPost.NetLikes != 0) { _likes.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Likes, _currentPost.NetLikes); var likesWidth = _likes.SizeThatFits(new CGSize(0, underPhotoPanelHeight)); _likes.Frame = new CGRect(likesMargin, _photoScroll.Frame.Bottom, likesWidth.Width, underPhotoPanelHeight); flagMargin = flagsMarginConst; } else { _likes.Frame = new CGRect(likesMargin, _photoScroll.Frame.Bottom, 0, 0); } _likersTapView.Frame = new CGRect(leftMargin, _photoScroll.Frame.Bottom, _likes.Frame.Right - leftMargin, _likes.Frame.Height); if (_currentPost.NetFlags != 0) { _flags.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Flags, _currentPost.NetFlags); var flagsWidth = _flags.SizeThatFits(new CGSize(0, underPhotoPanelHeight)); _flags.Frame = new CGRect(likesMargin + _likes.Frame.Width + flagMargin, _photoScroll.Frame.Bottom, flagsWidth.Width, underPhotoPanelHeight); } else { _flags.Frame = new CGRect(likesMargin, _photoScroll.Frame.Bottom, 0, 0); } _like.Frame = new CGRect(_contentView.Frame.Width - likeButtonWidthConst, _photoScroll.Frame.Bottom, likeButtonWidthConst, underPhotoPanelHeight); _like.Transform = CGAffineTransform.MakeScale(1f, 1f); if (_currentPost.VoteChanging) { Animate(); } else { _like.Layer.RemoveAllAnimations(); _like.LayoutIfNeeded(); _like.Image = _currentPost.Vote ? UIImage.FromBundle("ic_like_active") : UIImage.FromBundle("ic_like"); _like.UserInteractionEnabled = true; } _verticalSeparator.Frame = new CGRect(_contentView.Frame.Width - likeButtonWidthConst - 1, _photoScroll.Frame.Bottom + underPhotoPanelHeight / 2 - verticalSeparatorHeight / 2, 1, verticalSeparatorHeight); /* * _rewards.Text = BaseViewController.ToFormatedCurrencyString(_currentPost.TotalPayoutReward); * var rewardWidth = _rewards.SizeThatFits(new CGSize(0, underPhotoPanelHeight)); * _rewards.Frame = new CGRect(_verticalSeparator.Frame.Left - rewardWidth.Width, _photoScroll.Frame.Bottom, rewardWidth.Width, underPhotoPanelHeight); */ _topSeparator.Frame = new CGRect(0, _photoScroll.Frame.Bottom + underPhotoPanelHeight, UIScreen.MainScreen.Bounds.Width, 1); _attributedLabel.SetText(variables.Text); _attributedLabel.Frame = new CGRect(new CGPoint(leftMargin, _topSeparator.Frame.Bottom + 15), new CGSize(UIScreen.MainScreen.Bounds.Width - leftMargin * 2, variables.TextHeight)); _comments.Text = _currentPost.Children == 0 ? AppSettings.LocalizationManager.GetText(LocalizationKeys.PostFirstComment) : AppSettings.LocalizationManager.GetText(LocalizationKeys.ViewComments, _currentPost.Children); _comments.Frame = new CGRect(leftMargin - 5, _attributedLabel.Frame.Bottom + 5, _comments.SizeThatFits(new CGSize(10, 20)).Width + 10, 20 + 10); _bottomSeparator.Frame = new CGRect(0, _comments.Frame.Bottom + 10, UIScreen.MainScreen.Bounds.Width, 1); return(_bottomSeparator.Frame.Bottom); //for constant size checking //var constantsSize = _bottomSeparator.Frame.Bottom - _attributedLabel.Frame.Height - _bodyImage.Frame.Height; }
public nfloat UpdateCell(Post post, CellSizeHelper variables, nfloat direction) { _currentPost = post; if (direction == 0) { leftMargin = 0; } else if (direction > 0) { leftMargin = 5; } else { leftMargin = -5; } likesMargin = leftMargin; _avatarImage?.RemoveFromSuperview(); _avatarImage = new UIImageView(new CGRect(leftMargin, 20, 30, 30)); _avatarImage.Layer.CornerRadius = _avatarImage.Frame.Size.Width / 2; _avatarImage.ClipsToBounds = true; _avatarImage.ContentMode = UIViewContentMode.ScaleAspectFill; _contentView.AddSubview(_avatarImage); _scheduledWorkAvatar?.Cancel(); if (!string.IsNullOrEmpty(_currentPost.Avatar)) { _scheduledWorkAvatar = ImageService.Instance.LoadUrl(_currentPost.Avatar, TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .FadeAnimation(false) .DownSample(200) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Normal) .Into(_avatarImage); } else { _avatarImage.Image = UIImage.FromBundle("ic_noavatar"); } _author.Text = _currentPost.Author; _timestamp.Text = _currentPost.Created.ToPostTime(); _contentScroll.SetContentOffset(new CGPoint(0, 0), false); _photoScroll.Frame = new CGRect(0, 0, _contentScroll.Frame.Width, variables.PhotoHeight); _photoScroll.ContentSize = new CGSize(_contentScroll.Frame.Width /* * _currentPost.Media.Length*/, variables.PhotoHeight); _photoScroll.SetContentOffset(new CGPoint(0, 0), false); foreach (var subview in _photoScroll.Subviews) { subview.RemoveFromSuperview(); } for (int i = 0; i < _scheduledWorkBody.Length; i++) { _scheduledWorkBody[i]?.Cancel(); } _scheduledWorkBody = new IScheduledWork[1 /*_currentPost.Media.Length*/]; _bodyImage = new UIImageView[1 /*_currentPost.Media.Length*/]; for (int i = 0; i < 1 /*_currentPost.Media.Length*/; i++) { _bodyImage[i] = new UIImageView(); _bodyImage[i].Layer.CornerRadius = 10; _bodyImage[i].ClipsToBounds = true; _bodyImage[i].UserInteractionEnabled = true; _bodyImage[i].ContentMode = UIViewContentMode.ScaleAspectFill; _bodyImage[i].Frame = new CGRect(_contentScroll.Frame.Width * i, 0, _contentScroll.Frame.Width, variables.PhotoHeight); _photoScroll.AddSubview(_bodyImage[i]); _scheduledWorkBody[i] = ImageService.Instance.LoadUrl(_currentPost.Media[0].Url) .Retry(2) .FadeAnimation(false) .WithCache(FFImageLoading.Cache.CacheType.All) .WithPriority(LoadingPriority.Highest) //.DownloadProgress((f)=> //{ //}) .Into(_bodyImage[i]); } if (_currentPost.TopLikersAvatars.Any() && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[0])) { _firstLikerImage?.RemoveFromSuperview(); _firstLikerImage = new UIImageView(); _contentScroll.AddSubview(_firstLikerImage); _firstLikerImage.BackgroundColor = UIColor.White; _firstLikerImage.Layer.CornerRadius = likersCornerRadius; _firstLikerImage.ClipsToBounds = true; _firstLikerImage.ContentMode = UIViewContentMode.ScaleAspectFill; _firstLikerImage.Frame = new CGRect(leftMargin, _photoScroll.Frame.Bottom + likersY, likersImageSide, likersImageSide); _scheduledWorkfirst?.Cancel(); _scheduledWorkfirst = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[0], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .DownSample(width: 100) .FadeAnimation(false) .WithPriority(LoadingPriority.Lowest) .Into(_firstLikerImage); likesMargin = _firstLikerImage.Frame.Right + likesMarginConst; } else if (_firstLikerImage != null) { _firstLikerImage.Hidden = true; } if (_currentPost.TopLikersAvatars.Count() >= 2 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[1])) { _secondLikerImage?.RemoveFromSuperview(); _secondLikerImage = new UIImageView(); _contentScroll.AddSubview(_secondLikerImage); _secondLikerImage.BackgroundColor = UIColor.White; _secondLikerImage.Layer.CornerRadius = likersCornerRadius; _secondLikerImage.ClipsToBounds = true; _secondLikerImage.ContentMode = UIViewContentMode.ScaleAspectFill; _secondLikerImage.Frame = new CGRect(_firstLikerImage.Frame.Right - likersMargin, _photoScroll.Frame.Bottom + likersY, likersImageSide, likersImageSide); _scheduledWorksecond?.Cancel(); _scheduledWorksecond = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[1], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Lowest) .DownSample(width: 100) .FadeAnimation(false) .Into(_secondLikerImage); likesMargin = _secondLikerImage.Frame.Right + likesMarginConst; } else if (_secondLikerImage != null) { _secondLikerImage.Hidden = true; } if (_currentPost.TopLikersAvatars.Count() >= 3 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[2])) { _thirdLikerImage?.RemoveFromSuperview(); _thirdLikerImage = new UIImageView(); _contentScroll.AddSubview(_thirdLikerImage); _thirdLikerImage.BackgroundColor = UIColor.White; _thirdLikerImage.Layer.CornerRadius = likersCornerRadius; _thirdLikerImage.ClipsToBounds = true; _thirdLikerImage.ContentMode = UIViewContentMode.ScaleAspectFill; _thirdLikerImage.Frame = new CGRect(_secondLikerImage.Frame.Right - likersMargin, _photoScroll.Frame.Bottom + likersY, likersImageSide, likersImageSide); _scheduledWorkthird?.Cancel(); _scheduledWorkthird = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[2], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Lowest) .DownSample(width: 100) .FadeAnimation(false) .Into(_thirdLikerImage); likesMargin = _thirdLikerImage.Frame.Right + likesMarginConst; } else if (_thirdLikerImage != null) { _thirdLikerImage.Hidden = true; } nfloat flagMargin = 0; if (_currentPost.NetLikes != 0) { _likes.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Likes, _currentPost.NetLikes); var likesWidth = _likes.SizeThatFits(new CGSize(0, underPhotoPanelHeight)); _likes.Frame = new CGRect(likesMargin, _photoScroll.Frame.Bottom, likesWidth.Width, underPhotoPanelHeight); flagMargin = flagsMarginConst; } else { _likes.Frame = new CGRect(likesMargin, _photoScroll.Frame.Bottom, 0, 0); } _likersTapView.Frame = new CGRect(leftMargin, _photoScroll.Frame.Bottom, _likes.Frame.Right - leftMargin, _likes.Frame.Height); if (_currentPost.NetFlags != 0) { _flags.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Flags, _currentPost.NetFlags); var flagsWidth = _flags.SizeThatFits(new CGSize(0, underPhotoPanelHeight)); _flags.Frame = new CGRect(likesMargin + _likes.Frame.Width + flagMargin, _photoScroll.Frame.Bottom, flagsWidth.Width, underPhotoPanelHeight); } else { _flags.Frame = new CGRect(likesMargin, _photoScroll.Frame.Bottom, 0, 0); } _like.Frame = new CGRect(_contentView.Frame.Width - likeButtonWidthConst, _photoScroll.Frame.Bottom, likeButtonWidthConst, underPhotoPanelHeight); _like.Transform = CGAffineTransform.MakeScale(1f, 1f); if (_currentPost.VoteChanging) { Animate(); } else { _like.Layer.RemoveAllAnimations(); _like.LayoutIfNeeded(); _like.Image = _currentPost.Vote ? UIImage.FromBundle("ic_like_active") : UIImage.FromBundle("ic_like"); _like.UserInteractionEnabled = true; } _verticalSeparator.Frame = new CGRect(_contentView.Frame.Width - likeButtonWidthConst - 1, _photoScroll.Frame.Bottom + underPhotoPanelHeight / 2 - verticalSeparatorHeight / 2, 1, verticalSeparatorHeight); /* * _rewards.Text = BaseViewController.ToFormatedCurrencyString(_currentPost.TotalPayoutReward); * var rewardWidth = _rewards.SizeThatFits(new CGSize(0, underPhotoPanelHeight)); * _rewards.Frame = new CGRect(_verticalSeparator.Frame.Left - rewardWidth.Width, _photoScroll.Frame.Bottom, rewardWidth.Width, underPhotoPanelHeight); */ _topSeparator.Frame = new CGRect(0, _photoScroll.Frame.Bottom + underPhotoPanelHeight, _contentScroll.Frame.Width, 1); var at = new NSMutableAttributedString(); var _noLinkAttribute = new UIStringAttributes { Font = Constants.Regular14, ForegroundColor = Constants.R15G24B30, }; at.Append(new NSAttributedString(_currentPost.Title, _noLinkAttribute)); if (!string.IsNullOrEmpty(_currentPost.Description)) { at.Append(new NSAttributedString(Environment.NewLine)); at.Append(new NSAttributedString(Environment.NewLine)); at.Append(new NSAttributedString(post.Description, _noLinkAttribute)); } foreach (var tag in _currentPost.Tags) { if (tag == "steepshot") { continue; } NSUrl tagUrlWithoutWhitespaces = null; try { tagUrlWithoutWhitespaces = new NSUrl(tag.Replace(' ', '#')); } catch (Exception ex) { AppSettings.Reporter.SendCrash(ex); } var linkAttribute = new UIStringAttributes { Link = tagUrlWithoutWhitespaces, Font = Constants.Regular14, ForegroundColor = Constants.R231G72B0, }; at.Append(new NSAttributedString($" ", _noLinkAttribute)); at.Append(new NSAttributedString($"#{tag}", linkAttribute)); } _attributedLabel?.RemoveFromSuperview(); _attributedLabel = new TTTAttributedLabel(); _attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link; var prop = new NSDictionary(); _attributedLabel.LinkAttributes = prop; _attributedLabel.ActiveLinkAttributes = prop; _attributedLabel.Font = Constants.Regular14; _attributedLabel.Lines = 0; _attributedLabel.UserInteractionEnabled = true; _attributedLabel.Enabled = true; //_attributedLabel.BackgroundColor = UIColor.Blue; _contentScroll.AddSubview(_attributedLabel); _attributedLabel.Delegate = new TTTAttributedLabelFeedDelegate(_tagAction); _attributedLabel.SetText(at); var textHeight = _attributedLabel.SizeThatFits(new CGSize(_contentScroll.Frame.Width, 0)).Height; _attributedLabel.Frame = new CGRect(new CGPoint(leftMargin, _topSeparator.Frame.Bottom + 15), new CGSize(_contentScroll.Frame.Width, textHeight)); _comments.Text = _currentPost.Children == 0 ? AppSettings.LocalizationManager.GetText(LocalizationKeys.PostFirstComment) : AppSettings.LocalizationManager.GetText(LocalizationKeys.ViewComments, _currentPost.Children); _comments.Frame = new CGRect(leftMargin - 5, _attributedLabel.Frame.Bottom + 5, _comments.SizeThatFits(new CGSize(10, 20)).Width + 10, 20 + 10); _bottomSeparator.Frame = new CGRect(0, _comments.Frame.Bottom + 10, _contentScroll.Frame.Width, 1); _contentScroll.ContentSize = new CGSize(_contentScroll.Frame.Width, _bottomSeparator.Frame.Bottom); return(_bottomSeparator.Frame.Bottom); //for constant size checking //var constantsSize = _bottomSeparator.Frame.Bottom - _attributedLabel.Frame.Height - _bodyImage.Frame.Height; }
public void UpdateCell(Post post, CellSizeHelper variables) { _currentPost = post; likesMargin = leftMargin; nfloat likersY = underPhotoPanelHeight / 2 - likersImageSide / 2; _bodyImage.Image = null; _scheduledWorkBody?.Cancel(); _scheduledWorkBody = ImageService.Instance.LoadUrl(_currentPost.Media[0].Url, Constants.ImageCacheDuration) .Retry(5) .FadeAnimation(false) .WithCache(FFImageLoading.Cache.CacheType.All) .DownSample((int)UIScreen.MainScreen.Bounds.Width) .WithPriority(LoadingPriority.Highest) .Into(_bodyImage); _avatarImage.Image = null; _scheduledWorkAvatar?.Cancel(); if (!string.IsNullOrEmpty(_currentPost.Avatar)) { _scheduledWorkAvatar = ImageService.Instance.LoadUrl(_currentPost.Avatar, TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .FadeAnimation(false) .DownSample(200) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Normal) .Into(_avatarImage); } else { _avatarImage.Image = UIImage.FromBundle("ic_noavatar"); } _author.Text = _currentPost.Author; _timestamp.Text = _currentPost.Created.ToPostTime(); _bodyImage.Frame = new CGRect(0, _avatarImage.Frame.Bottom + 20, UIScreen.MainScreen.Bounds.Width, variables.PhotoHeight); /*_bodyImage.Image = null; * _scheduledWorkBody?.Cancel(); * _scheduledWorkBody = ImageService.Instance.LoadUrl(_currentPost.Media[0].Url, Constants.ImageCacheDuration) * .Retry(5) * .FadeAnimation(false) * .WithCache(FFImageLoading.Cache.CacheType.All) * .DownSample((int)UIScreen.MainScreen.Bounds.Width) * .WithPriority(LoadingPriority.Highest) * .Into(_bodyImage);*/ if (_currentPost.TopLikersAvatars.Count() >= 1 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[0])) { _firstLikerImage.Frame = new CGRect(leftMargin, _bodyImage.Frame.Bottom + likersY, likersImageSide, likersImageSide); _scheduledWorkfirst?.Cancel(); _firstLikerImage.Image = null; _firstLikerImage.Hidden = false; _scheduledWorkfirst = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[0], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .DownSample(width: 100) .FadeAnimation(false) .WithPriority(LoadingPriority.Lowest) .Into(_firstLikerImage); likesMargin = _firstLikerImage.Frame.Right + likesMarginConst; } else { _firstLikerImage.Hidden = true; } if (_currentPost.TopLikersAvatars.Count() >= 2 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[1])) { _secondLikerImage.Frame = new CGRect(_firstLikerImage.Frame.Right - likersMargin, _bodyImage.Frame.Bottom + likersY, likersImageSide, likersImageSide); _scheduledWorksecond?.Cancel(); _secondLikerImage.Image = null; _secondLikerImage.Hidden = false; _scheduledWorksecond = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[1], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Lowest) .DownSample(width: 100) .FadeAnimation(false) .Into(_secondLikerImage); likesMargin = _secondLikerImage.Frame.Right + likesMarginConst; } else { _secondLikerImage.Hidden = true; } if (_currentPost.TopLikersAvatars.Count() >= 3 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[2])) { _thirdLikerImage.Frame = new CGRect(_secondLikerImage.Frame.Right - likersMargin, _bodyImage.Frame.Bottom + likersY, likersImageSide, likersImageSide); _scheduledWorkthird?.Cancel(); _thirdLikerImage.Image = null; _thirdLikerImage.Hidden = false; _scheduledWorkthird = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[2], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Lowest) .DownSample(width: 100) .FadeAnimation(false) .Into(_thirdLikerImage); likesMargin = _thirdLikerImage.Frame.Right + likesMarginConst; } else { _thirdLikerImage.Hidden = true; } nfloat flagMargin = 0; if (_currentPost.NetLikes != 0) { _likes.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Likes, _currentPost.NetLikes); var likesWidth = _likes.SizeThatFits(new CGSize(0, underPhotoPanelHeight)); _likes.Frame = new CGRect(likesMargin, _bodyImage.Frame.Bottom, likesWidth.Width, underPhotoPanelHeight); flagMargin = flagsMarginConst; } else { _likes.Frame = new CGRect(likesMargin, _bodyImage.Frame.Bottom, 0, 0); } _likersTapView.Frame = new CGRect(leftMargin, _bodyImage.Frame.Bottom, _likes.Frame.Right - leftMargin, _likes.Frame.Height); if (_currentPost.NetFlags != 0) { _flags.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Flags, _currentPost.NetFlags); var flagsWidth = _flags.SizeThatFits(new CGSize(0, underPhotoPanelHeight)); _flags.Frame = new CGRect(likesMargin + _likes.Frame.Width + flagMargin, _bodyImage.Frame.Bottom, flagsWidth.Width, underPhotoPanelHeight); } else { _flags.Frame = new CGRect(likesMargin, _bodyImage.Frame.Bottom, 0, 0); } _like.Frame = new CGRect(ContentView.Frame.Width - likeButtonWidthConst, _bodyImage.Frame.Bottom, likeButtonWidthConst, underPhotoPanelHeight); _like.Transform = CGAffineTransform.MakeScale(1f, 1f); if (_currentPost.VoteChanging) { Animate(); } else { _like.Image = _currentPost.Vote ? UIImage.FromBundle("ic_like_active") : UIImage.FromBundle("ic_like"); _like.UserInteractionEnabled = true; } _verticalSeparator.Frame = new CGRect(ContentView.Frame.Width - likeButtonWidthConst - 1, _bodyImage.Frame.Bottom + underPhotoPanelHeight / 2 - verticalSeparatorHeight / 2, 1, verticalSeparatorHeight); /* * _rewards.Text = BaseViewController.ToFormatedCurrencyString(_currentPost.TotalPayoutReward); * var rewardWidth = _rewards.SizeThatFits(new CGSize(0, underPhotoPanelHeight)); * _rewards.Frame = new CGRect(_verticalSeparator.Frame.Left - rewardWidth.Width, _bodyImage.Frame.Bottom, rewardWidth.Width, underPhotoPanelHeight); */ _topSeparator.Frame = new CGRect(0, _bodyImage.Frame.Bottom + underPhotoPanelHeight, UIScreen.MainScreen.Bounds.Width, 1); _attributedLabel.SetText(variables.Text); _attributedLabel.Frame = new CGRect(new CGPoint(leftMargin, _topSeparator.Frame.Bottom + 15), new CGSize(UIScreen.MainScreen.Bounds.Width - leftMargin * 2, variables.TextHeight)); _comments.Text = _currentPost.Children == 0 ? AppSettings.LocalizationManager.GetText(LocalizationKeys.PostFirstComment) : AppSettings.LocalizationManager.GetText(LocalizationKeys.ViewComments, _currentPost.Children); _comments.Frame = new CGRect(leftMargin - 5, _attributedLabel.Frame.Bottom + 5, _comments.SizeThatFits(new CGSize(10, 20)).Width + 10, 20 + 10); _bottomSeparator.Frame = new CGRect(0, _comments.Frame.Bottom + 10, UIScreen.MainScreen.Bounds.Width, 1); //for constant size checking //var constantsSize = _bottomSeparator.Frame.Bottom - _attributedLabel.Frame.Height - _bodyImage.Frame.Height; }