예제 #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            CustomNavigationBar.TintColor = StyleHelper.Style.AccentColor;
            if (StyleHelper.Style.UseLogoInsteadOfConnectionStatus)
            {
                var titleImage = new UIImageView
                {
                    Image = UIImage.FromBundle(StyleHelper.Style.LogoBoundleName)
                };
                CustomNavigationItem.AddTitleView(titleImage);
            }
            else
            {
                _customTitleView = new ConnectionStatusView(CGRect.Empty);
                CustomNavigationItem.AddTitleView(_customTitleView);
            }
            CustomNavigationItem.SetCommand(UIBarButtonSystemItem.Add, ViewModel.CreateChatCommand, false);

            ChatsTableView.RegisterNibForCellReuse(ChatSummaryViewCell.Nib, ChatSummaryViewCell.Key);
            ChatsTableView.RowHeight       = 80;
            ChatsTableView.TableFooterView = new UIView();

            var source = ViewModel.Chats.GetTableViewSource((cell, viewModel, index) =>
            {
                (cell as ChatSummaryViewCell).BindViewModel(viewModel);
            }, ChatSummaryViewCell.Key);

            ChatsTableView.Source   = source;
            ChatsTableView.Delegate = new CustomViewDelegate(source, ViewModel);
            _sourceRef = WeakReferenceEx.Create(source);
        }
        private async Task InitTableViewAsync()
        {
            // delay is need to delay UI thread freezing while TableNode items are loaded
            // thus previous screen will not be frozen
            await Task.Delay(1);

            Table.KeyboardDismissMode = UIScrollViewKeyboardDismissMode.Interactive;
            Table.TranslatesAutoresizingMaskIntoConstraints = false;
            Table.BackgroundColor = UIColor.FromRGB(245, 245, 245);
            Table.AddGestureRecognizer(new UITapGestureRecognizer((obj) => Input.TextView.ResignFirstResponder()));

            var tableSource = new GroupedTableDataSource <DateTimeOffset, ChatMessageViewModel>(
                ViewModel.MessagesList.Messages,
                Table,
                viewModel => GetMessageNode(viewModel),
                TableNode.Inverted);

            Table.EstimatedRowHeight = MinCellHeight;
            Table.SeparatorStyle     = UITableViewCellSeparatorStyle.None;
            _dataSourceRef           = WeakReferenceEx.Create(tableSource);
            TableNode.DataSource     = tableSource;
            TableNode.Delegate       = _tableDelegate;
            TableNode.SetTuningParameters(new ASRangeTuningParameters {
                leadingBufferScreenfuls = 1, trailingBufferScreenfuls = 1
            }, ASLayoutRangeType.Display);
            TableNode.SetTuningParameters(new ASRangeTuningParameters {
                leadingBufferScreenfuls = 1, trailingBufferScreenfuls = 1
            }, ASLayoutRangeType.Preload);
            TableNode.ReloadData();
            TableNode.LeadingScreensForBatching = 3;
        }
        public ObservableGroupTableViewSource(
            UITableView tableView,
            IEnumerable <IGrouping <TKey, TItem> > items,
            Func <UITableView, TItem, IList <TItem>, NSIndexPath, UITableViewCell> getCellViewFunc,
            Func <nint, nint> getRowInSectionCountFunc         = null,
            Func <UITableView, TKey, UIView> getHeaderViewFunc = null,
            Func <UITableView, TKey, UIView> getFooterViewFunc = null,
            Func <TKey, nfloat> getHeaderHeightFunc            = null,
            Func <TKey, nfloat> getFooterHeightFunc            = null,
            Func <NSIndexPath, nfloat> getHeightForRowFunc     = null)
        {
            _getCellViewFunc          = getCellViewFunc;
            _getHeightForRowFunc      = getHeightForRowFunc;
            _getRowInSectionCountFunc = getRowInSectionCountFunc;
            _getHeaderViewFunc        = getHeaderViewFunc;
            _getFooterViewFunc        = getFooterViewFunc;
            _getFooterHeightFunc      = getFooterHeightFunc;
            _getHeaderHeightFunc      = getHeaderHeightFunc;
            _tableViewRef             = WeakReferenceEx.Create(tableView);

            DataSource = items;

            if (DataSource is INotifyKeyGroupCollectionChanged <TKey, TItem> dataSourceNew)
            {
                _subscription = new NotifyCollectionKeyGroupChangedEventSubscription <TKey, TItem>(dataSourceNew, NotifyCollectionChanged);
            }
        }
