Skip to content

Commit 22ffc5c

Browse files
authored
[Accessibility] Added Mode attached property to easily group or exclude views from VoiceOver/TalkBack. (#754)
1 parent 024002e commit 22ffc5c

File tree

20 files changed

+690
-224
lines changed

20 files changed

+690
-224
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## [53.8.0]
2+
- [Accessibility] Added `Mode` attached property.
3+
14
## [53.7.4]
25
- Fix error causing index out of range in `TabBadgeService` when tabs have changed
36

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<dui:ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
5+
xmlns:dui="http://dips.com/mobile.ui"
6+
xmlns:localizedStrings="clr-namespace:Components.Resources.LocalizedStrings"
7+
x:Class="Components.AccessibilitySamples.VoiceOverSamples.GroupChildrenSamples"
8+
Title="{x:Static localizedStrings:LocalizedStrings.VoiceOver_GroupChildren_Title}">
9+
10+
<dui:ScrollView Padding="{dui:Sizes size_4}">
11+
<dui:VerticalStackLayout Spacing="{dui:Sizes size_5}">
12+
13+
<dui:Label Text="{x:Static localizedStrings:LocalizedStrings.VoiceOver_GroupChildren_Description}"
14+
Style="{dui:Styles Label=UI200}"
15+
TextColor="{dui:Colors color_text_default}" />
16+
17+
<dui:VerticalStackLayout Spacing="{dui:Sizes size_2}">
18+
<dui:Label Text="{x:Static localizedStrings:LocalizedStrings.VoiceOver_Example}"
19+
Style="{dui:Styles Label=SectionHeader}" />
20+
21+
<dui:VerticalStackLayout Spacing="{dui:Sizes size_1}">
22+
<dui:Label Text="{x:Static localizedStrings:LocalizedStrings.VoiceOver_WithoutGrouping}"
23+
Style="{dui:Styles Label=UI300}"
24+
TextColor="{dui:Colors color_text_default}" />
25+
<dui:Label Text="{x:Static localizedStrings:LocalizedStrings.VoiceOver_SwipeGestures}"
26+
Style="{dui:Styles Label=UI100}"
27+
TextColor="{dui:Colors color_text_subtle}" />
28+
29+
<dui:VerticalStackLayout Spacing="{dui:Sizes size_1}"
30+
Padding="{dui:Sizes size_3}"
31+
BackgroundColor="{dui:Colors color_surface_subtle}"
32+
dui:Layout.AutoCornerRadius="True">
33+
<dui:Label Text="{x:Static localizedStrings:LocalizedStrings.VoiceOver_PatientCard_Name}"
34+
Style="{dui:Styles Label=SectionHeader}" />
35+
<dui:Label Text="{x:Static localizedStrings:LocalizedStrings.VoiceOver_PatientCard_Born}"
36+
Style="{dui:Styles Label=UI200}" />
37+
<dui:HorizontalStackLayout Spacing="{dui:Sizes size_1}">
38+
<dui:Label Text="{x:Static localizedStrings:LocalizedStrings.VoiceOver_PatientCard_Phone}"
39+
Style="{dui:Styles Label=UI200}" />
40+
<dui:Label Text="{x:Static localizedStrings:LocalizedStrings.VoiceOver_PatientCard_PhoneNumber}"
41+
Style="{dui:Styles Label=UI200}" />
42+
</dui:HorizontalStackLayout>
43+
<dui:Label Text="john.doe@example.com"
44+
Style="{dui:Styles Label=UI200}" />
45+
</dui:VerticalStackLayout>
46+
</dui:VerticalStackLayout>
47+
48+
<!-- With GroupChildren -->
49+
<dui:VerticalStackLayout Spacing="{dui:Sizes size_1}">
50+
<dui:Label Text="{x:Static localizedStrings:LocalizedStrings.VoiceOver_WithGrouping}"
51+
Style="{dui:Styles Label=UI300}"
52+
TextColor="{dui:Colors color_text_default}" />
53+
54+
<dui:VerticalStackLayout Spacing="{dui:Sizes size_1}"
55+
Padding="{dui:Sizes size_3}"
56+
BackgroundColor="{dui:Colors color_surface_subtle}"
57+
dui:Layout.AutoCornerRadius="True"
58+
dui:Accessibility.Mode="GroupChildren">
59+
<dui:Label Text="{x:Static localizedStrings:LocalizedStrings.VoiceOver_PatientCard_Name}"
60+
Style="{dui:Styles Label=Body400}" />
61+
<dui:Label Text="{x:Static localizedStrings:LocalizedStrings.VoiceOver_PatientCard_Born}"
62+
Style="{dui:Styles Label=UI200}" />
63+
<dui:HorizontalStackLayout Spacing="{dui:Sizes size_1}">
64+
<dui:Label Text="{x:Static localizedStrings:LocalizedStrings.VoiceOver_PatientCard_Phone}"
65+
Style="{dui:Styles Label=UI200}" />
66+
<dui:Label Text="{x:Static localizedStrings:LocalizedStrings.VoiceOver_PatientCard_PhoneNumber}"
67+
Style="{dui:Styles Label=UI200}" />
68+
</dui:HorizontalStackLayout>
69+
<dui:Label Text="john.doe@example.com"
70+
Style="{dui:Styles Label=UI200}" />
71+
</dui:VerticalStackLayout>
72+
</dui:VerticalStackLayout>
73+
74+
</dui:VerticalStackLayout>
75+
76+
</dui:VerticalStackLayout>
77+
</dui:ScrollView>
78+
79+
</dui:ContentPage>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Components.AccessibilitySamples.VoiceOverSamples;
2+
3+
public partial class GroupChildrenSamples : DIPS.Mobile.UI.Components.Pages.ContentPage
4+
{
5+
public GroupChildrenSamples()
6+
{
7+
InitializeComponent();
8+
}
9+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<dui:ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
5+
xmlns:dui="http://dips.com/mobile.ui"
6+
xmlns:localizedStrings="clr-namespace:Components.Resources.LocalizedStrings"
7+
xmlns:helpers="clr-namespace:Components.Helpers"
8+
xmlns:voiceOverSamples="clr-namespace:Components.AccessibilitySamples.VoiceOverSamples"
9+
x:Class="Components.AccessibilitySamples.VoiceOverSamples.VoiceOverSamples"
10+
Title="{x:Static localizedStrings:LocalizedStrings.VoiceOver}">
11+
12+
<dui:ScrollView Padding="{dui:Sizes size_4}">
13+
<dui:VerticalStackLayout Spacing="{dui:Sizes size_0}">
14+
15+
<dui:ListItem Title="{x:Static localizedStrings:LocalizedStrings.VoiceOver_GroupChildren_Title}"
16+
HasBottomDivider="True"
17+
Command="{helpers:NavigationCommand ContentPageType={x:Type voiceOverSamples:GroupChildrenSamples}}" />
18+
19+
</dui:VerticalStackLayout>
20+
21+
</dui:ScrollView>
22+
23+
</dui:ContentPage>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Components.AccessibilitySamples.VoiceOverSamples;
2+
3+
public partial class VoiceOverSamples
4+
{
5+
public VoiceOverSamples()
6+
{
7+
InitializeComponent();
8+
}
9+
}

src/app/Components/App.xaml.cs

Lines changed: 27 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,50 @@
11
using Components.Resources.LocalizedStrings;
2-
using Components.Services;
3-
using DIPS.Mobile.UI.API.Library;
2+
using Enum = System.Enum;
43

54
namespace Components;
65

76
public partial class App
87
{
9-
private readonly AppCenterService m_appCenterService;
10-
118
public App()
129
{
1310
InitializeComponent();
14-
15-
m_appCenterService = new AppCenterService();
1611
}
1712

1813
protected override Window CreateWindow(IActivationState? activationState)
1914
{
20-
var shell = new DIPS.Mobile.UI.Components.Shell.Shell
21-
{
22-
ShouldGarbageCollectPreviousPage = true,
23-
24-
};
15+
var shell = new DIPS.Mobile.UI.Components.Shell.Shell();
2516

17+
var allSamples = REGISTER_YOUR_SAMPLES_HERE.RegisterSamples();
2618
var tabBar = new TabBar();
27-
var tab = new Tab();
2819

29-
tab.Items.Add(new ShellContent
20+
foreach (var sampleType in Enum.GetValues<SampleType>())
3021
{
31-
ContentTemplate =
32-
new DataTemplate(() => new MainPage(new List<SampleType> {SampleType.Resources, SampleType.Components}.OrderBy(s => s.ToString()),
33-
REGISTER_YOUR_SAMPLES_HERE.RegisterSamples()))
34-
});
35-
tabBar.Items.Add(tab);
36-
shell.Items.Add(tabBar);
37-
38-
return new Window(shell);
39-
}
40-
41-
protected override void OnStart()
42-
{
43-
_ = TryGetLatestVersion();
44-
45-
base.OnStart();
46-
}
47-
48-
49-
private async Task<bool> TryGetLatestVersion()
50-
{
51-
#if DEBUG
52-
return true;
53-
#endif
54-
55-
var release = await m_appCenterService.GetLatestVersion();
56-
if (release != null)
57-
{
58-
var latestVersion = new Version(release.Version);
59-
var currentVersion = AppInfo.Version;
60-
if (currentVersion >= latestVersion)
22+
var samples = allSamples.Where(s => s.Type == sampleType).OrderBy(s => s.Name);
23+
var title = sampleType switch
6124
{
62-
return false;
63-
}
64-
65-
if (Current?.MainPage == null) return true;
66-
var wantToDownload = await Current.MainPage.DisplayAlert(LocalizedStrings.New_version,
67-
LocalizedStrings.New_version_message, LocalizedStrings.Download, LocalizedStrings.Cancel);
68-
if (!wantToDownload)
25+
SampleType.Resources => LocalizedStrings.Resources,
26+
SampleType.Components => LocalizedStrings.Components,
27+
SampleType.Accessibility => LocalizedStrings.Accessibility,
28+
_ => sampleType.ToString()
29+
};
30+
31+
var tab = new Tab
6932
{
70-
return false;
71-
}
72-
73-
await Launcher.OpenAsync(release.InstallUri);
74-
return true;
33+
Title = title,
34+
Items =
35+
{
36+
new ShellContent
37+
{
38+
ContentTemplate = new DataTemplate(() => new SamplesPage(sampleType, samples))
39+
}
40+
}
41+
};
42+
43+
tabBar.Items.Add(tab);
7544
}
45+
46+
shell.Items.Add(tabBar);
7647

77-
return false;
78-
}
79-
80-
protected override void OnResume()
81-
{
82-
_ = TryGetLatestVersion();
83-
base.OnResume();
84-
}
85-
86-
protected override void OnSleep()
87-
{
88-
base.OnSleep();
48+
return new Window(shell);
8949
}
9050
}

