forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Handle Animations precedence as in WinUI
- Loading branch information
1 parent
38924fc
commit 00c6bfe
Showing
7 changed files
with
202 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...SamplesApp/UITests.Shared/Windows_UI_Xaml/VisualStateTests/VisualState_LocalOverride.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<Page | ||
x:Class="UITests.Windows_UI_Xaml.VisualStateTests.VisualState_LocalOverride" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:UITests.Windows_UI_Xaml.VisualStateTests" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
||
<Grid> | ||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup> | ||
<VisualState x:Name="Large"> | ||
<VisualState.StateTriggers> | ||
<AdaptiveTrigger MinWindowWidth="10" /> | ||
</VisualState.StateTriggers> | ||
<VisualState.Setters> | ||
<Setter Target="RootGrid.Background" Value="#FF0000" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
<Grid x:Name="RootGrid" Background="#00FF00"> | ||
<Button | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
x:Name="SetColorButton" | ||
Click="SetColorButton_Click" | ||
Content="Set color" /> | ||
</Grid> | ||
</Grid> | ||
</Page> |
22 changes: 22 additions & 0 deletions
22
...plesApp/UITests.Shared/Windows_UI_Xaml/VisualStateTests/VisualState_LocalOverride.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Microsoft.UI; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Media; | ||
using Uno.UI.Samples.Controls; | ||
using Windows.UI; | ||
|
||
namespace UITests.Windows_UI_Xaml.VisualStateTests; | ||
|
||
[Sample("Visual states", Description = "Background should start off as red, but turn blue after the button is clicked.", IsManualTest = true)] | ||
public sealed partial class VisualState_LocalOverride : Page | ||
{ | ||
public VisualState_LocalOverride() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
private void SetColorButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
RootGrid.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 255)); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...sApp/UITests.Shared/Windows_UI_Xaml/VisualStateTests/VisualState_ReturnPreviousValue.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<Page | ||
x:Class="UITests.Windows_UI_Xaml.VisualStateTests.VisualState_ReturnPreviousValue" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:UITests.Windows_UI_Xaml.VisualStateTests" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
||
<Grid> | ||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup> | ||
<VisualState x:Name="DefaultState" /> | ||
<VisualState x:Name="SecondState"> | ||
<VisualState.Setters> | ||
<Setter Target="RootGrid.Background" Value="Red" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
<VisualState x:Name="ThirdState"> | ||
<VisualState.Setters> | ||
<Setter Target="RootGrid.Background" Value="Blue" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
<Grid x:Name="RootGrid" Background="Green"> | ||
<StackPanel Orientation="Vertical"> | ||
<Button x:Name="ChangeBackgroundButton" Click="ChangeBackground_Click">Change background (white)</Button> | ||
<Button x:Name="DefaultStateButton" Tag="DefaultState" Click="SetState_Click">Set default state (Green)</Button> | ||
<Button x:Name="SecondStateButton" Tag="SecondState" Click="SetState_Click">Set second state (Red)</Button> | ||
<Button x:Name="ThirdStateButton" Tag="ThirdState" Click="SetState_Click">Set third state (Blue)</Button> | ||
</StackPanel> | ||
</Grid> | ||
</Grid> | ||
</Page> |
72 changes: 72 additions & 0 deletions
72
...p/UITests.Shared/Windows_UI_Xaml/VisualStateTests/VisualState_ReturnPreviousValue.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.UI; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Media; | ||
using Uno.UI.Samples.Controls; | ||
using Windows.UI; | ||
|
||
namespace UITests.Windows_UI_Xaml.VisualStateTests; | ||
|
||
[Sample( | ||
"Visual states", | ||
Description = "Background should start off as green, but turn to different color depending on button, keeping in mind that once changed to white, you shouldn't be able to get it green again", | ||
IsManualTest = true)] | ||
public sealed partial class VisualState_ReturnPreviousValue : Page | ||
{ | ||
private bool _wasWhiteSet; | ||
|
||
public VisualState_ReturnPreviousValue() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
private async void SetState_Click(object sender, RoutedEventArgs e) | ||
{ | ||
var button = (Button)sender; | ||
var tag = button.Tag.ToString(); | ||
VisualStateManager.GoToState(this, tag, true); | ||
|
||
if (tag == "DefaultState") | ||
{ | ||
if (_wasWhiteSet && ((SolidColorBrush)RootGrid.Background).Color != Microsoft.UI.Colors.White) | ||
{ | ||
await ErrorAsync("Background is expected to be white."); | ||
} | ||
else if (!_wasWhiteSet && ((SolidColorBrush)RootGrid.Background).Color != Microsoft.UI.Colors.Green) | ||
{ | ||
await ErrorAsync("Background is expected to be green."); | ||
} | ||
} | ||
else if (tag == "SecondState" && ((SolidColorBrush)RootGrid.Background).Color != Microsoft.UI.Colors.Red) | ||
{ | ||
await ErrorAsync("Background is expected to be red."); | ||
} | ||
else if (tag == "ThirdState" && ((SolidColorBrush)RootGrid.Background).Color != Microsoft.UI.Colors.Blue) | ||
{ | ||
await ErrorAsync("Background is expected to be blue."); | ||
} | ||
} | ||
|
||
private async Task ErrorAsync(string text) | ||
{ | ||
var dialog = new ContentDialog() | ||
{ | ||
XamlRoot = this.XamlRoot, | ||
Content = text, | ||
}; | ||
|
||
await dialog.ShowAsync(); | ||
} | ||
|
||
private async void ChangeBackground_Click(object sender, RoutedEventArgs e) | ||
{ | ||
RootGrid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)); | ||
_wasWhiteSet = true; | ||
if (((SolidColorBrush)RootGrid.Background).Color != Microsoft.UI.Colors.White) | ||
{ | ||
await ErrorAsync("Background is expected to be white."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters