Bunch of interaction updates for the calendar item control.

This commit is contained in:
Burak Kaan Köse
2025-01-02 00:18:34 +01:00
parent 215dc6ea6d
commit 8a9265eb79
24 changed files with 333 additions and 102 deletions

File diff suppressed because one or more lines are too long

View File

@@ -3,6 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:abstract="using:Wino.Calendar.Views.Abstract"
xmlns:animations="using:CommunityToolkit.WinUI.Animations"
xmlns:calendarControls="using:Wino.Calendar.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:data="using:Wino.Calendar.ViewModels.Data"
@@ -15,12 +16,6 @@
mc:Ignorable="d">
<Page.Resources>
<!-- Teaching tip dialog sizing. -->
<x:Double x:Key="TeachingTipMinHeight">600</x:Double>
<x:Double x:Key="TeachingTipMaxHeight">600</x:Double>
<x:Double x:Key="TeachingTipMinWidth">600</x:Double>
<x:Double x:Key="TeachingTipMaxWidth">600</x:Double>
<CollectionViewSource
x:Key="GroupedCalendarEnumerableViewSource"
IsSourceGrouped="True"
@@ -28,11 +23,12 @@
</Page.Resources>
<Border
Margin="0,0,7,7"
Margin="4,0,7,7"
BorderBrush="{StaticResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="7">
<Grid>
<!-- Calendar control -->
<calendarControls:WinoCalendarControl
x:Name="CalendarControl"
DayRanges="{x:Bind ViewModel.DayRanges}"
@@ -42,6 +38,7 @@
TimelineCellSelected="CellSelected"
TimelineCellUnselected="CellUnselected" />
<!-- Popup canvas -->
<Canvas x:Name="CalendarOverlayCanvas" IsHitTestVisible="False">
<!-- Invisible target UI element for teaching tip display. -->
<Grid
@@ -50,13 +47,14 @@
IsHitTestVisible="False"
Visibility="Visible" />
<!-- Single popup to display create event dialog. -->
<!-- Popup to display create event dialog. -->
<Popup
x:Name="QuickEventPopupDialog"
ActualPlacementChanged="QuickEventPopupPlacementChanged"
ActualPlacementChanged="PopupPlacementChanged"
Closed="QuickEventPopupClosed"
DesiredPlacement="{x:Bind helpers:XamlHelpers.GetPlaccementModeForCalendarType(ViewModel.StatePersistanceService.CalendarDisplayType), Mode=OneWay}"
HorizontalOffset="16"
IsLightDismissEnabled="True"
IsOpen="{x:Bind ViewModel.IsQuickEventDialogOpen, Mode=TwoWay}"
PlacementTarget="{x:Bind TeachingTipPositionerGrid}"
VerticalOffset="16">
@@ -207,18 +205,20 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<PathIcon
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="F1 M 7.900391 17.5 C 8.011067 17.721354 8.129883 17.936197 8.256836 18.144531 C 8.383789 18.352865 8.522135 18.554688 8.671875 18.75 L 4.921875 18.75 C 4.433594 18.75 3.966471 18.650717 3.520508 18.452148 C 3.074544 18.25358 2.683919 17.986654 2.348633 17.651367 C 2.013346 17.31608 1.746419 16.925455 1.547852 16.479492 C 1.349284 16.033529 1.25 15.566406 1.25 15.078125 L 1.25 4.921875 C 1.25 4.433594 1.349284 3.966473 1.547852 3.520508 C 1.746419 3.074545 2.013346 2.68392 2.348633 2.348633 C 2.683919 2.013348 3.074544 1.74642 3.520508 1.547852 C 3.966471 1.349285 4.433594 1.25 4.921875 1.25 L 15.078125 1.25 C 15.566406 1.25 16.033527 1.349285 16.479492 1.547852 C 16.925455 1.74642 17.31608 2.013348 17.651367 2.348633 C 17.986652 2.68392 18.25358 3.074545 18.452148 3.520508 C 18.650715 3.966473 18.75 4.433594 18.75 4.921875 L 18.75 8.671875 C 18.554688 8.522136 18.352863 8.383789 18.144531 8.256836 C 17.936197 8.129883 17.721354 8.011068 17.5 7.900391 L 17.5 6.25 L 2.5 6.25 L 2.5 15.048828 C 2.5 15.38737 2.568359 15.704753 2.705078 16.000977 C 2.841797 16.297201 3.024088 16.55599 3.251953 16.777344 C 3.479818 16.998697 3.745117 17.174479 4.047852 17.304688 C 4.350586 17.434896 4.667969 17.5 5 17.5 Z M 4.951172 2.5 C 4.619141 2.5 4.303385 2.568359 4.003906 2.705078 C 3.704427 2.841797 3.44401 3.02409 3.222656 3.251953 C 3.001302 3.479818 2.825521 3.745117 2.695312 4.047852 C 2.565104 4.350587 2.5 4.66797 2.5 5 L 17.5 5 L 17.5 4.951172 C 17.5 4.625651 17.433268 4.314779 17.299805 4.018555 C 17.16634 3.722332 16.987305 3.461914 16.762695 3.237305 C 16.538086 3.012695 16.277668 2.83366 15.981445 2.700195 C 15.685221 2.566732 15.374349 2.5 15.048828 2.5 Z M 20 14.375 C 20 15.14974 19.851887 15.878906 19.555664 16.5625 C 19.259439 17.246094 18.857422 17.841797 18.349609 18.349609 C 17.841797 18.857422 17.246094 19.259439 16.5625 19.555664 C 15.878906 19.851889 15.149739 20 14.375 20 C 13.59375 20 12.861328 19.853516 12.177734 19.560547 C 11.494141 19.267578 10.898438 18.867188 10.390625 18.359375 C 9.882812 17.851562 9.482422 17.255859 9.189453 16.572266 C 8.896484 15.888672 8.75 15.15625 8.75 14.375 C 8.75 13.600261 8.898111 12.871094 9.194336 12.1875 C 9.49056 11.503906 9.892578 10.908203 10.400391 10.400391 C 10.908203 9.892578 11.503906 9.490561 12.1875 9.194336 C 12.871093 8.898112 13.60026 8.75 14.375 8.75 C 14.889322 8.75 15.385741 8.816732 15.864258 8.950195 C 16.342773 9.083659 16.790363 9.272461 17.207031 9.516602 C 17.623697 9.760742 18.004557 10.055339 18.349609 10.400391 C 18.69466 10.745443 18.989258 11.126303 19.233398 11.542969 C 19.477539 11.959636 19.66634 12.407227 19.799805 12.885742 C 19.933268 13.364258 20 13.860678 20 14.375 Z M 16.25 15 C 16.41927 15 16.565754 14.938151 16.689453 14.814453 C 16.81315 14.690756 16.875 14.544271 16.875 14.375 C 16.875 14.205729 16.81315 14.059245 16.689453 13.935547 C 16.565754 13.81185 16.41927 13.75 16.25 13.75 L 15 13.75 L 15 11.875 C 14.999999 11.705729 14.93815 11.559245 14.814453 11.435547 C 14.690755 11.31185 14.544271 11.25 14.375 11.25 C 14.205729 11.25 14.059244 11.31185 13.935547 11.435547 C 13.811849 11.559245 13.75 11.705729 13.75 11.875 L 13.75 14.375 C 13.75 14.544271 13.811849 14.690756 13.935547 14.814453 C 14.059244 14.938151 14.205729 15 14.375 15 Z " />
<ComboBox
Grid.Column="1"
HorizontalAlignment="Stretch"
TextSubmitted="ComboBox_TextSubmitted"
IsEditable="True"
IsEnabled="{x:Bind helpers:XamlHelpers.ReverseBoolConverter(ViewModel.IsAllDay), Mode=OneWay}"
ItemsSource="{x:Bind ViewModel.HourSelectionStrings, Mode=OneWay}"
SelectedItem="{x:Bind ViewModel.SelectedStartTimeString, Mode=TwoWay}" />
SelectedItem="{x:Bind ViewModel.SelectedStartTimeString, Mode=TwoWay}"
TextSubmitted="StartTimeDurationSubmitted" />
<TextBlock
Grid.Column="2"
@@ -231,7 +231,8 @@
IsEditable="True"
IsEnabled="{x:Bind helpers:XamlHelpers.ReverseBoolConverter(ViewModel.IsAllDay), Mode=OneWay}"
ItemsSource="{x:Bind ViewModel.HourSelectionStrings, Mode=OneWay}"
SelectedItem="{x:Bind ViewModel.SelectedEndTimeString, Mode=TwoWay}" />
SelectedItem="{x:Bind ViewModel.SelectedEndTimeString, Mode=TwoWay}"
TextSubmitted="EndTimeDurationSubmitted" />
</Grid>
<!-- Location -->
@@ -281,26 +282,8 @@
Style="{ThemeResource AccentButtonStyle}" />
</Grid>
</Grid>
<!-- Create events dialog -->
<!--<Button
x:Name="AddEvent"
Grid.Row="1"
Click="AddEventClicked"
Content="Add Event" />-->
</Grid>
</Popup>
<!--<muxc:TeachingTip
x:Name="NewEventTip"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
Target="{x:Bind TeachingTipPositionerGrid}">
</muxc:TeachingTip>-->
</Canvas>
</Grid>
</Border>

