예제 #1
0
        private async Task AddContact()
        {
            var viewModel = new ContactDetailPageViewModel(new Contact());
            var page      = new ContactDetailPage(viewModel);

            await Subscribe_ContactDetail_Add(page, viewModel);
        }
예제 #2
0
        private async Task Subscribe_ContactDetail_Add(ContactDetailPage page, ContactDetailPageViewModel viewModel)
        {
            SelectedContact         = null;
            viewModel.ContactAdded += async(source, args) =>
            {
                bool isAdd = args.Id == 0;
                if (isAdd)
                {
                    Contacts.Add(args);
                    await _contactService.AddContact(args);
                }
                else
                {
                    var existingContact = Contacts.Where(x => x.Id == args.Id).FirstOrDefault();
                    Contacts[Contacts.IndexOf(existingContact)] = args;
                    await _contactService.UpdateContact(args);
                }
                await _pageService.DisplayAlert("Add Contact",
                                                string.Format("Contact has been {0}", (isAdd) ? "added" : "modified"),
                                                "OK");

                await _pageService.PopAsync();
            };

            await _pageService.PushAsync(page);
        }
예제 #3
0
        private async Task OnSelectedContactAsync(object sender, SelectedItemChangedEventArgs e)
        {
            //Si el contacto seleccionado es null (ha seleccionado una fila vacia de la lista) salimos.
            if (ContactsListView.SelectedItem == null)
            {
                return;
            }

            var SelectedContact = e.SelectedItem as Contact; //Recogemos Item seleccionado.

            ContactsListView.SelectedItem = null;            //Dejamos el objeto de la vista a null, para cuando volvamos a la Page poder seleccionarlo de nuevo.

            //Creamos variable de la Pagina con el contacto dado por parametro
            var ContactDetailPage = new ContactDetailPage(SelectedContact);

            //Nos subscribimos al evento ContactAdded para en el caso de que el usuario seleccione un contacto en la lista, este se pueda actualizar al disparar el evento.
            ContactDetailPage.ContactUpdated += (source, contact) =>
            {
                if (ContactList.Contains(contact))
                {
                    SelectedContact.Id        = contact.Id;
                    SelectedContact.Name      = contact.Name;
                    SelectedContact.SurName   = contact.SurName;
                    SelectedContact.Phone     = contact.Phone;
                    SelectedContact.Email     = contact.Email;
                    SelectedContact.IsBlocked = contact.IsBlocked;
                }
            };

            await Navigation.PushAsync(ContactDetailPage);//Lanzamos la pagina gestionada mediante el controlador de eventos.
        }
예제 #4
0
 private async void ContactsCollectionView_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (ContactsCollectionView.SelectedItem is Contact contactItem)
     {
         ContactDetailPage contactDetailPage = new ContactDetailPage(contactItem);
         ContactsCollectionView.SelectedItem = null;
         await Shell.Current.Navigation.PushModalAsync(contactDetailPage);
     }
 }
예제 #5
0
        private async void OnAddContact(object sender, EventArgs e)
        {
            //Creamos variable de la Pagina con un contacto nuevo y vacio para rellenar
            var ContactDetailPage = new ContactDetailPage(new Contact());

            //Nos subscribimos al evento ContactAdded para en el caso de que el usuario pulse el boton Added la vista se vea notificada y lo añada a la lista
            ContactDetailPage.ContactAdded += (source, contact) => ContactList.Add(contact);

            await Navigation.PushAsync(new ContactDetailPage());//Lanzamos la pagina gestionada mediante el controlador de eventos.
        }
예제 #6
0
        private async Task Contact_Selected(Contact contactSelected)
        {
            if (contactSelected == null)
            {
                return;
            }
            SelectedContact = contactSelected;

            var viewModel = new ContactDetailPageViewModel(contactSelected);
            var page      = new ContactDetailPage(viewModel);

            await Subscribe_ContactDetail_Add(page, viewModel);
        }
