public override void DidSelectLinkWithURL(TTTAttributedLabel label, NSUrl url)
            {
                var stringUrl  = url.AbsoluteString;
                var tosUrl     = Phoebe.Build.TermsOfServiceUrl.ToString();
                var privacyUrl = Phoebe.Build.PrivacyPolicyUrl.ToString();

                if (stringUrl.Equals(tosUrl) || stringUrl.Equals(privacyUrl))
                {
                    url = new NSUrl(String.Format("{0}?simple=true", stringUrl));
                }
                WebViewController controller = new WebViewController(url);

                label.Window.RootViewController.PresentViewController(controller, true, null);
            }
        public static CellSizeHelper Calculate(Post post)
        {
            var photoHeight = (int)(OptimalPhotoSize.Get(new Size()
            {
                Height = post.Media[0].Size.Height, Width = post.Media[0].Size.Width
            },
                                                         (float)UIScreen.MainScreen.Bounds.Width, 180, (float)UIScreen.MainScreen.Bounds.Width + 50));

            var attributedLabel = new TTTAttributedLabel();
            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;
                }
                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($" #{tag}", linkAttribute));
            }

            attributedLabel.Lines = 0;
            attributedLabel.SetText(at);

            var textHeight = attributedLabel.SizeThatFits(new CGSize(UIScreen.MainScreen.Bounds.Width - 15 * 2, 0)).Height;

            return(new CellSizeHelper(photoHeight, textHeight, at));
        }
        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;
        }
Exemple #4
0
        protected override void OnElementChanged(ElementChangedEventArgs <Label> e)
        {
            base.OnElementChanged(e);

            if (Element == null)
            {
                return;
            }

            if (e.NewElement != null)
            {
                var attributedLabel = new TTTAttributedLabel();
                setupText(attributedLabel, e.NewElement as CustomLinkLabel);
                SetNativeControl(attributedLabel);
            }
        }
Exemple #5
0
 public static void LegalLabel (TTTAttributedLabel v)
 {
     v.Lines = 2;
     v.Font = UIFont.FromName ("HelveticaNeue", 16f);
     v.TextColor = Color.Gray;
     v.TextAlignment = UITextAlignment.Center;
     v.LinkAttributes = new UIStringAttributes () {
         ForegroundColor = Color.Green,
         ParagraphStyle = new NSMutableParagraphStyle () {
             Alignment = UITextAlignment.Center,
         },
     }.Dictionary;
     v.ActiveLinkAttributes = new UIStringAttributes () {
         ForegroundColor = Color.DarkGreen,
     }.Dictionary;
 }
        private static void SetLegalText(TTTAttributedLabel label)
        {
            var template = "SignupLegal".Tr();
            var arg0     = "SignupToS".Tr();
            var arg1     = "SignupPrivacy".Tr();

            var arg0idx = String.Format(template, "{0}", arg1).IndexOf("{0}", StringComparison.Ordinal);
            var arg1idx = String.Format(template, arg0, "{1}").IndexOf("{1}", StringComparison.Ordinal);

            label.Text = (NSString)String.Format(template, arg0, arg1);
            label.AddLinkToURL(
                new NSUrl(Phoebe.Build.TermsOfServiceUrl.ToString()),
                new NSRange(arg0idx, arg0.Length));
            label.AddLinkToURL(
                new NSUrl(Phoebe.Build.PrivacyPolicyUrl.ToString()),
                new NSRange(arg1idx, arg1.Length));
        }
Exemple #7
0
 public static void LegalLabel(TTTAttributedLabel v)
 {
     v.Lines          = 2;
     v.Font           = UIFont.FromName("HelveticaNeue", 16f);
     v.TextColor      = Color.Gray;
     v.TextAlignment  = UITextAlignment.Center;
     v.LinkAttributes = new UIStringAttributes()
     {
         ForegroundColor = Color.Green,
         ParagraphStyle  = new NSMutableParagraphStyle()
         {
             Alignment = UITextAlignment.Center,
         },
     }.Dictionary;
     v.ActiveLinkAttributes = new UIStringAttributes()
     {
         ForegroundColor = Color.DarkGreen,
     }.Dictionary;
 }
        public static TTTAttributedLabel GetBodyLabel(NSObject weakDelegate)
        {
            var bodyLabel = new TTTAttributedLabel
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor        = UIColor.White,
                UserInteractionEnabled = true,
                Lines                    = 0,
                TextColor                = Colors.MessageColor,
                Font                     = AttributedStringUtilities.MessageFont,
                LinkAttributes           = AttributedStringUtilities.LinkStringAttributes.Dictionary,
                EnabledTextCheckingTypes = NSTextCheckingType.Link,
                WeakDelegate             = weakDelegate
            };

            bodyLabel.SetContentCompressionResistancePriority(250, UILayoutConstraintAxis.Vertical);

            return(bodyLabel);
        }
