Esempio n. 1
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));
        }
Esempio n. 2
0
        public override ASLayoutSpec LayoutSpecThatFits(ASSizeRange constrainedSize)
        {
            var messageLayout = ASInsetLayoutSpec.InsetLayoutSpecWithInsets(
                new UIEdgeInsets(10, 10, 10, 10), _messageNode);

            var backgroundNode = new ASDisplayNode
            {
                BackgroundColor    = StyleHelper.Style.AccentColor,
                CornerRoundingType = ASCornerRoundingType.DefaultSlowCALayer,
                CornerRadius       = 16
            };

            var messageLayoutWithBackground = ASBackgroundLayoutSpec.BackgroundLayoutSpecWithChild(
                messageLayout, backgroundNode);

            var mainLayout = ASCenterLayoutSpec.CenterLayoutSpecWithCenteringOptions(
                ASCenterLayoutSpecCenteringOptions.Xy,
                ASCenterLayoutSpecSizingOptions.MinimumXY,
                messageLayoutWithBackground);

            return(ASInsetLayoutSpec.InsetLayoutSpecWithInsets(
                       new UIEdgeInsets(8, 20, 8, 20), mainLayout));
        }