* Create SemanticsPage

* Add SemanticsPage

* Dedup csproj compile line

* - add nullability test

* - fix bit operator and add tests

* - fix vsmac builds

* - fix test

* Update Startup.cs

* Update Maui.Controls.Sample.WinUI (Package).wapproj

Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
This commit is contained in:
Rachel Kang 2021-04-08 20:49:47 -04:00 коммит произвёл GitHub
Родитель 9df7b78218
Коммит 8997cd2805
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 252 добавлений и 9 удалений

Просмотреть файл

@ -938,7 +938,7 @@ Task("VSMAC")
.Does(() =>
{
MSBuild("src/Core/src.Core.csproj",
MSBuild("src/Core/src/Core.csproj",
GetMSBuildSettings()
.WithRestore());
@ -946,14 +946,15 @@ Task("VSMAC")
GetMSBuildSettings()
.WithRestore());
MSBuild("src/Controls/samples/Controls.Sample.iOS/Controls.Sample.iOS.csproj",
new MSBuildSettings().WithRestore());
MSBuild("src/Essentials/src/Essentials.csproj",
GetMSBuildSettings()
.WithProperty("iOSPlatform", "iPhoneSimulator")
.WithRestore());
MSBuild("src/Essentials/src/Essentials/Essentials.csproj",
GetMSBuildSettings()
.WithRestore());
MSBuild("src/SingleProject/Resizetizer/src/Resizetizer.csproj", GetMSBuildSettings().WithRestore());
StartVisualStudio();
});

Просмотреть файл

@ -3,6 +3,9 @@
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<PropertyGroup>
<SkipImportNetSdk>true</SkipImportNetSdk>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>

Просмотреть файл

@ -30,6 +30,12 @@
<MauiFont Include="Resources\Fonts\*" />
</ItemGroup>
<ItemGroup>
<Compile Update="Pages\SemanticsPage.xaml.cs">
<DependentUpon>SemanticsPage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<Import Project="..\..\..\..\.nuspec\Microsoft.Maui.Controls.MultiTargeting.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,181 @@
<controls:BasePage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:Maui.Controls.Sample.Controls"
x:Class="Maui.Controls.Sample.Pages.SemanticsPage">
<ScrollView Margin="15,20">
<VerticalStackLayout>
<Label
Text="Welcome to .NET MAUI Semantics!"
TextColor="DodgerBlue"
FontSize="30"
HorizontalTextAlignment="Center"/>
<Label
Text="We hope the all-new SemanticProperties will enable you to develop accessible apps more seamlessly"
TextColor="DodgerBlue"
FontSize="20"
HorizontalTextAlignment="Center"/>
<Label
Text="Turn on your screen reader and listen for what is read aloud. The text-based controls below are labeled to indicate what is expected to be read aloud: T refers to the Text, D is the Description text, and H is the Hint text."
TextColor="RoyalBlue"
FontAttributes="Bold"
FontSize="16"
Margin="0,10"/>
<Label
Text="Label text TH"
FontSize="14"
SemanticProperties.Hint="Hint text"/>
<Label
Text="Label text DH"
FontSize="14"
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<Button
Text="Button text TH"
FontSize="14"
HorizontalOptions="Center"
WidthRequest="200"
SemanticProperties.Hint="Hint text"/>
<Button
Text="Button text DH"
FontSize="14"
HorizontalOptions="CenterAndExpand"
WidthRequest="200"
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<Entry
Text="Entry text TH"
FontSize="14"
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<Entry
FontSize="14"
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<Editor
Text="Editor text TH"
FontSize="14"
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<Editor
FontSize="14"
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<SearchBar
Text="Search bar text"
Placeholder="Placeholder text"
PlaceholderColor="DodgerBlue"
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<Picker
Title="Select a monkey TH"
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text">
<Picker.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Baboon</x:String>
<x:String>Capuchin Monkey</x:String>
<x:String>Blue Monkey</x:String>
<x:String>Squirrel Monkey</x:String>
<x:String>Golden Lion Tamarin</x:String>
<x:String>Howler Monkey</x:String>
<x:String>Japanese Macaque</x:String>
</x:Array>
</Picker.ItemsSource>
</Picker>
<DatePicker
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<TimePicker
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<ActivityIndicator
IsRunning="True"
Color="DodgerBlue"
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<ProgressBar
Progress="0.5"
ProgressColor="DodgerBlue"
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<Slider
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<Stepper
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<Switch
IsToggled="True"
OnColor="DodgerBlue"
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<CheckBox
IsChecked="True"
Color="DodgerBlue"
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<Image
Source="dotnet_bot.png"
SemanticProperties.Description="Description text"
SemanticProperties.Hint="Hint text"/>
<Label
Text="This next set of controls exist solely for testing the HeadingLevel property. If testing on mobile, be sure to activate Headings and swipe up/down with one finger to test."
TextColor="RoyalBlue"
FontAttributes="Bold"
FontSize="16"
Margin="0,10"/>
<Label
Text="Heading 1"
TextColor="DodgerBlue"
FontSize="20"
SemanticProperties.HeadingLevel="Level1"/>
<Label
Text="not a heading"/>
<Label
Text="Heading 2"
TextColor="DodgerBlue"
FontSize="16"
SemanticProperties.HeadingLevel="Level2"/>
<Label
Text="not a heading"/>
<Label
Text="not a heading"/>
<Label
Text="Heading 3"
TextColor="DodgerBlue"
FontSize="14"
SemanticProperties.HeadingLevel="Level3"/>
</VerticalStackLayout>
</ScrollView>
</controls:BasePage>