Exemple #9
0
        private void setupText(TTTAttributedLabel attributedLabel, CustomLinkLabel label)
        {
            if ((attributedLabel != null) && (label != null))
            {
                NSMutableParagraphStyle paragraphStyle = new NSMutableParagraphStyle();
                paragraphStyle.LineBreakMode = UILineBreakMode.WordWrap;

                if (label.LineSpacing > 0)
                {
                    paragraphStyle.LineHeightMultiple = (float)label.LineSpacing;
                }

                UIElementsHelper.SetCustomLabelParagraphStyle(paragraphStyle, label);

                string text = string.Empty;
                if (!string.IsNullOrEmpty(label.Text))
                {
                    text = label.Text;
                }

                var attString = new NSMutableAttributedString(text, new UIStringAttributes
                {
                    ForegroundColor   = label.TextColor.ToUIColor(),
                    Font              = UIFont.SystemFontOfSize((nfloat)label.FontSize),
                    ParagraphStyle    = paragraphStyle,
                    KerningAdjustment = null
                });

                attributedLabel.LineBreakMode = UILineBreakMode.WordWrap;
                attributedLabel.Lines         = 0;
                attributedLabel.TextAlignment = paragraphStyle.Alignment;

                if (!string.IsNullOrEmpty(label.UrlText) && !string.IsNullOrEmpty(label.Url) && !string.IsNullOrEmpty(label.Text) && label.Text.Contains(label.UrlText))
                {
                    attributedLabel.AddLinkToURL(new NSUrl(label.Url), new NSRange(label.Text.IndexOf(label.UrlText), label.UrlText.Length));
                    attributedLabel.Delegate = new LabelDelegate();
                    attString.AddAttribute(UIStringAttributeKey.ForegroundColor, label.LinkColor.ToUIColor(), new NSRange(label.Text.IndexOf(label.UrlText), label.UrlText.Length));
                }

                attributedLabel.AttributedText = attString;
            }
        }
Exemple #10
0
        public static CellSizeHelper Calculate(Post post)
        {
            var attributedLabel = new TTTAttributedLabel();
            var at          = new NSMutableAttributedString();
            var photoHeight = PhotoHeight.Get(post.Media[0].Size);

            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            = Constants.Regular14,
                    ForegroundColor = Constants.R231G72B0,
                };
                at.Append(new NSAttributedString($" #{tag}", linkAttribute));
            }

            attributedLabel.Lines = 0;
            attributedLabel.SetText(at);

            var textHeight = attributedLabel.SizeThatFits(new CGSize(UIScreen.MainScreen.Bounds.Width - 15 * 2, 0)).Height;

            return(new CellSizeHelper(photoHeight, textHeight, at));
        }
        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 #12
0
 public override void DidSelectLinkWithURL(TTTAttributedLabel label, NSUrl url)
 {
     _tagAction?.Invoke(url.Description);
 }
