diff --git a/README.zh-CN.md b/README.zh-CN.md index 40238c7..f5fef56 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -51,8 +51,20 @@ Avalonia 11.1.1 及其以上
PS: AtomUI 目前仅在 Windows 11 平台测试
#### 中文社区 -目前我们暂时只创建微信开发者群的交流方式,下面是二维码,有兴趣的同学可以扫码加入: - +目前我们暂时只创建 QQ 和微信开发者群的交流方式,下面是二维码,有兴趣的同学可以扫码加入: + + + + + + + + +
+ + + +
> PS:扫码请注明来意,比如:学习`AtomUI`或者`Avalonia`爱好者 diff --git a/docs/images/QQ.png b/docs/images/QQ.png new file mode 100644 index 0000000..65c08ad Binary files /dev/null and b/docs/images/QQ.png differ diff --git a/samples/AtomUI.Demo.Desktop/ShowCase/DatePickerShowCase.cs.axaml b/samples/AtomUI.Demo.Desktop/ShowCase/DatePickerShowCase.cs.axaml index 8f619ad..0226d6f 100644 --- a/samples/AtomUI.Demo.Desktop/ShowCase/DatePickerShowCase.cs.axaml +++ b/samples/AtomUI.Demo.Desktop/ShowCase/DatePickerShowCase.cs.axaml @@ -5,20 +5,25 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:desktop="clr-namespace:AtomUI.Demo.Desktop" - xmlns:calendarpresenter="clr-namespace:AtomUI.Controls.CalendarView;assembly=AtomUI.Controls" xmlns:atom="https://atomui.net" mc:Ignorable="d"> - + + + + + + + + + - - - - - - \ No newline at end of file diff --git a/src/AtomUI.Controls/DatePicker/CalendarView/Calendar.cs b/src/AtomUI.Controls/DatePicker/CalendarView/Calendar.cs index 88e43c7..d5b6d0d 100644 --- a/src/AtomUI.Controls/DatePicker/CalendarView/Calendar.cs +++ b/src/AtomUI.Controls/DatePicker/CalendarView/Calendar.cs @@ -11,7 +11,7 @@ using Avalonia.Media; namespace AtomUI.Controls.CalendarView; -public class DateSelectedEventArgs : RoutedEventArgs +public class DateSelectedEventArgs : EventArgs { public DateTime? Value { get; } public DateSelectedEventArgs(DateTime? value) diff --git a/src/AtomUI.Controls/DatePicker/DatePicker.cs b/src/AtomUI.Controls/DatePicker/DatePicker.cs index 1a67fec..4156b20 100644 --- a/src/AtomUI.Controls/DatePicker/DatePicker.cs +++ b/src/AtomUI.Controls/DatePicker/DatePicker.cs @@ -4,7 +4,6 @@ using AtomUI.Data; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; -using Avalonia.Threading; namespace AtomUI.Controls; diff --git a/src/AtomUI.Controls/DatePicker/DatePickerPresenter.cs b/src/AtomUI.Controls/DatePicker/DatePickerPresenter.cs index 6d42772..d43ae2a 100644 --- a/src/AtomUI.Controls/DatePicker/DatePickerPresenter.cs +++ b/src/AtomUI.Controls/DatePicker/DatePickerPresenter.cs @@ -98,7 +98,6 @@ internal class DatePickerPresenter : PickerPresenterBase private Button? _confirmButton; private PickerCalendar? _calendarView; private IDisposable? _choosingStateDisposable; - private bool _isConfirmed; protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { @@ -112,13 +111,12 @@ internal class DatePickerPresenter : PickerPresenterBase ChoosingStatueChanged?.Invoke(this, new ChoosingStatusEventArgs(args.GetNewValue())); }); } - - _isConfirmed = false; } protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) { base.OnDetachedFromVisualTree(e); + _choosingStateDisposable?.Dispose(); _choosingStateDisposable = null; } diff --git a/src/AtomUI.Controls/DatePicker/DatePickerPresenterTheme.cs b/src/AtomUI.Controls/DatePicker/DatePickerPresenterTheme.cs index b5457ce..d2e0033 100644 --- a/src/AtomUI.Controls/DatePicker/DatePickerPresenterTheme.cs +++ b/src/AtomUI.Controls/DatePicker/DatePickerPresenterTheme.cs @@ -18,8 +18,8 @@ internal class DatePickerPresenterTheme : BaseControlTheme public const string NowButtonPart = "PART_NowButton"; public const string TodayButtonPart = "PART_TodayButton"; public const string ConfirmButtonPart = "PART_ConfirmButton"; - public const string ButtonsContainerPart = "PART_ButtonsContainer"; - public const string ButtonsContainerFramePart = "PART_ButtonsContainerFrame"; + public const string ButtonsLayoutPart = "PART_ButtonsLayout"; + public const string ButtonsFramePart = "PART_ButtonsFrame"; public const string CalendarViewPart = "PART_CalendarView"; public DatePickerPresenterTheme() : this(typeof(DatePickerPresenter)) @@ -44,7 +44,7 @@ internal class DatePickerPresenterTheme : BaseControlTheme var buttonsContainerFrame = new Border() { - Name = ButtonsContainerFramePart + Name = ButtonsFramePart }; CreateTemplateParentBinding(buttonsContainerFrame, Border.BorderThicknessProperty, DatePickerPresenter.BorderThicknessProperty); var buttonsPanel = BuildButtons(presenter, scope); @@ -73,7 +73,7 @@ internal class DatePickerPresenterTheme : BaseControlTheme { var buttonsPanel = new Panel() { - Name = ButtonsContainerPart + Name = ButtonsLayoutPart }; var nowButton = new Button @@ -114,11 +114,11 @@ internal class DatePickerPresenterTheme : BaseControlTheme protected override void BuildStyles() { - var buttonsFrameStyle = new Style(selector => selector.Nesting().Template().Name(ButtonsContainerFramePart)); + var buttonsFrameStyle = new Style(selector => selector.Nesting().Template().Name(ButtonsFramePart)); buttonsFrameStyle.Add(Border.BorderBrushProperty, GlobalTokenResourceKey.ColorBorderSecondary); Add(buttonsFrameStyle); - var buttonsPanelStyle = new Style(selector => selector.Nesting().Template().Name(ButtonsContainerPart)); + var buttonsPanelStyle = new Style(selector => selector.Nesting().Template().Name(ButtonsLayoutPart)); buttonsPanelStyle.Add(Panel.MarginProperty, DatePickerTokenResourceKey.ButtonsPanelMargin); Add(buttonsPanelStyle); diff --git a/src/AtomUI.Controls/DatePicker/DatePickerTheme.cs b/src/AtomUI.Controls/DatePicker/DatePickerTheme.cs index 1b8517d..4364640 100644 --- a/src/AtomUI.Controls/DatePicker/DatePickerTheme.cs +++ b/src/AtomUI.Controls/DatePicker/DatePickerTheme.cs @@ -25,10 +25,6 @@ internal class DatePickerTheme : InfoPickerInputTheme base.BuildStyles(); var commonStyle = new Style(selector => selector.Nesting()); commonStyle.Add(DatePicker.MinWidthProperty, DatePickerTokenResourceKey.PickerInputMinWidth); - - var choosingStyle = new Style(selector => selector.Nesting().Class(DatePicker.ChoosingPC)); - choosingStyle.Add(DatePicker.InputTextBrushProperty, GlobalTokenResourceKey.ColorTextTertiary); - commonStyle.Add(choosingStyle); Add(commonStyle); } diff --git a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.ControlThemeRegisterGenerator/ControlThemeRegister.g.cs b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.ControlThemeRegisterGenerator/ControlThemeRegister.g.cs index 4751c03..556b9e4 100644 --- a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.ControlThemeRegisterGenerator/ControlThemeRegister.g.cs +++ b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.ControlThemeRegisterGenerator/ControlThemeRegister.g.cs @@ -89,11 +89,11 @@ ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.TabStripItemTheme()); ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.TabStripTheme()); ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.TagTheme()); - ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.RangeTimePickerFlyoutPresenterTheme()); ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.RangeTimePickerTheme()); ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.TimePickerFlyoutPresenterTheme()); ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.TimePickerPresenterTheme()); ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.TimePickerTheme()); + ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.TimeViewTheme()); ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.ToolTipTheme()); ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.NodeSwitcherButtonTheme()); ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.TreeViewItemTheme()); diff --git a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs index f4dbc18..82a4ed9 100644 --- a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs +++ b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs @@ -581,6 +581,7 @@ namespace AtomUI.Theme.Styling public static readonly TokenResourceKey PickerPopupHeight = new TokenResourceKey("TimePicker.PickerPopupHeight", "AtomUI.Token"); public static readonly TokenResourceKey RangePickerArrowMargin = new TokenResourceKey("TimePicker.RangePickerArrowMargin", "AtomUI.Token"); public static readonly TokenResourceKey RangePickerIndicatorThickness = new TokenResourceKey("TimePicker.RangePickerIndicatorThickness", "AtomUI.Token"); + public static readonly TokenResourceKey PickerInputMinWidth = new TokenResourceKey("TimePicker.PickerInputMinWidth", "AtomUI.Token"); } public static class ToolTipTokenResourceKey diff --git a/src/AtomUI.Controls/Internal/InfoPickerInput/InfoPickerInputTheme.cs b/src/AtomUI.Controls/Internal/InfoPickerInput/InfoPickerInputTheme.cs index 8551bbf..2d9b9a3 100644 --- a/src/AtomUI.Controls/Internal/InfoPickerInput/InfoPickerInputTheme.cs +++ b/src/AtomUI.Controls/Internal/InfoPickerInput/InfoPickerInputTheme.cs @@ -140,6 +140,11 @@ internal class InfoPickerInputTheme : BaseControlTheme base.BuildStyles(); var commonStyle = new Style(selector => selector.Nesting()); commonStyle.Add(InfoPickerInput.InputTextBrushProperty, GlobalTokenResourceKey.ColorText); + + var choosingStyle = new Style(selector => selector.Nesting().Class(InfoPickerInput.ChoosingPC)); + choosingStyle.Add(InfoPickerInput.InputTextBrushProperty, GlobalTokenResourceKey.ColorTextTertiary); + commonStyle.Add(choosingStyle); + Add(commonStyle); } } \ No newline at end of file diff --git a/src/AtomUI.Controls/ListBox/ListBoxItem.cs b/src/AtomUI.Controls/ListBox/ListBoxItem.cs index 5effbe9..4083bea 100644 --- a/src/AtomUI.Controls/ListBox/ListBoxItem.cs +++ b/src/AtomUI.Controls/ListBox/ListBoxItem.cs @@ -1,4 +1,8 @@ -using Avalonia; +using AtomUI.Media; +using AtomUI.Theme.Utils; +using Avalonia; +using Avalonia.Animation; +using Avalonia.LogicalTree; namespace AtomUI.Controls; @@ -33,6 +37,53 @@ public class ListBoxItem : AvaloniaListBoxItem get => _disabledItemHoverEffect; set => SetAndRaise(DisabledItemHoverEffectProperty, ref _disabledItemHoverEffect, value); } + + internal static readonly DirectProperty DisabledItemHoverAnimationProperty = + AvaloniaProperty.RegisterDirect(nameof(DisabledItemHoverAnimation), + o => o.DisabledItemHoverAnimation, + (o, v) => o.DisabledItemHoverAnimation = v); + + private bool _disabledItemHoverAnimation = false; + + internal bool DisabledItemHoverAnimation + { + get => _disabledItemHoverAnimation; + set => SetAndRaise(DisabledItemHoverAnimationProperty, ref _disabledItemHoverAnimation, value); + } #endregion + + protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) + { + base.OnAttachedToLogicalTree(e); + if (!DisabledItemHoverAnimation) + { + Transitions ??= new Transitions + { + AnimationUtils.CreateTransition(BackgroundProperty) + }; + } + } + + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + base.OnPropertyChanged(change); + if (VisualRoot is not null) + { + if (change.Property == DisabledItemHoverAnimationProperty) + { + if (DisabledItemHoverAnimation) + { + Transitions?.Clear(); + } + else + { + Transitions = new Transitions + { + AnimationUtils.CreateTransition(BackgroundProperty) + }; + } + } + } + } } \ No newline at end of file diff --git a/src/AtomUI.Controls/ListBox/ListBoxItemTheme.cs b/src/AtomUI.Controls/ListBox/ListBoxItemTheme.cs index ddc9102..1e7b8b5 100644 --- a/src/AtomUI.Controls/ListBox/ListBoxItemTheme.cs +++ b/src/AtomUI.Controls/ListBox/ListBoxItemTheme.cs @@ -1,8 +1,5 @@ -using AtomUI.Media; -using AtomUI.Theme; +using AtomUI.Theme; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; -using Avalonia.Animation; using Avalonia.Controls; using Avalonia.Controls.Presenters; using Avalonia.Controls.Primitives; @@ -34,11 +31,10 @@ internal class ListBoxItemTheme : BaseControlTheme Name = ContentPresenterPart }; - contentPresenter.Transitions = new Transitions - { - AnimationUtils.CreateTransition(ContentPresenter.BackgroundProperty) - }; - + CreateTemplateParentBinding(contentPresenter, ContentPresenter.ForegroundProperty, + TemplatedControl.ForegroundProperty); + CreateTemplateParentBinding(contentPresenter, ContentPresenter.BackgroundProperty, + TemplatedControl.BackgroundProperty); CreateTemplateParentBinding(contentPresenter, ContentPresenter.CornerRadiusProperty, TemplatedControl.CornerRadiusProperty); CreateTemplateParentBinding(contentPresenter, ContentPresenter.ContentProperty, @@ -66,32 +62,20 @@ internal class ListBoxItemTheme : BaseControlTheme private void BuildCommonStyle() { var commonStyle = new Style(selector => selector.Nesting()); - commonStyle.Add(Layoutable.MarginProperty, ListBoxTokenResourceKey.ItemMargin); - { - var contentPresenterStyle = new Style(selector => selector.Nesting().Template().Name(ContentPresenterPart)); - contentPresenterStyle.Add(ContentPresenter.ForegroundProperty, ListBoxTokenResourceKey.ItemColor); - contentPresenterStyle.Add(ContentPresenter.BackgroundProperty, ListBoxTokenResourceKey.ItemBgColor); - commonStyle.Add(contentPresenterStyle); - } + commonStyle.Add(ListBoxItem.MarginProperty, ListBoxTokenResourceKey.ItemMargin); + commonStyle.Add(ListBoxItem.ForegroundProperty, ListBoxTokenResourceKey.ItemColor); + commonStyle.Add(ListBoxItem.BackgroundProperty, ListBoxTokenResourceKey.ItemBgColor); var disabledItemHoverStyle = new Style(selector => - selector.Nesting().PropertyEquals(ListBoxItem.DisabledItemHoverEffectProperty, false)); - { - var contentPresenterStyle = new Style(selector => - selector.Nesting().Template().Name(ContentPresenterPart).Class(StdPseudoClass.PointerOver)); - contentPresenterStyle.Add(ContentPresenter.ForegroundProperty, ListBoxTokenResourceKey.ItemHoverColor); - contentPresenterStyle.Add(ContentPresenter.BackgroundProperty, ListBoxTokenResourceKey.ItemHoverBgColor); - disabledItemHoverStyle.Add(contentPresenterStyle); - } + selector.Nesting().PropertyEquals(ListBoxItem.DisabledItemHoverEffectProperty, false).Class(StdPseudoClass.PointerOver)); + disabledItemHoverStyle.Add(ListBoxItem.ForegroundProperty, ListBoxTokenResourceKey.ItemHoverColor); + disabledItemHoverStyle.Add(ListBoxItem.BackgroundProperty, ListBoxTokenResourceKey.ItemHoverBgColor); + commonStyle.Add(disabledItemHoverStyle); var selectedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Selected)); - { - var contentPresenterStyle = new Style(selector => selector.Nesting().Template().Name(ContentPresenterPart)); - contentPresenterStyle.Add(ContentPresenter.ForegroundProperty, ListBoxTokenResourceKey.ItemSelectedColor); - contentPresenterStyle.Add(ContentPresenter.BackgroundProperty, ListBoxTokenResourceKey.ItemSelectedBgColor); - selectedStyle.Add(contentPresenterStyle); - } + selectedStyle.Add(ListBoxItem.ForegroundProperty, ListBoxTokenResourceKey.ItemSelectedColor); + selectedStyle.Add(ListBoxItem.BackgroundProperty, ListBoxTokenResourceKey.ItemSelectedBgColor); commonStyle.Add(selectedStyle); Add(commonStyle); } diff --git a/src/AtomUI.Controls/TimePicker/DateTimePickerPanel.cs b/src/AtomUI.Controls/TimePicker/DateTimePickerPanel.cs index b1a9f67..bb8ff60 100644 --- a/src/AtomUI.Controls/TimePicker/DateTimePickerPanel.cs +++ b/src/AtomUI.Controls/TimePicker/DateTimePickerPanel.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using AtomUI.Controls.TimePickerLang; -using AtomUI.Data; using AtomUI.Theme.Data; using AtomUI.Theme.Styling; using AtomUI.Utils; @@ -29,31 +28,99 @@ public enum DateTimePickerPanelType TimePeriod //AM or PM } +public struct CellHoverInfo +{ + public DateTimePickerPanelType PanelType { get; } + public int CellValue { get; } + + public CellHoverInfo(DateTimePickerPanelType panelType, int cellValue) + { + PanelType = panelType; + CellValue = cellValue; + } +} + +internal class CellHoverEventArgs : EventArgs +{ + public CellHoverInfo? CellHoverInfo { get; } + public CellHoverEventArgs(CellHoverInfo? hoverInfo) + { + CellHoverInfo = hoverInfo; + } +} + internal class DateTimePickerPanel : Panel, ILogicalScrollable { - /// - /// Defines the property - /// - public static readonly StyledProperty ItemHeightProperty = + #region 公共属性定义 + + /// + /// Defines the property + /// + public static readonly StyledProperty ItemHeightProperty = AvaloniaProperty.Register(nameof(ItemHeight), 40.0); - /// - /// Defines the property - /// - public static readonly StyledProperty PanelTypeProperty = + /// + /// Defines the property + /// + public static readonly StyledProperty PanelTypeProperty = AvaloniaProperty.Register(nameof(PanelType)); - /// - /// Defines the property - /// - public static readonly StyledProperty ItemFormatProperty = + /// + /// Defines the property + /// + public static readonly StyledProperty ItemFormatProperty = AvaloniaProperty.Register(nameof(ItemFormat), "yyyy"); - /// - /// Defines the property - /// - public static readonly StyledProperty ShouldLoopProperty = + /// + /// Defines the property + /// + public static readonly StyledProperty ShouldLoopProperty = AvaloniaProperty.Register(nameof(ShouldLoop)); + + /// + /// Gets or sets the height of each item + /// + public double ItemHeight + { + get => GetValue(ItemHeightProperty); + set => SetValue(ItemHeightProperty, value); + } + + /// + /// Gets or sets what this panel displays in date or time units + /// + public DateTimePickerPanelType PanelType + { + get => GetValue(PanelTypeProperty); + set => SetValue(PanelTypeProperty, value); + } + + /// + /// Gets or sets the string format for the items, using standard + /// .net DateTime or TimeSpan formatting. Format must match panel type + /// + public string ItemFormat + { + get => GetValue(ItemFormatProperty); + set => SetValue(ItemFormatProperty, value); + } + + /// + /// Gets or sets whether the panel should loop + /// + public bool ShouldLoop + { + get => GetValue(ShouldLoopProperty); + set => SetValue(ShouldLoopProperty, value); + } + + #endregion + + #region 内部事件定义 + + internal event EventHandler? CellHovered; + + #endregion //Backing fields for properties private int _minimumValue = 1; @@ -76,7 +143,7 @@ internal class DateTimePickerPanel : Panel, ILogicalScrollable public DateTimePickerPanel() { FormatDate = DateTime.Now; - AddHandler(TappedEvent, OnItemTapped, RoutingStrategies.Bubble); + AddHandler(TappedEvent, HandleItemTapped, RoutingStrategies.Bubble); } static DateTimePickerPanel() @@ -85,44 +152,7 @@ internal class DateTimePickerPanel : Panel, ILogicalScrollable BackgroundProperty.OverrideDefaultValue(Brushes.Transparent); AffectsMeasure(ItemHeightProperty); } - - /// - /// Gets or sets what this panel displays in date or time units - /// - public DateTimePickerPanelType PanelType - { - get => GetValue(PanelTypeProperty); - set => SetValue(PanelTypeProperty, value); - } - - /// - /// Gets or sets the height of each item - /// - public double ItemHeight - { - get => GetValue(ItemHeightProperty); - set => SetValue(ItemHeightProperty, value); - } - - /// - /// Gets or sets the string format for the items, using standard - /// .net DateTime or TimeSpan formatting. Format must match panel type - /// - public string ItemFormat - { - get => GetValue(ItemFormatProperty); - set => SetValue(ItemFormatProperty, value); - } - - /// - /// Gets or sets whether the panel should loop - /// - public bool ShouldLoop - { - get => GetValue(ShouldLoopProperty); - set => SetValue(ShouldLoopProperty, value); - } - + /// /// Gets or sets the minimum value /// @@ -370,6 +400,7 @@ internal class DateTimePickerPanel : Panel, ILogicalScrollable { UpdateItems(); RaiseScrollInvalidated(EventArgs.Empty); + EnableCellHoverAnimation(); _hasInit = true; } @@ -532,7 +563,16 @@ internal class DateTimePickerPanel : Panel, ILogicalScrollable HorizontalContentAlignment = HorizontalAlignment.Center, Focusable = false, CornerRadius = new CornerRadius(0), - SizeType = SizeType.Middle + SizeType = SizeType.Middle, + DisabledItemHoverAnimation = true + }; + item.PointerEntered += (sender, args) => + { + if (sender is ListBoxItem target) + { + var cellValue = (int)target.Tag!; + CellHovered?.Invoke(this, new CellHoverEventArgs(new CellHoverInfo(PanelType, cellValue))); + } }; TokenResourceBinder.CreateTokenBinding(item, TemplatedControl.PaddingProperty, TimePickerTokenResourceKey.ItemPadding, BindingPriority.LocalValue); @@ -640,7 +680,7 @@ internal class DateTimePickerPanel : Panel, ILogicalScrollable return newValue; } - private void OnItemTapped(object? sender, TappedEventArgs e) + private void HandleItemTapped(object? sender, TappedEventArgs e) { if (e.Source is Visual source && GetItemFromSource(source) is ListBoxItem listBoxItem && @@ -687,4 +727,14 @@ internal class DateTimePickerPanel : Panel, ILogicalScrollable Offset = Offset.WithY(snapY); } } + + private void EnableCellHoverAnimation() + { + var children = Children; + for (var i = 0; i < children.Count; i++) + { + var item = (ListBoxItem)children[i]; + item.DisabledItemHoverAnimation = false; + } + } } \ No newline at end of file diff --git a/src/AtomUI.Controls/TimePicker/RangeTimePicker.cs b/src/AtomUI.Controls/TimePicker/RangeTimePicker.cs index c62b441..c917cc1 100644 --- a/src/AtomUI.Controls/TimePicker/RangeTimePicker.cs +++ b/src/AtomUI.Controls/TimePicker/RangeTimePicker.cs @@ -104,7 +104,7 @@ public class RangeTimePicker : RangeInfoPickerInput protected override Flyout CreatePickerFlyout() { - return new RangeTimePickerFlyout(this); + return new TimePickerFlyout(); } protected override void NotifyFlyoutAboutToClose(bool selectedIsValid) diff --git a/src/AtomUI.Controls/TimePicker/RangeTimePickerFlyout.cs b/src/AtomUI.Controls/TimePicker/RangeTimePickerFlyout.cs deleted file mode 100644 index f49477d..0000000 --- a/src/AtomUI.Controls/TimePicker/RangeTimePickerFlyout.cs +++ /dev/null @@ -1,31 +0,0 @@ -using AtomUI.Data; -using Avalonia.Controls; - -namespace AtomUI.Controls; - -internal class RangeTimePickerFlyout : Flyout -{ - internal RangeTimePicker RangeTimePickerRef { get; set; } - - public RangeTimePickerFlyout(RangeTimePicker timePicker) - { - RangeTimePickerRef = timePicker; - } - - protected override Control CreatePresenter() - { - var presenter = new RangeTimePickerFlyoutPresenter(RangeTimePickerRef); - - BindUtils.RelayBind(this, IsShowArrowEffectiveProperty, presenter, IsShowArrowProperty); - - BindUtils.RelayBind(RangeTimePickerRef, RangeTimePicker.MinuteIncrementProperty, presenter, - RangeTimePickerFlyoutPresenter.MinuteIncrementProperty); - BindUtils.RelayBind(RangeTimePickerRef, RangeTimePicker.SecondIncrementProperty, presenter, - RangeTimePickerFlyoutPresenter.SecondIncrementProperty); - BindUtils.RelayBind(RangeTimePickerRef, RangeTimePicker.ClockIdentifierProperty, presenter, - RangeTimePickerFlyoutPresenter.ClockIdentifierProperty); - CalculateShowArrowEffective(); - SetupArrowPosition(Popup, presenter); - return presenter; - } -} \ No newline at end of file diff --git a/src/AtomUI.Controls/TimePicker/RangeTimePickerFlyoutPresenter.cs b/src/AtomUI.Controls/TimePicker/RangeTimePickerFlyoutPresenter.cs deleted file mode 100644 index 811595f..0000000 --- a/src/AtomUI.Controls/TimePicker/RangeTimePickerFlyoutPresenter.cs +++ /dev/null @@ -1,164 +0,0 @@ -using System.Reactive.Disposables; -using AtomUI.Controls.Internal; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Controls.Primitives; -using Avalonia.Interactivity; -using Avalonia.Layout; - -namespace AtomUI.Controls; - -internal class RangeTimePickerFlyoutPresenter : FlyoutPresenter -{ - public static readonly StyledProperty MinuteIncrementProperty = - TimePicker.MinuteIncrementProperty.AddOwner(); - - public static readonly StyledProperty SecondIncrementProperty = - TimePicker.SecondIncrementProperty.AddOwner(); - - public static readonly StyledProperty TimeProperty = - AvaloniaProperty.Register(nameof(Time)); - - public static readonly StyledProperty ClockIdentifierProperty = - TimePicker.ClockIdentifierProperty.AddOwner(); - - public int MinuteIncrement - { - get => GetValue(MinuteIncrementProperty); - set => SetValue(MinuteIncrementProperty, value); - } - - public int SecondIncrement - { - get => GetValue(SecondIncrementProperty); - set => SetValue(SecondIncrementProperty, value); - } - - public TimeSpan Time - { - get => GetValue(TimeProperty); - set => SetValue(TimeProperty, value); - } - - public ClockIdentifierType ClockIdentifier - { - get => GetValue(ClockIdentifierProperty); - set => SetValue(ClockIdentifierProperty, value); - } - - protected override Type StyleKeyOverride => typeof(TimePickerFlyoutPresenter); - - internal RangeTimePicker TimePickerRef { get; set; } - - private TimePickerPresenter? _timePickerPresenter; - private CompositeDisposable? _compositeDisposable; - private Button? _confirmButton; - private Button? _nowButton; - - public RangeTimePickerFlyoutPresenter(RangeTimePicker timePicker) - { - TimePickerRef = timePicker; - HorizontalAlignment = HorizontalAlignment.Left; - } - - protected override void OnApplyTemplate(TemplateAppliedEventArgs e) - { - base.OnApplyTemplate(e); - _timePickerPresenter = e.NameScope.Get(ArrowDecoratedBoxTheme.ContentPresenterPart); - _confirmButton = e.NameScope.Get