示例#1
0
            public void ReloadUI(AnswerListRow row, UITableView tableView)
            {
                var post = row._post;

                _text.Text = row._body;

                _details.Text = BclEx.OffsetFromNow(post.creation_date) + " by";
                _author.SetData(row._controller, post.owner);
                _details2.Text = string.Format("{0}\uD83D\uDC4D  {1} comments", post.score, post.comments != null ? post.comments.Count : 0);

                float titleHeight = row.GetHeightTitle(tableView);

                _text.Frame     = new RectangleF(6, 0, tableView.Frame.Width - 24, titleHeight);
                _details.Frame  = new RectangleF(6, titleHeight, _details.StringSize(_details.Text, _details.Font).Width, 20);
                _author.Frame   = new RectangleF(_details.Frame.X + _details.Frame.Width + 4, titleHeight, _author.StringSize(_author.Text, _author.Font).Width, 20);
                _details2.Frame = new RectangleF(6, 20 + titleHeight, tableView.Frame.Width - 24, 20);

                if (post.is_accepted)
                {
                    _tick.Frame = new RectangleF(_details2.StringSize(_details2.Text, _details2.Font).Width + 10, _details2.Frame.Y, 20, 20);
                }
                else
                {
                    _tick.Frame = RectangleF.Empty;
                }

                if (row._isDetails)
                {
                    _text.Frame = RectangleF.Empty;
                }
            }
示例#2
0
            public void ReloadUI(InboxRow row, UITableView tableView)
            {
                var item = row._item;

                _title.Text    = item.TitleDecoded;
                _details.Text  = item.BodyDecoded;
                _details2.Text = item.item_type.Replace("_", " ") + " " + BclEx.OffsetFromNow(item.creation_date);

                _title.Font   = row.HeadingFont;
                _details.Font = row.DetailsFont;

                if (!string.IsNullOrEmpty(row.Details))
                {
                    _details.Text = row.Details;
                }

                float titleHeight   = row.GetHeightTitle(tableView);
                float detailsHeight = row.GetHeightDetails(tableView);

                float leftOffset = row.HasImage ? 58 : 18;

                _details2.Frame = new RectangleF(leftOffset, 0, tableView.Frame.Width - leftOffset - 18, 20);
                _title.Frame    = new RectangleF(leftOffset, 20, tableView.Frame.Width - leftOffset - 18, titleHeight);
                _details.Frame  = new RectangleF(leftOffset, titleHeight + 20, tableView.Frame.Width - leftOffset - 18, detailsHeight);


                if (row.HasImage)
                {
                    _image.Frame = new RectangleF(4, 4, 50, row.GetHeight(tableView) - 8);
                }

                //if (row.ImageGetter != null)
                //    row.SetImage (this, row.ImageGetter());
            }
示例#3
0
            public void ReloadUI(QuestionListRow row, UITableView tableView)
            {
                var post = row._post;

                _text.Text    = post.TitleDecoded;
                _details.Text = BclEx.OffsetFromNow(post.creation_date) + " by";
                _author.SetData(row._controller, post.owner);
                _details2.Text = string.Format("{0}\uD83D\uDC4D  {1}\u2606  {2}\uD83D\uDC40  {3} answers  {4} comments", post.score, post.favorite_count, GetViewCount(post.view_count), post.answer_count, post.comments != null ? post.comments.Count : 0);

                if (post.tags != null)
                {
                    if (row.RichTags)
                    {
                        RichTags(post.tags, row);
                    }
                    else
                    {
                        PlainTags(post.tags);
                    }
                }

                float titleHeight = row.GetHeightTitle(tableView);

                _text.Frame         = new RectangleF(6, 0, tableView.Frame.Width - 24, titleHeight);
                _details.Frame      = new RectangleF(6, titleHeight, _details.StringSize(_details.Text, _details.Font).Width, 20);
                _author.Frame       = new RectangleF(_details.Frame.X + _details.Frame.Width + 4, titleHeight, _author.StringSize(_author.Text, _author.Font).Width, 20);
                _details2.Frame     = new RectangleF(6, 20 + titleHeight, tableView.Frame.Width - 24, 20);
                _richDetails2.Frame = new RectangleF(6, 40 + titleHeight, tableView.Frame.Width - 24, 20);
                _tags.Frame         = new RectangleF(6, 40 + titleHeight, tableView.Frame.Width - 24, 20);
            }