Exemple #13
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);
        }
        public FeedCellBuilder(UIView contentView)
        {
            _contentView = contentView;

            _moreButton       = new UIButton();
            _moreButton.Frame = new CGRect(_contentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, 60);
            _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal);
            //_moreButton.BackgroundColor = UIColor.Black;
            _contentView.AddSubview(_moreButton);

            _avatarImage = new UIImageView(new CGRect(leftMargin, 15, 30, 30));
            _contentView.AddSubview(_avatarImage);

            var authorX = _avatarImage.Frame.Right + 10;

            _author      = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _moreButton.Frame.Left - authorX, 18));
            _author.Font = Constants.Semibold14;
            //_author.BackgroundColor = UIColor.Yellow;
            _author.LineBreakMode = UILineBreakMode.TailTruncation;
            _author.TextColor     = Constants.R15G24B30;
            _contentView.AddSubview(_author);

            _timestamp      = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _moreButton.Frame.Left - authorX, 16));
            _timestamp.Font = Constants.Regular12;
            //_timestamp.BackgroundColor = UIColor.Green;
            _timestamp.LineBreakMode = UILineBreakMode.TailTruncation;
            _timestamp.TextColor     = Constants.R151G155B158;
            _contentView.AddSubview(_timestamp);

            _photoScroll = new UIScrollView();
            _photoScroll.BackgroundColor = Constants.R244G244B246;
            _photoScroll.ShowsHorizontalScrollIndicator = false;
            _photoScroll.Bounces       = false;
            _photoScroll.PagingEnabled = true;
            _photoScroll.Scrolled     += (sender, e) =>
            {
                var pageWidth = _photoScroll.Frame.Size.Width;
                _pageControl.CurrentPage = (int)Math.Floor((_photoScroll.ContentOffset.X - pageWidth / 2) / pageWidth) + 1;
            };
            contentView.AddSubview(_photoScroll);

            _pageControl        = new UIPageControl();
            _pageControl.Hidden = true;
            _pageControl.UserInteractionEnabled = false;
            contentView.AddSubview(_pageControl);

            _likes                        = new UILabel();
            _likes.Font                   = Constants.Semibold14;
            _likes.LineBreakMode          = UILineBreakMode.TailTruncation;
            _likes.TextColor              = Constants.R15G24B30;
            _likes.UserInteractionEnabled = true;
            _contentView.AddSubview(_likes);

            _flags      = new UILabel();
            _flags.Font = Constants.Semibold14;
            //_flags.BackgroundColor = UIColor.Orange;
            _flags.LineBreakMode          = UILineBreakMode.TailTruncation;
            _flags.TextColor              = Constants.R15G24B30;
            _flags.UserInteractionEnabled = true;
            _contentView.AddSubview(_flags);

            _rewards      = new UILabel();
            _rewards.Font = Constants.Semibold14;
            //_rewards.BackgroundColor = UIColor.Orange;
            _rewards.LineBreakMode          = UILineBreakMode.TailTruncation;
            _rewards.TextColor              = Constants.R15G24B30;
            _rewards.UserInteractionEnabled = true;
            _contentView.AddSubview(_rewards);

            _like             = new UIImageView();
            _like.ContentMode = UIViewContentMode.Center;
            _contentView.AddSubview(_like);

            _verticalSeparator = new UIView();
            _verticalSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_verticalSeparator);

            _topSeparator = new UIView();
            _topSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_topSeparator);

            var _noLinkAttribute = new UIStringAttributes
            {
                Font            = Constants.Regular14,
                ForegroundColor = Constants.R151G155B158,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString("...", _noLinkAttribute));

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

            _attributedLabel.LinkAttributes       = prop;
            _attributedLabel.ActiveLinkAttributes = prop;
            _attributedLabel.Font  = Constants.Regular14;
            _attributedLabel.Lines = 3;
            _attributedLabel.UserInteractionEnabled = true;
            _attributedLabel.Enabled = true;
            _attributedLabel.AttributedTruncationToken = at;
            //_attributedLabel.BackgroundColor = UIColor.Blue;
            _contentView.AddSubview(_attributedLabel);

            _comments      = new UILabel();
            _comments.Font = Constants.Regular14;
            //_comments.BackgroundColor = UIColor.DarkGray;
            _comments.LineBreakMode          = UILineBreakMode.TailTruncation;
            _comments.TextColor              = Constants.R151G155B158;
            _comments.UserInteractionEnabled = true;
            _comments.TextAlignment          = UITextAlignment.Center;
            _contentView.AddSubview(_comments);

            _bottomSeparator = new UIView();
            _bottomSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_bottomSeparator);

            _profileTapView = new UIView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width / 2, likeButtonWidthConst));
            _profileTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_profileTapView);

            _likersTapView = new UIView();
            _likersTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_likersTapView);

            likersY            = underPhotoPanelHeight / 2 - likersImageSide / 2;
            likersCornerRadius = likersImageSide / 2;

            var liketap = new UITapGestureRecognizer(LikeTap);

            _like.AddGestureRecognizer(liketap);

            _sliderView          = new SliderView(UIScreen.MainScreen.Bounds.Width);
            _sliderView.LikeTap += () =>
            {
                LikeTap();
            };
            BaseViewController.SliderAction += (isSliderOpening) =>
            {
                if (_sliderView.Superview != null && !isSliderOpening)
                {
                    _sliderView.Close();
                }
            };

            var likelongtap = new UILongPressGestureRecognizer((UILongPressGestureRecognizer obj) =>
            {
                if (AppSettings.User.HasPostingPermission && !_currentPost.Vote)
                {
                    if (obj.State == UIGestureRecognizerState.Began)
                    {
                        if (!BasePostPresenter.IsEnableVote || BaseViewController.IsSliderOpen)
                        {
                            return;
                        }
                        BaseViewController.IsSliderOpen = true;
                        _sliderView.Show(_contentView);
                    }
                }
            });

            _like.AddGestureRecognizer(likelongtap);

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

            _photoScroll.AddGestureRecognizer(tap);

            var profileTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });
            var headerTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });

            _profileTapView.AddGestureRecognizer(headerTap);
            _rewards.AddGestureRecognizer(profileTap);

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

            _comments.AddGestureRecognizer(commentTap);

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

            _likersTapView.AddGestureRecognizer(netVotesTap);

            var flagersTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Flagers, _currentPost);
            });

            _flags.AddGestureRecognizer(flagersTap);

            _moreButton.TouchDown += FlagButton_TouchDown;
        }
        public FeedCellBuilder(UIView contentView)
        {
            _contentView = contentView;

            _moreButton       = new UIButton();
            _moreButton.Frame = new CGRect(_contentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst);
            _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal);
            //_moreButton.BackgroundColor = UIColor.Black;
            _contentView.AddSubview(_moreButton);

            _avatarImage = new UIImageView(new CGRect(leftMargin, 20, 30, 30));
            _contentView.AddSubview(_avatarImage);

            var authorX = _avatarImage.Frame.Right + 10;

            _author      = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _moreButton.Frame.Left - authorX, 18));
            _author.Font = Constants.Semibold14;
            //_author.BackgroundColor = UIColor.Yellow;
            _author.LineBreakMode = UILineBreakMode.TailTruncation;
            _author.TextColor     = Constants.R15G24B30;
            _contentView.AddSubview(_author);

            _timestamp      = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _moreButton.Frame.Left - authorX, 16));
            _timestamp.Font = Constants.Regular12;
            //_timestamp.BackgroundColor = UIColor.Green;
            _timestamp.LineBreakMode = UILineBreakMode.TailTruncation;
            _timestamp.TextColor     = Constants.R151G155B158;
            _contentView.AddSubview(_timestamp);

            _photoScroll = new UIScrollView();
            _photoScroll.ShowsHorizontalScrollIndicator = false;
            _photoScroll.Bounces       = false;
            _photoScroll.PagingEnabled = true;
            contentView.AddSubview(_photoScroll);

            _likes                        = new UILabel();
            _likes.Font                   = Constants.Semibold14;
            _likes.LineBreakMode          = UILineBreakMode.TailTruncation;
            _likes.TextColor              = Constants.R15G24B30;
            _likes.UserInteractionEnabled = true;
            _contentView.AddSubview(_likes);

            _flags      = new UILabel();
            _flags.Font = Constants.Semibold14;
            //_flags.BackgroundColor = UIColor.Orange;
            _flags.LineBreakMode          = UILineBreakMode.TailTruncation;
            _flags.TextColor              = Constants.R15G24B30;
            _flags.UserInteractionEnabled = true;
            _contentView.AddSubview(_flags);

            _rewards      = new UILabel();
            _rewards.Font = Constants.Semibold14;
            //_rewards.BackgroundColor = UIColor.Orange;
            _rewards.LineBreakMode          = UILineBreakMode.TailTruncation;
            _rewards.TextColor              = Constants.R15G24B30;
            _rewards.UserInteractionEnabled = true;
            _contentView.AddSubview(_rewards);

            _like             = new UIImageView();
            _like.ContentMode = UIViewContentMode.Center;
            _contentView.AddSubview(_like);

            _verticalSeparator = new UIView();
            _verticalSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_verticalSeparator);

            _topSeparator = new UIView();
            _topSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_topSeparator);

            var _noLinkAttribute = new UIStringAttributes
            {
                Font            = Constants.Regular14,
                ForegroundColor = Constants.R151G155B158,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString("...", _noLinkAttribute));

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

            _attributedLabel.LinkAttributes       = prop;
            _attributedLabel.ActiveLinkAttributes = prop;
            _attributedLabel.Font  = Constants.Regular14;
            _attributedLabel.Lines = 3;
            _attributedLabel.UserInteractionEnabled = true;
            _attributedLabel.Enabled = true;
            _attributedLabel.AttributedTruncationToken = at;
            //_attributedLabel.BackgroundColor = UIColor.Blue;
            _contentView.AddSubview(_attributedLabel);

            _comments      = new UILabel();
            _comments.Font = Constants.Regular14;
            //_comments.BackgroundColor = UIColor.DarkGray;
            _comments.LineBreakMode          = UILineBreakMode.TailTruncation;
            _comments.TextColor              = Constants.R151G155B158;
            _comments.UserInteractionEnabled = true;
            _comments.TextAlignment          = UITextAlignment.Center;
            _contentView.AddSubview(_comments);

            _bottomSeparator = new UIView();
            _bottomSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_bottomSeparator);

            _profileTapView = new UIView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width / 2, likeButtonWidthConst));
            _profileTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_profileTapView);

            _likersTapView = new UIView();
            _likersTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_likersTapView);

            likersY            = underPhotoPanelHeight / 2 - likersImageSide / 2;
            likersCornerRadius = likersImageSide / 2;

            var liketap = new UITapGestureRecognizer(LikeTap);

            _like.AddGestureRecognizer(liketap);

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

            _photoScroll.AddGestureRecognizer(tap);

            var profileTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });
            var headerTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });

            _profileTapView.AddGestureRecognizer(headerTap);
            _rewards.AddGestureRecognizer(profileTap);

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

            _comments.AddGestureRecognizer(commentTap);

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

            _likersTapView.AddGestureRecognizer(netVotesTap);

            var flagersTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Flagers, _currentPost);
            });

            _flags.AddGestureRecognizer(flagersTap);

            _moreButton.TouchDown += FlagButton_TouchDown;
        }
        public override void LoadView()
        {
            View = new UIView()
                   .Apply(Style.Screen);

            View.Add(inputsContainer = new UIView().Apply(Style.Signup.InputsContainer));

            inputsContainer.Add(topBorder = new UIView().Apply(Style.Signup.InputsBorder));

            inputsContainer.Add(emailTextField = new UITextField()
            {
                Placeholder            = "SignupEmailHint".Tr(),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                KeyboardType           = UIKeyboardType.EmailAddress,
                ReturnKeyType          = UIReturnKeyType.Next,
                ClearButtonMode        = UITextFieldViewMode.Always,
                ShouldReturn           = HandleShouldReturn,
            }.Apply(Style.Signup.EmailField));
            emailTextField.EditingChanged += OnTextFieldEditingChanged;

            inputsContainer.Add(middleBorder = new UIView().Apply(Style.Signup.InputsBorder));

            inputsContainer.Add(passwordTextField = new PasswordTextField()
            {
                Placeholder            = "SignupPasswordHint".Tr(),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                AutocorrectionType     = UITextAutocorrectionType.No,
                SecureTextEntry        = true,
                ReturnKeyType          = UIReturnKeyType.Go,
                ShouldReturn           = HandleShouldReturn,
            }.Apply(Style.Signup.PasswordField));
            passwordTextField.EditingChanged += OnTextFieldEditingChanged;

            inputsContainer.Add(bottomBorder = new UIView().Apply(Style.Signup.InputsBorder));

            View.Add(passwordActionButton = new UIButton()
                                            .Apply(Style.Signup.SignupButton));
            passwordActionButton.SetTitle("SignupSignupButtonText".Tr(), UIControlState.Normal);
            passwordActionButton.TouchUpInside += OnPasswordActionButtonTouchUpInside;

            View.Add(googleActionButton = new UIButton()
                                          .Apply(Style.Signup.GoogleButton));
            googleActionButton.SetTitle("SignupGoogleButtonText".Tr(), UIControlState.Normal);
            googleActionButton.TouchUpInside += OnGoogleActionButtonTouchUpInside;

            View.Add(legalLabel = new TTTAttributedLabel()
            {
                Delegate = new LegalLabelDelegate(),
            }.Apply(Style.Signup.LegalLabel));
            SetLegalText(legalLabel);

            inputsContainer.AddConstraints(
                topBorder.AtTopOf(inputsContainer),
                topBorder.AtLeftOf(inputsContainer),
                topBorder.AtRightOf(inputsContainer),
                topBorder.Height().EqualTo(1f),

                emailTextField.Below(topBorder),
                emailTextField.AtLeftOf(inputsContainer, 20f),
                emailTextField.AtRightOf(inputsContainer, 10f),
                emailTextField.Height().EqualTo(42f),

                middleBorder.Below(emailTextField),
                middleBorder.AtLeftOf(inputsContainer, 20f),
                middleBorder.AtRightOf(inputsContainer),
                middleBorder.Height().EqualTo(1f),

                passwordTextField.Below(middleBorder),
                passwordTextField.AtLeftOf(inputsContainer, 20f),
                passwordTextField.AtRightOf(inputsContainer),
                passwordTextField.Height().EqualTo(42f),

                bottomBorder.Below(passwordTextField),
                bottomBorder.AtLeftOf(inputsContainer),
                bottomBorder.AtRightOf(inputsContainer),
                bottomBorder.AtBottomOf(inputsContainer),
                bottomBorder.Height().EqualTo(1f)
                );

            inputsContainer.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                inputsContainer.AtTopOf(View, 80f),
                inputsContainer.AtLeftOf(View),
                inputsContainer.AtRightOf(View),

                passwordActionButton.Below(inputsContainer, 20f),
                passwordActionButton.AtLeftOf(View),
                passwordActionButton.AtRightOf(View),
                passwordActionButton.Height().EqualTo(60f),

                googleActionButton.Below(passwordActionButton, 5f),
                googleActionButton.AtLeftOf(View),
                googleActionButton.AtRightOf(View),
                googleActionButton.Height().EqualTo(60f),

                legalLabel.AtBottomOf(View, 30f),
                legalLabel.AtLeftOf(View, 40f),
                legalLabel.AtRightOf(View, 40f)
                );

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            ResetSignupButtonState();
        }
 public override void DidSelectLinkWithURL(TTTAttributedLabel label, NSUrl url)
 {
     UIApplication.SharedApplication.OpenUrl(url);
 }
