Skip to content
Merged
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
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,27 @@ jobs:
os: ubuntu-latest
project: samples/Sample.Avalonia.Browser
wasm: true
- name: FrontDialog (Ubuntu)
os: ubuntu-latest
project: samples/Sample.FrontDialog
- name: FrontDialog (Windows)
os: windows-latest
project: samples/Sample.FrontDialog
- name: FrontDialog (macOS)
os: macos-latest
project: samples/Sample.FrontDialog
- name: InfinityNavigation (Ubuntu)
os: ubuntu-latest
project: samples/Sample.InfinityNavigation
- name: InfinityNavigation (Windows)
os: windows-latest
project: samples/Sample.InfinityNavigation
- name: InfinityNavigation (macOS)
os: macos-latest
project: samples/Sample.InfinityNavigation
- name: WPF InfinityNavigation
os: windows-latest
project: samples/Sample.Wpf.InfinityNavigation

steps:
- uses: actions/checkout@v5
Expand Down
1 change: 0 additions & 1 deletion samples/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.6" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="2.3.1" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.28000.2526" />
<PackageVersion Include="Pipboy.Avalonia" Version="1.0.0" />
</ItemGroup>
</Project>
17 changes: 17 additions & 0 deletions samples/Sample.Avalonia/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
<Style Selector="Button.FloatView">
<Setter Property="Height" Value="30" />
<Setter Property="Width" Value="300" />
<Setter Property="IsVisible" Value="{ReflectionBinding !IsDialog}" />
<Setter Property="Command" Value="{ReflectionBinding FloatViewCommand}" />
<Setter Property="Content" Value="{ReflectionBinding FloatButtonText}"/>
<Setter Property="CommandParameter" Value="{ReflectionBinding $self.Tag}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
<Style Selector="Button.Navigation">
<Setter Property="Height" Value="30" />
<Setter Property="Width" Value="300" />
Expand All @@ -57,6 +67,13 @@
<Setter Property="CommandParameter" Value="{ReflectionBinding $self.Tag}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
<Style Selector="Button.RouterNavigation">
<Setter Property="Height" Value="30" />
<Setter Property="Width" Value="300" />
<Setter Property="Command" Value="{ReflectionBinding AsyncPathNavigateAndForgetCommand}" />
<Setter Property="CommandParameter" Value="{ReflectionBinding $self.Tag}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
<Style Selector="Button.DialogShow">
<Setter Property="Height" Value="30" />
<Setter Property="Width" Value="300" />
Expand Down
5 changes: 3 additions & 2 deletions samples/Sample.Avalonia/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public override void OnFrameworkInitializationCompleted()
services.AddNavigationSupport(navigationOptions)
.AddFloatingSupport()
.AddSingletonWithAllMembers<MainWindowViewModel>()
.RegisterNavigationInterceptor<SampleNavigationInterceptor>()
.RegisterView<LightView, LightViewModel>(nameof(LightView))
.RegisterView<ItemsRegionView, ItemsRegionViewModel>(nameof(ItemsRegionView))
.RegisterView<ChildContentRegionView, ChildContentRegionViewModel>(nameof(ChildContentRegionView))
Expand Down Expand Up @@ -75,15 +76,15 @@ public override void OnFrameworkInitializationCompleted()