예제 #4
0
 public ChatInputKeyboardDelegate(ChatInputView chatInputView)
 {
     _chatInputView    = new WeakReferenceEx <ChatInputView>(chatInputView);
     _willShowObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillShowNotification, (notification) =>
     {
         if (!KeyBoardOpened)
         {
             TryInvokeOpenKeyboardEvent(notification);
         }
     });
     _willHideObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, (notification) =>
     {
         if (KeyBoardOpened)
         {
             KeyBoardOpened = false;
             KeyboardHeightChanged?.Invoke(0);
         }
     });
     _willChangeFrameObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillChangeFrameNotification, (notification) =>
     {
         if (KeyBoardOpened)
         {
             TryInvokeOpenKeyboardEvent(notification);
         }
     });
 }
예제 #5
0
 public LocationListener(
     LocationManager locationManager,
     TaskCompletionSource <LocationModel?> tcs)
 {
     _locationManagerRef = WeakReferenceEx.Create(locationManager);
     _tcs = tcs;
 }
예제 #6
0
        public ChatInputScrollViewDelegate(ChatInputView chatInputView, UIScrollView scrollView, nfloat scrollViewBottomMargin)
        {
            _scrollView             = new WeakReferenceEx <UIScrollView>(scrollView);
            _chatInputView          = chatInputView;
            _scrollViewBottomMargin = scrollViewBottomMargin;

            _chatInputView.KeyboardDelegate.KeyboardHeightChanged += KeyboardDelegate_KeyboardHeightChanged;
        }
        public void Bind(TViewModel viewModel)
        {
            ViewModel = WeakReferenceEx.Create(viewModel);

            Bindings.DetachAllAndClear();

            DoAttachBindings();
        }
        public override nint NumberOfSections(UICollectionView collectionView)
        {
            if (_collectionViewRef == null)
            {
                _collectionViewRef = WeakReferenceEx.Create(collectionView);
            }

            return(DataSource.Count());
        }
예제 #9
0
        public void SetDataContext(object dataContext)
        {
            _viewModelRef = new WeakReferenceEx <TabViewModel <TKey> >((TabViewModel <TKey>)dataContext);

            _textBinding?.Detach();
            _textBinding = this.SetBinding(() => _viewModelRef.Target.BadgeText).WhenSourceChanges(UpdateBadge);

            _visibilityBinding?.Detach();
            _visibilityBinding = this.SetBinding(() => _viewModelRef.Target.IsBadgeVisible).WhenSourceChanges(UpdateBadge);
        }
예제 #10
0
        public void BindViewModel(ChatSummaryViewModel viewModel)
        {
            _viewModelRef = WeakReferenceEx.Create(viewModel);

            LastMessageBodyPhotoIcon.Image = UIImage.FromBundle(StyleHelper.Style.LastMessageBodyPhotoIcon);
            LastMessageBodyPhotoLabel.Text = viewModel.LocalizedStrings.Photo;

            _bindings.Apply(x => x.Detach());
            _bindings.Clear();

            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.ChatName, () => ChatNameLabel.Text));
            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.LastMessageViewModel.Body).WhenSourceChanges((obj) =>
            {
                MessageBodyLabel.Text = _viewModelRef.Target.LastMessageViewModel.Body;
                BodyContainer.Hidden  = !_viewModelRef.Target.LastMessageViewModel.HasBody && !_viewModelRef.Target.LastMessageViewModel.HasPhoto;
            }));
            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.ChatPhotoUrl).WhenSourceChanges(() =>
            {
                SenderPhotoImageView.LoadImageWithTextPlaceholder(
                    _viewModelRef.Target.ChatPhotoUrl,
                    _viewModelRef.Target.ChatName,
                    StyleHelper.Style.AvatarStyles);
            }));
            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.IsMuted).WhenSourceChanges(() =>
            {
                if (UnreadMessageCountLabel != null)
                {
                    UnreadMessageCountBackground.BackgroundColor = _viewModelRef.Target.IsMuted
                        ? UIColor.FromRGB(180, 180, 180)
                        : StyleHelper.Style.AccentColor;
                }
            }));
            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.UnreadMessageCount).WhenSourceChanges(() =>
            {
                if (UnreadMessageCountLabel != null)
                {
                    UnreadMessageCountLabel.Text        = _viewModelRef.Target.UnreadMessageCount.ToString();
                    UnreadMessageCountBackground.Hidden = _viewModelRef.Target.UnreadMessageCount == 0;
                }
            }));
            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.LastMessageViewModel.DateTime, () => DateTimeLabel.Text));
            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.UnreadMessageCount, () => UnreadMessageCountLabel.Text));
            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.LastMessageViewModel.HasPhoto).WhenSourceChanges(() =>
            {
                if (!_viewModelRef.Target.LastMessageViewModel.HasBody && _viewModelRef.Target.LastMessageViewModel.HasPhoto)
                {
                    LastMessageBodyPhotoView.Hidden = false;
                }
                else
                {
                    LastMessageBodyPhotoView.Hidden = true;
                }
                BodyContainer.Hidden = !_viewModelRef.Target.LastMessageViewModel.HasBody && !_viewModelRef.Target.LastMessageViewModel.HasPhoto;
            }));
        }
