private async void StopListView_ItemTapped(object sender, ItemTappedEventArgs e) { var stop = e.Item as Stop; if (stop != null) { if (stop.IsDestinationStart) { // look for stops near you var stopsToDest = await DbHelper.Instance.SearchStopsNearMeToADestination(stop); if (stopsToDest.Count == 0) { var alertConfig = new AlertConfig { Message = $"No stops found near you to {stop.Title}. Please select another stop", OkText = "OK", OnAction = null }; UserDialogs.Instance.Alert(alertConfig); } else { var nearViwModel = new StopLiteViewModel(stopsToDest, true); await Navigation.PushAsync(new StopLitePage(nearViwModel) { Title = $"Stops to {stop.Title}" }); } } else { //go to predictions page await Navigation.PushAsync(new PredictionsPage(stop)); } } }
private async void StopListView_OnItemSelected(object sender, SelectedItemChangedEventArgs e) { var address = e.SelectedItem as GoogleAddress; if (address != null) { var stopsFound = _viewModel.SearchStops(address).Result; if (stopsFound.Count != 0) { var viewModel = new StopLiteViewModel(stopsFound, true); await Navigation.PushAsync(new StopLitePage (viewModel) { Title = $"Stops near { address.Name } at {address.FormattedAddress}" }); } else { var alertConfig = new AlertConfig { Message = $"No stops found near {address.Name}. Please select another address", OkText = "OK", OnAction = null }; UserDialogs.Instance.Alert(alertConfig); } } }
public StopLitePage(StopLiteViewModel viewModel) { InitializeComponent(); _StopLiteViewModel = viewModel; BindingContext = viewModel; }