Skip to content

Commit

Permalink
messagebox draft
Browse files Browse the repository at this point in the history
  • Loading branch information
kikipoulet committed May 25, 2024
1 parent 2a6d31e commit 8766d2a
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 160 deletions.
14 changes: 14 additions & 0 deletions SukiUI.Demo/Features/ControlsLibrary/MiscView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@
</StackPanel>
</controls:GroupBox>
</controls:GlassCard>

<controls:GlassCard>
<controls:GroupBox Header="Message Box">
<StackPanel Spacing="8">
<Button Margin="5"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Classes="Primary"
Command="{Binding OpenBoxCommand}"
Content="Open MessageBox" />

</StackPanel>
</controls:GroupBox>
</controls:GlassCard>
</WrapPanel>
</ScrollViewer>
</Grid>
Expand Down
7 changes: 7 additions & 0 deletions SukiUI.Demo/Features/ControlsLibrary/MiscViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Material.Icons;
using SukiUI.Controls;

namespace SukiUI.Demo.Features.ControlsLibrary;

Expand All @@ -23,6 +24,12 @@ private async Task ToggleBusy()
await Task.Delay(3000);
IsBusy = false;
}

[RelayCommand]
private void OpenBox()
{
SukiHost.ShowDialog(new MessageBox(), false, true);
}

[RelayCommand]
private void OpenFile()
Expand Down
159 changes: 65 additions & 94 deletions SukiUI/Controls/MessageBox.axaml
Original file line number Diff line number Diff line change
@@ -1,99 +1,70 @@
<Window x:Class="SukiUI.Controls.MessageBox"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:content="clr-namespace:SukiUI.Content"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="500"
Height="150"
MaxWidth="500"
MaxHeight="150"
d:DesignHeight="200"
d:DesignWidth="500"
Background="{DynamicResource SukiBackground}"
Classes="NakedWindow"
ExtendClientAreaToDecorationsHint="True"
mc:Ignorable="d">
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:SukiUI.Controls"
xmlns:content="clr-namespace:SukiUI.Content"
mc:Ignorable="d" d:DesignWidth="480" Width="480"
x:Class="SukiUI.Controls.MessageBox">
<Panel>
<Panel.Styles>
<Style Selector="Grid.AnimatedGrid">
<Style.Animations>
<Animation Duration="0:0:4">
<KeyFrame Cue="0%">
<Setter Property="ScaleTransform.ScaleX" Value="1" />
<Setter Property="ScaleTransform.ScaleY" Value="1" />
</KeyFrame>
<KeyFrame Cue="80%">
<Setter Property="ScaleTransform.ScaleX" Value="1" />
<Setter Property="ScaleTransform.ScaleY" Value="1" />
</KeyFrame>
<KeyFrame Cue="84%">
<Setter Property="ScaleTransform.ScaleX" Value="0.99" />
<Setter Property="ScaleTransform.ScaleY" Value="0.99" />
</KeyFrame>
<KeyFrame Cue="88%">
<Setter Property="ScaleTransform.ScaleX" Value="1" />
<Setter Property="ScaleTransform.ScaleY" Value="1" />
</KeyFrame>
<KeyFrame Cue="94%">
<Setter Property="ScaleTransform.ScaleX" Value="0.99" />
<Setter Property="ScaleTransform.ScaleY" Value="0.99" />
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="ScaleTransform.ScaleX" Value="1" />
<Setter Property="ScaleTransform.ScaleY" Value="1" />
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
</Panel.Styles>
<Panel Background="{DynamicResource SukiBackground}" IsHitTestVisible="False" />
<Button Width="23"
Height="23"
Margin="12"
Padding="0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Background="Transparent"
BorderThickness="0"
Classes="ZoomOnHover"
Click="Close">
<PathIcon Data="{x:Static content:Icons.CircleOutlineClose}" Foreground="DarkRed" />
</Button>
<Border Background="{DynamicResource SukiCardBackground}" BorderBrush="{DynamicResource SukiBorderBrush}" BorderThickness="1" CornerRadius="25" Margin="0,90,0,0">
<Border CornerRadius="25" ClipToBounds="True">
<Panel>
<Panel IsVisible="{DynamicResource IsDark}">

<Panel.Background>
<LinearGradientBrush StartPoint="0%,0%" EndPoint="100%,100%">
<GradientStop Color="{DynamicResource SukiAccentColor3}" Offset="0"></GradientStop>
<GradientStop Color="{DynamicResource SukiPrimaryColor15}" Offset="1"></GradientStop>

<Grid Classes="AnimatedGrid">
<PathIcon Name="InfoIcon"
Width="50"
Height="50"
Margin="25,35,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Data="{x:Static content:Icons.CircleInformation}"
DockPanel.Dock="Left"
Foreground="{DynamicResource SukiPrimaryColor}" />
</Grid>
</LinearGradientBrush>
</Panel.Background>

</Panel>

<Panel IsVisible="{DynamicResource IsLight}">
<Panel.Background>
<LinearGradientBrush StartPoint="0%,0%" EndPoint="100%,100%">
<GradientStop Color="{DynamicResource SukiAccentColor5}" Offset="0"></GradientStop>
<GradientStop Color="{DynamicResource SukiPrimaryColor7}" Offset="1"></GradientStop>