예제 #11
0
 // TODO: add support actions for right swipe
 public SwipeCallback(
     Context context,
     RecyclerView recyclerView,
     Action <RecyclerView.ViewHolder, int, ICollection <ISwipeActionView> > createSwipeActionViews)
     : base(0, ItemTouchHelper.Left)
 {
     _recyclerViewRef               = WeakReferenceEx.Create(recyclerView);
     _createSwipeActionViews        = createSwipeActionViews;
     _gestureDetector               = new GestureDetector(context, new CustomGestureListener(OnSingleTapConfirmedHandler));
     _recyclerViewRef.Target.Touch += RecyclerViewTouchHandler;
 }
예제 #12
0
 public ObservableGroupAdapter(
     ObservableKeyGroupsCollection <TKey, TValue> items,
     ExpandableListView parent,
     Func <int, int, bool, View, ViewGroup, TValue, View> getChildViewFunc,
     Func <int, bool, View, ViewGroup, TKey, View> getGroupViewFunc)
 {
     _dataSource       = items;
     _parent           = WeakReferenceEx.Create(parent);
     _getChildViewFunc = getChildViewFunc;
     _getGroupViewFunc = getGroupViewFunc;
     _subscription     = new NotifyCollectionChangedEventSubscription(_dataSource, OnCollectionChanged);
 }
예제 #13
0
        public ChatMessageNode(
            ChatMessageViewModel viewModel,
            IItemActionHandler <ChatMessageViewModel> contextMenuComponent)
        {
            _viewModelRef         = WeakReferenceEx.Create(viewModel);
            _contextMenuComponent = contextMenuComponent;
            _isMyMessage          = viewModel.IsMine;

            Execute.BeginOnUIThread(() => View.AddGestureRecognizer(new UILongPressGestureRecognizer(TryShowMenu)));

            BackgroundColor = UIColor.FromRGB(245, 245, 245);
            SelectionStyle  = UITableViewCellSelectionStyle.None;
            AutomaticallyManagesSubnodes = true;

            UpdateText();

            if (_viewModelRef.Target != null)
            {
                var dateTimeText           = _viewModelRef.Target?.TextDateTime;
                var attributedDateTimeText = dateTimeText.BuildAttributedString()
                                             .Font(UIFont.SystemFontOfSize(11, UIFontWeight.Semibold))
                                             .Foreground(UIColor.FromRGB(141, 141, 141));
                _dateTimeTextNode.AttributedText = attributedDateTimeText;
            }

            _avatarImageNode.ImageModificationBlock = image =>
            {
                var size = new CGSize(AvatarSize, AvatarSize);
                return(image.MakeCircularImageWithSize(size));
            };
            _avatarImageNode.ContentMode = UIViewContentMode.ScaleAspectFill;
            _avatarImageNode.Hidden      = _isMyMessage;
            if (!_isMyMessage)
            {
                _avatarImageNode.LoadImageWithTextPlaceholder(
                    _viewModelRef.Target.SenderPhotoUrl,
                    _viewModelRef.Target.SenderName,
                    new AvatarImageHelpers.AvatarStyles
                {
                    BackgroundHexColors = StyleHelper.Style.AvatarStyles.BackgroundHexColors,
                    Font = StyleHelper.Style.AvatarStyles.Font,
                    Size = new System.Drawing.Size((int)AvatarSize, (int)AvatarSize)
                });
            }

            _attachmentImageNode.ContentMode            = UIViewContentMode.ScaleAspectFit;
            _attachmentImageNode.ImageModificationBlock = image => image.MakeImageWithRoundedCorners(12);
            LoadAttachmentImageIfNeeded();

            _statusImageNode.ContentMode = UIViewContentMode.Center;
            _statusImageNode.Hidden      = !_isMyMessage;
        }