예제 #7
0
        private async void TimeLineListView_OnItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem is TimeLineItem timeLineItem)
            {
                if (timeLineItem.ItemObject is Picture picture)
                {
                    PhotoDetailPage photoPage = new PhotoDetailPage(picture.PictureId);
                    // Reset selection
                    TimeLineListView.SelectedItem = null;
                    await Shell.Current.Navigation.PushModalAsync(photoPage);
                }

                if (timeLineItem.ItemObject is Video video)
                {
                    VideoDetailPage videoPage = new VideoDetailPage(video.VideoId);
                    // Reset selection
                    TimeLineListView.SelectedItem = null;
                    await Shell.Current.Navigation.PushModalAsync(videoPage);
                }

                if (timeLineItem.ItemObject is Sleep sleep)
                {
                    SleepDetailPage sleepDetailPage = new SleepDetailPage(sleep);
                    TimeLineListView.SelectedItem = null;
                    await Shell.Current.Navigation.PushModalAsync(sleepDetailPage);
                }

                if (timeLineItem.ItemObject is CalendarItem calendarItem)
                {
                    EventDetailPage eventDetailPage = new EventDetailPage(calendarItem);
                    TimeLineListView.SelectedItem = null;
                    await Shell.Current.Navigation.PushModalAsync(eventDetailPage);
                }

                if (timeLineItem.ItemObject is Location locationItem)
                {
                    LocationDetailPage locationDetailPage = new LocationDetailPage(locationItem);
                    TimeLineListView.SelectedItem = null;
                    await Shell.Current.Navigation.PushModalAsync(locationDetailPage);
                }

                if (timeLineItem.ItemObject is Vaccination vaccinationItem)
                {
                    VaccinationDetailPage vaccinationDetailPage = new VaccinationDetailPage(vaccinationItem);
                    TimeLineListView.SelectedItem = null;
                    await Shell.Current.Navigation.PushModalAsync(vaccinationDetailPage);
                }

                if (timeLineItem.ItemObject is VocabularyItem vocabularyItem)
                {
                    VocabularyDetailPage vocabularyDetailPage = new VocabularyDetailPage(vocabularyItem);
                    TimeLineListView.SelectedItem = null;
                    await Shell.Current.Navigation.PushModalAsync(vocabularyDetailPage);
                }

                if (timeLineItem.ItemObject is Skill skillItem)
                {
                    SkillDetailPage skillDetailPage = new SkillDetailPage(skillItem);
                    TimeLineListView.SelectedItem = null;
                    await Shell.Current.Navigation.PushModalAsync(skillDetailPage);
                }

                if (timeLineItem.ItemObject is Measurement measurementItem)
                {
                    MeasurementDetailPage measurementDetailPage = new MeasurementDetailPage(measurementItem);
                    TimeLineListView.SelectedItem = null;
                    await Shell.Current.Navigation.PushModalAsync(measurementDetailPage);
                }

                if (timeLineItem.ItemObject is Friend friendItem)
                {
                    FriendDetailPage friendDetailPage = new FriendDetailPage(friendItem);
                    TimeLineListView.SelectedItem = null;
                    await Shell.Current.Navigation.PushModalAsync(friendDetailPage);
                }

                if (timeLineItem.ItemObject is Contact contactItem)
                {
                    ContactDetailPage contactDetailPage = new ContactDetailPage(contactItem);
                    TimeLineListView.SelectedItem = null;
                    await Shell.Current.Navigation.PushModalAsync(contactDetailPage);
                }

                if (timeLineItem.ItemObject is Note noteItem)
                {
                    NoteDetailPage noteDetailPage = new NoteDetailPage(noteItem);
                    TimeLineListView.SelectedItem = null;
                    await Shell.Current.Navigation.PushModalAsync(noteDetailPage);
                }
            }
        }