src/app/Components/Components.csproj

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net9.0-ios|AnyCPU'">
2929
<CreatePackage>false</CreatePackage>
30+
<CodesignKey>Apple Development</CodesignKey>
3031
<CodesignProvision>Automatic</CodesignProvision>
31-
<CodesignKey>iPhone Developer</CodesignKey>
3232
</PropertyGroup>
3333
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net9.0-ios|AnyCPU'">
3434
<CreatePackage>false</CreatePackage>
@@ -133,6 +133,10 @@
133133
<DependentUpon>BarcodeScanningSample.xaml</DependentUpon>
134134
<SubType>Code</SubType>
135135
</Compile>
136+
<Compile Update="AccessibilitySamples\VoiceOverSamples\VoiceOverSamples.xaml.cs">
137+
<DependentUpon>VoiceOverSamples.xaml</DependentUpon>
138+
<SubType>Code</SubType>
139+
</Compile>
136140
</ItemGroup>
137141

138142
<ItemGroup>
@@ -163,6 +167,13 @@
163167
<MauiXaml Update="ComponentsSamples\PhotoCapturing\PhotoCaptureSample.xaml">
164168
<SubType>Designer</SubType>
165169
</MauiXaml>
170+
<MauiXaml Update="AccessibilitySamples\VoiceOverSamples\VoiceOverSamples.xaml">
171+
<SubType>Designer</SubType>
172+
</MauiXaml>
173+
</ItemGroup>
174+
175+
<ItemGroup>
176+
<Folder Include="Services\" />
166177
</ItemGroup>
167178

168179

src/app/Components/MainPage.cs

Lines changed: 0 additions & 69 deletions
This file was deleted.

src/app/Components/REGISTER_YOUR_SAMPLES_HERE.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Components.AccessibilitySamples;
2+
using Components.AccessibilitySamples.VoiceOverSamples;
13
using Components.ComponentsSamples.Alerting;
24
using Components.ComponentsSamples.AmplitudeView;
35
using Components.ComponentsSamples.BarcodeScanning;
@@ -65,6 +67,7 @@ public static List<Sample> RegisterSamples()
6567
new(SampleType.Components, "Tag", () => new TagsSamples()),
6668
new(SampleType.Components, "Counters", () => new CountersSamples()),
6769
new(SampleType.Components, "TabView", () => new TabViewSamples()),
70+
new(SampleType.Accessibility, "VoiceOver/TalkBack", () => new VoiceOverSamples()),
6871

6972

7073

0 commit comments

Comments
 (0)