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

v1.3.0 #67

Merged
merged 7 commits into from
Dec 21, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: .NET
name: CI

on:
push:
branches: [ "main" ]
branches: [ "main", "develop" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "develop" ]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ We welcome feedback, suggestions, and contributions from anyone who is intereste
To use AvaloniaInside.Shell in your Avalonia project, you can install the package via NuGet using the following command in the Package Manager Console:

```bash
dotnet add package AvaloniaInside.Shell --version 1.2.0
dotnet add package AvaloniaInside.Shell --version 1.3.0
```

Alternatively, you can also install the package through Visual Studio's NuGet Package Manager.
Expand Down
4 changes: 2 additions & 2 deletions src/AvaloniaInside.Shell/AppBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace AvaloniaInside.Shell;
public static class AppBuilderExtensions
{
public static AppBuilder UseShell(this AppBuilder builder, Func<INavigationViewLocator>? viewLocatorFactory = null) =>
builder.AfterPlatformServicesSetup(_ =>
builder.AfterPlatformServicesSetup(_ => Locator.RegisterResolverCallbackChanged(() =>
{
if (Locator.CurrentMutable is null)
{
Expand Down Expand Up @@ -37,7 +37,7 @@ public static AppBuilder UseShell(this AppBuilder builder, Func<INavigationViewL
viewLocator
);
});
});
}));

public static AppBuilder UseShell(this AppBuilder builder, Func<NavigationNode, object> viewFactory)
=> builder.UseShell(() => new DelegateNavigationViewLocator(viewFactory));
Expand Down
4 changes: 2 additions & 2 deletions src/AvaloniaInside.Shell/AvaloniaInside.Shell.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<Version>1.2.0</Version>
<Version>1.3.0</Version>
<Title>Shell view for Avalonia</Title>
<Description>Shell reduces the complexity of mobile/desktop application development by providing the fundamental features that most applications require</Description>
<Copyright>AvaloniaInside</Copyright>
Expand All @@ -19,14 +19,14 @@
</PropertyGroup>
<ItemGroup>
<AvaloniaResource Include="Assets\**" />
<AvaloniaResource Include="**\*.axaml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Include="XamlNameReferenceGenerator" Version="1.3.4" />
</ItemGroup>
<ItemGroup>
<UpToDateCheckInput Remove="Assets\avalonia-logo.ico" />
Expand Down
103 changes: 51 additions & 52 deletions src/AvaloniaInside.Shell/BindingNavigate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,64 @@
using System.Threading.Tasks;
using System.Windows.Input;

namespace AvaloniaInside.Shell
namespace AvaloniaInside.Shell;

