Skip to content
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

WIP: DockControl #1352

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ csharp_space_around_binary_operators=before_and_after
csharp_preserve_single_line_blocks=true
csharp_preserve_single_line_statements=true

dotnet_diagnostic.CA1848.severity = none
dotnet_diagnostic.CS0162.severity = none; CS0162: Unreachable code detected
dotnet_diagnostic.CS0169.severity = none; CS0169: The field '{0}' is never used
dotnet_diagnostic.CS0414.severity = none; CS0414: The field '{0}' is assigned but its value is never used
dotnet_diagnostic.CS8321.severity = none; CS8321: The local function '{0}' is declared but never used
dotnet_diagnostic.CA1822.severity = none; CA1822: Mark members as static
dotnet_diagnostic.CA1823.severity = none; CA1823: Unused field '{0}'
dotnet_diagnostic.CA1848.severity = none; CA1848: Use the LoggerMessage delegates
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,16 @@ private Shell BuildShell()
AddNavigationItems(nv);

// landing navigation
ShellNavigateTo<NavigationBarSamplePage>(
#if WINDOWS_UWP
// note: on uwp, NavigationView.SelectedItem MUST be set on launch to avoid entering compact-mode
trySynchronizeCurrentItem: true
#else
// workaround for uno#5069: setting NavView.SelectedItem at launch bricks it
trySynchronizeCurrentItem: false
#endif
);
// ShellNavigateTo<NavigationBarSamplePage>(
//#if WINDOWS_UWP
// // note: on uwp, NavigationView.SelectedItem MUST be set on launch to avoid entering compact-mode
// trySynchronizeCurrentItem: true
//#else
// // workaround for uno#5069: setting NavView.SelectedItem at launch bricks it
// trySynchronizeCurrentItem: false
//#endif
// );
_shell.NavigationView.Content = new DockControl_NestedPage();

// navigation + setting handler
nv.ItemInvoked += OnNavigationItemInvoked;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Page x:Class="Uno.Toolkit.Samples.Content.Controls.DockControlSamplePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Uno.Toolkit.Samples.Content.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sample="using:Uno.Toolkit.Samples"
xmlns:utu="using:Uno.Toolkit.UI"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">


<Grid Background="{ThemeResource SurfaceBrush}">
<sample:SamplePageLayout x:Name="SamplePageLayout" IsDesignAgnostic="True">
<sample:SamplePageLayout.DesignAgnosticTemplate>
<DataTemplate>
<Grid Height="500">
<utu:DockControl />
</Grid>
</DataTemplate>
</sample:SamplePageLayout.DesignAgnosticTemplate>
</sample:SamplePageLayout>
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Uno.Toolkit.Samples.Entities;
using Uno.Toolkit.UI;

#if IS_WINUI
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
#else
using Windows.UI;
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;
#endif

namespace Uno.Toolkit.Samples.Content.Controls;

[SamplePage(SampleCategory.Controls, nameof(DockControl))]
public sealed partial class DockControlSamplePage : Page
{
public DockControlSamplePage()
{
this.InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Page x:Class="Uno.Toolkit.Samples.Content.NestedSamples.DockControl_NestedPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Uno.Toolkit.Samples.Content.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sample="using:Uno.Toolkit.Samples"
xmlns:utu="using:Uno.Toolkit.UI"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
<utu:DockControl x:Name="SUT" />

<StackPanel HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="50" Background="Pink">
<Button Content="AddDocument" Click="AddDocument" />
<Button Content="AddTool" Click="AddTool" />
</StackPanel>
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Uno.Toolkit.Samples.Entities;
using Uno.Toolkit.UI;

#if IS_WINUI
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
#else
using Windows.UI;
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;
#endif

namespace Uno.Toolkit.Samples.Content.NestedSamples;

public sealed partial class DockControl_NestedPage : Page
{
private int _itemCounter = 0;
public DockControl_NestedPage()
{
this.InitializeComponent();
}

private void AddDocument(object sender, RoutedEventArgs e)
{
_itemCounter++;

SUT.AddItem(new DocumentItem
{
Header = $"Document {_itemCounter}.txt",
Title = $"title: Document {_itemCounter}.txt", // should be unused
Content = $"contnet: asdasd {_itemCounter}",
});
}

private void AddTool(object sender, RoutedEventArgs e)
{
_itemCounter++;

SUT.AddItem(new ToolItem
{
Header = $"Tool {_itemCounter}",
Title = $"title: Tool Window {_itemCounter}",
Content = $"content: Tool {_itemCounter}",
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
using Uno.Toolkit.Samples.Content.NestedSamples;
using Uno.Toolkit.Samples.Helpers;
using Uno.Toolkit.UI;
using System.Collections;
using System.Collections.Generic;

#if __IOS__
using Foundation;
#endif

#if IS_WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
Expand Down Expand Up @@ -247,11 +248,13 @@ object FindViewOfInterest()
var target = FindViewOfInterest();
var targetTree = (target as DependencyObject)?.TreeGraph();

var dcLogicalTree = (target as DependencyObject)?.GetFirstDescendant<DockControl>()?.LogicalTreeGraph();

// note: you can also tag element with unique x:Name to inspect here
//var sut = this.GetFirstDescendant<Chip>(x => x.Name == "SUT");
//var tree = sut?.TreeGraph();

#if WINDOWS || WINDOWS_UWP
#if WINDOWS || WINDOWS_UWP || HAS_UNO_SKIA
var data = new DataPackage();
data.SetText(targetTree ?? tree);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)App.xaml.Navigation.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Content\Controls\DockControlSamplePage.xaml.cs">
<DependentUpon>DockControlSamplePage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Content\Controls\ItemsRepeaterExtensionsIncrementalLoadingSamplePage.xaml.cs">
<DependentUpon>ItemsRepeaterExtensionsIncrementalLoadingSamplePage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -83,6 +86,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Content\Helpers\ResponsiveExtensionsSamplePage.xaml.cs">
<DependentUpon>ResponsiveExtensionsSamplePage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Content\NestedSamples\DockControl_NestedPage.xaml.cs">
<DependentUpon>DockControl_NestedPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Content\NestedSamples\FluentNavigationBarSampleNestedPage1.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Content\NestedSamples\FluentNavigationBarSampleNestedPage2.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Content\NestedSamples\FluentNavigationBarSampleNestedPage3.xaml.cs">
Expand Down Expand Up @@ -239,6 +245,10 @@
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\en\Resources.resw" />
</ItemGroup>
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)Content\Controls\DockControlSamplePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Content\Controls\ItemsRepeaterExtensionsIncrementalLoadingSamplePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -339,6 +349,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Content\NestedSamples\DockControl_NestedPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Content\NestedSamples\FluentNavigationBarSampleNestedPage1.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
Loading
Loading