Add CanResize property to drawers and dialogs with corresponding UI controls

This commit introduces a new `CanResize` property to `DrawerOptions`, `OverlayDialogOptions`, and their respective controls. It also adds UI resizing functionality through the `DialogResizer` control, with styles adjusted to support different drawer positions. Code formatting and organization have been improved for readability across modified files.
This commit is contained in:
rabbitism
2024-09-17 23:06:00 +08:00
parent c512cb6e13
commit 219ead2172
6 changed files with 320 additions and 177 deletions

View File

@@ -205,16 +205,17 @@ public static class Drawer
drawer.Position = options.Position;
drawer.IsCloseButtonVisible = options.IsCloseButtonVisible;
drawer.CanLightDismiss = options.CanLightDismiss;
drawer.CanResize = options.CanResize;
if (options.Position == Position.Left || options.Position == Position.Right)
{
drawer.MinWidth = options.MinWidth ?? 0.0;
drawer.MaxWidth = options.MaxWidth ?? double.PositiveInfinity;
if(options.MinWidth is not null) drawer.MinWidth = options.MinWidth.Value;
if(options.MaxWidth is not null) drawer.MaxWidth = options.MaxWidth.Value;
}
if (options.Position is Position.Top or Position.Bottom)
{
drawer.MinHeight = options.MinHeight ?? 0.0;
drawer.MaxHeight = options.MaxHeight ?? double.PositiveInfinity;
if(options.MinHeight is not null) drawer.MinHeight = options.MinHeight.Value;
if(options.MaxHeight is not null) drawer.MaxHeight = options.MaxHeight.Value;
}
}
@@ -226,16 +227,17 @@ public static class Drawer
drawer.CanLightDismiss = options.CanLightDismiss;
drawer.Buttons = options.Buttons;
drawer.Title = options.Title;
drawer.CanResize = options.CanResize;
if (options.Position == Position.Left || options.Position == Position.Right)
{
drawer.MinWidth = options.MinWidth ?? 0.0;
drawer.MaxWidth = options.MaxWidth ?? double.PositiveInfinity;
if(options.MinWidth is not null) drawer.MinWidth = options.MinWidth.Value;
if(options.MaxWidth is not null) drawer.MaxWidth = options.MaxWidth.Value;
}
if (options.Position is Position.Top or Position.Bottom)
{
drawer.MinHeight = options.MinHeight ?? 0.0;
drawer.MaxHeight = options.MaxHeight ?? double.PositiveInfinity;
if(options.MinHeight is not null) drawer.MinHeight = options.MinHeight.Value;
if(options.MaxHeight is not null) drawer.MaxHeight = options.MaxHeight.Value;
}
}
}

View File

@@ -22,6 +22,15 @@ public abstract class DrawerControlBase: OverlayFeedbackElement
AvaloniaProperty.Register<DrawerControlBase, Position>(
nameof(Position), defaultValue: Position.Right);
public static readonly StyledProperty<bool> CanResizeProperty = AvaloniaProperty.Register<DrawerControlBase, bool>(
nameof(CanResize));
public bool CanResize
{
get => GetValue(CanResizeProperty);
set => SetValue(CanResizeProperty, value);
}
public Position Position
{
get => GetValue(PositionProperty);

View File

@@ -20,4 +20,6 @@ public class DrawerOptions
/// The hash code of the top level dialog host. This is used to identify the dialog host if there are multiple dialog hosts with the same id. If this is not provided, the dialog will be added to the first dialog host with the same id.
/// </summary>
public int? TopLevelHashCode { get; set; }
public bool CanResize { get; set; }
}