Esempio n. 1
0
        static void AddHeroImage(this MessageCell cell, int row, string imageUrl)
        {
            var index = cell.AddHeroImage();

            //cell.HeroImageViews [index].SetCacheFormat (getCacheFormat (MessageCell.HeroScaledImageSize));

            if (string.IsNullOrEmpty(imageUrl))
            {
                cell.SetHeroImage(row, index, null);
            }
            else
            {
                var placeholder = getPlaceholderImage(MessageCell.HeroScaledImageSize);

                Glide.With(cell.Context).Load(imageUrl).Placeholder(placeholder).Into(cell.HeroImageViews [index]);

                //using (NSUrl url = new NSUrl (imageUrl))
                //{
                //	cell?.HeroImageViews [index].SetImage (url, placeholder, (img) => cell.SetHeroImage (indexPath.Row, index, img), (err) =>
                //	{
                //		cell.SetHeroImage (indexPath.Row, index, null);

                //		Log.Debug (err.LocalizedDescription);
                //	});
                //}
            }
        }
Esempio n. 2
0
        public static ImageView GetHeroImageView(MessageCell cell)
        {
            var heroImageView = new ImageView(cell.Context)
            {
            };

            heroImageView.LayoutParameters = cell.LayoutParameters;

            return(heroImageView);
        }
Esempio n. 3
0
        public static ImageView GetThumbnailImageView(MessageCell cell)
        {
            var thumbnailImageView = new ImageView(cell.Context)
            {
            };

            thumbnailImageView.LayoutParameters = cell.LayoutParameters;

            return(thumbnailImageView);
        }
Esempio n. 4
0
        public static ImageView GetAvatarView(MessageCell cell)
        {
            var avatarView = new ImageView(cell.Context)
            {
            };

            avatarView.LayoutParameters = cell.LayoutParameters;

            return(avatarView);
        }
Esempio n. 5
0
        public static LinearLayout GetContentStackView(MessageCell cell)
        {
            var stackView = new LinearLayout(cell.Context)
            {
            };

            stackView.LayoutParameters = cell.LayoutParameters;

            return(stackView);
        }
Esempio n. 6
0
        public static TextView GetTimestampLabel(MessageCell cell)
        {
            var timestampLabel = new TextView(cell.Context)
            {
            };

            timestampLabel.SetTextColor(Color.WhiteSmoke /*Color.LightGray*/);

            timestampLabel.LayoutParameters = cell.LayoutParameters;

            return(timestampLabel);
        }
Esempio n. 7
0
        public static TextView GetTitleLabel(MessageCell cell)
        {
            var titleLabel = new TextView(cell.Context)
            {
            };

            titleLabel.SetTextColor(Color.White /*Colors.MessageColor*/);

            titleLabel.LayoutParameters = cell.LayoutParameters;

            return(titleLabel);
        }
Esempio n. 8
0
        public static TextView GetBodyLabel(MessageCell cell)
        {
            var bodyLabel = new TextView(cell.Context)
            {
            };

            bodyLabel.SetTextColor(Color.White /*Colors.MessageColor*/);
            bodyLabel.SetLinkTextColor(Colors.MessageLinkColor);

            bodyLabel.LayoutParameters = cell.LayoutParameters;

            return(bodyLabel);
        }
Esempio n. 9
0
        public static TextView GetAttachmentSubtitleLabel(MessageCell cell)
        {
            var subTitleLabel = new TextView(cell.Context)
            {
            };

            subTitleLabel.SetTextColor(Color.GhostWhite /*Color.DarkGray*/);
            subTitleLabel.SetLinkTextColor(Colors.MessageLinkColor);

            subTitleLabel.LayoutParameters = cell.LayoutParameters;

            return(subTitleLabel);
        }
Esempio n. 10
0
        public static Button GetButton(MessageCell cell, string title)
        {
            var button = new Button(cell.Context)
            {
                Text = title
            };

            button.SetTextColor(Color.DarkGray);

            button.LayoutParameters = cell.LayoutParameters;

            return(button);
        }
Esempio n. 11
0
        static void SetHeader(this MessageCell cell, int row, BotMessage message)
        {
            cell.SetHeader(message.LocalTimeStamp, message.Activity?.From?.Name);

            //cell.ImageView.SetCacheFormat (getCacheFormat (MessageCell.AvatarImageSize));

            //if (message.Activity.From.Id == "DigitalAgencies")
            //{
            //	cell.SetAvatar (row, UIImage.FromBundle ("avatar_microsoft"));
            //}
            //else
            //{
            var avatarUrl = string.IsNullOrEmpty(message.Activity?.From?.Id) ? string.Empty : BotClient.Shared.GetAvatarUrl(message.Activity.From.Id);

            if (string.IsNullOrEmpty(avatarUrl))
            {
                cell.SetAvatar(row, null);
            }
            else
            {
                var placeholder = getPlaceholderImage(MessageCell.AvatarImageSize);

                Glide.With(cell.Context).Load(avatarUrl).Placeholder(placeholder).Into(cell.AvatarView);

                //using (NSUrl url = new NSUrl (avatarUrl))
                //{
                //	cell?.ImageView.SetImage (url, placeholder, (img) => cell.SetAvatar (indexPath.Row, img), (err) =>
                //	{
                //		cell.SetAvatar (indexPath.Row, null);

                //		Log.Debug (err.LocalizedDescription);
                //	});
                //}
            }
            //}
        }
Esempio n. 12
0
        public static void SetMessageCell(this List <BotMessage> messages, MessageCell cell, int row)
        {
            if (messages?.Count > 0 && messages.Count > row)
            {
                var message = messages [row];

                //var cell = holder.ItemView as MessageCell;

                cell.Key = row;

                if (message.Head)
                {
                    cell.SetHeader(row, message);
                }

                if (message.HasText)
                {
                    cell.SetMessage(message.AttributedText);
                }

                if (message.HasAtachments)
                {
                    foreach (var attachment in message.Attachments)
                    {
                        // images
                        if (attachment.Content.HasImages)
                        {
                            foreach (var image in attachment.Content.Images)
                            {
                                cell.AddHeroImage(row, image.Url);
                            }
                        }

                        // title
                        if (attachment.Content.HasTitle)
                        {
                            cell.AddAttachmentTitle(attachment.Content.AttributedTitle);
                        }

                        // subtitle
                        if (attachment.Content.HasSubtitle)
                        {
                            cell.AddAttachmentSubtitle(attachment.Content.AttributedSubtitle);
                        }

                        // text
                        if (attachment.Content.HasText)
                        {
                            cell.AddAttachmentText(attachment.Content.AttributedText);
                        }

                        // buttons
                        if (attachment.Content.HasButtons)
                        {
                            cell.SetButtons(attachment.Content.Buttons.Select(b => (b.Title, b.Value.ToString())).ToArray());
                        }
                    }
                }

                // Cells must inherit the table view's transform
                // This is very important, since the main table view may be inverted
                //cell.Transform = tableView.Transform;

                //return cell;
            }

            //return null;
        }
 public MessageCellViewHolder(MessageCell itemView)
     : base(itemView)
 {
 }