Esempio n. 1
0
        private void SetCellText(IFeedPost post, UITableViewCell cell)
        {
            if (!string.IsNullOrWhiteSpace(post.Text))
            {
                var text = GetText(post);

                var feedCell = cell as FeedPostCell;

                if (feedCell != null)
                {
                    feedCell.PostText.AttributedText = text;

                    CalculateTextHeight(post, feedCell);
                }
            }
        }
Esempio n. 2
0
        private NSAttributedString GetText(IFeedPost post)
        {
            NSAttributedString text;

            if (!_htmlTexts.ContainsKey(post.Id))
            {
                text = post.Text.ConvertHtml();

                _htmlTexts[post.Id] = text;
            }
            else
            {
                text = _htmlTexts[post.Id];
            }

            return(text);
        }
Esempio n. 3
0
        private nfloat GetPostCellHeight(IFeedPost post)
        {
            // Top border height             1px
            // Top border <-> Avatar        14px
            // Avatar height                45px
            // Avatar <-> text               8px

            // Text                         CALCULATE
            // MainImage                    CALCULATE

            // Text <-> ruler                8px
            // Ruler height                  1px
            // Button height                50px
            // Bottom border height          1px
            // BottomSpacing (OPTIONAL)      5px
            //----------------------------------
            // Total                        133px

            nfloat finalHeight = 133;

            // Calculate text height
            finalHeight += _textHeights.ContainsKey(post.Id) ? _textHeights[post.Id] : 0;

            if (post.NumberOfImages == 1)
            {
                // 8 spacing below image
                finalHeight += UIScreen.MainScreen.Bounds.Width * 0.6f + 8;
            }
            else if (post.NumberOfImages == 2)
            {
                // 8 spacing below image
                finalHeight += (UIScreen.MainScreen.Bounds.Width - 3) / 2 * 0.6f + 8;
            }
            else if (post.NumberOfImages > 2)
            {
                // 8 spacing below image
                finalHeight += UIScreen.MainScreen.Bounds.Width * 0.6f + 8;
                finalHeight += (UIScreen.MainScreen.Bounds.Width - 3) / 2 * 0.6f + 3;
            }

            return(finalHeight);
        }
Esempio n. 4
0
        private void CalculateTextHeight(IFeedPost post, FeedPostCell feedCell)
        {
            var textSize = feedCell.PostText.SizeThatFits(new CGSize(feedCell.PostText.Frame.Width, MaxValue));

            _textHeights[post.Id] = textSize.Height;
        }