private async void OnBindingContextChanged(object sender, EventArgs e) { familyTabPageViewModel = (FamilyTabPageViewModel)Parent.BindingContext; if (!string.IsNullOrEmpty(familyTabPageViewModel.user.familyId)) { familyTabPageViewModel.family = await familyRepository.GetOneAsync(familyTabPageViewModel.user.familyId); } if (familyTabPageViewModel.family != null) { if (familyTabPageViewModel.family.toDoList != null && familyTabPageViewModel.family.toDoList.Count > 0 && ((List <UsersForDomesticas>)familyTabPageViewModel.usersForDomesticas).Count != familyTabPageViewModel.family.toDoList.Count) { lblNoDomestica.IsVisible = false; lstDomesticas.IsVisible = true; familyTabPageViewModel.usersForDomesticas = new List <UsersForDomesticas>(); foreach (Domesticas d in familyTabPageViewModel.family.toDoList) { familyTabPageViewModel.addUsersForDomesticas(new UsersForDomesticas(d, ((List <User>)familyTabPageViewModel.members).Find(use => use.uid.Equals(d.user)))); } } else if (familyTabPageViewModel.family.toDoList.Count == 0) { lblNoDomestica.IsVisible = true; lstDomesticas.IsVisible = false; } await Device.InvokeOnMainThreadAsync(async() => { lstDomesticas.ItemsSource = familyTabPageViewModel.usersForDomesticas; }); firstTime = false; } }
private async void OnAppearing(object sender, EventArgs e) { familyTabPageViewModel = new FamilyTabPageViewModel(); if (string.IsNullOrEmpty(user.photoURL)) { user.photoURL = "placeholder_profile.png"; } else { if (!File.Exists(user.photoURL)) { await LoadImmage(); } } familyTabPageViewModel.user = user; if (!string.IsNullOrEmpty(familyTabPageViewModel.user.familyId)) { familyTabPageViewModel.family = await familyRepository.GetOneAsync(familyTabPageViewModel.user.familyId); } List <User> members = new List <User>(); foreach (string id in familyTabPageViewModel.family.membersID) { members.Add(await userRepository.GetOneAsync(id)); } familyTabPageViewModel.members = members; BindingContext = familyTabPageViewModel; }
public HomeTabPage() { InitializeComponent(); familyTabPageViewModel = new FamilyTabPageViewModel(); familyRepository = new FamilyRepository(); userRepository = new UserRepository(); Appearing += OnAppearing; BindingContextChanged += OnBindingContextChanged; }
public FamilyTabPage() { InitializeComponent(); familyTabPageViewModel = new FamilyTabPageViewModel(); familyRepository = new FamilyRepository(); userRepository = new UserRepository(); toDisplay = new List <User>(); Appearing += OnAppearing; }
public DomesticasPopup(FamilyTabPageViewModel familyTabPageViewModel, bool edit, UsersForDomesticas domesticas) { InitializeComponent(); this.edit = edit; this.familyTabPageViewModel = familyTabPageViewModel; BindingContext = familyTabPageViewModel.members; if (!edit) { lblDomesticas.Text = "Aggiungi compito famigliare"; this.domesticas = new UsersForDomesticas(new Domesticas(), familyTabPageViewModel.user); } else { lblDomesticas.Text = "Modifica compito famigliare"; this.domesticas = domesticas; domesticasNameEntry.Text = this.domesticas.domesticas.name; lstUsers.SelectedItem = ((List <User>)BindingContext).Find(use => use.uid.Equals(this.domesticas.user.uid)); } }
private async void OnAppearing(object sender, EventArgs e) { toDisplay.Clear(); familyTabPageViewModel = (FamilyTabPageViewModel)BindingContext; if (!string.IsNullOrEmpty(familyTabPageViewModel.user.familyId)) { familyTabPageViewModel.family = familyTabPageViewModel.family = await familyRepository.GetOneAsync(familyTabPageViewModel.user.familyId); } if (!string.IsNullOrEmpty(familyTabPageViewModel.user.familyId)) { GoInEditMode(); toDisplay = familyTabPageViewModel.members; } else { GoInAddMode(); } await Device.InvokeOnMainThreadAsync(async() => { lstUsers.ItemsSource = familyTabPageViewModel.members; }); await Device.InvokeOnMainThreadAsync(async() => { familyNameEntry.Text = familyTabPageViewModel.family.familyName; }); }