예제 #14
0
 internal DroidRecyclerObservableKeyGroupCollectionHandler(
     RecyclerView.Adapter recyclerView,
     IEnumerable <IGrouping <TKey, TItem> > dataSource,
     IList <FlatItem> flatMapping,
     bool withSectionHeader,
     bool withSectionFooter)
 {
     _recyclerViewAdapterRef = WeakReferenceEx.Create(recyclerView);
     _dataSource             = dataSource;
     _flatMapping            = flatMapping;
     _withSectionHeader      = withSectionHeader;
     _withSectionFooter      = withSectionFooter;
 }
예제 #15
0
            public void BindHolder(CustomerSource item, bool isSelected)
            {
                _textView.Text = item.Id;
                _source        = WeakReferenceEx.Create(item);

                var card = item.AsCard();

                _textView.Text = $"{card.Brand} - ...{card.Last4}";

                var imageId = (int)Card.BrandResourceMap[card.Brand];

                _imageView.SetImageResource(imageId);

                _selectedImage.Visibility = isSelected ? ViewStates.Visible : ViewStates.Invisible;
            }
예제 #16
0
        public override void BindViewModel(ChatUserViewModel viewModel)
        {
            _viewModelRef = WeakReferenceEx.Create(viewModel);

            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.Username, () => ContactUserNameTextView.Text));
            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.IsSelected, () => ContactSwitch.Checked, BindingMode.TwoWay));
            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.PhotoUrl).WhenSourceChanges(() =>
            {
                ContactPhotoImageView.LoadImageWithTextPlaceholder(
                    _viewModelRef.Target.PhotoUrl,
                    _viewModelRef.Target.Username,
                    StyleHelper.Style.ChatAvatarStyles,
                    (TaskParameter x) => x.Transform(new CircleTransformation()));
            }));
        }
예제 #17
0
        public void BindViewModel(ChatMessageInputViewModel viewModel)
        {
            _viewModelRef = new WeakReferenceEx <ChatMessageInputViewModel>(viewModel);

            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.MessageBody, () => _messageEditText.Text, BindingMode.TwoWay));
            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.IsInEditMessageMode).WhenSourceChanges(() =>
            {
                if (_viewModelRef.Target.IsInEditMessageMode)
                {
                    _editingMessageBodyTextView.Text = _viewModelRef.Target.EditedMessageOriginalBody;

                    KeyboardService.ShowSoftKeyboard(_messageEditText);
                }
                else
                {
                    KeyboardService.HideSoftKeyboard(_messageEditText);
                }

                _editingMessageLayout.Visibility = BoolToViewStateConverter.ConvertGone(_viewModelRef.Target.IsInEditMessageMode);
            }));
            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.ImageObject).WhenSourceChanges(() =>
            {
                if (_viewModelRef.Target.ImageObject == null)
                {
                    _imagePreview.SetImageBitmap(null);
                    _editImageContainer.Visibility = ViewStates.Gone;
                }
                else
                {
                    _imagePreview.SetImageBitmap((Android.Graphics.Bitmap)_viewModelRef.Target.ImageObject);
                    _editImageContainer.Visibility = ViewStates.Visible;
                }
            }));

            if (!_inited)
            {
                _messageEditText.Hint      = _viewModelRef.Target.EnterMessagePlaceholderString;
                _editingMessageHeader.Text = _viewModelRef.Target.EditMessageHeaderString;

                _takeAttachmentButton.SetCommand(_viewModelRef.Target.OpenCameraCommand);
                _addAttachmentButton.SetCommand(_viewModelRef.Target.OpenGalleryCommand);
                _sendButton.SetCommand(_viewModelRef.Target.SendMessageCommand);
                _removeImageButton.SetCommand(_viewModelRef.Target.DeleteImageCommand);
                _editingMessageCloseButton.SetCommand(_viewModelRef.Target.CancelEditingCommand);
                _inited = true;
            }
        }