<TextBlock Name="Title"
Margin="100,45,0,-45"
HorizontalAlignment="Left"
Classes="h3"
DockPanel.Dock="Top" />
<ScrollViewer Margin="102,45,14,10"
HorizontalAlignment="Left"
VerticalAlignment="Center">
<TextBlock Name="Message"
FontWeight="Light"
TextWrapping="Wrap" />
</ScrollViewer>
</LinearGradientBrush>
</Panel.Background>
</Panel>
<StackPanel>
<TextBlock Margin="0,60,0,0" Text="New Update Available !" FontWeight="DemiBold" FontSize="26" HorizontalAlignment="Center" Foreground="{DynamicResource SukiText}"></TextBlock>
<TextBlock Margin="30,20,30,30" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." FontWeight="DemiBold" TextWrapping="Wrap" Foreground="{DynamicResource SukiLowText}"></TextBlock>
<StackPanel Orientation="Horizontal" Spacing="15" Margin="0,0,30,30" HorizontalAlignment="Right">

<Button Classes="Flat" Content="Update Now"></Button>
</StackPanel>
</StackPanel>
</Panel>
</Border>
</Border>

<Border CornerRadius="50" Margin="0,50,0,0" Height="60" Width="70" HorizontalAlignment="Center" VerticalAlignment="Top" BoxShadow="0 0 40 0 blue"></Border>
<Border
Margin="0,20,0,0" Background="#fafafa" Width="100" Height="100" CornerRadius="50" VerticalAlignment="Top" HorizontalAlignment="Center">
<Border CornerRadius="50" ClipToBounds="True">
<Panel>
<Panel Opacity="1" >
<Panel.Background>
<LinearGradientBrush StartPoint="0%,0%" EndPoint="100%,100%">
<GradientStop Color="{DynamicResource SukiPrimaryColor}" Offset="0"></GradientStop>
<GradientStop Color="{DynamicResource SukiPrimaryColor50}" Offset="1"></GradientStop>

<Button Width="80"
Margin="0,0,0,7"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Classes="Basic"
Click="Close"
DockPanel.Dock="Bottom">
<TextBlock />
</Button>
</LinearGradientBrush>
</Panel.Background>
</Panel>

<PathIcon Width="28" Margin="0,0,0,0"
Height="28" HorizontalAlignment="Center" VerticalAlignment="Center"
Data="{x:Static content:Icons.InformationOutline}"
Foreground="White" />

</Panel>
</Border>
</Border>
</Panel>
</Window>
</UserControl>
66 changes: 7 additions & 59 deletions SukiUI/Controls/MessageBox.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,66 +1,14 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using SukiUI.Content;
using SukiUI.Extensions;

namespace SukiUI.Controls;

public partial class MessageBox : Window
namespace SukiUI.Controls
{
private static readonly SolidColorBrush InfoBrush = new(Color.FromRgb(47, 84, 235));

public MessageBox()
{
InitializeComponent();
}

public MessageBox(string title, string message)
{
InitializeComponent();
this.FindRequiredControl<TextBlock>("Title").Text = title;
this.FindRequiredControl<TextBlock>("Message").Text = message;
}

private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
CanResize = false;
}

public static void Info(Window owner, string title, string message, WindowStartupLocation startupLocation = WindowStartupLocation.CenterScreen)
{
var mbox = new MessageBox(title, message);
if (mbox.FindControl<PathIcon>("InfoIcon") is not { } icon) return;
icon.Data = Icons.CircleInformation;
icon.Foreground = InfoBrush;
mbox.WindowStartupLocation = startupLocation;
mbox.ShowDialog(owner);
}

public static void Success(Window owner, string title, string message, WindowStartupLocation startupLocation = WindowStartupLocation.CenterScreen)
{
var mbox = new MessageBox(title, message);
if (mbox.FindControl<PathIcon>("InfoIcon") is not { } icon) return;
icon.Data = Icons.CircleCheck;
icon.Foreground = Brushes.DarkGreen;
mbox.WindowStartupLocation = startupLocation;
mbox.ShowDialog(owner);
}

public static void Error(Window owner, string title, string message, WindowStartupLocation startupLocation = WindowStartupLocation.CenterScreen)
{
var mbox = new MessageBox(title, message);
if (mbox.FindControl<PathIcon>("InfoIcon") is not { } icon) return;
icon.Data = Icons.CircleClose;
icon.Foreground = Brushes.DarkRed;
mbox.WindowStartupLocation = startupLocation;
mbox.ShowDialog(owner);
}

private void Close(object sender, RoutedEventArgs e)
public partial class MessageBox : UserControl
{
Close();
public MessageBox()
{
InitializeComponent();
}
}
}
6 changes: 3 additions & 3 deletions SukiUI/Controls/SukiToast.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@
Margin="20,0,0,0" Background="{DynamicResource SukiCardBackground}" Width="40" Height="40" CornerRadius="40" VerticalAlignment="Center" HorizontalAlignment="Left">
<Border CornerRadius="40" ClipToBounds="True">
<Panel>
<Panel IsVisible="{DynamicResource IsDark}" Opacity="0.3" Background="{TemplateBinding Foreground}"></Panel>
<Panel IsVisible="{DynamicResource IsLight}" Opacity="0.1" Background="{TemplateBinding Foreground}"></Panel>
<Panel IsVisible="{DynamicResource IsDark}" Opacity="1" Background="{TemplateBinding Foreground}"></Panel>
<Panel IsVisible="{DynamicResource IsLight}" Opacity="1" Background="{TemplateBinding Foreground}"></Panel>
<PathIcon Width="16" Margin="0,0,0,0"
Height="16" HorizontalAlignment="Center" VerticalAlignment="Center"
Data="{TemplateBinding Icon}"
Foreground="{TemplateBinding Foreground}" />
Foreground="White" />

</Panel>
</Border>
Expand Down
4 changes: 0 additions & 4 deletions SukiUI/SukiUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@
<DependentUpon>WaveProgress.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Controls\MessageBox.axaml.cs">
<DependentUpon>MessageBox.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>

</Project>

0 comments on commit 8766d2a

Please sign in to comment.