private void SetAgreementDecoration()
        {
            var tsAttribute = new UIStringAttributes
            {
                Link            = new NSUrl(Pp),
                Font            = Constants.Regular12,
                ForegroundColor = Constants.R15G24B30,
            };

            var ppAttribute = new UIStringAttributes
            {
                Link            = new NSUrl(Tos),
                Font            = Constants.Regular12,
                ForegroundColor = Constants.R15G24B30,
            };

            var noLinkAttribute = new UIStringAttributes
            {
                Font            = Constants.Regular12,
                ForegroundColor = Constants.R151G155B158,
            };

            var attributedLabel = new TTTAttributedLabel();

            attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link;
            attributedLabel.Lines = 2;

            var prop = new NSDictionary();

            attributedLabel.LinkAttributes       = prop;
            attributedLabel.ActiveLinkAttributes = prop;

            attributedLabel.Delegate = new TTTAttributedLabelCustomDelegate();
            agreementView.AddSubview(attributedLabel);

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString("I agree with ", noLinkAttribute));
            at.Append(new NSAttributedString("Terms of Service", tsAttribute));
            at.Append(new NSAttributedString(" & ", noLinkAttribute));
            at.Append(new NSAttributedString("Privacy Policy", ppAttribute));

            attributedLabel.SetText(at);
            attributedLabel.AutoAlignAxis(axis: ALAxis.Horizontal, otherView: termsSwitcher);
            attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 15f);
            termsSwitcher.AutoPinEdge(ALEdge.Left, ALEdge.Right, attributedLabel, 5f);
            termsSwitcher.Layer.CornerRadius = 16;
        }
        public void UpdateCell(Post post, Action <string> TagAction)
        {
            var attributedLabel = new TTTAttributedLabel();

            attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link;
            var prop = new NSDictionary();

            attributedLabel.LinkAttributes       = prop;
            attributedLabel.ActiveLinkAttributes = prop;

            DescriptionView.AddSubview(attributedLabel);
            attributedLabel.Font  = Helpers.Constants.Regular14;
            attributedLabel.Lines = 0;
            attributedLabel.UserInteractionEnabled = true;
            attributedLabel.Enabled = true;
            attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Right);
            attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 15f);
            attributedLabel.Delegate = new TTTAttributedLabelFeedDelegate(TagAction);

            var separator = new UIView();

            separator.BackgroundColor = iOS.Helpers.Constants.R245G245B245;
            DescriptionView.AddSubview(separator);

            separator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, attributedLabel, 15f);
            separator.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            separator.AutoPinEdgeToSuperviewEdge(ALEdge.Right);
            separator.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom);
            separator.AutoSetDimension(ALDimension.Height, 1);

            var noLinkAttribute = new UIStringAttributes
            {
                Font            = Helpers.Constants.Regular14,
                ForegroundColor = Helpers.Constants.R15G24B30,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString(post.Title, noLinkAttribute));
            if (!string.IsNullOrEmpty(post.Description))
            {
                at.Append(new NSAttributedString(Environment.NewLine));
                at.Append(new NSAttributedString(Environment.NewLine));
                at.Append(new NSAttributedString(post.Description, noLinkAttribute));
            }

            foreach (var tag in post.Tags)
            {
                if (tag == "steepshot")
                {
                    continue;
                }
                var linkAttribute = new UIStringAttributes
                {
                    Link            = new NSUrl(tag),
                    Font            = Helpers.Constants.Regular14,
                    ForegroundColor = Helpers.Constants.R231G72B0,
                };
                at.Append(new NSAttributedString($" #{tag}", linkAttribute));
            }
            attributedLabel.SetText(at);
        }
