/// <summary> /// Save state before navigating /// </summary> /// <param name="suspensionState"></param> /// <param name="suspending"></param> /// <returns></returns> public override async Task OnNavigatedFromAsync(IDictionary <string, object> suspensionState, bool suspending) { if (suspending) { suspensionState[nameof(CurrentEgg)] = JsonConvert.SerializeObject(CurrentEgg); suspensionState[nameof(SelectedEggIncubator)] = SelectedEggIncubator.ToByteString().ToBase64(); } await Task.CompletedTask; }
/// <summary> /// </summary> /// <param name="parameter">MapPokemonWrapper containing the Pokemon that we're trying to capture</param> /// <param name="mode"></param> /// <param name="suspensionState"></param> /// <returns></returns> public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> suspensionState) { if (suspensionState.Any()) { // Recovering the state CurrentEgg = JsonConvert.DeserializeObject <PokemonDataWrapper>((string)suspensionState[nameof(CurrentEgg)]); SelectedEggIncubator.MergeFrom(ByteString.FromBase64((string)suspensionState[nameof(SelectedEggIncubator)]).CreateCodedInput()); } else { // Navigating from game page, so we need to actually load the encounter CurrentEgg = (PokemonDataWrapper)NavigationHelper.NavigationState[nameof(CurrentEgg)]; } await Task.CompletedTask; }