feat: add fix to drawer.
This commit is contained in:
@@ -10,7 +10,7 @@ public class CustomDrawerControl: DrawerControlBase
|
|||||||
base.OnApplyTemplate(e);
|
base.OnApplyTemplate(e);
|
||||||
if (_closeButton is not null)
|
if (_closeButton is not null)
|
||||||
{
|
{
|
||||||
_closeButton.IsVisible = IsCloseButtonVisible;
|
_closeButton.IsVisible = IsCloseButtonVisible ?? true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,23 @@ public class DefaultDrawerControl: DrawerControlBase
|
|||||||
public const string PART_OKButton = "PART_OKButton";
|
public const string PART_OKButton = "PART_OKButton";
|
||||||
public const string PART_CancelButton = "PART_CancelButton";
|
public const string PART_CancelButton = "PART_CancelButton";
|
||||||
|
|
||||||
private Button? _yesButton;
|
public static readonly StyledProperty<DialogButton> ButtonsProperty =
|
||||||
|
AvaloniaProperty.Register<DefaultDrawerControl, DialogButton>(
|
||||||
|
nameof(Buttons), DialogButton.OKCancel);
|
||||||
|
|
||||||
|
public static readonly StyledProperty<DialogMode> ModeProperty =
|
||||||
|
AvaloniaProperty.Register<DefaultDrawerControl, DialogMode>(
|
||||||
|
nameof(Mode), DialogMode.None);
|
||||||
|
|
||||||
|
public static readonly StyledProperty<string?> TitleProperty =
|
||||||
|
AvaloniaProperty.Register<DefaultDrawerControl, string?>(
|
||||||
|
nameof(Title));
|
||||||
|
|
||||||
|
private Button? _cancelButton;
|
||||||
private Button? _noButton;
|
private Button? _noButton;
|
||||||
private Button? _okButton;
|
private Button? _okButton;
|
||||||
private Button? _cancelButton;
|
|
||||||
|
|
||||||
public static readonly StyledProperty<DialogButton> ButtonsProperty = AvaloniaProperty.Register<DefaultDrawerControl, DialogButton>(
|
private Button? _yesButton;
|
||||||
nameof(Buttons), DialogButton.OKCancel);
|
|
||||||
|
|
||||||
public DialogButton Buttons
|
public DialogButton Buttons
|
||||||
{
|
{
|
||||||
@@ -34,18 +44,12 @@ public class DefaultDrawerControl: DrawerControlBase
|
|||||||
set => SetValue(ButtonsProperty, value);
|
set => SetValue(ButtonsProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<DialogMode> ModeProperty = AvaloniaProperty.Register<DefaultDrawerControl, DialogMode>(
|
|
||||||
nameof(Mode), DialogMode.None);
|
|
||||||
|
|
||||||
public DialogMode Mode
|
public DialogMode Mode
|
||||||
{
|
{
|
||||||
get => GetValue(ModeProperty);
|
get => GetValue(ModeProperty);
|
||||||
set => SetValue(ModeProperty, value);
|
set => SetValue(ModeProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<string?> TitleProperty = AvaloniaProperty.Register<DefaultDrawerControl, string?>(
|
|
||||||
nameof(Title));
|
|
||||||
|
|
||||||
public string? Title
|
public string? Title
|
||||||
{
|
{
|
||||||
get => GetValue(TitleProperty);
|
get => GetValue(TitleProperty);
|
||||||
@@ -66,28 +70,29 @@ public class DefaultDrawerControl: DrawerControlBase
|
|||||||
|
|
||||||
private void SetButtonVisibility()
|
private void SetButtonVisibility()
|
||||||
{
|
{
|
||||||
bool isCloseButtonVisible = DataContext is IDialogContext || Buttons != DialogButton.YesNo;
|
var isCloseButtonVisible =
|
||||||
Button.IsVisibleProperty.SetValue(isCloseButtonVisible, _closeButton);
|
IsCloseButtonVisible ?? (DataContext is IDialogContext || Buttons != DialogButton.YesNo);
|
||||||
|
IsVisibleProperty.SetValue(isCloseButtonVisible, _closeButton);
|
||||||
switch (Buttons)
|
switch (Buttons)
|
||||||
{
|
{
|
||||||
case DialogButton.None:
|
case DialogButton.None:
|
||||||
Button.IsVisibleProperty.SetValue(false, _okButton, _cancelButton, _yesButton, _noButton);
|
IsVisibleProperty.SetValue(false, _okButton, _cancelButton, _yesButton, _noButton);
|
||||||
break;
|
break;
|
||||||
case DialogButton.OK:
|
case DialogButton.OK:
|
||||||
Button.IsVisibleProperty.SetValue(true, _okButton);
|
IsVisibleProperty.SetValue(true, _okButton);
|
||||||
Button.IsVisibleProperty.SetValue(false, _cancelButton, _yesButton, _noButton);
|
IsVisibleProperty.SetValue(false, _cancelButton, _yesButton, _noButton);
|
||||||
break;
|
break;
|
||||||
case DialogButton.OKCancel:
|
case DialogButton.OKCancel:
|
||||||
Button.IsVisibleProperty.SetValue(true, _okButton, _cancelButton);
|
IsVisibleProperty.SetValue(true, _okButton, _cancelButton);
|
||||||
Button.IsVisibleProperty.SetValue(false, _yesButton, _noButton);
|
IsVisibleProperty.SetValue(false, _yesButton, _noButton);
|
||||||
break;
|
break;
|
||||||
case DialogButton.YesNo:
|
case DialogButton.YesNo:
|
||||||
Button.IsVisibleProperty.SetValue(false, _okButton, _cancelButton);
|
IsVisibleProperty.SetValue(false, _okButton, _cancelButton);
|
||||||
Button.IsVisibleProperty.SetValue(true, _yesButton, _noButton);
|
IsVisibleProperty.SetValue(true, _yesButton, _noButton);
|
||||||
break;
|
break;
|
||||||
case DialogButton.YesNoCancel:
|
case DialogButton.YesNoCancel:
|
||||||
Button.IsVisibleProperty.SetValue(false, _okButton);
|
IsVisibleProperty.SetValue(false, _okButton);
|
||||||
Button.IsVisibleProperty.SetValue(true, _cancelButton, _yesButton, _noButton);
|
IsVisibleProperty.SetValue(true, _cancelButton, _yesButton, _noButton);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,21 +102,12 @@ public class DefaultDrawerControl: DrawerControlBase
|
|||||||
if (sender is Button button)
|
if (sender is Button button)
|
||||||
{
|
{
|
||||||
if (button == _okButton)
|
if (button == _okButton)
|
||||||
{
|
|
||||||
OnElementClosing(this, DialogResult.OK);
|
OnElementClosing(this, DialogResult.OK);
|
||||||
}
|
|
||||||
else if (button == _cancelButton)
|
else if (button == _cancelButton)
|
||||||
{
|
|
||||||
OnElementClosing(this, DialogResult.Cancel);
|
OnElementClosing(this, DialogResult.Cancel);
|
||||||
}
|
|
||||||
else if (button == _yesButton)
|
else if (button == _yesButton)
|
||||||
{
|
|
||||||
OnElementClosing(this, DialogResult.Yes);
|
OnElementClosing(this, DialogResult.Yes);
|
||||||
}
|
else if (button == _noButton) OnElementClosing(this, DialogResult.No);
|
||||||
else if (button == _noButton)
|
|
||||||
{
|
|
||||||
OnElementClosing(this, DialogResult.No);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +119,7 @@ public class DefaultDrawerControl: DrawerControlBase
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DialogResult result = Buttons switch
|
var result = Buttons switch
|
||||||
{
|
{
|
||||||
DialogButton.None => DialogResult.None,
|
DialogButton.None => DialogResult.None,
|
||||||
DialogButton.OK => DialogResult.OK,
|
DialogButton.OK => DialogResult.OK,
|
||||||
|
|||||||
@@ -37,15 +37,7 @@ public abstract class DrawerControlBase: OverlayFeedbackElement
|
|||||||
set => SetValue(IsOpenProperty, value);
|
set => SetValue(IsOpenProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<bool> IsCloseButtonVisibleProperty =
|
internal bool? IsCloseButtonVisible { get; set; }
|
||||||
AvaloniaProperty.Register<DrawerControlBase, bool>(
|
|
||||||
nameof(IsCloseButtonVisible), defaultValue: true);
|
|
||||||
|
|
||||||
public bool IsCloseButtonVisible
|
|
||||||
{
|
|
||||||
get => GetValue(IsCloseButtonVisibleProperty);
|
|
||||||
set => SetValue(IsCloseButtonVisibleProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected internal bool CanLightDismiss { get; set; }
|
protected internal bool CanLightDismiss { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ public class DrawerOptions
|
|||||||
internal static DrawerOptions Default => new ();
|
internal static DrawerOptions Default => new ();
|
||||||
public Position Position { get; set; } = Position.Right;
|
public Position Position { get; set; } = Position.Right;
|
||||||
public bool CanLightDismiss { get; set; } = true;
|
public bool CanLightDismiss { get; set; } = true;
|
||||||
public bool IsCloseButtonVisible { get; set; } = true;
|
public bool? IsCloseButtonVisible { get; set; } = true;
|
||||||
public double? MinWidth { get; set; } = null;
|
public double? MinWidth { get; set; } = null;
|
||||||
public double? MinHeight { get; set; } = null;
|
public double? MinHeight { get; set; } = null;
|
||||||
public double? MaxWidth { get; set; } = null;
|
public double? MaxWidth { get; set; } = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user