示例#4
0
 protected override ContentRow GetRow(Notification item)
 {
     return(new TitleDynamicRow {
         Text = BclEx.RemoveHtmlTags(item.body),
         Details = BclEx.OffsetFromNow(item.creation_date),
         AfterGetCellInit = cell => {
             cell._image.SetImage(new NSUrl(item.site.logo_url), placeholder);
         }
     });
 }
示例#5
0
 public CommentListRow(Comment comment)
 {
     _comment = comment;
     _body    = _comment.BodyDecoded;
     if (_body.IsNotNullOrEmpty())
     {
         _body = BclEx.RemoveHtmlTags(_body);
         _body = _body.Trim();
         _body = _body.CollapseWhitespace();
     }
 }
示例#6
0
        public AnswerListRow(Post post, bool isDetails)
        {
            _isDetails = isDetails;
            _post      = post;

            _body = _post.BodyDecoded;
            if (_body.IsNotNullOrEmpty())
            {
                _body = BclEx.RemoveHtmlTags(_body);
                _body = _body.Trim();
                _body = _body.CollapseWhitespace();
            }
        }
示例#7
0
            public void ReloadUI(CommentListRow row, UITableView tableView)
            {
                var comment = row._comment;

                _text.Text     = row._body;
                _details.Text  = BclEx.OffsetFromNow(comment.creation_date) + " by";
                _details2.Text = string.Format("{0}\uD83D\uDC4D", comment.score);
                _author.SetData(row._controller, comment.owner);

                float titleHeight = row.GetHeightTitle(tableView);

                _text.Frame     = new RectangleF(6, 0, tableView.Frame.Width - 24, titleHeight);
                _details.Frame  = new RectangleF(6, titleHeight, _details.StringSize(_details.Text, _details.Font).Width, 20);
                _author.Frame   = new RectangleF(_details.Frame.X + _details.Frame.Width + 4, titleHeight, _author.StringSize(_author.Text, _author.Font).Width, 20);
                _details2.Frame = new RectangleF(6, 20 + titleHeight, tableView.Frame.Width - 24, 20);
            }
        protected override ContentRow GetRow(Timeline item)
        {
            string text = "";

            text += item.TitleDecoded;
            if (!item.DetailDecoded.IsNotNullOrEmpty())
            {
                if (!text.IsNotNullOrEmpty())
                {
                    text += ", ";
                }

                text += ", " + item.DetailDecoded;
            }

            var row = new TitleDynamicRow {
                Text    = text,
                Details = item.timeline_type + " " + BclEx.OffsetFromNow(item.creation_date),
            };

            var clickableTypes = new[] { "answered", "commented", "asked", "accepted", "revision" };

            if (clickableTypes.Contains(item.timeline_type))
            {
                if (item.post_type == "question")
                {
                    row.NavController = () => new QuestionDetailsController(item.post_id);
                }
                else if (item.post_type == "answer")
                {
                    row.NavController = () => new AnswerDetailsController(item.post_id);
                }

                row.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            }

            return(row);
        }
        public async override void ViewDidLoad()
        {
            try {
                LongRunning = true;
                base.ViewDidLoad();

                AddTableHeader(InitializeHeader());

                var response = await ServiceProxy.GetUserById(_shallowUser.user_id);

                var user = response.items.First();

                AddValue1FixedRow("Reputation", user.reputation.ToString());

                if (user.age > 0)
                {
                    AddValue1FixedRow("Age", user.age.ToString());
                }

                AddRow(new Value1FixedRow {
                    Text          = "Questions",
                    Details       = user.question_count.ToString(),
                    Accessory     = UITableViewCellAccessory.DisclosureIndicator,
                    NavController = () => new QuestionsByUserController(user.user_id)
                });

                AddRow(new Value1FixedRow {
                    Text          = "Answers",
                    Details       = user.answer_count.ToString(),
                    Accessory     = UITableViewCellAccessory.DisclosureIndicator,
                    NavController = () => new AnswersForUserController(user.user_id)
                });

                AddRow(new DefaultFixedRow {
                    Text             = "Badges",
                    IsFixed          = true,
                    NavController    = () => new BadgesController(user.user_id),
                    Accessory        = UITableViewCellAccessory.DisclosureIndicator,
                    AfterGetCellInit = cell => {
                        float offset = 90;

                        if (user.badge_counts.silver > 999)
                        {
                            offset -= 4;
                        }

                        if (user.badge_counts.bronze > 999)
                        {
                            offset -= 4;
                        }

                        if (user.badge_counts.gold > 0)
                        {
                            var label = new UILabel {
                                Text = user.badge_counts.gold.ToString()
                            };
                            var image = new UIImageView(UIImage.FromFile("badges/gold.png"));
                            cell.ContentView.Add(label);
                            cell.ContentView.Add(image);
                            label.Frame = new RectangleF(offset, 10, label.StringSize(label.Text, label.Font).Width, 24);
                            image.Frame = new RectangleF(label.Frame.X + label.Frame.Width, 10, 24, 24);
                            offset     += label.Frame.Width + image.Frame.Width + 8;
                        }

                        if (user.badge_counts.silver > 0)
                        {
                            var label = new UILabel {
                                Text = user.badge_counts.silver.ToString()
                            };
                            var image = new UIImageView(UIImage.FromFile("badges/silver.png"));
                            cell.ContentView.Add(label);
                            cell.ContentView.Add(image);
                            label.Frame = new RectangleF(offset, 10, label.StringSize(label.Text, label.Font).Width, 24);
                            image.Frame = new RectangleF(label.Frame.X + label.Frame.Width, 10, 24, 24);
                            offset     += label.Frame.Width + image.Frame.Width + 8;
                        }

                        if (user.badge_counts.bronze > 0)
                        {
                            var label = new UILabel {
                                Text = user.badge_counts.bronze.ToString()
                            };
                            var image = new UIImageView(UIImage.FromFile("badges/bronze.png"));
                            cell.ContentView.Add(label);
                            cell.ContentView.Add(image);
                            label.Frame = new RectangleF(offset, 10, label.StringSize(label.Text, label.Font).Width, 24);
                            image.Frame = new RectangleF(label.Frame.X + label.Frame.Width, 10, 24, 24);
                            offset     += label.Frame.Width + image.Frame.Width + 8;
                        }
                    }
                });

                AddRow(new DefaultFixedRow {
                    Text          = "Favorites",
                    NavController = () => new FavoritesByUserController(user.user_id, true),
                    Accessory     = UITableViewCellAccessory.DisclosureIndicator
                });

                AddRow(new DefaultFixedRow {
                    Text          = "Mentions",
                    NavController = () => new UserMentionsController(user),
                    Accessory     = UITableViewCellAccessory.DisclosureIndicator
                });

                AddRow(new DefaultFixedRow {
                    Text          = "Top Tags",
                    NavController = () => new TopTagsForUserController(user.user_id),
                    Accessory     = UITableViewCellAccessory.DisclosureIndicator
                });

                AddValue1FixedRow("Profile Created", BclEx.OffsetFromNow(user.creation_date));

                AddSubtitleFixedRow("Votes", string.Format("{0} \uD83D\uDC4D, {1} \uD83D\uDC4E", user.up_vote_count, user.down_vote_count));

                if (user.is_employee)
                {
                    AddDefaultFixedRow("He is StackExchange employee");
                }

                AddRow(new SubtitleFixedRow {
                    Text          = "Activity",
                    Details       = "Last seen " + BclEx.OffsetFromNow(user.last_access_date),
                    NavController = () => new TimelineController(user.user_id),
                    Accessory     = UITableViewCellAccessory.DisclosureIndicator
                });

                if (user.location.IsNotNullOrEmpty())
                {
                    AddSubtitleDynamicRow("Location", user.location);
                }

                AddValue1FixedRow("Profile Views", user.view_count.ToString());

                if (user.website_url.IsNotNullOrEmpty())
                {
                    AddRow(new SubtitleFixedRow
                    {
                        Text          = "Website",
                        Details       = user.website_url,
                        Accessory     = UITableViewCellAccessory.DisclosureIndicator,
                        NavController = () => new WebBrowserController(user.website_url)
                    });
                }

                string bio = user.about_me;
                if (bio.IsNotNullOrEmpty())
                {
                    bio = HttpUtility.HtmlDecode(bio);
                    bio = BclEx.RemoveHtmlTags(bio);
                    bio = bio.Trim();
                    bio = bio.CollapseWhitespace();
                }

                if (bio.IsNotNullOrEmpty())
                {
                    AddRow(new SubtitleDynamicRow {
                        Text          = "About",
                        Details       = bio,
                        MaxHeight     = 80,
                        Accessory     = UITableViewCellAccessory.DisclosureIndicator,
                        NavController = () => new UserBioController(user)
                    });
                }

                ForceReloadData();

                await Database.AddUserHistory(_shallowUser.user_id);
            }
            catch (Exception ex) {
                this.UnhandledError(ex);
            }
        }