Exemple #18
0
        public override void DidSelectLinkWithURL(TTTAttributedLabel label, NSUrl url)
        {
            var type = (PlagiarismLinkType)Enum.Parse(typeof(PlagiarismLinkType), url.ToString(), true);

            _linkAction?.Invoke(type);
        }
Exemple #19
0
        protected NewFeedCollectionViewCell(IntPtr handle) : base(handle)
        {
            //ContentView.BackgroundColor = UIColor.Cyan;

            _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);

            _moreButton       = new UIButton();
            _moreButton.Frame = new CGRect(ContentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst);
            _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal);
            //_moreButton.BackgroundColor = UIColor.Black;
            ContentView.AddSubview(_moreButton);

            var authorX = _avatarImage.Frame.Right + 10;

            _author      = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _moreButton.Frame.Left - authorX, 18));
            _author.Font = Constants.Semibold14;
            //_author.BackgroundColor = UIColor.Yellow;
            _author.LineBreakMode = UILineBreakMode.TailTruncation;
            _author.TextColor     = Constants.R15G24B30;
            ContentView.AddSubview(_author);

            _timestamp      = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _moreButton.Frame.Left - authorX, 16));
            _timestamp.Font = Constants.Regular12;
            //_timestamp.BackgroundColor = UIColor.Green;
            _timestamp.LineBreakMode = UILineBreakMode.TailTruncation;
            _timestamp.TextColor     = Constants.R151G155B158;
            ContentView.AddSubview(_timestamp);

            _bodyImage = new UIImageView();
            _bodyImage.ClipsToBounds          = true;
            _bodyImage.UserInteractionEnabled = true;
            _bodyImage.ContentMode            = UIViewContentMode.ScaleAspectFill;
            ContentView.AddSubview(_bodyImage);

            var likersCornerRadius = likersImageSide / 2;

            _firstLikerImage = new UIImageView();
            _firstLikerImage.Layer.CornerRadius = likersCornerRadius;
            _firstLikerImage.ClipsToBounds      = true;
            _firstLikerImage.ContentMode        = UIViewContentMode.ScaleAspectFill;
            ContentView.AddSubview(_firstLikerImage);

            _secondLikerImage = new UIImageView();
            _secondLikerImage.Layer.CornerRadius = likersCornerRadius;
            _secondLikerImage.ClipsToBounds      = true;
            _secondLikerImage.ContentMode        = UIViewContentMode.ScaleAspectFill;
            ContentView.AddSubview(_secondLikerImage);

            _thirdLikerImage = new UIImageView();
            _thirdLikerImage.Layer.CornerRadius = likersCornerRadius;
            _thirdLikerImage.ClipsToBounds      = true;
            _thirdLikerImage.ContentMode        = UIViewContentMode.ScaleAspectFill;
            ContentView.AddSubview(_thirdLikerImage);

            _likes      = new UILabel();
            _likes.Font = Constants.Semibold14;
            //_likes.BackgroundColor = UIColor.Magenta;
            _likes.LineBreakMode          = UILineBreakMode.TailTruncation;
            _likes.TextColor              = Constants.R15G24B30;
            _likes.UserInteractionEnabled = true;
            ContentView.AddSubview(_likes);

            _flags      = new UILabel();
            _flags.Font = Constants.Semibold14;
            //_flags.BackgroundColor = UIColor.Orange;
            _flags.LineBreakMode          = UILineBreakMode.TailTruncation;
            _flags.TextColor              = Constants.R15G24B30;
            _flags.UserInteractionEnabled = true;
            ContentView.AddSubview(_flags);

            _rewards      = new UILabel();
            _rewards.Font = Constants.Semibold14;
            //_rewards.BackgroundColor = UIColor.Orange;
            _rewards.LineBreakMode          = UILineBreakMode.TailTruncation;
            _rewards.TextColor              = Constants.R15G24B30;
            _rewards.UserInteractionEnabled = true;
            ContentView.AddSubview(_rewards);

            _like             = new UIImageView();
            _like.ContentMode = UIViewContentMode.Center;
            ContentView.AddSubview(_like);

            _verticalSeparator = new UIView();
            _verticalSeparator.BackgroundColor = Constants.R244G244B246;
            ContentView.AddSubview(_verticalSeparator);

            _topSeparator = new UIView();
            _topSeparator.BackgroundColor = Constants.R244G244B246;
            ContentView.AddSubview(_topSeparator);

            _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;
            ContentView.AddSubview(_attributedLabel);

            _comments      = new UILabel();
            _comments.Font = Constants.Regular14;
            //_comments.BackgroundColor = UIColor.DarkGray;
            _comments.LineBreakMode          = UILineBreakMode.TailTruncation;
            _comments.TextColor              = Constants.R151G155B158;
            _comments.UserInteractionEnabled = true;
            _comments.TextAlignment          = UITextAlignment.Center;
            ContentView.AddSubview(_comments);

            _bottomSeparator = new UIView();
            _bottomSeparator.BackgroundColor = Constants.R244G244B246;
            ContentView.AddSubview(_bottomSeparator);

            _profileTapView = new UIView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width / 2, likeButtonWidthConst));
            _profileTapView.UserInteractionEnabled = true;
            ContentView.AddSubview(_profileTapView);

            _likersTapView = new UIView();
            _likersTapView.UserInteractionEnabled = true;
            ContentView.AddSubview(_likersTapView);

            var liketap = new UITapGestureRecognizer(LikeTap);

            _like.AddGestureRecognizer(liketap);

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

            _bodyImage.AddGestureRecognizer(tap);

            var profileTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });
            var headerTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });

            _profileTapView.AddGestureRecognizer(headerTap);
            _rewards.AddGestureRecognizer(profileTap);

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

            _comments.AddGestureRecognizer(commentTap);

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

            _likersTapView.AddGestureRecognizer(netVotesTap);

            var flagersTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Flagers, _currentPost);
            });

            _flags.AddGestureRecognizer(flagersTap);

            _moreButton.TouchDown += FlagButton_TouchDown;
        }
 public override void DidSelectLinkWithURL(TTTAttributedLabel label, NSUrl url)
 {
     Console.WriteLine("Clicked URL: {0}", url.ToString());
 }
