Example #1
0
        public void Update(Conversation conversation, User user, Theme newTheme, LocalData localData)
        {
            User = user;
            int id1 = conversation.member1.Id;
            int id2 = conversation.member2.Id;

            _conversation = localData.GetConversations().First(c => (c.member1.Id == id1 && c.member2.Id == id2) || (c.member1.Id == id2 && c.member2.Id == id1));
            messagesId    = new Dictionary <Guid, Message>();
            theme         = newTheme;
            _localData    = localData;

            if (_conversation.messages == null)
            {
                _conversation.messages = new List <Message>();
            }

            List <Message> orderedEnumerable = _conversation.messages.OrderBy(x => x.DateTime).ToList();

            int length = orderedEnumerable.Count();

            stack.Children.Clear();

            for (int i = 0; i < length; i++)
            {
                Message message = orderedEnumerable.ElementAt(i);
                Button  button  = CreateButton(message, _conversation.member1 == user);
                button.SetTheme(theme);
                stack.Children.Add(button);
            }
        }
Example #2
0
        private void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            Debug.WriteLine("[m] [MessagesView] ListView_ItemTapped running");

            if (sender is ListView lv)
            {
                int          index        = e.ItemIndex;
                Conversation conversation = _localData.GetConversations().First(c => c.Id == keyValues[index]);
                OpenDialodRequest(user, conversation);
            }

            (sender as ListView).SelectedItem = null;
        }