예제 #1
0
        private bool BuildAttachmentImageNodeIfNeeded(nfloat width, out IASLayoutElement layoutElement)
        {
            if (_viewModelRef.Target == null || !_viewModelRef.Target.HasAttachment)
            {
                layoutElement = null;
                return(false);
            }

            var maxWidth = width - 50 - 73 - 17 - (nfloat)AvatarSize;

            if (_attachmentImageNode.Image != null)
            {
                _attachmentImageNode.Style.PreferredSize = CalculateAttachmentImageNodeSize(
                    _attachmentImageNode.Image.Size, maxWidth);

                layoutElement = _attachmentImageNode;
            }
            else
            {
                var placeholderImage     = UIImage.FromBundle(StyleHelper.Style.AttachmentImagePlaceholderBundleName);
                var placeholderImageNode = new ASImageNode {
                    Image = placeholderImage
                };

                placeholderImageNode.Style.PreferredSize = CalculateAttachmentImageNodeSize(placeholderImage.Size, maxWidth);

                layoutElement = placeholderImageNode;
            }

            return(true);
        }
예제 #2
0
        private IASLayoutElement BuildDateTimeNode()
        {
            IASLayoutElement dateTimeNode = _dateTimeTextNode;

            if (!_statusImageNode.Hidden)
            {
                _statusImageNode.Style.PreferredSize = new CGSize(17, _dateTimeTextNode.Style.Height.value);

                dateTimeNode = new ASStackLayoutSpec
                {
                    Direction = ASStackLayoutDirection.Horizontal,
                    Children  = new IASLayoutElement[] { _dateTimeTextNode, _statusImageNode },
                    Spacing   = 4
                };
            }

            var dateTimeLayoutNode = new ASRelativeLayoutSpec(
                ASRelativeLayoutSpecPosition.End,
                ASRelativeLayoutSpecPosition.Start,
                ASRelativeLayoutSpecSizingOption.Default,
                dateTimeNode);

            dateTimeLayoutNode.Style.SpacingBefore = 5;

            return(dateTimeLayoutNode);
        }
예제 #3
0
        private IASLayoutElement BuildMessageBodyWithBackground(IASLayoutElement messageBodyNode)
        {
            var backgroundImageBundleName = _isMyMessage
                ? StyleHelper.Style.BubbleMineBoundleName
                : StyleHelper.Style.BubbleOtherBoundleName;

            var backgroundImage = UIImage.FromBundle(backgroundImageBundleName)
                                  ?.CreateResizableImage(new UIEdgeInsets(36, 20, 10, 20));

            var backgroundNode = new ASImageNode {
                Image = backgroundImage
            };

            return(ASBackgroundLayoutSpec.BackgroundLayoutSpecWithChild(messageBodyNode, backgroundNode));
        }