public ConversationsPageViewModel(INavigation navigation, ConversationsPage conversationPage) { this.navigation = navigation; this.masterDetailPage = conversationPage; Conversations = BackupConversations = App.ConversationManager?.Conversations; AddContactCommand = new Command(async() => await OnContactAdded()); }
async Task OnContactAdded() { var contactsPage = new ContactsPage(); contactsPage.NewConversationRequest += async(selectedContacts) => { if (App.ConversationManager.FindConversation(selectedContacts) != null) { await ConversationsPage.PushConversation( App.ConversationManager.StartConversation(selectedContacts), this.masterDetailPage.Parent as MasterDetailPage); return; } var editPageContext = new EditPageViewModel { DefaultText = "Enter Topic Name..." }; editPageContext.EditFinished += async(sender, e) => { var topicName = string.IsNullOrEmpty(e) ? "New Topic" : e; await this.navigation.PopModalAsync(true); await ConversationsPage.PushConversation( App.ConversationManager.StartConversation(selectedContacts), this.masterDetailPage.Parent as MasterDetailPage, topicName); }; await this.navigation.PushModalAsync(new EditPage { BindingContext = editPageContext }, true); }; await this.navigation.PushModalAsync(new NavigationPage(contactsPage) { BarBackgroundColor = (Color)Application.Current.Resources["primaryBlue"], BarTextColor = Color.White }); }