public ConversationView(Conversation conv) { InitializeComponent(); conversationScrollView.IsVisible = true; setConversationInfo(conv); conversation = conv; entryBottom.IsVisible = true; conversationList.ItemSelected += OnItemSelected; type = MessageApiManager.CommentType.Converzation; ConversationId = conv.ConversationID; UpdateList(true); setSize(true); bool scrollDelay = false; commentEntryBottom.Focused += async (sender, e) => { conversationList.TranslationY = 90; conversationScrollView.HeightRequest = 1000; conversationInfo.IsVisible = false; try { await Task.Delay(1); if (conversationList.ItemsSource.OfType<Comment>().Last() != null) { conversationList.ScrollTo(conversationList.ItemsSource.OfType<Comment>().Last(), ScrollToPosition.End, true); } } catch (Exception ex) { } scrollDelay = true; await Task.Delay(200); scrollDelay = false; }; commentEntryBottom.Unfocused += (sender, e) => { conversationList.TranslationY = 0; }; conversationScrollView.Scrolled += (sender, e) => { System.Diagnostics.Debug.WriteLine(conversationScrollView.ScrollY); if (conversationScrollView.ScrollY > 0 && conversationScrollView.ScrollY < 100 && !scrollDelay) { DependencyService.Get<ForceCloseKeyboard>().CloseKeyboard(); } if (conversationScrollView.ScrollY < 10 && !scrollDelay) { if (conversation.ModelType != ConversationModelType.Profile) { conversationInfo.IsVisible = true; } } }; App.coreView.viewdConversation = this; }
public InviteListView(Conversation conversation, bool create) { InitializeComponent(); conversationSetup(conversation); if (create) { addBtn.Text = "Create"; addBtn.Clicked += async (sender, e) => { App.coreView.returnToPreviousView(); profilesAdded.Add(App.userProfile); Conversation conv = await _dataManager.MessageApiManager.CreateConversations(conversation.ModelType, profilesAdded, conversation.ModelId, ""); if (conv != null) { App.coreView.setContentViewWithQueue(new ConversationView(conv)); } }; } else { addBtn.Clicked += async (sender, e) => { App.coreView.returnToPreviousView(); Conversation newConv = await _dataManager.MessageApiManager.AddProfilesToConversation(conversation.ConversationID, profilesAdded); if (newConv != null) { App.coreView.setContentViewWithQueue(new ConversationView(newConv)); } }; } }
async void conversationSetup(Conversation conversation) { //Normal Conversation if (conversation.ModelType == ConversationModelType.Profile) { profilesThatCanBeAdded = App.userProfile.Friends; } //Event Conversation if (conversation.ModelType == ConversationModelType.Event) { var eve = await _dataManager.EventApiManager.GetEventById(conversation.ModelId); profilesThatCanBeAdded = eve.Attendees; if (eve.ProfileOwners != null) { foreach (Profile p in eve.GroupOwner.ProfileOwners) { if (!profilesThatCanBeAdded.Exists(prof => prof.ProfileId == p.ProfileId)) profilesThatCanBeAdded.Add(p); } } } //Group Conversation if (conversation.ModelType == ConversationModelType.Group) { var grp = await _dataManager.GroupApiManager.GetGroup(conversation.ModelId); profilesThatCanBeAdded = grp.Members; if (grp.ProfileOwners != null) { foreach (Profile p in grp.ProfileOwners) { if (!profilesThatCanBeAdded.Exists(prof => prof.ProfileId == p.ProfileId)) profilesThatCanBeAdded.Add(p); } } } //Organization Conversation /* if (conversation.ModelType == ConversationModelType.Organization) { var org = await _dataManager.OrganizationApiManager.GetOrganization(conversation.ModelId); profilesThatCanBeAdded = org.Members; } */ profilesThatCanBeAdded.RemoveAll(p => p.ProfileId == App.StoredUserFacebookId); setup(); }
public async Task<Conversation> GetOneConversation(string id) { Conversation conversation = new Conversation(); try { var response = await httpClient.GetAsync(new Uri(App.serverUri + "message/conversation/getOne/" + id)); if (response.IsSuccessStatusCode) { var recievedContent = await response.Content.ReadAsStringAsync(); return conversation = JsonConvert.DeserializeObject<Conversation>(recievedContent); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(@" ERROR {0}", ex.Message); } return null; }
public async Task<bool> UpdateList(bool update) { if (update) { if (type == MessageApiManager.CommentType.Converzation) { conversation = await _dataManager.MessageApiManager.GetOneConversation(ConversationId); comments = conversation.Messages; } else { comments = await _dataManager.MessageApiManager.GetComments(ConversationId, type); } } if (type == MessageApiManager.CommentType.Converzation) { comments = comments.OrderBy(c => c.DateAndTime).ToList(); conversationList.ItemsSource = comments; conversationList.IsRefreshing = false; } else { comments = comments.OrderByDescending(c => c.DateAndTime).ToList(); commentList.ItemsSource = comments; commentList.IsRefreshing = false; } await Task.Delay(10); if (type == MessageApiManager.CommentType.Converzation) { conversationList.ScrollTo(conversationList.ItemsSource.OfType<Comment>().Last(), ScrollToPosition.End, false); } else { commentList.HeightRequest = comments.Count * 120 + 100; listViewRow.Height = comments.Count * 120 + 100; wallLayout.HeightRequest = comments.Count * 120 + 100; commentList.ScrollTo(commentList.ItemsSource.OfType<Comment>().First(), ScrollToPosition.Start, true); } return true; }
async void setConversationInfo(Conversation c) { TapGestureRecognizer t = new TapGestureRecognizer(); conversationInfo.IsVisible = true; if (c.ModelType == ConversationModelType.Event) { conversationInfoProfilesButton.Clicked += (sender, e) => { App.coreView.GoToSelectedEvent(c.ModelId); }; Event eve = await _dataManager.EventApiManager.GetEventById(c.ModelId); conversationInfoImage.Source = eve.ImageSource; conversationInfoModelLabel.Text = "Event: " + eve.Title; } else if (c.ModelType == ConversationModelType.Group) { conversationInfoProfilesButton.Clicked += (sender, e) => { App.coreView.GoToSelectedGroup(c.ModelId); }; Group grp = await _dataManager.GroupApiManager.GetGroup(c.ModelId); conversationInfoImage.Source = grp.ImageSource; conversationInfoModelLabel.Text = "Group: " + grp.Name; } else { conversationInfo.IsVisible = false; conversationInfoProfilesButton.IsVisible = false; } closeEditTitle.Clicked += (sender, e) => { editTitleGrid.IsVisible = !editTitleGrid.IsVisible; }; editTitleButton.Clicked += async (sender, e) => { await _dataManager.MessageApiManager.EditConversationTitle(conversation.ConversationID, editTitleEntry.Text); c = await _dataManager.MessageApiManager.GetOneConversation(c.ConversationID); App.coreView.setContentViewReplaceCurrent(new ConversationView(c), 1); }; }