-
-
Notifications
You must be signed in to change notification settings - Fork 56
feat: improve screen reader support #684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,16 +1,18 @@ | ||||||||||||||
#nullable enable | ||||||||||||||
|
||||||||||||||
using System; | ||||||||||||||
using System.Windows.Input; | ||||||||||||||
using CommunityToolkit.Mvvm.DependencyInjection; | ||||||||||||||
using Screenbox.Core.Enums; | ||||||||||||||
using Screenbox.Core.ViewModels; | ||||||||||||||
using System; | ||||||||||||||
using System.Windows.Input; | ||||||||||||||
using Windows.UI.Xaml; | ||||||||||||||
using Windows.UI.Xaml.Automation; | ||||||||||||||
using Windows.UI.Xaml.Controls; | ||||||||||||||
|
||||||||||||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | ||||||||||||||
|
||||||||||||||
namespace Screenbox.Controls; | ||||||||||||||
|
||||||||||||||
public sealed partial class MediaListViewItem : UserControl | ||||||||||||||
{ | ||||||||||||||
public static readonly DependencyProperty PlayCommandProperty = DependencyProperty.Register( | ||||||||||||||
|
@@ -42,16 +44,30 @@ public MediaListViewItem() | |||||||||||||
private GridLength BoolToGridLength(bool visibility) => | ||||||||||||||
visibility ? new GridLength(1, GridUnitType.Star) : new GridLength(0); | ||||||||||||||
|
||||||||||||||
private void UpdatePlayButtonsAutomationName(bool isPlaying) | ||||||||||||||
{ | ||||||||||||||
var media = DataContext as MediaViewModel; | ||||||||||||||
string playPauseText = isPlaying ? Strings.Resources.Pause : Strings.Resources.Play; | ||||||||||||||
|
||||||||||||||
AutomationProperties.SetName(PlayButton, $"{playPauseText} {media?.Name}"); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential null reference exception if
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
private void OnDataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) | ||||||||||||||
{ | ||||||||||||||
_firstPlay = true; | ||||||||||||||
AdaptiveLayoutBehavior.Override = | ||||||||||||||
(DataContext as MediaViewModel)?.MediaType != MediaPlaybackType.Music ? 0 : -1; | ||||||||||||||
var media = DataContext as MediaViewModel; | ||||||||||||||
AdaptiveLayoutBehavior.Override = media?.MediaType != MediaPlaybackType.Music ? 0 : -1; | ||||||||||||||
|
||||||||||||||
UpdatePlayButtonsAutomationName(media?.IsPlaying ?? false); | ||||||||||||||
AutomationProperties.SetName(ArtistButton, $"{Strings.Resources.Artist}: {media?.MainArtist?.Name}"); | ||||||||||||||
AutomationProperties.SetName(AlbumButton, $"{Strings.Resources.Albums}: {media?.Album?.Name}"); | ||||||||||||||
Comment on lines
+62
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
private async void PlayingStatesOnCurrentStateChanged(object sender, VisualStateChangedEventArgs e) | ||||||||||||||
{ | ||||||||||||||
if (_firstPlay && e.NewState?.Name == nameof(Playing)) | ||||||||||||||
bool isPlaying = e.NewState?.Name == nameof(Playing); | ||||||||||||||
UpdatePlayButtonsAutomationName(isPlaying); // TODO: Use MediaViewModel PropertyChanged (IsPlaying) event. | ||||||||||||||
if (_firstPlay && isPlaying) | ||||||||||||||
{ | ||||||||||||||
_firstPlay = false; | ||||||||||||||
await PlayingIndicator.PlayAsync(0, 1, true); | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential null reference exception if
Model.Title
is null. The method should handle the case whereModel.Title
might be null to prevent runtime exceptions.Copilot uses AI. Check for mistakes.