/// <summary> /// Updates UI for settings changes /// </summary> private void CurrentSettings_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == nameof(AppSettings.IsRoutingEnabled)) { _startDirectionsButton.Hidden = !AppSettings.CurrentSettings.IsRoutingEnabled; } RelayoutRequested?.Invoke(this, EventArgs.Empty); }
/// <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()); }
/// <summary> /// Updates UI for viewmodel property changes /// </summary> private void ViewModel_Changed(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName != nameof(_viewModel.CurrentRoom)) { return; } _primaryLabel.Text = _viewModel.CurrentRoom?.PrimaryDisplayField; _secondaryLabel.Text = _viewModel.CurrentRoom?.SecondaryDisplayField; if (string.IsNullOrWhiteSpace(_secondaryLabel.Text)) { _directionsButtonToSecondaryLabelTopConstraint.Active = false; _directionsButtonToPrimaryLabelTopConstraint.Active = true; } else { _directionsButtonToSecondaryLabelTopConstraint.Active = true; _directionsButtonToPrimaryLabelTopConstraint.Active = false; } // Since values have changed, UI may now need more space. RelayoutRequested?.Invoke(this, EventArgs.Empty); }