예제 #8
0
 public Task PushModalAsync(ContactDetailPage contactDetails)
 {
     throw new NotImplementedException();
 }
        private async void NotificationsListCollectionView_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (NotificationsListCollectionView.SelectedItem is MobileNotification notification)
            {
                if (!notification.Read)
                {
                    notification.Read = true;
                    await UserService.UpdateNotification(notification);
                }

                int  itemId;
                bool parsed = int.TryParse(notification.ItemId, out itemId);
                if (notification.ItemType == (int)KinaUnaTypes.TimeLineType.Sleep)
                {
                    if (parsed)
                    {
                        Sleep sleep = await ProgenyService.GetSleep(itemId, await UserService.GetAuthAccessToken(),
                                                                    await UserService.GetUserTimezone());

                        SleepDetailPage sleepDetailPage = new SleepDetailPage(sleep);
                        await Shell.Current.Navigation.PushModalAsync(sleepDetailPage);
                    }
                }

                if (notification.ItemType == (int)KinaUnaTypes.TimeLineType.Photo)
                {
                    if (parsed)
                    {
                        PhotoDetailPage photoDetailPage = new PhotoDetailPage(itemId);
                        await Shell.Current.Navigation.PushModalAsync(photoDetailPage);
                    }
                }

                if (notification.ItemType == (int)KinaUnaTypes.TimeLineType.Video)
                {
                    if (parsed)
                    {
                        VideoDetailPage videoDetailPage = new VideoDetailPage(itemId);
                        await Shell.Current.Navigation.PushModalAsync(videoDetailPage);
                    }
                }

                if (notification.ItemType == (int)KinaUnaTypes.TimeLineType.Note)
                {
                    if (parsed)
                    {
                        Note noteItem = await ProgenyService.GetNote(itemId, await UserService.GetAuthAccessToken(), await UserService.GetUserTimezone());

                        NoteDetailPage noteDetailPage = new NoteDetailPage(noteItem);
                        await Shell.Current.Navigation.PushModalAsync(noteDetailPage);
                    }
                }

                if (notification.ItemType == (int)KinaUnaTypes.TimeLineType.Measurement)
                {
                    if (parsed)
                    {
                        Measurement measurementItem = await ProgenyService.GetMeasurement(itemId, await UserService.GetAuthAccessToken());

                        MeasurementDetailPage measurementDetailPage = new MeasurementDetailPage(measurementItem);
                        await Shell.Current.Navigation.PushModalAsync(measurementDetailPage);
                    }
                }

                if (notification.ItemType == (int)KinaUnaTypes.TimeLineType.Calendar)
                {
                    if (parsed)
                    {
                        CalendarItem calendarItem = await ProgenyService.GetCalendarItem(itemId, await UserService.GetAuthAccessToken(), await UserService.GetUserTimezone());

                        EventDetailPage eventDetailPage = new EventDetailPage(calendarItem);
                        await Shell.Current.Navigation.PushModalAsync(eventDetailPage);
                    }
                }

                if (notification.ItemType == (int)KinaUnaTypes.TimeLineType.Contact)
                {
                    if (parsed)
                    {
                        Contact contact = await ProgenyService.GetContact(itemId, await UserService.GetAuthAccessToken());

                        ContactDetailPage contactDetailPage = new ContactDetailPage(contact);
                        await Shell.Current.Navigation.PushModalAsync(contactDetailPage);
                    }
                }

                if (notification.ItemType == (int)KinaUnaTypes.TimeLineType.Friend)
                {
                    if (parsed)
                    {
                        Friend friend = await ProgenyService.GetFriend(itemId, await UserService.GetAuthAccessToken());

                        FriendDetailPage friendDetailPage = new FriendDetailPage(friend);
                        await Shell.Current.Navigation.PushModalAsync(friendDetailPage);
                    }
                }

                if (notification.ItemType == (int)KinaUnaTypes.TimeLineType.Location)
                {
                    if (parsed)
                    {
                        Location location = await ProgenyService.GetLocation(itemId, await UserService.GetAuthAccessToken(), await UserService.GetUserTimezone());

                        LocationDetailPage locationDetailPage = new LocationDetailPage(location);
                        await Shell.Current.Navigation.PushModalAsync(locationDetailPage);
                    }
                }

                if (notification.ItemType == (int)KinaUnaTypes.TimeLineType.Skill)
                {
                    if (parsed)
                    {
                        Skill skill = await ProgenyService.GetSkill(itemId, await UserService.GetAuthAccessToken(), await UserService.GetUserTimezone());

                        SkillDetailPage skillDetailPage = new SkillDetailPage(skill);
                        await Shell.Current.Navigation.PushModalAsync(skillDetailPage);
                    }
                }

                if (notification.ItemType == (int)KinaUnaTypes.TimeLineType.Vaccination)
                {
                    if (parsed)
                    {
                        Vaccination vaccination = await ProgenyService.GetVaccination(itemId, await UserService.GetAuthAccessToken(), await UserService.GetUserTimezone());

                        VaccinationDetailPage vaccinationDetailPage = new VaccinationDetailPage(vaccination);
                        await Shell.Current.Navigation.PushModalAsync(vaccinationDetailPage);
                    }
                }

                if (notification.ItemType == (int)KinaUnaTypes.TimeLineType.Vocabulary)
                {
                    if (parsed)
                    {
                        VocabularyItem vocabularyItem = await ProgenyService.GetVocabularyItem(itemId, await UserService.GetAuthAccessToken(), await UserService.GetUserTimezone());

                        VocabularyDetailPage vocabularyDetailPage = new VocabularyDetailPage(vocabularyItem);
                        await Shell.Current.Navigation.PushModalAsync(vocabularyDetailPage);
                    }
                }

                if (notification.ItemType == (int)KinaUnaTypes.TimeLineType.UserAccess)
                {
                    if (parsed)
                    {
                        await Shell.Current.GoToAsync("useraccess");
                    }
                }
            }

            NotificationsListCollectionView.SelectedItem = null;
            await Reload();
        }