예제 #18
0
 public CustomViewDelegate(ObservableTableViewSource <ChatSummaryViewModel> source, ChatsListViewModel viewModel)
 {
     _sourceRef    = WeakReferenceEx.Create(source);
     _viewModelRef = WeakReferenceEx.Create(viewModel);
 }
예제 #19
0
 internal IosTableObservableKeyGroupCollectionHandler(UITableView tableView)
 {
     _tableViewRef = WeakReferenceEx.Create(tableView);
 }
예제 #20
0
 private void Setup()
 {
     _target    = new CommonTestClass();
     _reference = WeakReferenceEx.Create(_target);
 }
예제 #21
0
        public override void BindViewModel(ChatMessageViewModel viewModel)
        {
            _viewModelRef = WeakReferenceEx.Create(viewModel);

            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.Body).WhenSourceChanges(() =>
            {
                // TODO: check
                Execute.OnUIThread(() =>
                {
                    var hideMessageBody            = string.IsNullOrEmpty(_viewModelRef.Target.Body) && _viewModelRef.Target.HasAttachment;
                    MessageBodyTextView.Visibility = BoolToViewStateConverter.ConvertGone(hideMessageBody == false);
                    MessageBodyTextView.Text       = _viewModelRef.Target.Body;
                });
            }));
            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.TextDateTime).WhenSourceChanges(() =>
            {
                // TODO: check
                Execute.OnUIThread(() =>
                {
                    MessageDateTimeTextView.Text = _viewModelRef.Target.TextDateTime;
                });
            }));

            if (_viewModelRef.Target.HasAttachment)
            {
                var model = _viewModelRef.Target.Model;
                var expr  = default(TaskParameter);

                AttachmentImageView.SetImageResource(StyleHelper.Style.AttachmentImagePlaceholder);
                UpdateAttachmentImageViewSizeAndVisibility();

                if (!string.IsNullOrEmpty(model.ImageCacheKey))
                {
                    expr = ImageService.Instance.LoadFile(model.ImageCacheKey);
                }
                else if (!string.IsNullOrEmpty(model.ImageRemoteUrl))
                {
                    expr = ImageService.Instance.LoadUrl(model.ImageRemoteUrl);
                }

                if (expr == null)
                {
                    return;
                }

                _downloadAttachTask = expr.DownSampleInDip(90, 90)
                                      .Finish(x =>
                {
                    Execute.BeginOnUIThread(UpdateAttachmentImageViewSizeAndVisibility);
                });
                _downloadAttachTask.IntoAsync(AttachmentImageView);
            }
            else
            {
                _downloadAttachTask?.Dispose();
                AttachmentImageView.SetImageDrawable(null);
                AttachmentImageView.Visibility = ViewStates.Gone;
            }

            if (_isIncomingMessageViewType && SenderPhotoImageView != null)
            {
                SenderPhotoImageView.LoadImageWithTextPlaceholder(
                    _viewModelRef.Target.SenderPhotoUrl,
                    _viewModelRef.Target.SenderName,
                    new WhiteLabel.Droid.Controls.AvatarPlaceholderDrawable.AvatarStyles
                {
                    BackgroundHexColors = StyleHelper.Style.ChatAvatarStyles.BackgroundHexColors,
                    Size = new System.Drawing.Size(35, 35)
                },
                    x => x.Transform(new CircleTransformation()));
            }

            if (!_isIncomingMessageViewType && MessageStatusView != null)
            {
                Bindings.Add(this.SetBinding(() => _viewModelRef.Target.Status).WhenSourceChanges(() =>
                {
                    // TODO: check
                    Execute.OnUIThread(() =>
                    {
                        if (_viewModelRef.Target == null)
                        {
                            return;
                        }

                        ChangeMessageViewStatus(_viewModelRef.Target.Status);
                    });
                }));
            }
        }
예제 #22
0
 internal IosCollectionObservableKeyGroupCollectionHandler(UICollectionView collectionView)
 {
     _collectionViewRef = WeakReferenceEx.Create(collectionView);
 }