Exemple #21
0
 public override void DidSelectLinkWithURL (TTTAttributedLabel label, NSUrl url)
 {
     UIApplication.SharedApplication.OpenUrl (url);
 }
        public UIView CreateView()
        {
            var screenWidth = UIScreen.MainScreen.Bounds.Width;

            UserInteractionEnabled = true;

            #region topPanel

            topView = new UIView();
            topView.BackgroundColor = UIColor.Clear;
            topView.Frame           = new CGRect(mainMargin - 5, mainMargin, screenWidth - mainMargin * 2, topViewHeight);

            avatar = new UIImageView(new CGRect(5, 5, photoSide, photoSide));
            avatar.Layer.CornerRadius     = photoSide / 2;
            avatar.ClipsToBounds          = true;
            avatar.UserInteractionEnabled = true;
            avatar.ContentMode            = UIViewContentMode.ScaleAspectFill;
            avatar.BackgroundColor        = UIColor.Clear;
            powerFrame = new CircleFrame(avatar, new CGRect(0, 0, powerFrameSide, powerFrameSide));

            infoView              = new UIStackView();
            infoView.Axis         = UILayoutConstraintAxis.Vertical;
            infoView.Alignment    = UIStackViewAlignment.Fill;
            infoView.Distribution = UIStackViewDistribution.FillEqually;
            infoView.Frame        = new CGRect(powerFrameSide + topViewSpacing, 0, screenWidth - mainMargin * 2 - (powerFrameSide + topViewSpacing), topViewHeight + 8);

            userName = new UILabel();
            userName.UserInteractionEnabled = false;
            userName.TextColor       = Helpers.Constants.R15G24B30;
            userName.Font            = Helpers.Constants.Semibold20;
            userName.Lines           = 1;
            userName.LineBreakMode   = UILineBreakMode.TailTruncation;
            userName.BackgroundColor = UIColor.Clear;

            userLocation = new UILabel();
            userLocation.UserInteractionEnabled = false;
            userLocation.TextColor       = Helpers.Constants.R151G155B158;
            userLocation.Font            = Helpers.Constants.Regular14;
            userLocation.Lines           = 1;
            userLocation.LineBreakMode   = UILineBreakMode.TailTruncation;
            userLocation.BackgroundColor = UIColor.Clear;

            var topEmptyView    = new UIView();
            var bottomEmptyView = new UIView();

            infoView.AddArrangedSubview(topEmptyView);
            infoView.AddArrangedSubview(userName);
            infoView.AddArrangedSubview(userLocation);
            infoView.AddArrangedSubview(bottomEmptyView);

            topView.AddSubview(powerFrame);
            topView.AddSubview(infoView);
            AddSubview(topView);

            #endregion

            attributedLabel       = new TTTAttributedLabel();
            attributedLabel.Lines = 0;
            attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link;

            var prop = new NSDictionary();
            attributedLabel.LinkAttributes       = prop;
            attributedLabel.ActiveLinkAttributes = prop;

            attributedLabel.Delegate = new TTTAttributedLabelCustomDelegate();

            at = new NSMutableAttributedString();

            followButton = new UIButton();
            followButton.BackgroundColor = UIColor.Clear;
            AddSubview(followButton);

            followProgress = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray);
            followProgress.HidesWhenStopped = false;
            followProgress.StartAnimating();
            AddSubview(followProgress);

            #region originality

            originalityContainer = new UIView();
            originalityContainer.BackgroundColor    = Helpers.Constants.R250G250B250;
            originalityContainer.Layer.CornerRadius = 10;

            originalityLabel = new UILabel();
            originalityLabel.UserInteractionEnabled = false;
            //originalityLabel.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Originality);
            originalityLabel.TextColor     = UIColor.Black;
            originalityLabel.Font          = Helpers.Constants.Regular14;
            originalityLabel.Lines         = 1;
            originalityLabel.LineBreakMode = UILineBreakMode.TailTruncation;

            originality = new UILabel();
            originality.UserInteractionEnabled = false;
            originality.Text      = "100%";
            originality.TextColor = Helpers.Constants.R255G34B5;
            originality.Font      = Helpers.Constants.Semibold14;
            originality.Lines     = 1;

            originalityContainer.AddSubview(originalityLabel);
            originalityContainer.AddSubview(originality);

            //contentView.AddSubview(originalityContainer);

            #endregion

            #region stats

            statsView              = new UIStackView();
            statsView.Axis         = UILayoutConstraintAxis.Horizontal;
            statsView.Alignment    = UIStackViewAlignment.Fill;
            statsView.Distribution = UIStackViewDistribution.Fill;
            statsView.TranslatesAutoresizingMaskIntoConstraints = false;

            photos    = new UIButton();
            following = new UIButton();
            followers = new UIButton();

            var emptySpace = new UIView();

            var firstSpacing  = new UIView();
            var secondSpacing = new UIView();

            statsView.AddArrangedSubview(photos);
            statsView.AddArrangedSubview(firstSpacing);
            statsView.AddArrangedSubview(following);
            statsView.AddArrangedSubview(secondSpacing);
            statsView.AddArrangedSubview(followers);
            statsView.AddArrangedSubview(emptySpace);

            statsContainer = new UIView();
            statsContainer.AddSubview(statsView);

            AddSubview(statsContainer);

            #endregion

            #region balance

            balanceContainer = new UIView();
            balanceContainer.UserInteractionEnabled = true;

            var topSeparator    = new UIView();
            var bottomSeparator = new UIView();
            topSeparator.BackgroundColor = bottomSeparator.BackgroundColor = Helpers.Constants.R245G245B245;

            var balanceImage = new UIImageView();
            balanceImage.Image = UIImage.FromBundle("ic_balance");

            var balanceLabel = new UILabel();
            balanceLabel.UserInteractionEnabled = false;
            balanceLabel.Text      = AppSettings.LocalizationManager.GetText(LocalizationKeys.AccountBalance);
            balanceLabel.TextColor = UIColor.Black;
            balanceLabel.Font      = Helpers.Constants.Regular14;
            balanceLabel.Lines     = 1;

            balance = new UILabel();
            balance.UserInteractionEnabled = false;
            balance.TextColor     = Helpers.Constants.R255G34B5;
            balance.TextAlignment = UITextAlignment.Right;
            balance.Font          = Helpers.Constants.Semibold14;
            balance.Lines         = 1;

            var balanceArrow = new UIImageView();
            balanceArrow.Image = UIImage.FromBundle("ic_forward");

            balanceContainer.AddSubview(topSeparator);
            balanceContainer.AddSubview(bottomSeparator);
            balanceContainer.AddSubview(balanceImage);
            balanceContainer.AddSubview(balanceLabel);
            balanceContainer.AddSubview(balanceArrow);
            balanceContainer.AddSubview(balance);

            UITapGestureRecognizer balanceTap = new UITapGestureRecognizer(() =>
            {
                ProfileAction?.Invoke(ActionType.Balance);
            });
            balanceContainer.AddGestureRecognizer(balanceTap);