if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow(sp.GetRequiredService<AsyncNavigation.Floating.IViewPlacementService>())
desktop.MainWindow = new MainWindow
{
DataContext = sp.GetRequiredService<MainWindowViewModel>()
};
desktop.ShutdownMode = ShutdownMode.OnMainWindowClose;
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
{
singleViewPlatform.MainView = new MainView(sp.GetRequiredService<AsyncNavigation.Floating.IViewPlacementService>())
singleViewPlatform.MainView = new MainView
{
DataContext = sp.GetRequiredService<MainWindowViewModel>()
};
Expand Down
7 changes: 2 additions & 5 deletions samples/Sample.Avalonia/Sample.Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
</ItemGroup>

<ItemGroup>
<Compile Update="Views\TabRegionViewModel.axaml.cs">
<DependentUpon>TabRegionViewModel.axaml</DependentUpon>
<Compile Update="Views\LightView.axaml.cs">
<DependentUpon>LightView.axaml</DependentUpon>
</Compile>
<Compile Update="Views\TabRegionView.axaml.cs">
<DependentUpon>TabRegionView.axaml</DependentUpon>
Expand All @@ -50,9 +50,6 @@
<Compile Update="Views\HeavyView.axaml.cs">
<DependentUpon>HeavyView.axaml</DependentUpon>
</Compile>
<Compile Update="Views\HeavyView.axaml.cs">
<DependentUpon>HeavyView.axaml</DependentUpon>
</Compile>
<Compile Update="Views\AWindow.axaml.cs">
<DependentUpon>AWindow.axaml</DependentUpon>
</Compile>
Expand Down
4 changes: 0 additions & 4 deletions samples/Sample.Avalonia/Views/ChildContentRegionView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
Classes="Navigation"
Content="ToHeavyView"
Tag="HeavyView" />
<Button
Padding="8,4"
Click="FloatChildRegion_Click"
Content="Floating: current ChildContentRegion view" />
</StackPanel>
<ContentControl an:RegionManager.RegionName="ChildContentRegion" />
</DockPanel>
Expand Down
33 changes: 1 addition & 32 deletions samples/Sample.Avalonia/Views/ChildContentRegionView.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,43 +1,12 @@
using AsyncNavigation.Abstractions;
using AsyncNavigation.Floating;
using Avalonia.Controls;
using Avalonia.Interactivity;
using System;
using System.Diagnostics;

namespace Sample.Avalonia.Views;

public partial class ChildContentRegionView : UserControl, IView
{
private readonly IViewPlacementService? _placementService;

public ChildContentRegionView() : this(null)
{
}

public ChildContentRegionView(IViewPlacementService? placementService)
public ChildContentRegionView()
{
_placementService = placementService;
InitializeComponent();
}

private async void FloatChildRegion_Click(object? sender, RoutedEventArgs e)
{
if (_placementService is null)
return;

try
{
await _placementService.FloatAsync("ChildContentRegion", options: new FloatingWindowOptions
{
Title = "AsyncNavigation floating ChildContentRegion",
Width = 720,
Height = 480
});
}
catch (Exception ex) when (ex is InvalidOperationException or NotSupportedException)
{
Debug.WriteLine($"Cannot float ChildContentRegion: {ex.Message}");
}
}
}
1 change: 1 addition & 0 deletions samples/Sample.Avalonia/Views/HeavyView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Text="{Binding InstanceNumber}" />
</TextBlock>
<Button Classes="UnloadView" />
<Button Classes="FloatView" />
<Button Classes="CloseDialog" />
<ItemsControl ItemsSource="{Binding HeavyItems}">
<ItemsControl.ItemTemplate>
Expand Down
4 changes: 0 additions & 4 deletions samples/Sample.Avalonia/Views/ItemsRegionView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
Classes="NavigationAndForget"
Content="ToLightView:Forget"
Tag="LightView" />
<Button
Padding="8,4"
Click="FloatSelectedItem_Click"
Content="Floating: selected ItemsRegion view" />
</StackPanel>
<ScrollViewer>
<ItemsControl an:RegionManager.RegionName="ItemsRegion">
Expand Down
34 changes: 2 additions & 32 deletions samples/Sample.Avalonia/Views/ItemsRegionView.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,42 +1,12 @@
using AsyncNavigation.Abstractions;
using AsyncNavigation.Floating;
using AsyncNavigation.Abstractions;
using Avalonia.Controls;
using Avalonia.Interactivity;
using System;
using System.Diagnostics;

namespace Sample.Avalonia.Views;

public partial class ItemsRegionView : UserControl, IView
{
private readonly IViewPlacementService? _placementService;

public ItemsRegionView() : this(null)
{
}

public ItemsRegionView(IViewPlacementService? placementService)
public ItemsRegionView()
{
_placementService = placementService;
InitializeComponent();
}
private async void FloatSelectedItem_Click(object? sender, RoutedEventArgs e)
{
if (_placementService is null)
return;

try
{
await _placementService.FloatAsync("ItemsRegion", options: new FloatingWindowOptions
{
Title = "AsyncNavigation floating ItemsRegion item",
Width = 720,
Height = 480
});
}
catch (Exception ex) when (ex is InvalidOperationException or NotSupportedException)
{
Debug.WriteLine($"Cannot float ItemsRegion: {ex.Message}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@
Text="{Binding InstanceNumber}" />
</TextBlock>
<Button Classes="UnloadView" />
<Button Classes="FloatView" />
<Button Classes="CloseDialog" />
<Button Classes="CloseDialogWithCancelling" />
<CheckBox
Margin="4"
Content="Block leaving (INavigationGuard)"
IsChecked="{Binding PreventLeave}" />
</StackPanel>
</Border>
</DockPanel>
Expand Down
4 changes: 0 additions & 4 deletions samples/Sample.Avalonia/Views/ListBoxRegionView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
Classes="Navigation"
Content="ToHeavyView"
Tag="HeavyView" />
<Button
Padding="8,4"
Click="FloatSelectedItem_Click"
Content="Floating: selected CustomListBoxRegion view" />
</StackPanel>
<ListBox an:RegionManager.RegionName="CustomListBoxRegion" />
</DockPanel>
Expand Down
33 changes: 1 addition & 32 deletions samples/Sample.Avalonia/Views/ListBoxRegionView.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,43 +1,12 @@
using AsyncNavigation.Abstractions;
using AsyncNavigation.Floating;
using Avalonia.Controls;
using Avalonia.Interactivity;
using System;
using System.Diagnostics;

namespace Sample.Avalonia.Views;

public partial class ListBoxRegionView : UserControl, IView
{
private readonly IViewPlacementService? _placementService;

public ListBoxRegionView() : this(null)
{
}

public ListBoxRegionView(IViewPlacementService? placementService)
public ListBoxRegionView()
{
_placementService = placementService;
InitializeComponent();
}

private async void FloatSelectedItem_Click(object? sender, RoutedEventArgs e)
{
if (_placementService is null)
return;

try
{
await _placementService.FloatAsync("CustomListBoxRegion", options: new FloatingWindowOptions
{
Title = "AsyncNavigation floating CustomListBoxRegion item",
Width = 720,
Height = 480
});
}
catch (Exception ex) when (ex is InvalidOperationException or NotSupportedException)
{
Debug.WriteLine($"Cannot float CustomListBoxRegion: {ex.Message}");
}
}
}
25 changes: 16 additions & 9 deletions samples/Sample.Avalonia/Views/MainView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,9 @@
d:DesignWidth="800"
x:DataType="vm:MainWindowViewModel"
mc:Ignorable="d">
<Grid RowDefinitions="Auto,*,30">
<Border Grid.Row="0" Padding="8">
<StackPanel Orientation="Horizontal" Spacing="8">
<Button Click="FloatMainRegion_Click" Content="Floating: current MainRegion view" />
<TextBlock VerticalAlignment="Center" Text="The same UserControl instance moves to the window; use Dock to region to return it. Closing closes the view." />
</StackPanel>
</Border>
<Grid RowDefinitions="*,30">
<SplitView
Grid.Row="1"
Grid.Row="0"
DisplayMode="CompactInline"
IsPaneOpen="{Binding IsSplitViewPaneOpen}"
OpenPaneLength="310"
Expand Down Expand Up @@ -126,6 +120,19 @@
Classes="WindowShow"
Content="ToLightView:Window.Show"
Tag="AWindow" />
<Separator Margin="4" />
<Button
Classes="RouterNavigation"
Content="Router: Path_ChildHeavyView"
Tag="Path_ChildHeavyView" />
<Button
Classes="RouterNavigation"
Content="Router: Tab/Tab_A (segments)"
Tag="/Tab/Tab_A" />
<Button
Classes="RouterNavigation"
Content="Router: unknown path (fallback)"
Tag="Path_UnknownView" />
<Button
Command="{Binding CollectCommand}"
Content="Collect"
Expand All @@ -140,7 +147,7 @@
</SplitView>
<SelectableTextBlock
Name="footer"
Grid.Row="2"
Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
Expand Down
Loading
Loading