Exemple #3
0
        public override void UpdateCell(Post post)
        {
            _currentPost      = post;
            avatarImage.Image = null;
            _scheduledWorkAvatar?.Cancel();

            bodyImage.Image = null;
            _scheduledWorkBody?.Cancel();

            var media = _currentPost.Media[0];

            _scheduledWorkBody = ImageService.Instance.LoadUrl(media.Url, Helpers.Constants.ImageCacheDuration)
                                 //.Retry(5)
                                 .FadeAnimation(false)
                                 .WithCache(FFImageLoading.Cache.CacheType.All)
                                 .DownSample((int)UIScreen.MainScreen.Bounds.Width)
                                 .WithPriority(LoadingPriority.Highest)
                                 .Into(bodyImage);

            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");
            }

            topLikers.Hidden = true;
            if (_currentPost.TopLikersAvatars.Count() >= 1 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[0]))
            {
                _scheduledWorkfirst?.Cancel();
                firstLiker.Image    = null;
                topLikers.Hidden    = false;
                firstLiker.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)
                                      .WithPriority(LoadingPriority.Lowest)
                                      .Into(firstLiker);
            }
            else
            {
                firstLiker.Hidden = true;
            }

            if (_currentPost.TopLikersAvatars.Count() >= 2 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[1]))
            {
                _scheduledWorksecond?.Cancel();
                secondLiker.Image    = null;
                secondLiker.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)
                                       .Into(secondLiker);
            }
            else
            {
                secondLiker.Hidden = true;
            }

            if (_currentPost.TopLikersAvatars.Count() >= 3 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[2]))
            {
                _scheduledWorkthird?.Cancel();
                thirdLiker.Image    = null;
                thirdLiker.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)
                                      .Into(thirdLiker);
            }
            else
            {
                thirdLiker.Hidden = true;
            }

            cellText.Text  = _currentPost.Author;
            rewards.Hidden = !BasePresenter.User.IsNeedRewards;
            //rewards.Text = BaseViewController.ToFormatedCurrencyString(_currentPost.TotalPayoutReward);

            netVotes.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Like, _currentPost.NetVotes);

            if (_currentPost.VoteChanging)
            {
                Animate();
            }
            else
            {
                likeButton.Transform = CGAffineTransform.MakeScale(1f, 1f);
                likeButton.Selected  = _currentPost.Vote;
            }

            flagButton.Selected  = _currentPost.Flag;
            viewCommentText.Text = _currentPost.Children == 0
                ? AppSettings.LocalizationManager.GetText(LocalizationKeys.PostFirstComment)
                : AppSettings.LocalizationManager.GetText(LocalizationKeys.ViewComments, _currentPost.Children);

            likeButton.Enabled = true;
            flagButton.Enabled = true;
            postTimeStamp.Text = _currentPost.Created.ToPostTime();

            imageHeight.Constant      = PhotoHeight.Get(media.Size);
            contentViewWidth.Constant = UIScreen.MainScreen.Bounds.Width;

            if (!_isButtonBinded)
            {
                cellText.Font        = Helpers.Constants.Semibold14;
                postTimeStamp.Font   = Helpers.Constants.Regular12;
                netVotes.Font        = Helpers.Constants.Semibold14;
                rewards.Font         = Helpers.Constants.Semibold14;
                viewCommentText.Font = Helpers.Constants.Regular14;

                avatarImage.Layer.CornerRadius = avatarImage.Frame.Size.Width / 2;
                firstLiker.Layer.CornerRadius  = firstLiker.Frame.Size.Width / 2;
                secondLiker.Layer.CornerRadius = secondLiker.Frame.Size.Width / 2;
                thirdLiker.Layer.CornerRadius  = thirdLiker.Frame.Size.Width / 2;

                attributedLabel = new TTTAttributedLabel();
                attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link;
                var prop = new NSDictionary();
                attributedLabel.LinkAttributes       = prop;
                attributedLabel.ActiveLinkAttributes = prop;

                commentView.AddSubview(attributedLabel);
                attributedLabel.Font  = Helpers.Constants.Regular14;
                attributedLabel.Lines = 0;
                attributedLabel.UserInteractionEnabled = true;
                attributedLabel.Enabled = true;
                attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 15f);
                attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 15f);
                attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 15f);
                viewCommentText.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, attributedLabel, 5f);
                attributedLabel.Delegate = new TTTAttributedLabelFeedDelegate(TagAction);

                UITapGestureRecognizer tap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Preview, _currentPost);
                });
                bodyImage.AddGestureRecognizer(tap);

                UITapGestureRecognizer imageTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Profile, _currentPost);
                });
                UITapGestureRecognizer textTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Profile, _currentPost);
                });
                UITapGestureRecognizer moneyTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Profile, _currentPost);
                });
                avatarImage.AddGestureRecognizer(imageTap);
                cellText.AddGestureRecognizer(textTap);
                rewards.AddGestureRecognizer(moneyTap);

                UITapGestureRecognizer commentTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Comments, _currentPost);
                });
                viewCommentText.AddGestureRecognizer(commentTap);

                UITapGestureRecognizer netVotesTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Voters, _currentPost);
                });
                netVotes.AddGestureRecognizer(netVotesTap);

                flagButton.TouchDown += FlagButton_TouchDown;
                likeButton.TouchDown += LikeTap;

                _isButtonBinded = true;

                Debug.WriteLine("Cell created");
            }

            var noLinkAttribute = new UIStringAttributes
            {
                Font            = Helpers.Constants.Regular14,
                ForegroundColor = Helpers.Constants.R15G24B30,
            };

            var at = new NSMutableAttributedString();

            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(_currentPost.Description, noLinkAttribute));
            }

            foreach (var tag in _currentPost.Tags)
            {
                if (tag == "steepshot")
                {
                    continue;
                }
                var linkAttribute = new UIStringAttributes
                {
                    Link            = new NSUrl(tag),
                    Font            = Helpers.Constants.Regular14,
                    ForegroundColor = Helpers.Constants.R231G72B0,
                };
                at.Append(new NSAttributedString($" #{tag}", linkAttribute));
            }
            attributedLabel.SetText(at);
        }
