Exemplo n.º 1
0
 /// <summary>
 /// Gets new suggestions based on the search bar text
 /// </summary>
 private async void UpdateTableView()
 {
     try
     {
         _suggestionSource.UpdateSuggestions(await _viewModel.GetLocationSuggestionsAsync(_searchBar.Text));
         _autoSuggestionsTableView.ReloadData();
         _autoSuggestionsTableView.Hidden = false;
         InvalidateIntrinsicContentSize();
     }
     catch (Exception ex)
     {
         ErrorLogger.Instance.LogException(ex);
     }
 }
        /// <summary>
        /// Update UI for viewmodel property changes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName != nameof(_viewModel.CurrentRoute))
            {
                return;
            }

            Route firstRoute = _viewModel.CurrentRoute?.Routes?.FirstOrDefault();

            if (firstRoute == null)
            {
                _stopsTable.Source = null;
                return;
            }

            // Build up the walk time label
            StringBuilder walkTimeStringBuilder = new StringBuilder();

            // Add walk time and distance label
            if (firstRoute.TotalTime.Hours > 0)
            {
                walkTimeStringBuilder.Append($"{firstRoute.TotalTime.Hours}:{firstRoute.TotalTime.Minutes}");
            }
            else
            {
                walkTimeStringBuilder.Append($"{firstRoute.TotalTime.Minutes + 1} " + "RouteTimeMinutesLabel".Localize());
            }

            _routeDurationLabel.Text = walkTimeStringBuilder.ToString();

            // Create the list of stop features (origin and destination)
            var tableSource = new List <Feature> {
                _viewModel.FromLocationFeature, _viewModel.ToLocationFeature
            };

            // Update the stops table with new data
            _stopsTable.Source = new RouteTableSource(tableSource);

            // necessary so that table is reloaded before layout is requested
            _stopsTable.ReloadData();

            RelayoutRequested?.Invoke(this, EventArgs.Empty);

            UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, (NSString)"RouteFoundAccessibilityAnnouncement".Localize());
        }