示例#10
0
        public async override void ViewDidLoad()
        {
            try {
                this.InitLeftButton();
                LongRunning = true;
                Title       = "Site Info";

                base.ViewDidLoad();

                var site = await ServiceProxy.GetSiteInfo(_siteName);

                var statistics = site.items[0];

                var imageView = new UIImageView(new RectangleF(0, 0, View.Frame.Width, 60));
                imageView.ContentMode = UIViewContentMode.ScaleAspectFit;
                imageView.SetImage(new MonoTouch.Foundation.NSUrl(statistics.site.logo_url));

                AddTableHeader(imageView);

                AddRow(new SubtitleDynamicRow {
                    Text    = statistics.site.NameDecoded,
                    Details = statistics.site.AudienceDecoded
                });

                AddSubtitleFixedRow("Site Url", statistics.site.site_url);
                AddValue1FixedRow("Launch Date", BclEx.UnixToDate(statistics.site.launch_date).ToString("d MMM yyyy"));
                AddRow(new DefaultFixedRow {
                    Accessory     = UITableViewCellAccessory.DisclosureIndicator,
                    Text          = "View Moderators",
                    NavController = () => new ModeratorsController()
                });

                AddHeaderRow("Site statistics");
                AddValue1FixedRow("Total Questions", statistics.total_questions.ToString());
                AddValue1FixedRow("Unanswered Questions", statistics.total_unanswered.ToString());
                AddValue1FixedRow("Total Answers", statistics.total_answers.ToString());
                AddValue1FixedRow("Accepted Answers", statistics.total_accepted.ToString());
                AddValue1FixedRow("Total Comments", statistics.total_comments.ToString());
                AddValue1FixedRow("Total Users", statistics.total_users.ToString());
                AddValue1FixedRow("New Active Users", statistics.new_active_users.ToString());
                AddValue1FixedRow("Total Votes", statistics.total_votes.ToString());
                AddValue1FixedRow("Total Badges", statistics.total_badges.ToString());
                AddValue1FixedRow("Badges per minute", statistics.badges_per_minute.ToString());
                AddValue1FixedRow("Questions per minute", statistics.questions_per_minute.ToString());
                AddValue1FixedRow("Answers per minute", statistics.answers_per_minute.ToString());

                AddHeaderRow("Developer info");
                AddValue1FixedRow("API Revision", statistics.api_revision);
                AddValue1FixedRow("API Site Param", statistics.site.api_site_parameter);
                AddSubtitleFixedRow("Markdown Extensions", statistics.site.markdown_extensions.JoinStrings(", "));

                if (statistics.site.aliases != null && statistics.site.aliases.Any())
                {
                    AddSubtitleDynamicRow("Aliases", statistics.site.aliases.JoinStrings(", "));
                }

                AddValue1FixedRow("Site State", statistics.site.site_state);
                AddValue1FixedRow("Site Type", statistics.site.site_type);

                ForceReloadData();
            }
            catch (Exception ex) {
                this.UnhandledError(ex);
            }
        }