void InitUI() { // Adjust constraints as needed PhotoImageViewHeightConstraint.Constant = ViewModel.ShowImage ? _photoImageViewDefaultHeightConstraint : 0; // Map values to UI elements BodyTextView.Text = null; BodyTextView.Text = ViewModel.Text; BodyTextViewHeightConstraint.Constant = BodyTextView.SizeThatFits(new CGSize(BodyTextView.Frame.Width, nfloat.MaxValue)).Height; TimeLabel.Text = ViewModel.ShowDateTime ? ViewModel.DisplayDateTime : string.Empty; NameLabel.SetHighlightText(ViewModel.UserName, ViewModel.UserName.IndexOf("@"), UIColor.LightGray); LikeButton.SetTitle(ViewModel.LikeButtonText, UIControlState.Normal); LikeButton.SetTitleColor(ViewModel.LikeButtonTextColor.ToUIColor(), UIControlState.Normal); CommentButton.SetTitle(ViewModel.CommentButtonText, UIControlState.Normal); CommentButton.SetTitleColor(ViewModel.CommentButtonTextColor.ToUIColor(), UIControlState.Normal); ShareButton.SetTitle(ViewModel.ShareButtonText, UIControlState.Normal); ShareButton.SetTitleColor(ViewModel.ShareButtonTextColor.ToUIColor(), UIControlState.Normal); if (ViewModel.ShowImage) { ActivityIndicator.StartAnimating(); } else { ActivityIndicator.StopAnimating(); } SocialTypeImageView.Image = UIImage.FromBundle(ViewModel.SocialMediaImage); SocialTypeImageView.Hidden = !ViewModel.ShowSocialMediaImage; UserImageView.SetImage( url: new NSUrl(ViewModel.UserImageUrl), placeholder: UIImage.FromBundle(ViewModel.UserImagePlaceholder) ); if (ViewModel.ShowImage) { PhotoImageView.SetImage( url: new NSUrl(ViewModel.ImageUrl), completionHandler: ((UIImage image, NSError error, SDImageCacheType cacheType, NSUrl imageUrl) => { ActivityIndicator.StopAnimating(); }) ); } else { PhotoImageView.Image = null; } if (ViewModel.ShowTimeline) { ContainerViewLeadingConstraint.Constant = _containerViewTimelineLeadingConstraint; TimelineView.Hidden = false; } else { ContainerViewLeadingConstraint.Constant = _containerViewDefaultLeadingConstraint; TimelineView.Hidden = true; } CommentButton.Hidden = !ViewModel.ShowCommentButton; ShareButton.Hidden = !ViewModel.ShowShareButton; // TODO: Remove this when we're ready to support sharing ShareButton.Hidden = true; }
void ReleaseDesignerOutlets() { if (TimelineView != null) { TimelineView.Dispose(); TimelineView = null; } if (ActivityIndicator != null) { ActivityIndicator.Dispose(); ActivityIndicator = null; } if (BodyTextView != null) { BodyTextView.Dispose(); BodyTextView = null; } if (BodyTextViewHeightConstraint != null) { BodyTextViewHeightConstraint.Dispose(); BodyTextViewHeightConstraint = null; } if (CommentButton != null) { CommentButton.Dispose(); CommentButton = null; } if (ContainerView != null) { ContainerView.Dispose(); ContainerView = null; } if (LikeButton != null) { LikeButton.Dispose(); LikeButton = null; } if (NameLabel != null) { NameLabel.Dispose(); NameLabel = null; } if (PhotoImageView != null) { PhotoImageView.Dispose(); PhotoImageView = null; } if (PhotoImageViewHeightConstraint != null) { PhotoImageViewHeightConstraint.Dispose(); PhotoImageViewHeightConstraint = null; } if (ShareButton != null) { ShareButton.Dispose(); ShareButton = null; } if (SocialTypeImageView != null) { SocialTypeImageView.Dispose(); SocialTypeImageView = null; } if (TimeLabel != null) { TimeLabel.Dispose(); TimeLabel = null; } if (UserImageView != null) { UserImageView.Dispose(); UserImageView = null; } if (ContainerViewLeadingConstraint != null) { ContainerViewLeadingConstraint.Dispose(); ContainerViewLeadingConstraint = null; } }