private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (!alreadyLoaded) { detailVm = new StopDetailViewModel(e.NavigationParameter as Stop); DataContext = detailVm; //Check if the stop is in user's favorites list if(detailVm.IsFavorite()) { FavButton.Click += UnfavoriteBtnPressed; FavButton.Label = "unfavorite"; FavButton.Icon = new SymbolIcon(Symbol.Remove); } else { FavButton.Click += FavoriteBtnPressed; FavButton.Label = "favorite"; FavButton.Icon = new SymbolIcon(Symbol.Favorite); } if(!SecondaryTile.Exists(detailVm.tileId)) { PinButton.Click += detailVm.PinTile; PinButton.Label = "pin"; PinButton.Icon = new SymbolIcon(Symbol.Pin); } else { PinButton.Label = "unpin"; PinButton.Icon = new SymbolIcon(Symbol.UnPin); } alreadyLoaded = true; } StatusBar statusBar = StatusBar.GetForCurrentView(); await statusBar.ProgressIndicator.ShowAsync(); statusBar.ProgressIndicator.Text = "Getting Arrival Times"; statusBar.ProgressIndicator.ProgressValue = null; if (!await detailVm.LoadTimes()) { Frame.GoBack(); } if (!detailVm.Alerts.Any()) DetailPivot.Items.RemoveAt(1); statusBar.ProgressIndicator.ProgressValue = 0; await statusBar.ProgressIndicator.HideAsync(); }
private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (!alreadyLoaded) { detailVm = new StopDetailViewModel(e.NavigationParameter as Stop); DataContext = detailVm; //Check if the stop is in user's favorites list if(detailVm.IsFavorite()) { FavButton.Click += UnfavoriteBtnPressed; FavButton.Label = "unfavorite"; FavButton.Icon = new SymbolIcon(Symbol.UnFavorite); } else { FavButton.Click += FavoriteBtnPressed; FavButton.Label = "favorite"; FavButton.Icon = new SymbolIcon(Symbol.Favorite); } if(!SecondaryTile.Exists(detailVm.tileId)) { PinButton.Click += detailVm.PinTile; PinButton.Label = "pin"; PinButton.Icon = new SymbolIcon(Symbol.Pin); } else { PinButton.Label = "unpin"; PinButton.Icon = new SymbolIcon(Symbol.UnPin); } if (!await detailVm.LoadTimes()) //TODO: Make Timer accessible so I do not need to load all times just to restart it. //TODO: Times do not automatically refresh after navigating back from map page { Frame.GoBack(); } alreadyLoaded = true; } await UIHelper.ShowStatusBar("Getting Arrival Times"); //if (!detailVm.Alerts.Any()) DetailPivot.Items.RemoveAt(1); LoadingRing.IsActive = false; await UIHelper.HideStatusBar(); }