//#if DEBUG
            AddSubview(balanceContainer);
//#endif
            #endregion

            AddSubview(bottomSeparator);

            #region constraints

            /*
             * originalityLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left, extraMargin);
             * originalityLabel.AutoAlignAxis(ALAxis.Horizontal, originalityContainer);
             * originality.AutoPinEdgeToSuperviewEdge(ALEdge.Right, extraMargin);
             * originality.AutoAlignAxis(ALAxis.Horizontal, originalityContainer);
             */

            statsView.AutoPinEdgesToSuperviewEdges();

            topSeparator.AutoSetDimension(ALDimension.Height, 1);
            topSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Top);
            topSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            topSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Right);

            bottomSeparator.AutoSetDimension(ALDimension.Height, 1);
            bottomSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            bottomSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Right);
            bottomSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom);

            followProgress.AutoAlignAxis(ALAxis.Horizontal, followButton);
            followProgress.AutoAlignAxis(ALAxis.Vertical, followButton);
//#if DEBUG
            balanceImage.AutoSetDimensionsToSize(new CGSize(10, 10));
            balanceImage.AutoPinEdgeToSuperviewEdge(ALEdge.Left, mainMargin);
            balanceImage.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            balanceLabel.AutoPinEdge(ALEdge.Left, ALEdge.Right, balanceImage, 20);
            balanceLabel.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            balanceArrow.AutoSetDimensionsToSize(new CGSize(6, 10));
            balanceArrow.AutoPinEdgeToSuperviewEdge(ALEdge.Right, mainMargin);
            balanceArrow.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            balance.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 55);
            balance.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
