Skip to content

Commit

Permalink
fixing button and busyarea loading embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
kikipoulet committed Oct 15, 2024
1 parent da9b61c commit fae64e5
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 6 deletions.
10 changes: 7 additions & 3 deletions SukiUI/Controls/BusyArea.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:suki="clr-namespace:SukiUI.Controls"
xmlns:converters="https://github.com/kikipoulet/SukiUI"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
Expand All @@ -23,9 +24,12 @@
IsVisible="{TemplateBinding BusyText,
Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Text="{TemplateBinding BusyText}" />
<suki:Loading HorizontalAlignment="Center"
VerticalAlignment="Center"
IsHitTestVisible="False" />

<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"
IsHitTestVisible="False" Content="{TemplateBinding IsBusy, Converter={x:Static converters:ProgressToContentCOnverter.Instance}}"></ContentPresenter>


</DockPanel>
</Panel>
</ControlTemplate>
Expand Down
30 changes: 30 additions & 0 deletions SukiUI/Converters/ProgressToContentCOnverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Globalization;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Data.Converters;
using SukiUI.Controls;

namespace SukiUI.Converters
{
public class ProgressToContentCOnverter : IValueConverter
{
public static readonly ProgressToContentCOnverter Instance = new ProgressToContentCOnverter();


public object? Convert(object? value, Type targetType, object? parameter,
CultureInfo culture)
{
if ((bool)value)
return new Loading() { LoadingStyle = LoadingStyle.Simple };

return new Panel();
}

public object ConvertBack(object? value, Type targetType,
object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}
7 changes: 4 additions & 3 deletions SukiUI/Theme/Button.axaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:SukiUI.Controls"
xmlns:theme="clr-namespace:SukiUI.Theme">
xmlns:theme="clr-namespace:SukiUI.Theme"
xmlns:suki="https://github.com/kikipoulet/SukiUI">
<ControlTheme x:Key="SukiButtonStyle" TargetType="Button">
<Setter Property="BorderThickness" Value="1.2" />
<Setter Property="BorderBrush" Value="{DynamicResource SukiMediumBorderBrush}" />
Expand Down Expand Up @@ -30,14 +31,14 @@
<theme:BoolToWidthProgressConverter x:Key="WidthConverter" />
</Border.Resources>
<StackPanel HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Orientation="Horizontal">
<Viewbox Margin="0,-5" Width="{TemplateBinding theme:ButtonExtensions.ShowProgress, Converter={StaticResource WidthConverter}}" Height="24">
<Viewbox Margin="0,-5" Width="{TemplateBinding theme:ButtonExtensions.ShowProgress, Converter={StaticResource WidthConverter}}" Height="24">
<Viewbox.Transitions>
<Transitions>
<DoubleTransition Property="Width" Duration="0:0:0.3" />
</Transitions>
</Viewbox.Transitions>

<controls:Loading LoadingStyle="Simple" Foreground="{DynamicResource SukiText}" />
<ContentPresenter Content="{TemplateBinding theme:ButtonExtensions.ShowProgress, Converter={x:Static suki:ProgressToContentCOnverter.Instance}}"></ContentPresenter>

</Viewbox>
<ContentPresenter HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Expand Down
32 changes: 32 additions & 0 deletions SukiUI/Theme/ButtonLoadingStyles.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:suki="https://github.com/kikipoulet/SukiUI">
<Design.PreviewWith>
<Border Padding="20">
<!-- Add Controls for Previewer Here -->
</Border>
</Design.PreviewWith>

<Style Selector="Button suki|Loading">
<Setter Property="Foreground" Value="{DynamicResource SukiText}"></Setter>
</Style>

<Style Selector="Button.Outlined suki|Loading">
<Setter Property="Foreground" Value="{DynamicResource SukiPrimaryColor}"></Setter>
</Style>

<Style Selector="Button.Basic suki|Loading">
<Setter Property="Foreground" Value="{DynamicResource SukiPrimaryColor}"></Setter>
</Style>

<Style Selector="Button.Accent suki|Loading">
<Setter Property="Foreground" Value="{DynamicResource SukiAccentColor}"></Setter>
</Style>


<Style Selector="Button.Flat suki|Loading">
<Setter Property="Foreground" Value="White"></Setter>
</Style>


</Styles>
1 change: 1 addition & 0 deletions SukiUI/Theme/Index.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<StyleInclude Source="avares://SukiUI/Theme/CheckBoxStyles.axaml" />
<StyleInclude Source="avares://SukiUI/Theme/ScrollBarStyle.axaml" />
<StyleInclude Source="avares://SukiUI/Theme/ScrollViewerStyles.axaml" />
<StyleInclude Source="avares://SukiUI/Theme/ButtonLoadingStyles.axaml" />

<Styles.Resources>
<ResourceDictionary>
Expand Down

0 comments on commit fae64e5

Please sign in to comment.