feat: Add Avalonia FlexPanel and demo.
This commit is contained in:
1 parent
d6e16736e4
commit
3aea65a6b9
14 files changed
+892
-7
No files matched your search
@@ -0,0 +1,6 @@
|
||||
namespace HandyControlDemo.UserControl;
|
||||
|
||||
internal interface IFull
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
x:Class="HandyControlDemo.UserControl.FlexPanelDemo"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<UserControl.Resources>
|
||||
<ControlTheme x:Key="Border4FlexPanelDemoStyle" TargetType="Border">
|
||||
<Setter Property="Width" Value="100" />
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}" />
|
||||
<Setter Property="Margin" Value="10" />
|
||||
<Setter Property="CornerRadius" Value="10" />
|
||||
</ControlTheme>
|
||||
</UserControl.Resources>
|
||||
<TransitioningContentControl>
|
||||
<ScrollViewer>
|
||||
<hc:FlexPanel Margin="32"
|
||||
AlignItems="FlexStart"
|
||||
AlignContent="SpaceBetween"
|
||||
JustifyContent="SpaceAround"
|
||||
FlexWrap="WrapReverse"
|
||||
FlexDirection="RowReverse">
|
||||
<Border hc:FlexPanel.Order="99" Height="50" Theme="{StaticResource Border4FlexPanelDemoStyle}">
|
||||
<TextBlock Text="0" Theme="{StaticResource TextBlockTitle}" />
|
||||
</Border>
|
||||
<Border hc:FlexPanel.FlexBasis="200" Height="100" Theme="{StaticResource Border4FlexPanelDemoStyle}">
|
||||
<TextBlock Text="1" Theme="{StaticResource TextBlockTitle}" />
|
||||
</Border>
|
||||
<Border hc:FlexPanel.AlignSelf="FlexEnd" Height="50" Theme="{StaticResource Border4FlexPanelDemoStyle}">
|
||||
<TextBlock Text="2" Theme="{StaticResource TextBlockTitle}" />
|
||||
</Border>
|
||||
<Border Height="100" Theme="{StaticResource Border4FlexPanelDemoStyle}">
|
||||
<TextBlock Text="3" Theme="{StaticResource TextBlockTitle}" />
|
||||
</Border>
|
||||
<Border Height="50" Theme="{StaticResource Border4FlexPanelDemoStyle}">
|
||||
<TextBlock Text="4" Theme="{StaticResource TextBlockTitle}" />
|
||||
</Border>
|
||||
<Border Height="100" Theme="{StaticResource Border4FlexPanelDemoStyle}">
|
||||
<TextBlock Text="5" Theme="{StaticResource TextBlockTitle}" />
|
||||
</Border>
|
||||
<Border Height="50" Theme="{StaticResource Border4FlexPanelDemoStyle}">
|
||||
<TextBlock Text="6" Theme="{StaticResource TextBlockTitle}" />
|
||||
</Border>
|
||||
<Border Height="100" Theme="{StaticResource Border4FlexPanelDemoStyle}">
|
||||
<TextBlock Text="7" Theme="{StaticResource TextBlockTitle}" />
|
||||
</Border>
|
||||
<Border Height="50" Theme="{StaticResource Border4FlexPanelDemoStyle}">
|
||||
<TextBlock Text="8" Theme="{StaticResource TextBlockTitle}" />
|
||||
</Border>
|
||||
<Border Height="100" Theme="{StaticResource Border4FlexPanelDemoStyle}">
|
||||
<TextBlock Text="9" Theme="{StaticResource TextBlockTitle}" />
|
||||
</Border>
|
||||
</hc:FlexPanel>
|
||||
</ScrollViewer>
|
||||
</TransitioningContentControl>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace HandyControlDemo.UserControl;
|
||||
|
||||
public partial class FlexPanelDemo : Avalonia.Controls.UserControl, IFull
|
||||
{
|
||||
public FlexPanelDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,21 @@
|
||||
<UserControl x:Class="HandyControlDemo.UserControl.MainContent"
|
||||
<UserControl x:Class="HandyControlDemo.UserControl.MainContent"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Panel>
|
||||
<Border Margin="16">
|
||||
<Grid MinHeight="300"
|
||||
<Border Name="BorderRoot" Margin="16">
|
||||
<Grid Name="GridMain"
|
||||
MinHeight="300"
|
||||
MinWidth="200"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
RowDefinitions="Auto,*">
|
||||
<Border Grid.RowSpan="2"
|
||||
<Border Name="BorderEffect"
|
||||
Grid.RowSpan="2"
|
||||
Background="{DynamicResource RegionBrush}"
|
||||
CornerRadius="10"
|
||||
Effect="{StaticResource EffectShadow4}" />
|
||||
<Border Height="32"
|
||||
<Border Name="BorderTitle"
|
||||
Height="32"
|
||||
Grid.Row="0"
|
||||
CornerRadius="10,10,0,0"
|
||||
Background="{DynamicResource TitleBrush}"
|
||||
@@ -26,7 +29,8 @@
|
||||
</Border>
|
||||
<Border Grid.Row="1"
|
||||
ClipToBounds="True">
|
||||
<ContentControl Margin="0,0,0,10"
|
||||
<ContentControl Name="PresenterMain"
|
||||
Margin="0,0,0,10"
|
||||
Content="{Binding SubContent}" />
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
@@ -1,9 +1,49 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Layout;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||
using HandyControlDemo.Data;
|
||||
|
||||
namespace HandyControlDemo.UserControl;
|
||||
|
||||
public partial class MainContent : Avalonia.Controls.UserControl
|
||||
{
|
||||
private bool _isFull;
|
||||
|
||||
public MainContent()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
WeakReferenceMessenger.Default.Register<ValueChangedMessage<bool>, string>(this, MessageToken.FullSwitch, (_, m) => FullSwitch(m.Value));
|
||||
}
|
||||
|
||||
private void FullSwitch(bool isFull)
|
||||
{
|
||||
if (_isFull == isFull)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isFull = isFull;
|
||||
|
||||
if (_isFull)
|
||||
{
|
||||
BorderEffect.IsVisible = false;
|
||||
BorderTitle.IsVisible = false;
|
||||
GridMain.HorizontalAlignment = HorizontalAlignment.Stretch;
|
||||
GridMain.VerticalAlignment = VerticalAlignment.Stretch;
|
||||
PresenterMain.Margin = new Thickness();
|
||||
BorderRoot.Margin = new Thickness();
|
||||
}
|
||||
else
|
||||
{
|
||||
BorderEffect.IsVisible = true;
|
||||
BorderTitle.IsVisible = true;
|
||||
GridMain.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
GridMain.VerticalAlignment = VerticalAlignment.Center;
|
||||
PresenterMain.Margin = new Thickness(0, 0, 0, 10);
|
||||
BorderRoot.Margin = new Thickness(16);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user