예제 #23
0
 protected BindableTableViewSourceBase(UITableView tableView)
 {
     _tableViewRef = WeakReferenceEx.Create(tableView);
 }
예제 #24
0
        public override void BindViewModel(ChatSummaryViewModel viewModel)
        {
            _viewModelRef = WeakReferenceEx.Create(viewModel);

            _messageBodyPhotoLabel.Text = viewModel.LocalizedStrings.Photo;
            _messageBodyPhotoImageView.SetImageResource(StyleHelper.Style.LastMessageBodyPhotoIcon);

            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.ChatName, () => _chatNameTextView.Text));
            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.LastMessageViewModel.Username, () => _userNameTextView.Text));
            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.LastMessageViewModel.Body).WhenSourceChanges(() =>
            {
                _messageBodyTextView.Text       = _viewModelRef.Target.LastMessageViewModel.Body;
                _messageBodyTextView.Visibility = BoolToViewStateConverter.ConvertGone(_viewModelRef.Target.LastMessageViewModel.HasBody);
            }));
            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.LastMessageViewModel.DateTime, () => _dateTimeTextView.Text));

            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.ChatPhotoUrl).WhenSourceChanges(() =>
            {
                if (_chatPhotoImageView == null)
                {
                    return;
                }

                _chatPhotoImageView.LoadImageWithTextPlaceholder(
                    _viewModelRef.Target.ChatPhotoUrl,
                    _viewModelRef.Target.ChatName,
                    new AvatarPlaceholderDrawable.AvatarStyles
                {
                    BackgroundHexColors = StyleHelper.Style.ChatAvatarStyles.BackgroundHexColors,
                    Size = new System.Drawing.Size(44, 44)
                },
                    x => x.Transform(new CircleTransformation()));
            }));

            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.UnreadMessageCount).WhenSourceChanges(() =>
            {
                if (_unreadMessageCountTextView != null)
                {
                    _unreadMessageCountTextView.Text       = _viewModelRef.Target.UnreadMessageCount.ToString();
                    _unreadMessageCountTextView.Visibility = BoolToViewStateConverter.ConvertGone(_viewModelRef.Target.UnreadMessageCount > 0);
                }
            }));

            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.IsMuted).WhenSourceChanges(() =>
            {
                if (_unreadMessageCountTextView != null)
                {
                    var colorResId = _viewModelRef.Target.IsMuted
                        ? StyleHelper.Style.UnreadMutedMessagesCountColor
                        : StyleHelper.Style.UnreadMessagesCountColor;

                    var color = ContextCompat.GetColor(_unreadMessageCountTextView.Context, colorResId);

                    _unreadMessageCountTextView.Background = CreateBackgroundWithCornerRadius(color, 56f);
                }
            }));

            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.LastMessageViewModel.Status).WhenSourceChanges(() =>
            {
                Color color;

                switch (_viewModelRef.Target.LastMessageViewModel.Status)
                {
                case ChatMessageStatus.Read:
                    color = Color.GreenYellow;
                    break;

                case ChatMessageStatus.Other:
                    color = Color.Transparent;
                    break;

                default:
                    color = Color.ParseColor(ChatStatusDefaultColor);
                    break;
                }

                _messageStatusIndicatorView?.SetBackgroundColor(color);
            }));

            Bindings.Add(this.SetBinding(() => _viewModelRef.Target.LastMessageViewModel.HasPhoto).WhenSourceChanges(() =>
            {
                if (!_viewModelRef.Target.LastMessageViewModel.HasBody && _viewModelRef.Target.LastMessageViewModel.HasPhoto)
                {
                    _messageBodyTextView.Visibility  = ViewStates.Gone;
                    _messageBodyPhotoView.Visibility = ViewStates.Visible;
                }
                else
                {
                    _messageBodyTextView.Visibility  = BoolToViewStateConverter.ConvertGone(_viewModelRef.Target.LastMessageViewModel.HasBody);
                    _messageBodyPhotoView.Visibility = ViewStates.Gone;
                }
            }));
        }
예제 #25
0
 public OnItemClickListener(CommandAction viewModel)
 {
     _viewModelRef = WeakReferenceEx.Create(viewModel);
 }