[TypeConverter(typeof(BindingNavigateConverter))]
public class BindingNavigate : AvaloniaObject, ICommand
{
[TypeConverter(typeof(BindingNavigateConverter))]
public class BindingNavigate : AvaloniaObject, ICommand
{
private bool _singletonCanExecute = true;
private EventHandler? _singletonCanExecuteChanged;
private bool _singletonCanExecute = true;
private EventHandler? _singletonCanExecuteChanged;

public AvaloniaObject? Sender { get; internal set; }
public string Path { get; set; }
public NavigateType? Type { get; set; }
public IPageTransition? Transition { get; set; }
public AvaloniaObject? Sender { get; internal set; }
public string Path { get; set; }

Check warning on line 19 in src/AvaloniaInside.Shell/BindingNavigate.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Path' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 19 in src/AvaloniaInside.Shell/BindingNavigate.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Path' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public NavigateType? Type { get; set; }
public IPageTransition? Transition { get; set; }

public event EventHandler? CanExecuteChanged
{
add => _singletonCanExecuteChanged += value;
remove => _singletonCanExecuteChanged -= value;
}
public event EventHandler? CanExecuteChanged
{
add => _singletonCanExecuteChanged += value;
remove => _singletonCanExecuteChanged -= value;
}

public bool CanExecute(object? parameter) => _singletonCanExecute;
public void Execute(object? parameter) => ExecuteAsync(parameter, CancellationToken.None);
public bool CanExecute(object? parameter) => _singletonCanExecute;
public void Execute(object? parameter) => ExecuteAsync(parameter, CancellationToken.None);

Check warning on line 30 in src/AvaloniaInside.Shell/BindingNavigate.cs

View workflow job for this annotation

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 30 in src/AvaloniaInside.Shell/BindingNavigate.cs

View workflow job for this annotation

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

public async Task ExecuteAsync(object? parameter, CancellationToken cancellationToken)
{
if (Sender is not Visual visual) return;
if (visual.FindAncestorOfType<ShellView>() is not { } shell) return;
public async Task ExecuteAsync(object? parameter, CancellationToken cancellationToken)
{
if (Sender is not Visual visual) return;
if (visual.FindAncestorOfType<ShellView>() is not { } shell) return;

_singletonCanExecute = false;
_singletonCanExecuteChanged?.Invoke(this, EventArgs.Empty);
try
{
if (parameter != null)
await shell.Navigator.NavigateAsync(
Path,
Type,
parameter,
Sender,
true,
Transition,
cancellationToken);
else
await shell.Navigator.NavigateAsync(
Path,
Type,
Sender,
true,
Transition,
cancellationToken);
}
finally
{
_singletonCanExecute = true;
_singletonCanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
_singletonCanExecute = false;
_singletonCanExecuteChanged?.Invoke(this, EventArgs.Empty);
try
{
if (parameter != null)
await shell.Navigator.NavigateAsync(
Path,
Type,
parameter,
Sender,
true,
Transition,
cancellationToken);
else
await shell.Navigator.NavigateAsync(
Path,
Type,
Sender,
true,
Transition,
cancellationToken);
}

public static implicit operator BindingNavigate(string path) => new BindingNavigate
finally
{
Path = path
};
_singletonCanExecute = true;
_singletonCanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
}

public static implicit operator BindingNavigate(string path) => new BindingNavigate
{
Path = path
};
}
3 changes: 1 addition & 2 deletions src/AvaloniaInside.Shell/BindingNavigateConverter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Avalonia.Media;
using System;
using System;
using System.ComponentModel;
using System.Globalization;

Expand Down
189 changes: 4 additions & 185 deletions src/AvaloniaInside.Shell/Default.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,192 +3,11 @@

<Styles.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key='Light'>
<SolidColorBrush x:Key='AppBackground' Color="{OnPlatform White, iOS=Black}"></SolidColorBrush>
<SolidColorBrush x:Key='PageBackground'>White</SolidColorBrush>
</ResourceDictionary>
<ResourceDictionary x:Key='Dark'>
<SolidColorBrush x:Key='AppBackground'>Black</SolidColorBrush>
<SolidColorBrush x:Key='PageBackground'>Black</SolidColorBrush>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="Theme/Default/Colors.axaml"></ResourceInclude>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Styles.Resources>

<Style Selector="NavigationBar">
<Setter Property="Template">
<ControlTemplate TargetType="NavigationBar">
<Border Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}"
Margin="{TemplateBinding Margin}"
MinHeight="35">
<Grid RowDefinitions="Auto,*">
<Border Grid.Row="0"
Height="{TemplateBinding TopSafeSpace}"
IsVisible="{TemplateBinding ApplyTopSafePadding}"></Border>
<Button Name="PART_ActionButton"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Width="35"
Grid.Row="1">
</Button>
<TransitioningContentControl Grid.Row="1" Name="PART_Header" HorizontalAlignment="Center" VerticalAlignment="Center" />
<TransitioningContentControl Grid.Row="1" Name="PART_Items" HorizontalAlignment="Right" VerticalAlignment="Center" />
</Grid>
</Border>
</ControlTemplate>
</Setter>
</Style>

<Style Selector="ShellView">
<Setter Property="Template">
<ControlTemplate>
<Panel Background="{TemplateBinding Background}">
<SplitView Name="PART_SplitView" DisplayMode="Inline">
<SplitView.Pane>
<SideMenu Name="PART_SideMenu"
SelectedItem="{TemplateBinding SideMenuSelectedItem, Mode=TwoWay}"
Header="{TemplateBinding SideMenuHeader}"
Footer="{TemplateBinding SideMenuFooter}"
Contents="{TemplateBinding SideMenuContents}"
ContentsTemplate="{TemplateBinding SideMenuContentsTemplate}">
</SideMenu>
</SplitView.Pane>

<Grid RowDefinitions="Auto,*,Auto">
<NavigationBar Name="PART_NavigationBar"
TopSafePadding="{TemplateBinding TopSafePadding}"
TopSafeSpace="{TemplateBinding TopSafeSpace}"
ApplyTopSafePadding="{TemplateBinding ApplyTopSafePadding}"/>
<StackContentView Name="PART_ContentView"
Grid.Row="1"
PageTransition="{TemplateBinding DefaultPageTransition}"></StackContentView>
<Border Grid.Row="2"
IsVisible="{TemplateBinding ApplyBottomSafePadding}"
Height="{TemplateBinding BottomSafeSpace}">
<Border.Styles>
<Style Selector="Border[IsVisible=True]">
<Setter Property="RenderTransform" Value="scaleY(1)"></Setter>
</Style>
<Style Selector="Border[IsVisible=False]">
<Setter Property="RenderTransform" Value="scaleY(0)"></Setter>
</Style>
</Border.Styles>
</Border>
</Grid>
</SplitView>

<Rectangle IsVisible="{Binding ElementName=PART_Modal, Path=HasContent}"
Opacity="0.5">
<Rectangle.Fill>
<VisualBrush
TileMode="Tile"
SourceRect="0,0,8,8"
DestinationRect="0,0,8,8"
Stretch="UniformToFill">
<VisualBrush.Visual>
<Canvas Width="8" Height="8">
<Rectangle Fill="Black" Width="8" Height="8"></Rectangle>
<Line StartPoint="0,0" EndPoint="8,8" Stroke="#55555555" StrokeThickness="1" />
<Line StartPoint="0,8" EndPoint="8,0" Stroke="#55555555" StrokeThickness="1" />
</Canvas>
</VisualBrush.Visual>
</VisualBrush>
</Rectangle.Fill>
</Rectangle>

<StackContentView Name="PART_Modal"
IsVisible="{Binding ElementName=PART_Modal, Path=HasContent}"
PageTransition="{TemplateBinding ModalPageTransition}">
</StackContentView>
</Panel>
</ControlTemplate>
</Setter>
<Setter Property="SideMenuContentsTemplate">
<DataTemplate>
<ContentPresenter Content="{Binding .}"></ContentPresenter>
</DataTemplate>
</Setter>
</Style>

<Style Selector="SideMenu">
<Setter Property="Template">
<ControlTemplate>
<Grid RowDefinitions="Auto,*,Auto">
<ContentPresenter Name="PART_Header"
ContentTemplate="{TemplateBinding HeaderTemplate}"
Content="{TemplateBinding Header}"></ContentPresenter>
<ScrollViewer Grid.Row="1">
<StackPanel Orientation="Vertical">
<ListBox Name="PART_Items"
ItemsSource="{TemplateBinding Items}"
SelectedItem="{TemplateBinding SelectedItem, Mode=TwoWay}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel></StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="22" Spacing="8">
<Image Source="{Binding Icon}"
IsVisible="{Binding !!Icon}"
VerticalAlignment="Center"></Image>
<TextBlock Text="{Binding Title}"
VerticalAlignment="Center"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ItemsControl Name="PART_Contents"
ItemsSource="{TemplateBinding Contents}"
ItemTemplate="{TemplateBinding ContentsTemplate}" />
</StackPanel>
</ScrollViewer>
<ContentPresenter Grid.Row="2"
Name="PART_Footer"
ContentTemplate="{TemplateBinding FooterTemplate}"
Content="{TemplateBinding Footer}"></ContentPresenter>
</Grid>
</ControlTemplate>
</Setter>
</Style>

<Style Selector="Button.BackButton">
<Setter Property="Template">
<ControlTemplate>
<Viewbox Stretch="UniformToFill">
<Canvas Width="16" Height="16" Margin="5" Background="#00000000">
<Line StartPoint="7,2" EndPoint="2,8" StrokeThickness="3" Stroke="{DynamicResource ButtonForeground}"></Line>
<Line StartPoint="2,6" EndPoint="7,12" StrokeThickness="3" Stroke="{DynamicResource ButtonForeground}"></Line>
</Canvas>
</Viewbox>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="Button.SideMenuButton">
<Setter Property="RenderTransform" Value="rotate(180deg)" />
<Setter Property="Template">
<ControlTemplate>
<Viewbox Stretch="UniformToFill">
<Canvas Width="16" Height="16" Margin="5" Background="#00000000">
<Line StartPoint="1,4" EndPoint="15,4" StrokeThickness="3" Stroke="{DynamicResource ButtonForeground}"></Line>
<Line StartPoint="1,8" EndPoint="15,8" StrokeThickness="3" Stroke="{DynamicResource ButtonForeground}"></Line>
<Line StartPoint="1,12" EndPoint="15,12" StrokeThickness="3" Stroke="{DynamicResource ButtonForeground}"></Line>
</Canvas>
</Viewbox>
</ControlTemplate>
</Setter>
</Style>

<Style Selector="Page">
<Setter Property="Background" Value="{DynamicResource PageBackground}" />
</Style>

<Style Selector="ShellView">
<Setter Property="Background" Value="{DynamicResource AppBackground}" />
</Style>
<StyleInclude Source="/Theme/Default/Controls.axaml" />
</Styles>
Loading
Loading