Skip to content

Commit

Permalink
Merge pull request #4 from Corona-Studio/master
Browse files Browse the repository at this point in the history
Add support for Avalonia 0.11.
  • Loading branch information
SKProCH authored Aug 22, 2022
2 parents badc101 + c4a802e commit bef0889
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
<None Remove=".gitignore" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.16" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.16" />
<PackageReference Include="Avalonia" Version="11.0.0-preview1" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview1" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview1" />

<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.16" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.16" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview1" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AsyncImageLoader.Avalonia\AsyncImageLoader.Avalonia.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
_splitView = e.NameScope.Find<SplitView>("PART_NavigationPane");
}

protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> change) {
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);

if (change.Property == BoundsProperty && _splitView is not null)
{
EnsureSplitViewMode(change.OldValue.GetValueOrDefault<Rect>(), change.NewValue.GetValueOrDefault<Rect>());
EnsureSplitViewMode((Rect)change.OldValue, (Rect)change.NewValue);
}
}

Expand Down
28 changes: 17 additions & 11 deletions AsyncImageLoader.Avalonia.Demo/Pages/AdvancedImagePage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
x:Class="AsyncImageLoader.Avalonia.Demo.Pages.AdvancedImagePage">
<Grid ColumnDefinitions="* 8 150 150" RowDefinitions="Auto Auto Auto Auto"
HorizontalAlignment="Center">
<TextBlock Grid.Column="2" Grid.Row="0" HorizontalAlignment="Center">AdvancedImage</TextBlock>
<TextBlock Grid.Column="3" Grid.Row="0" HorizontalAlignment="Center">Image</TextBlock>
<TextBlock Grid.Column="2" Grid.Row="0" HorizontalAlignment="Center" Text="AdvancedImage"/>
<TextBlock Grid.Column="3" Grid.Row="0" HorizontalAlignment="Center" Text="Image"/>

<StackPanel Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left">
<TextBlock TextWrapping="Wrap">
This control allows to specify a custom IAsyncImageLoader for particular control.
Also this control has loading indicator support.
<TextBlock.Text>
This control allows to specify a custom IAsyncImageLoader for particular control.
Also this control has loading indicator support.

I created and used loader, which will be delay image loading by one second.
I created and used loader, which will be delay image loading by one second.
</TextBlock.Text>
</TextBlock>
<Button HorizontalAlignment="Center"
Click="ReloadButton_OnClick">Reload</Button>
Expand All @@ -28,17 +30,21 @@ I created and used loader, which will be delay image loading by one second.
Loader="{x:Static services:LongLoader.Instance}"/>

<TextBlock Grid.Row="2" Grid.Column="0" TextWrapping="Wrap">
This control provides access to BaseUri.
So you can not only upload pictures from a file or from the Internet, but also specify their relative path as in the usual Image.
This control fully implements the functionality of Image, and adds all the functions of the loaders.
Current images loaded from AvaloniaResource Source="../Assets/cat4.jpg".
<TextBlock.Text>
This control provides access to BaseUri.
So you can not only upload pictures from a file or from the Internet, but also specify their relative path as in the usual Image.
This control fully implements the functionality of Image, and adds all the functions of the loaders.
Current images loaded from AvaloniaResource Source="../Assets/cat4.jpg".
</TextBlock.Text>
</TextBlock>
<asyncImageLoader:AdvancedImage Grid.Row="2" Grid.Column="2" Width="150" Height="150" Source="../Assets/cat4.jpg" />
<Image Grid.Row="2" Grid.Column="3" Source="../Assets/cat4.jpg" Width="150" Height="150" />

<TextBlock Grid.Row="3" Grid.Column="0" TextWrapping="Wrap">
Also, you can use specify absolute path to AvaloniaResource.
Current images loaded from AvaloniaResource Source="/Assets/cat5.jpg".
<TextBlock.Text>
Also, you can use specify absolute path to AvaloniaResource.
Current images loaded from AvaloniaResource Source="/Assets/cat5.jpg".
</TextBlock.Text>
</TextBlock>
<asyncImageLoader:AdvancedImage Grid.Row="3" Grid.Column="2" Width="150" Height="150" Source="/Assets/cat5.jpg" />
<Image Grid.Row="3" Grid.Column="3" Source="/Assets/cat5.jpg" Width="150" Height="150" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AsyncImageLoader.Avalonia.Demo.Pages.AttachedPropertiesPage">
<StackPanel Orientation="Vertical">
<TextBlock TextAlignment="Center">Images from Internet</TextBlock>
<TextBlock TextAlignment="Center" Text="Images from Internet"/>
<StackPanel Orientation="Horizontal">
<Image asyncImageLoader:ImageLoader.Source="https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/raw/master/AsyncImageLoader.Avalonia.Demo/Assets/cat0.jpg" />
<Image asyncImageLoader:ImageLoader.Source="https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/raw/master/AsyncImageLoader.Avalonia.Demo/Assets/cat1.jpg" />
Expand All @@ -15,12 +15,12 @@
<Image asyncImageLoader:ImageLoader.Source="https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/raw/master/AsyncImageLoader.Avalonia.Demo/Assets/cat2.jpg" />
<Image asyncImageLoader:ImageLoader.Source="https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/raw/master/AsyncImageLoader.Avalonia.Demo/Assets/cat3.jpg" />
</StackPanel>
<TextBlock TextAlignment="Center">Images from Assets (AvaloniaResource)</TextBlock>
<TextBlock TextAlignment="Center" Text="Images from Assets (AvaloniaResource)"/>
<StackPanel Orientation="Horizontal">
<Image asyncImageLoader:ImageLoader.Source="avares://AsyncImageLoader.Avalonia.Demo/Assets/cat4.jpg" />
<Image asyncImageLoader:ImageLoader.Source="avares://AsyncImageLoader.Avalonia.Demo/Assets/cat5.jpg" />
</StackPanel>
<TextBlock TextAlignment="Center">Images from manifest resources (EmbeddedResource)</TextBlock>
<TextBlock TextAlignment="Center" Text="Images from manifest resources (EmbeddedResource)"/>
<StackPanel Orientation="Horizontal">
<Image asyncImageLoader:ImageLoader.Source="resm:AsyncImageLoader.Avalonia.Demo.Assets.cat6.jpg" />
<Image asyncImageLoader:ImageLoader.Source="resm:AsyncImageLoader.Avalonia.Demo.Assets.cat7.jpg" />
Expand Down
2 changes: 1 addition & 1 deletion AsyncImageLoader.Avalonia/AdvancedImage.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static AdvancedImage() {

var loaderChangedObservable = LoaderProperty.Changed
.Where(args => args.IsEffectiveValueChange)
.Where((args, i) => i == 0 || args.Sender.GetValue(ShouldLoaderChangeTriggerUpdateProperty))
.Where((args, i) => i == 0 || (bool)args.Sender.GetValue(ShouldLoaderChangeTriggerUpdateProperty)!)
.Select(args => args.NewValue.Value)
.StartWith((IAsyncImageLoader?)null);

Expand Down
2 changes: 1 addition & 1 deletion AsyncImageLoader.Avalonia/AsyncImageLoader.Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.0" />
<PackageReference Include="Avalonia" Version="11.0.0-preview1" />
</ItemGroup>

</Project>

0 comments on commit bef0889

Please sign in to comment.