Skip to content

Commit

Permalink
feat: Add CommandBar SamplePage
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpinedam committed Feb 21, 2021
1 parent 3aa7144 commit 266ebc5
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Expand Up @@ -3921,6 +3921,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CommandBar\CustomContent\CommandBar_Frame.xaml" >
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CommandBar\CustomContent\CommandBar_Page1.xaml" >
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Helpers\BindableBase.cs" />
Expand Down Expand Up @@ -4587,6 +4595,12 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\BitmapIconTests\BitmapIcon_Generic.xaml.cs">
<DependentUpon>BitmapIcon_Generic.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CommandBar\CustomContent\CommandBar_Frame.xaml.cs" >
<DependentUpon>CommandBar_Frame.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CommandBar\CustomContent\CommandBar_Page1.xaml.cs" >
<DependentUpon>CommandBar_Page1.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CommandBar\Native_Frame\Page_Detail.xaml.cs">
<DependentUpon>Page_Detail.xaml</DependentUpon>
</Compile>
Expand Down
@@ -0,0 +1,25 @@
<UserControl x:Class="UITests.Windows_UI_Xaml_Controls.CommandBar.CustomContent.CommandBar_Frame"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xamarin="http://uno.ui/xamarin"
mc:Ignorable="d xamarin"
d:DesignHeight="300"
d:DesignWidth="400">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<Frame x:Name="HostFrame"
xamarin:Style="{StaticResource NativeDefaultFrame}" />

<Button x:Name="NavigateInitialButton"
Grid.Row="1"
Content="Navigate to main page"
Click="Navigate_Initial" />
</Grid>
</UserControl>
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using UITests.Windows_UI_Xaml_Controls.CommandBar.Native_Frame;
using Uno.UI.Samples.Controls;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236

namespace UITests.Windows_UI_Xaml_Controls.CommandBar.CustomContent
{
[SampleControlInfo("CommandBar", "CommandBar_CustomContent")]
public sealed partial class CommandBar_Frame : UserControl
{
public CommandBar_Frame()
{
this.InitializeComponent();
}

private void Navigate_Initial(object sender, RoutedEventArgs args)
{
HostFrame.Navigate(typeof(CommandBar_Page1));
}
}
}
@@ -0,0 +1,52 @@
<Page
x:Class="UITests.Windows_UI_Xaml_Controls.CommandBar.CustomContent.CommandBar_Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xamarin="http://uno.ui/xamarin"
mc:Ignorable="d xamarin"
d:DesignHeight="300"
d:DesignWidth="400">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<CommandBar x:Name="Page1CommandBar">
<CommandBar.Content>
<Border VerticalAlignment="Center"
Height="44"
HorizontalAlignment="Center">
<TextBlock Text="Header with custom Content"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap"
Foreground="Blue" />
</Border>
</CommandBar.Content>
</CommandBar>

<StackPanel Grid.Row="1"
Spacing="10"
VerticalAlignment="Center">

<TextBlock Text="Main Page"
HorizontalAlignment="Center" />

<TextBlock Text="-1"
x:Name="ExpectedSize"
HorizontalAlignment="Center" />

<TextBlock Text="-1"
x:Name="CurrentSize"
HorizontalAlignment="Center" />

<TextBlock Text="-1"
x:Name="Result"
HorizontalAlignment="Center" />
</StackPanel>

</Grid>
</Page>
@@ -0,0 +1,54 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Windows.UI;
using Uno.UI.Samples.Controls;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;

#if __IOS__
using UIKit;
using Uno.UI.Controls;
#endif

// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236

namespace UITests.Windows_UI_Xaml_Controls.CommandBar.CustomContent
{
public sealed partial class CommandBar_Page1 : Page
{
public CommandBar_Page1()
{
this.InitializeComponent();
this.Loaded += OnLoaded;
}

private void OnLoaded(object sender, RoutedEventArgs e)
{
#if __IOS__
UIView parent = this;
while (parent.HasParent())
{
parent = parent.Superview;
}

var titleViewChild = parent.FindFirstChild<TitleView>()?.Child;

var height = titleViewChild?.Frame.Height ?? 0;
var width = titleViewChild?.Frame.Width ?? 0;

var expectedHeight = titleViewChild?.DesiredSize.Height ?? 0;
var expectedWidth = titleViewChild?.DesiredSize.Width ?? 0;

ExpectedSize.Text = $"Title Content desired size: ({expectedWidth}x{expectedHeight})";
CurrentSize.Text = $"Title Content current size: ({width}x{height})";

Result.Text =
(height > 0 || height <= 0 && expectedHeight <= 0) && (width > 0 || width <= 0 && expectedWidth <= 0)
? "PASSED"
: "FAILED";
#endif
}
}
}

0 comments on commit 266ebc5

Please sign in to comment.