//#endif
            firstSpacing.AutoSetDimension(ALDimension.Width, 48);
            secondSpacing.AutoSetDimension(ALDimension.Width, 48);

            #endregion

            return(this);
        }
 public override void DidSelectLinkWithURL (TTTAttributedLabel label, NSUrl url)
 {
     var stringUrl = url.AbsoluteString;
     var tosUrl = Phoebe.Build.TermsOfServiceUrl.ToString ();
     var privacyUrl = Phoebe.Build.PrivacyPolicyUrl.ToString ();
     if (stringUrl.Equals (tosUrl) || stringUrl.Equals (privacyUrl)) {
         url = new NSUrl (String.Format ("{0}?simple=true", stringUrl));
     }
     WebViewController controller = new WebViewController (url);
     label.Window.RootViewController.PresentViewController (controller, true, null);
 }
        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;
        }
Exemple #25
0
        private static void SetLegalText (TTTAttributedLabel label)
        {
            var template = "SignupLegal".Tr ();
            var arg0 = "SignupToS".Tr ();
            var arg1 = "SignupPrivacy".Tr ();

            var arg0idx = String.Format (template, "{0}", arg1).IndexOf ("{0}", StringComparison.Ordinal);
            var arg1idx = String.Format (template, arg0, "{1}").IndexOf ("{1}", StringComparison.Ordinal);

            label.Text = (NSString)String.Format (template, arg0, arg1);
            label.AddLinkToURL (
                new NSUrl (Phoebe.Build.TermsOfServiceUrl.ToString ()),
                new NSRange (arg0idx, arg0.Length));
            label.AddLinkToURL (
                new NSUrl (Phoebe.Build.PrivacyPolicyUrl.ToString ()),
                new NSRange (arg1idx, arg1.Length));
        }
Exemple #26
0
        public override void DidSelectLinkWithURL(TTTAttributedLabel label, NSUrl url)
        {
            var t = url.Description.Replace('#', ' ');

            _tagAction?.Invoke(t);
        }
Exemple #27
0
        public override void LoadView ()
        {
            View = new UIView ()
                .Apply (Style.Screen);

            View.Add (inputsContainer = new UIView ().Apply (Style.Signup.InputsContainer));

            inputsContainer.Add (topBorder = new UIView ().Apply (Style.Signup.InputsBorder));

            inputsContainer.Add (emailTextField = new UITextField () {
                Placeholder = "SignupEmailHint".Tr (),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                KeyboardType = UIKeyboardType.EmailAddress,
                ReturnKeyType = UIReturnKeyType.Next,
                ClearButtonMode = UITextFieldViewMode.Always,
                ShouldReturn = HandleShouldReturn,
            }.Apply (Style.Signup.EmailField));
            emailTextField.EditingChanged += OnTextFieldEditingChanged;

            inputsContainer.Add (middleBorder = new UIView ().Apply (Style.Signup.InputsBorder));

            inputsContainer.Add(passwordTextField = new PasswordTextField () {
                Placeholder = "SignupPasswordHint".Tr (),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                AutocorrectionType = UITextAutocorrectionType.No,
                SecureTextEntry = true,
                ReturnKeyType = UIReturnKeyType.Go,
                ShouldReturn = HandleShouldReturn,
            }.Apply (Style.Signup.PasswordField));
            passwordTextField.EditingChanged += OnTextFieldEditingChanged;

            inputsContainer.Add (bottomBorder = new UIView ().Apply (Style.Signup.InputsBorder));

            View.Add (passwordActionButton = new UIButton ()
                .Apply (Style.Signup.SignupButton));
            passwordActionButton.SetTitle ("SignupSignupButtonText".Tr (), UIControlState.Normal);
            passwordActionButton.TouchUpInside += OnPasswordActionButtonTouchUpInside;

            View.Add (googleActionButton = new UIButton ()
                .Apply (Style.Signup.GoogleButton));
            googleActionButton.SetTitle ("SignupGoogleButtonText".Tr (), UIControlState.Normal);
            googleActionButton.TouchUpInside += OnGoogleActionButtonTouchUpInside;

            View.Add (legalLabel = new TTTAttributedLabel () {
                Delegate = new LegalLabelDelegate (),
            }.Apply (Style.Signup.LegalLabel));
            SetLegalText (legalLabel);

            inputsContainer.AddConstraints (
                topBorder.AtTopOf (inputsContainer),
                topBorder.AtLeftOf (inputsContainer),
                topBorder.AtRightOf (inputsContainer),
                topBorder.Height ().EqualTo (1f),

                emailTextField.Below (topBorder),
                emailTextField.AtLeftOf (inputsContainer, 20f),
                emailTextField.AtRightOf (inputsContainer, 10f),
                emailTextField.Height ().EqualTo (42f),

                middleBorder.Below (emailTextField),
                middleBorder.AtLeftOf (inputsContainer, 20f),
                middleBorder.AtRightOf (inputsContainer),
                middleBorder.Height ().EqualTo (1f),

                passwordTextField.Below (middleBorder),
                passwordTextField.AtLeftOf (inputsContainer, 20f),
                passwordTextField.AtRightOf (inputsContainer),
                passwordTextField.Height ().EqualTo (42f),

                bottomBorder.Below (passwordTextField),
                bottomBorder.AtLeftOf (inputsContainer),
                bottomBorder.AtRightOf (inputsContainer),
                bottomBorder.AtBottomOf (inputsContainer),
                bottomBorder.Height ().EqualTo (1f)
            );

            inputsContainer.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();

            View.AddConstraints (
                inputsContainer.AtTopOf (View, 80f),
                inputsContainer.AtLeftOf (View),
                inputsContainer.AtRightOf (View),

                passwordActionButton.Below (inputsContainer, 20f),
                passwordActionButton.AtLeftOf (View),
                passwordActionButton.AtRightOf (View),
                passwordActionButton.Height ().EqualTo (60f),

                googleActionButton.Below (passwordActionButton, 5f),
                googleActionButton.AtLeftOf (View),
                googleActionButton.AtRightOf (View),
                googleActionButton.Height ().EqualTo (60f),

                legalLabel.AtBottomOf (View, 30f),
                legalLabel.AtLeftOf (View, 40f),
                legalLabel.AtRightOf (View, 40f)
            );

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();

            ResetSignupButtonState ();
        }
Exemple #28
0
        public void DidSelectLinkWithURL(TTTAttributedLabel label, NSUrl url)
        {
            UIApplication.SharedApplication.OpenUrl(url);

            System.Diagnostics.Debug.WriteLine($"DidSelectLinkWithURL Label = {label}, Url = {url})");
        }