Skip to content

Commit

Permalink
Dialogs fully themed with a lot of demos !
Browse files Browse the repository at this point in the history
  • Loading branch information
flarive committed Dec 5, 2023
1 parent b91ea68 commit ab92fe2
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>0.8.0</Version>
<Version>0.9.0</Version>
<Title>Neumorphism.Avalonia</Title>
<Authors>Eviral</Authors>
<Company>Eviral</Company>
Expand All @@ -24,7 +24,7 @@
<PackageReference Include="Avalonia" Version="11.0.5" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.5" />
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.0.5" />
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.0.5" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.5" />
<PackageReference Include="DialogHost.Avalonia" Version="0.7.7" />
<PackageReference Include="SkiaSharp" Version="2.88.6" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
using Avalonia.Data.Converters;
using Avalonia.Media.Imaging;

namespace Avalonia.Themes.Neumorphism
namespace Avalonia.Themes.Neumorphism.Converters
{
internal class IBitmapToImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null && value is Bitmap bm)
return new Image { Source=bm };
return new Image { Source = bm };

return null;
}

Expand All @@ -21,4 +21,4 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
throw new NotImplementedException();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
using Avalonia.Controls;
using Avalonia.Media.Imaging;
using Avalonia.Media;
using Avalonia.Themes.Neumorphism.Dialogs.Interfaces;
using Avalonia.Themes.Neumorphism.Dialogs.ViewModels;

namespace Avalonia.Themes.Neumorphism.Dialogs.Views
{
public partial class AlertDialog : Window, IDialogWindowResult<DialogResult>, IHasNegativeResult
{
public AlertDialog() {
public AlertDialog()
{
InitializeComponent();

RenderOptions.SetBitmapInterpolationMode(this, BitmapInterpolationMode.HighQuality);
}

public DialogResult GetResult() => (DataContext as AlertDialogViewModel)?.DialogResult;
Expand Down
11 changes: 8 additions & 3 deletions Avalonia.Themes.Neumorphism/Dialogs/Views/CommonDialog.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Themes.Neumorphism.Dialogs.Interfaces;
using Avalonia.Themes.Neumorphism.Dialogs.ViewModels;

namespace Avalonia.Themes.Neumorphism.Dialogs.Views
{
public partial class CommonDialog : Window, IDialogWindowResult<DialogResult>, IHasNegativeResult
{
public CommonDialog() {
public CommonDialog()
{
InitializeComponent();

RenderOptions.SetBitmapInterpolationMode(this, BitmapInterpolationMode.HighQuality);
}

public DialogResult GetResult() => (DataContext as AlertDialogViewModel)?.DialogResult;
public DialogResult GetResult() => (DataContext as CommonDialogViewModel)?.DialogResult;

public void SetNegativeResult(DialogResult result)
{
if (DataContext is AlertDialogViewModel viewModel)
if (DataContext is CommonDialogViewModel viewModel)
viewModel.DialogResult = result;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using Avalonia.Controls;
using Avalonia.Controls.Presenters;
using Avalonia.Media.Imaging;
using Avalonia.Media;
using Avalonia.Themes.Neumorphism.Dialogs.Interfaces;
using Avalonia.Themes.Neumorphism.Dialogs.ViewModels;
using Avalonia.Threading;
Expand All @@ -14,6 +16,8 @@ public TextFieldDialog() {

InitializeComponent();

RenderOptions.SetBitmapInterpolationMode(this, BitmapInterpolationMode.HighQuality);

Closed += TextFieldDialog_Closed;
Opened += TextFieldDialog_Opened;
}
Expand Down
6 changes: 4 additions & 2 deletions Avalonia.Themes.Neumorphism/Themes/NativeMenuBar.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Avalonia.Themes.Neumorphism">
<local:IBitmapToImageConverter x:Key="AvaloniaThemesFluentNativeMenuBarIBitmapToImageConverter"/>
xmlns:converters="using:Avalonia.Themes.Neumorphism.Converters">

<converters:IBitmapToImageConverter x:Key="AvaloniaThemesFluentNativeMenuBarIBitmapToImageConverter"/>

<ControlTheme x:Key="{x:Type NativeMenuBar}" TargetType="NativeMenuBar">
<Setter Property="Template">
<ControlTemplate>
Expand Down
3 changes: 2 additions & 1 deletion Neumorphism.Avalonia.Demo/ViewModels/DialogsDemoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private async IAsyncEnumerable<string> CreateErrorDialog()
var dialog = DialogHelper.CreateAlertDialog(new AlertDialogBuilderParams
{
ContentHeader = "Error !",
SupportingText = "An error occured !",
SupportingText = "A strange unexpected error occured !",
WindowTitle = "Error dialog",
DialogHeaderIcon = DialogIconKind.Error,
DialogIcon = DialogIconKind.Error,
Expand Down Expand Up @@ -246,6 +246,7 @@ await DialogHelper.CreateCommonDialog(new CommonDialogBuilderParams
StartupLocation = WindowStartupLocation.CenterOwner,
DialogHeaderIcon = DialogIconKind.Success,
Borderless = true,
Width = 480,
}).ShowDialog(_window);

_appModelBase.IsDialogOpened = false;
Expand Down
6 changes: 3 additions & 3 deletions Neumorphism.Avalonia.Demo/Windows/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@
</StackPanel>
</ListBoxItem>

<!--<ListBoxItem IsEnabled="True">
<ListBoxItem IsEnabled="True">
<StackPanel Orientation="Horizontal">
<icons:MaterialIcon Kind="WindowMaximize" Width="24" Height="24" VerticalAlignment="Center" Foreground="Gray" />
<TextBlock Text="Dialogs" VerticalAlignment="Center" Margin="8,0,0,0" />
</StackPanel>
</ListBoxItem>-->
</ListBoxItem>

</ListBox>
</Grid>
Expand Down Expand Up @@ -302,7 +302,7 @@
<!--Menus-->
<pages:MenusDemo/>
<!--Dialogs-->
<!--<pages:DialogsDemo/>-->
<pages:DialogsDemo/>
</Carousel>
</Border>
</ScrollViewer>
Expand Down

0 comments on commit ab92fe2

Please sign in to comment.