Просмотреть файл

@ -0,0 +1,14 @@
using Maui.Controls.Sample.Controls;
using Microsoft.Maui.Controls.Xaml;
namespace Maui.Controls.Sample.Pages
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SemanticsPage : BasePage
{
public SemanticsPage()
{
InitializeComponent();
}
}
}

Просмотреть файл

@ -17,6 +17,7 @@ namespace Maui.Controls.Sample
{
public class Startup : IStartup
{
public readonly static bool UseSemanticsPage = false;
public readonly static bool UseXamlPage = false;
public readonly static bool UseXamlApp = true;
@ -57,6 +58,8 @@ namespace Maui.Controls.Sample
if (UseXamlPage)
services.AddTransient<IPage, XamlPage>();
else if (UseSemanticsPage)
services.AddTransient<IPage, SemanticsPage>();
else
services.AddTransient<IPage, MainPage>();

Просмотреть файл

@ -42,7 +42,7 @@ namespace Microsoft.Maui
if (semantics.IsHeading)
nativeView.AccessibilityTraits |= UIAccessibilityTrait.Header;
else
nativeView.AccessibilityTraits |= ~UIAccessibilityTrait.Header;
nativeView.AccessibilityTraits &= ~UIAccessibilityTrait.Header;
}
public static T? FindDescendantView<T>(this UIView view) where T : UIView

Просмотреть файл

@ -79,6 +79,30 @@ namespace Microsoft.Maui.DeviceTests
Assert.Equal(20, insets.Bottom);
}
[Fact(DisplayName = "Default Accessibility Traits Don't Change")]
[InlineData()]
public async Task ValidateDefaultAccessibilityTraits()
{
var view = new ButtonStub();
var trait = await GetValueAsync((IView)view,
handler =>
{
// Accessibility Traits don't initialize until after
// a UIView is added to the visual hierarchy so we are just
// initializing here and then validating that the value doesn't get cleared
handler.NativeView.AccessibilityTraits = UIAccessibilityTrait.Button;
view.Semantics.Hint = "Test Hint";
view.Handler.UpdateValue("Semantics");
return handler.NativeView.AccessibilityTraits;
});
Assert.Equal(UIAccessibilityTrait.Button, trait);
}
UIButton GetNativeButton(ButtonHandler buttonHandler) =>
(UIButton)buttonHandler.NativeView;

Просмотреть файл

@ -50,5 +50,16 @@ namespace Microsoft.Maui.DeviceTests
var id = await GetValueAsync((IView)view, handler => GetSemanticHeading(handler));
Assert.Equal(view.Semantics.HeadingLevel, id);
}
[Fact(DisplayName = "Null Semantics Doesnt throw exception")]
[InlineData()]
public async Task NullSemanticsClass()
{
var view = new TStub();
view.Semantics = null;
view.AutomationId = "CreationFailed";
var id = await GetValueAsync((IView)view, handler => GetAutomationId(handler));
Assert.Equal(view.AutomationId, id);
}
}
}