View File

@@ -1,8 +1,10 @@
using System;
using CommunityToolkit.Mvvm.Messaging;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Navigation;
using Wino.Calendar.Args;
using Wino.Calendar.ViewModels.Messages;
using Wino.Calendar.Views.Abstract;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Models.Calendar;
@@ -13,7 +15,8 @@ namespace Wino.Calendar.Views
public sealed partial class CalendarPage : CalendarPageAbstract,
IRecipient<ScrollToDateMessage>,
IRecipient<GoNextDateRequestedMessage>,
IRecipient<GoPreviousDateRequestedMessage>
IRecipient<GoPreviousDateRequestedMessage>,
IRecipient<CalendarItemRightTappedMessage>
{
private const int PopupDialogOffset = 12;
@@ -83,34 +86,44 @@ namespace Wino.Calendar.Views
CalendarControl.ResetTimelineSelection();
}
private void QuickEventPopupPlacementChanged(object sender, object e)
private void PopupPlacementChanged(object sender, object e)
{
// When the quick event Popup is positioned for different calendar types,
// we must adjust the offset to make sure the tip is not hidden and has nice
// spacing from the cell.
switch (QuickEventPopupDialog.ActualPlacement)
if (sender is Popup senderPopup)
{
case Windows.UI.Xaml.Controls.Primitives.PopupPlacementMode.Top:
QuickEventPopupDialog.VerticalOffset = PopupDialogOffset * -1;
break;
case Windows.UI.Xaml.Controls.Primitives.PopupPlacementMode.Bottom:
QuickEventPopupDialog.VerticalOffset = PopupDialogOffset;
break;
case Windows.UI.Xaml.Controls.Primitives.PopupPlacementMode.Left:
QuickEventPopupDialog.HorizontalOffset = PopupDialogOffset * -1;
break;
case Windows.UI.Xaml.Controls.Primitives.PopupPlacementMode.Right:
QuickEventPopupDialog.HorizontalOffset = PopupDialogOffset;
break;
default:
break;
// When the quick event Popup is positioned for different calendar types,
// we must adjust the offset to make sure the tip is not hidden and has nice
// spacing from the cell.
switch (senderPopup.ActualPlacement)
{
case PopupPlacementMode.Top:
senderPopup.VerticalOffset = PopupDialogOffset * -1;
break;
case PopupPlacementMode.Bottom:
senderPopup.VerticalOffset = PopupDialogOffset;
break;
case PopupPlacementMode.Left:
senderPopup.HorizontalOffset = PopupDialogOffset * -1;
break;
case PopupPlacementMode.Right:
senderPopup.HorizontalOffset = PopupDialogOffset;
break;
default:
break;
}
}
}
private void ComboBox_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
public void Receive(CalendarItemRightTappedMessage message)
{
ViewModel.SelectedStartTimeString = args.Text;
}
private void StartTimeDurationSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
=> ViewModel.SelectedStartTimeString = args.Text;
private void EndTimeDurationSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
=> ViewModel.SelectedEndTimeString = args.Text;
}
}