Exemple #4
0
        protected TransactionCollectionViewCell(IntPtr handle) : base(handle)
        {
            var sideMargin = DeviceHelper.IsSmallDevice ? 15 : 30;

            ContentView.UserInteractionEnabled = true;

            var background = new UIView();

            background.BackgroundColor    = Constants.R255G255B255;
            background.Layer.CornerRadius = 16;
            ContentView.AddSubview(background);

            background.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 60);
            background.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 5);
            background.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 10);
            background.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom, 5);

            var emptyBackground = new UIView();

            ContentView.AddSubview(emptyBackground);

            emptyBackground.AutoPinEdge(ALEdge.Right, ALEdge.Left, background);
            emptyBackground.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            emptyBackground.AutoPinEdgeToSuperviewEdge(ALEdge.Top);
            emptyBackground.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom);

            var leftContainer = new UIView();

            background.AddSubview(leftContainer);

            leftContainer.AutoPinEdgeToSuperviewEdge(ALEdge.Left, sideMargin);
            leftContainer.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);

            _action.Font = Constants.Semibold14;
            leftContainer.AddSubview(_action);

            _action.AutoPinEdgeToSuperviewEdge(ALEdge.Top);
            _action.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            _action.AutoPinEdgeToSuperviewEdge(ALEdge.Right);

            _to.AdjustsFontSizeToFitWidth = true;
            _to.EnabledTextCheckingTypes  = NSTextCheckingType.Link;
            var prop = new NSDictionary();

            _to.LinkAttributes         = prop;
            _to.ActiveLinkAttributes   = prop;
            _to.UserInteractionEnabled = true;
            _to.Enabled = true;
            leftContainer.AddSubview(_to);

            _to.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, _action);
            _to.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom);
            _to.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            _to.AutoPinEdgeToSuperviewEdge(ALEdge.Right);

            _amount.Font          = Constants.Semibold16;
            _amount.TextAlignment = UITextAlignment.Right;
            background.AddSubview(_amount);

            _amount.AutoPinEdge(ALEdge.Left, ALEdge.Right, leftContainer);
            _amount.AutoAlignAxis(ALAxis.Horizontal, leftContainer);
            _amount.AutoPinEdgeToSuperviewEdge(ALEdge.Right, sideMargin);

            var circle = new UIView();

            circle.BackgroundColor    = UIColor.FromRGB(230, 230, 230);
            circle.Layer.CornerRadius = 4;
            emptyBackground.AddSubview(circle);

            circle.AutoSetDimensionsToSize(new CGSize(8, 8));
            circle.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            circle.AutoAlignAxisToSuperviewAxis(ALAxis.Vertical);

            _topLine = new UIView();
            _topLine.BackgroundColor    = UIColor.FromRGB(240, 240, 240);
            _topLine.Layer.CornerRadius = 1;
            emptyBackground.AddSubview(_topLine);

            _topLine.AutoSetDimension(ALDimension.Width, 2);
            _topLine.AutoAlignAxisToSuperviewAxis(ALAxis.Vertical);
            _topLine.AutoPinEdgeToSuperviewEdge(ALEdge.Top);
            _topLine.AutoPinEdge(ALEdge.Bottom, ALEdge.Top, circle, -16);

            _bottomLine = new UIView();
            _bottomLine.BackgroundColor    = UIColor.FromRGB(240, 240, 240);
            _bottomLine.Layer.CornerRadius = 1;
            emptyBackground.AddSubview(_bottomLine);

            _bottomLine.AutoSetDimension(ALDimension.Width, 2);
            _bottomLine.AutoAlignAxisToSuperviewAxis(ALAxis.Vertical);
            _bottomLine.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom);
            _bottomLine.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, circle, 16);
        }