Fixing couple issues with context flyout and moving items.

This commit is contained in:
Burak Kaan Köse
2026-04-09 00:17:30 +02:00
parent d6049bbd88
commit 832a4b0348
6 changed files with 66 additions and 48 deletions
@@ -164,18 +164,17 @@ public partial class EventDetailsPageViewModel : CalendarBaseViewModel
CurrentSettings = _preferencesService.GetCurrentCalendarSettings();
IsDarkWebviewRenderer = _underlyingThemeService.IsUnderlyingThemeDark();
// Initialize Show As options
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.Free));
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.Tentative));
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.Busy));
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.OutOfOffice));
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.WorkingElsewhere));
SelectedShowAsOption = ShowAsOptions[2]; // Default to Busy
foreach (var showAs in CalendarItemActionOptions.ShowAsOptions)
{
ShowAsOptions.Add(new ShowAsOption(showAs));
}
// Initialize RSVP status options
RsvpStatusOptions.Add(new RsvpStatusOption(CalendarItemStatus.Accepted));
RsvpStatusOptions.Add(new RsvpStatusOption(CalendarItemStatus.Tentative));
RsvpStatusOptions.Add(new RsvpStatusOption(CalendarItemStatus.Cancelled));
SelectedShowAsOption = ShowAsOptions.FirstOrDefault(option => option.ShowAs == CalendarItemShowAs.Busy) ?? ShowAsOptions.FirstOrDefault();
foreach (var responseStatus in CalendarItemActionOptions.ResponseOptions)
{
RsvpStatusOptions.Add(new RsvpStatusOption(responseStatus));
}
}
public override async void OnNavigatedTo(NavigationMode mode, object parameters)
@@ -0,0 +1,23 @@
using System.Collections.Generic;
using Wino.Core.Domain.Enums;
namespace Wino.Core.Domain;
public static class CalendarItemActionOptions
{
public static IReadOnlyList<CalendarItemShowAs> ShowAsOptions { get; } =
[
CalendarItemShowAs.Free,
CalendarItemShowAs.Tentative,
CalendarItemShowAs.Busy,
CalendarItemShowAs.OutOfOffice,
CalendarItemShowAs.WorkingElsewhere
];
public static IReadOnlyList<CalendarItemStatus> ResponseOptions { get; } =
[
CalendarItemStatus.Accepted,
CalendarItemStatus.Tentative,
CalendarItemStatus.Cancelled
];
}
@@ -1,5 +1,6 @@
using System.Linq;
using FluentAssertions;
using Wino.Core.Domain;
using Wino.Core.Domain.Entities.Calendar;
using Wino.Core.Domain.Enums;
using Wino.Services;
@@ -30,15 +31,12 @@ public class CalendarContextMenuItemServiceTests
items.Should().NotContain(item => item.Action.ActionType == CalendarContextMenuActionType.Respond);
var showAsItem = items.Single(item => item.Action.ActionType == CalendarContextMenuActionType.ShowAs);
showAsItem.Children.Should().HaveCount(5);
showAsItem.Children.Should().HaveCount(CalendarItemActionOptions.ShowAsOptions.Count);
showAsItem.Children.Select(child => child.Action.ShowAs).Should().BeEquivalentTo(
[
CalendarItemShowAs.Free,
CalendarItemShowAs.Tentative,
CalendarItemShowAs.Busy,
CalendarItemShowAs.OutOfOffice,
CalendarItemShowAs.WorkingElsewhere
]);
CalendarItemActionOptions.ShowAsOptions);
var deleteItem = items.Single(item => item.Action.ActionType == CalendarContextMenuActionType.Delete);
deleteItem.Action.TargetType.Should().BeNull();
}
[Fact]
@@ -30,8 +30,10 @@
<Grid.ContextFlyout>
<local:CalendarItemCommandBarFlyout
AlwaysExpanded="True"
Item="{x:Bind CalendarItem, Mode=OneWay}"
Placement="Top" />
Placement="BottomEdgeAlignedLeft"
ShowMode="Transient" />
</Grid.ContextFlyout>
@@ -845,13 +845,13 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty
}
private void TimedViewportPointerMoved(object sender, PointerRoutedEventArgs e)
=> SetHoverTarget(ResolveTimedDropTarget(e.GetCurrentPoint(TimedViewport).Position, _activeDragPackage?.CalendarItemViewModel));
=> UpdateHoverTargetForActiveDrag(() => ResolveTimedDropTarget(e.GetCurrentPoint(TimedViewport).Position, _activeDragPackage?.CalendarItemViewModel));
private void TimedAllDayHostPointerMoved(object sender, PointerRoutedEventArgs e)
=> SetHoverTarget(ResolveTimedAllDayDropTarget(e.GetCurrentPoint(TimedAllDayHost).Position, _activeDragPackage?.CalendarItemViewModel));
=> UpdateHoverTargetForActiveDrag(() => ResolveTimedAllDayDropTarget(e.GetCurrentPoint(TimedAllDayHost).Position, _activeDragPackage?.CalendarItemViewModel));
private void MonthViewportPointerMoved(object sender, PointerRoutedEventArgs e)
=> SetHoverTarget(ResolveMonthDropTarget(e.GetCurrentPoint(MonthViewport).Position, _activeDragPackage?.CalendarItemViewModel));
=> UpdateHoverTargetForActiveDrag(() => ResolveMonthDropTarget(e.GetCurrentPoint(MonthViewport).Position, _activeDragPackage?.CalendarItemViewModel));
private void CalendarDropTargetPointerExited(object sender, PointerRoutedEventArgs e)
{
@@ -861,6 +861,17 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty
}
}
private void UpdateHoverTargetForActiveDrag(Func<CalendarDropTargetInfo?> resolveHoverTarget)
{
if (_activeDragPackage == null)
{
SetHoverTarget(null);
return;
}
SetHoverTarget(resolveHoverTarget());
}
private void TimedViewportDragOver(object sender, DragEventArgs e)
{
if (!TryGetDragPackage(e, out var dragPackage))
+10 -25
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Wino.Core.Domain;
using Wino.Core.Domain.Entities.Calendar;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Interfaces;
@@ -8,22 +9,6 @@ namespace Wino.Services;
public class CalendarContextMenuItemService : ICalendarContextMenuItemService
{
private static readonly IReadOnlyList<CalendarItemShowAs> ShowAsOptions =
[
CalendarItemShowAs.Free,
CalendarItemShowAs.Tentative,
CalendarItemShowAs.Busy,
CalendarItemShowAs.OutOfOffice,
CalendarItemShowAs.WorkingElsewhere
];
private static readonly IReadOnlyList<CalendarItemStatus> ResponseOptions =
[
CalendarItemStatus.Accepted,
CalendarItemStatus.Tentative,
CalendarItemStatus.Cancelled
];
public IReadOnlyList<CalendarContextMenuItem> GetContextMenuItems(CalendarItem calendarItem)
{
if (calendarItem == null)
@@ -66,12 +51,12 @@ public class CalendarContextMenuItemService : ICalendarContextMenuItemService
new CalendarContextMenuAction(CalendarContextMenuActionType.Delete),
IsPrimary: true,
ChildItems:
[
CreateScopeLeaf(CalendarContextMenuActionType.Delete, CalendarEventTargetType.Single),
CreateScopeLeaf(CalendarContextMenuActionType.Delete, CalendarEventTargetType.Series)
])
[
CreateScopeLeaf(CalendarContextMenuActionType.Delete, CalendarEventTargetType.Single),
CreateScopeLeaf(CalendarContextMenuActionType.Delete, CalendarEventTargetType.Series)
])
: new CalendarContextMenuItem(
new CalendarContextMenuAction(CalendarContextMenuActionType.Delete, CalendarEventTargetType.Single),
new CalendarContextMenuAction(CalendarContextMenuActionType.Delete),
IsPrimary: true);
private static CalendarContextMenuItem CreateShowAsItem(bool isRecurringChild)
@@ -102,9 +87,9 @@ public class CalendarContextMenuItemService : ICalendarContextMenuItemService
private static IReadOnlyList<CalendarContextMenuItem> CreateShowAsLeaves(CalendarEventTargetType targetType)
{
var items = new List<CalendarContextMenuItem>(ShowAsOptions.Count);
var items = new List<CalendarContextMenuItem>(CalendarItemActionOptions.ShowAsOptions.Count);
foreach (var showAs in ShowAsOptions)
foreach (var showAs in CalendarItemActionOptions.ShowAsOptions)
{
items.Add(new CalendarContextMenuItem(
new CalendarContextMenuAction(CalendarContextMenuActionType.ShowAs, targetType, showAs)));
@@ -115,9 +100,9 @@ public class CalendarContextMenuItemService : ICalendarContextMenuItemService
private static IReadOnlyList<CalendarContextMenuItem> CreateResponseLeaves(CalendarEventTargetType targetType)
{
var items = new List<CalendarContextMenuItem>(ResponseOptions.Count);
var items = new List<CalendarContextMenuItem>(CalendarItemActionOptions.ResponseOptions.Count);
foreach (var responseStatus in ResponseOptions)
foreach (var responseStatus in CalendarItemActionOptions.ResponseOptions)
{
items.Add(new CalendarContextMenuItem(
new CalendarContextMenuAction(CalendarContextMenuActionType.Respond, targetType, ResponseStatus: responseStatus)));