New quick event dialog using Popup.

This commit is contained in:
Burak Kaan Köse
2025-01-01 19:17:54 +01:00
parent 1c79d14260
commit 428dcb2348
5 changed files with 296 additions and 268 deletions

View File

@@ -648,6 +648,11 @@ namespace Wino.Calendar.ViewModels
} }
} }
partial void OnSelectedQuickEventDateChanged(DateTime? value)
{
}
partial void OnSelectedStartTimeStringChanged(string newValue) partial void OnSelectedStartTimeStringChanged(string newValue)
{ {
var parsedTime = _currentSettings.GetTimeSpan(newValue); var parsedTime = _currentSettings.GetTimeSpan(newValue);

View File

@@ -16,8 +16,10 @@
<Page.Resources> <Page.Resources>
<!-- Teaching tip dialog sizing. --> <!-- Teaching tip dialog sizing. -->
<x:Double x:Key="TeachingTipMinWidth">900</x:Double> <x:Double x:Key="TeachingTipMinHeight">600</x:Double>
<x:Double x:Key="TeachingTipMaxWidth">900</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 <CollectionViewSource
x:Key="GroupedCalendarEnumerableViewSource" x:Key="GroupedCalendarEnumerableViewSource"
@@ -45,41 +47,40 @@
<Grid <Grid
x:Name="TeachingTipPositionerGrid" x:Name="TeachingTipPositionerGrid"
Background="Transparent" Background="Transparent"
IsHitTestVisible="False"
Visibility="Visible" /> Visibility="Visible" />
<!-- Single teaching tip to display create event dialog. --> <!-- Single popup to display create event dialog. -->
<muxc:TeachingTip <Popup
x:Name="NewEventTip" x:Name="QuickEventPopupDialog"
HorizontalContentAlignment="Stretch" ActualPlacementChanged="QuickEventPopupPlacementChanged"
VerticalContentAlignment="Stretch" Closed="QuickEventPopupClosed"
Closed="CreateEventTipClosed" DesiredPlacement="{x:Bind helpers:XamlHelpers.GetPlaccementModeForCalendarType(ViewModel.StatePersistanceService.CalendarDisplayType), Mode=OneWay}"
HorizontalOffset="16"
IsOpen="{x:Bind ViewModel.IsQuickEventDialogOpen, Mode=TwoWay}" IsOpen="{x:Bind ViewModel.IsQuickEventDialogOpen, Mode=TwoWay}"
PreferredPlacement="{x:Bind helpers:XamlHelpers.GetPlaccementModeForCalendarType(ViewModel.StatePersistanceService.CalendarDisplayType), Mode=OneWay}" PlacementTarget="{x:Bind TeachingTipPositionerGrid}"
Target="{x:Bind TeachingTipPositionerGrid}"> VerticalOffset="16">
<Popup.ChildTransitions>
<TransitionCollection>
<PopupThemeTransition />
</TransitionCollection>
</Popup.ChildTransitions>
<muxc:TeachingTip.Content>
<Grid <Grid
Margin="-12" MinWidth="500"
Padding="6,3,6,6" MinHeight="300"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
BorderBrush="{x:Bind helpers:XamlHelpers.GetSolidColorBrushFromHex(ViewModel.SelectedQuickEventAccountCalendar.BackgroundColorHex), Mode=OneWay, TargetNullValue='LightGray'}"
BorderThickness="1"
CornerRadius="8"
RowSpacing="12"> RowSpacing="12">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="32" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="32" />
</Grid.ColumnDefinitions>
<!-- Title background -->
<Grid
Grid.ColumnSpan="2"
Margin="-6,-3,-6,-6"
Background="{x:Bind helpers:XamlHelpers.GetSolidColorBrushFromHex(ViewModel.SelectedQuickEventAccountCalendar.BackgroundColorHex), Mode=OneWay, TargetNullValue='LightGray'}" />
<!-- Title and close button area. --> <!-- Title and close button area. -->
<Grid VerticalAlignment="Top" ColumnSpacing="6"> <Grid VerticalAlignment="Top" Background="{x:Bind helpers:XamlHelpers.GetSolidColorBrushFromHex(ViewModel.SelectedQuickEventAccountCalendar.BackgroundColorHex), Mode=OneWay, TargetNullValue='LightGray'}">
<Button <Button
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
@@ -87,22 +88,27 @@
VerticalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
Background="Transparent"> Background="Transparent">
<Button.Content> <Button.Content>
<Grid ColumnSpacing="12"> <Grid Height="30" ColumnSpacing="12">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Foreground="{x:Bind helpers:XamlHelpers.GetReadableTextColor(ViewModel.SelectedQuickEventAccountCalendar.BackgroundColorHex), Mode=OneWay}" Text="{x:Bind ViewModel.SelectedQuickEventAccountCalendar.Account.Name, Mode=OneWay}" /> <TextBlock
VerticalAlignment="Center"
Foreground="{x:Bind helpers:XamlHelpers.GetReadableTextColor(ViewModel.SelectedQuickEventAccountCalendar.BackgroundColorHex), Mode=OneWay}"
Text="{x:Bind ViewModel.SelectedQuickEventAccountCalendar.Account.Name, Mode=OneWay}" />
<TextBlock <TextBlock
Grid.Column="1" Grid.Column="1"
HorizontalAlignment="Right" HorizontalAlignment="Stretch"
VerticalAlignment="Center"
FontWeight="SemiBold" FontWeight="SemiBold"
Foreground="{x:Bind helpers:XamlHelpers.GetReadableTextColor(ViewModel.SelectedQuickEventAccountCalendar.BackgroundColorHex), Mode=OneWay}" Foreground="{x:Bind helpers:XamlHelpers.GetReadableTextColor(ViewModel.SelectedQuickEventAccountCalendar.BackgroundColorHex), Mode=OneWay}"
Text="{x:Bind ViewModel.SelectedQuickEventAccountCalendarName, Mode=OneWay}" Text="{x:Bind ViewModel.SelectedQuickEventAccountCalendarName, Mode=OneWay}"
TextTrimming="CharacterEllipsis" /> TextTrimming="CharacterEllipsis" />
<Viewbox Grid.Column="2" Width="12"> <Viewbox Grid.Column="2" Width="14">
<PathIcon <PathIcon
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
@@ -121,7 +127,10 @@
SelectionChanged="QuickEventAccountSelectorSelectionChanged"> SelectionChanged="QuickEventAccountSelectorSelectionChanged">
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate x:DataType="data:AccountCalendarViewModel"> <DataTemplate x:DataType="data:AccountCalendarViewModel">
<StackPanel Orientation="Horizontal" Spacing="6"> <StackPanel
Margin="0,0,16,0"
Orientation="Horizontal"
Spacing="6">
<Ellipse <Ellipse
Width="16" Width="16"
Height="16" Height="16"
@@ -141,7 +150,7 @@
<GroupStyle.HeaderTemplate> <GroupStyle.HeaderTemplate>
<DataTemplate> <DataTemplate>
<TextBlock <TextBlock
FontSize="16" FontSize="14"
FontWeight="SemiBold" FontWeight="SemiBold"
Text="{Binding Key.Name}" /> Text="{Binding Key.Name}" />
</DataTemplate> </DataTemplate>
@@ -157,9 +166,8 @@
<!-- Rest of the content --> <!-- Rest of the content -->
<Grid <Grid
Grid.Row="1" Grid.Row="1"
Grid.ColumnSpan="2" Padding="12"
Padding="0,6,6,6" RowSpacing="20">
RowSpacing="12">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@@ -206,6 +214,7 @@
<ComboBox <ComboBox
Grid.Column="1" Grid.Column="1"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
TextSubmitted="ComboBox_TextSubmitted"
IsEditable="True" IsEditable="True"
IsEnabled="{x:Bind helpers:XamlHelpers.ReverseBoolConverter(ViewModel.IsAllDay), Mode=OneWay}" IsEnabled="{x:Bind helpers:XamlHelpers.ReverseBoolConverter(ViewModel.IsAllDay), Mode=OneWay}"
ItemsSource="{x:Bind ViewModel.HourSelectionStrings, Mode=OneWay}" ItemsSource="{x:Bind ViewModel.HourSelectionStrings, Mode=OneWay}"
@@ -249,7 +258,7 @@
<PathIcon <PathIcon
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Data="F1 M 17.050781 4.794922 C 17.20052 5.192058 17.312824 5.598959 17.387695 6.015625 C 17.462564 6.432293 17.5 6.85547 17.5 7.285156 C 17.5 8.144531 17.35026 8.972982 17.050781 9.770508 C 16.751301 10.568034 16.324869 11.292318 15.771484 11.943359 C 15.660807 12.073568 15.545247 12.195639 15.424805 12.30957 C 15.304361 12.423503 15.182291 12.542318 15.058594 12.666016 C 14.941405 12.776693 14.835611 12.897136 14.741211 13.027344 C 14.64681 13.157553 14.580078 13.304037 14.541016 13.466797 L 13.447266 18.076172 C 13.382161 18.362631 13.273111 18.623047 13.120117 18.857422 C 12.967121 19.091797 12.783202 19.293619 12.568359 19.462891 C 12.353515 19.632162 12.114257 19.763998 11.850586 19.858398 C 11.586914 19.952799 11.308594 20 11.015625 20 L 8.984375 20 C 8.691406 20 8.413086 19.952799 8.149414 19.858398 C 7.885742 19.763998 7.646484 19.632162 7.431641 19.462891 C 7.216797 19.293619 7.032877 19.091797 6.879883 18.857422 C 6.726888 18.623047 6.617838 18.362631 6.552734 18.076172 L 5.439453 13.447266 C 5.39388 13.271484 5.330403 13.126628 5.249023 13.012695 C 5.167643 12.898764 5.061849 12.779948 4.931641 12.65625 C 4.807942 12.539062 4.685872 12.421875 4.56543 12.304688 C 4.444987 12.1875 4.329427 12.063803 4.21875 11.933594 C 3.665365 11.282553 3.24056 10.559896 2.944336 9.765625 C 2.648112 8.971354 2.5 8.144531 2.5 7.285156 C 2.5 6.601563 2.591146 5.945639 2.773438 5.317383 C 2.955729 4.689128 3.21289 4.104818 3.544922 3.564453 C 3.876953 3.02409 4.272461 2.53418 4.731445 2.094727 C 5.19043 1.655273 5.698242 1.280926 6.254883 0.97168 C 6.811523 0.662436 7.405599 0.423178 8.037109 0.253906 C 8.668619 0.084637 9.322916 0 10 0 C 10.774739 0 11.531575 0.113934 12.270508 0.341797 C 13.009439 0.569662 13.701172 0.904949 14.345703 1.347656 C 14.176432 1.477865 14.016926 1.621094 13.867188 1.777344 C 13.717447 1.933594 13.567708 2.08659 13.417969 2.236328 C 12.910155 1.904297 12.364908 1.656902 11.782227 1.494141 C 11.199544 1.331381 10.605469 1.25 10 1.25 C 9.440104 1.25 8.898111 1.319988 8.374023 1.459961 C 7.849935 1.599936 7.356771 1.798504 6.894531 2.055664 C 6.432292 2.312826 6.007487 2.623699 5.620117 2.988281 C 5.232747 3.352865 4.900716 3.758139 4.624023 4.204102 C 4.347331 4.650065 4.132487 5.133464 3.979492 5.654297 C 3.826497 6.175131 3.75 6.718751 3.75 7.285156 C 3.75 8.170573 3.924153 8.982748 4.272461 9.72168 C 4.620768 10.460612 5.117188 11.129558 5.761719 11.728516 C 5.989583 11.93685 6.178385 12.151693 6.328125 12.373047 C 6.477864 12.594401 6.588542 12.858073 6.660156 13.164062 C 6.699219 13.320312 6.735026 13.473308 6.767578 13.623047 L 6.992188 14.53125 C 7.03125 14.6875 7.067057 14.84375 7.099609 15 L 12.900391 15 L 13.330078 13.173828 C 13.401692 12.867839 13.512369 12.604167 13.662109 12.382812 C 13.811848 12.161459 14.00065 11.946615 14.228516 11.738281 C 14.879557 11.139323 15.37923 10.470378 15.727539 9.731445 C 16.075846 8.992514 16.25 8.177084 16.25 7.285156 C 16.25 6.790365 16.184895 6.292318 16.054688 5.791016 Z M 9.375 8.486328 L 15.185547 2.685547 C 15.309244 2.56185 15.455729 2.5 15.625 2.5 C 15.79427 2.5 15.940754 2.56185 16.064453 2.685547 C 16.18815 2.809246 16.25 2.95573 16.25 3.125 C 16.25 3.294271 16.18815 3.440756 16.064453 3.564453 L 9.814453 9.814453 C 9.690755 9.938151 9.544271 10 9.375 10 C 9.205729 10 9.059244 9.938151 8.935547 9.814453 L 6.435547 7.314453 C 6.311849 7.190756 6.25 7.044271 6.25 6.875 C 6.25 6.705729 6.311849 6.559245 6.435547 6.435547 C 6.559244 6.31185 6.705729 6.25 6.875 6.25 C 7.044271 6.25 7.190755 6.31185 7.314453 6.435547 Z M 11.015625 18.75 C 11.302083 18.75 11.559244 18.660482 11.787109 18.481445 C 12.014973 18.302408 12.164713 18.072916 12.236328 17.792969 C 12.301432 17.532553 12.36328 17.275391 12.421875 17.021484 C 12.480468 16.767578 12.539062 16.510416 12.597656 16.25 L 7.392578 16.25 C 7.42513 16.380209 7.457682 16.510416 7.490234 16.640625 L 7.666016 17.402344 C 7.698567 17.532553 7.73112 17.66276 7.763672 17.792969 C 7.835286 18.072916 7.983398 18.302408 8.208008 18.481445 C 8.432617 18.660482 8.691406 18.75 8.984375 18.75 Z " /> Data="F1 M 10 1.25 C 10.572916 1.25 11.126302 1.324871 11.660156 1.474609 C 12.19401 1.62435 12.692057 1.834311 13.154297 2.104492 C 13.616536 2.374676 14.038086 2.700195 14.418945 3.081055 C 14.799805 3.461914 15.125325 3.883465 15.395508 4.345703 C 15.665689 4.807943 15.87565 5.30599 16.025391 5.839844 C 16.175129 6.373699 16.25 6.927084 16.25 7.5 L 16.25 12.099609 L 17.871094 14.248047 C 17.949219 14.358725 18.011066 14.477539 18.056641 14.604492 C 18.102213 14.731445 18.125 14.860026 18.125 14.990234 C 18.125 15.166016 18.092447 15.330404 18.027344 15.483398 C 17.962238 15.636394 17.872721 15.769857 17.758789 15.883789 C 17.644855 15.997722 17.511393 16.08724 17.358398 16.152344 C 17.205402 16.217449 17.041016 16.25 16.865234 16.25 L 13.066406 16.25 C 12.98828 16.614584 12.854816 16.949869 12.666016 17.255859 C 12.477213 17.56185 12.247721 17.825521 11.977539 18.046875 C 11.707356 18.268229 11.402994 18.440756 11.064453 18.564453 C 10.725911 18.68815 10.371094 18.75 10 18.75 C 9.628906 18.75 9.274088 18.68815 8.935547 18.564453 C 8.597005 18.440756 8.292643 18.268229 8.022461 18.046875 C 7.752278 17.825521 7.522786 17.56185 7.333984 17.255859 C 7.145182 16.949869 7.011719 16.614584 6.933594 16.25 L 3.134766 16.25 C 2.958984 16.25 2.794596 16.217449 2.641602 16.152344 C 2.488607 16.08724 2.355143 15.997722 2.241211 15.883789 C 2.127279 15.769857 2.03776 15.636394 1.972656 15.483398 C 1.907552 15.330404 1.875 15.166016 1.875 14.990234 C 1.875 14.860026 1.897786 14.731445 1.943359 14.604492 C 1.988932 14.477539 2.050781 14.358725 2.128906 14.248047 L 3.75 12.099609 L 3.75 7.5 C 3.75 6.927084 3.82487 6.373699 3.974609 5.839844 C 4.124349 5.30599 4.33431 4.807943 4.604492 4.345703 C 4.874674 3.883465 5.200195 3.461914 5.581055 3.081055 C 5.961914 2.700195 6.383463 2.374676 6.845703 2.104492 C 7.307942 1.834311 7.805989 1.62435 8.339844 1.474609 C 8.873697 1.324871 9.427083 1.25 10 1.25 Z M 10 2.5 C 9.309896 2.5 8.660481 2.630209 8.051758 2.890625 C 7.443034 3.151043 6.912435 3.507488 6.459961 3.959961 C 6.007487 4.412436 5.651042 4.943034 5.390625 5.551758 C 5.130208 6.160482 5 6.809896 5 7.5 L 5 12.207031 C 5 12.304688 4.983724 12.403972 4.951172 12.504883 C 4.91862 12.605795 4.873047 12.695312 4.814453 12.773438 L 3.134766 15 L 16.865234 15 L 15.185547 12.773438 C 15.126953 12.695312 15.08138 12.605795 15.048828 12.504883 C 15.016275 12.403972 14.999999 12.304688 15 12.207031 L 15 7.5 C 14.999999 6.809896 14.869791 6.160482 14.609375 5.551758 C 14.348958 4.943034 13.992513 4.412436 13.540039 3.959961 C 13.087564 3.507488 12.556965 3.151043 11.948242 2.890625 C 11.339518 2.630209 10.690104 2.5 10 2.5 Z M 8.232422 16.25 C 8.297525 16.438803 8.388672 16.609701 8.505859 16.762695 C 8.623047 16.915689 8.759766 17.047525 8.916016 17.158203 C 9.072266 17.268881 9.243164 17.353516 9.428711 17.412109 C 9.614258 17.470703 9.804688 17.5 10 17.5 C 10.195312 17.5 10.385742 17.470703 10.571289 17.412109 C 10.756836 17.353516 10.927734 17.268881 11.083984 17.158203 C 11.240234 17.047525 11.376953 16.915689 11.494141 16.762695 C 11.611328 16.609701 11.702474 16.438803 11.767578 16.25 Z " />
<ComboBox Grid.Column="1" HorizontalAlignment="Stretch" /> <ComboBox Grid.Column="1" HorizontalAlignment="Stretch" />
</Grid> </Grid>
@@ -281,8 +290,17 @@
Content="Add Event" />--> Content="Add Event" />-->
</Grid> </Grid>
</muxc:TeachingTip.Content> </Popup>
</muxc:TeachingTip>
<!--<muxc:TeachingTip
x:Name="NewEventTip"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
Target="{x:Bind TeachingTipPositionerGrid}">
</muxc:TeachingTip>-->
</Canvas> </Canvas>
</Grid> </Grid>
</Border> </Border>

View File

@@ -1,11 +1,9 @@
using System; using System;
using CommunityToolkit.Mvvm.Messaging; using CommunityToolkit.Mvvm.Messaging;
using Microsoft.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation; using Windows.UI.Xaml.Navigation;
using Wino.Calendar.Args; using Wino.Calendar.Args;
using Wino.Calendar.Views.Abstract; using Wino.Calendar.Views.Abstract;
using Wino.Core.Domain.Entities.Calendar;
using Wino.Core.Domain.Enums; using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Models.Calendar; using Wino.Core.Domain.Models.Calendar;
using Wino.Messaging.Client.Calendar; using Wino.Messaging.Client.Calendar;
@@ -15,9 +13,10 @@ namespace Wino.Calendar.Views
public sealed partial class CalendarPage : CalendarPageAbstract, public sealed partial class CalendarPage : CalendarPageAbstract,
IRecipient<ScrollToDateMessage>, IRecipient<ScrollToDateMessage>,
IRecipient<GoNextDateRequestedMessage>, IRecipient<GoNextDateRequestedMessage>,
IRecipient<GoPreviousDateRequestedMessage>, IRecipient<GoPreviousDateRequestedMessage>
IRecipient<CalendarDisplayTypeChangedMessage>
{ {
private const int PopupDialogOffset = 12;
public CalendarPage() public CalendarPage()
{ {
InitializeComponent(); InitializeComponent();
@@ -51,7 +50,6 @@ namespace Wino.Calendar.Views
private void CellSelected(object sender, TimelineCellSelectedArgs e) private void CellSelected(object sender, TimelineCellSelectedArgs e)
{ {
// Selected date is in Local kind.
ViewModel.SelectedQuickEventDate = e.ClickedDate; ViewModel.SelectedQuickEventDate = e.ClickedDate;
TeachingTipPositionerGrid.Width = e.CellSize.Width; TeachingTipPositionerGrid.Width = e.CellSize.Width;
@@ -60,39 +58,18 @@ namespace Wino.Calendar.Views
Canvas.SetLeft(TeachingTipPositionerGrid, e.PositionerPoint.X); Canvas.SetLeft(TeachingTipPositionerGrid, e.PositionerPoint.X);
Canvas.SetTop(TeachingTipPositionerGrid, e.PositionerPoint.Y); Canvas.SetTop(TeachingTipPositionerGrid, e.PositionerPoint.Y);
var testCalendarItem = new CalendarItem
{
CalendarId = Guid.Parse("9ead7613-dacb-4163-8d33-2e32e65008a1"),
StartDate = ViewModel.SelectedQuickEventDate.Value,
DurationInSeconds = TimeSpan.FromMinutes(30).TotalSeconds,
CreatedAt = DateTime.UtcNow,
Description = "Test Description",
Location = "Poland",
Title = "Test event",
Id = Guid.NewGuid()
};
// Adjust the start and end time in the flyout. // Adjust the start and end time in the flyout.
var startTime = ViewModel.SelectedQuickEventDate.Value.TimeOfDay; var startTime = ViewModel.SelectedQuickEventDate.Value.TimeOfDay;
var endTime = startTime.Add(TimeSpan.FromMinutes(30)); var endTime = startTime.Add(TimeSpan.FromMinutes(30));
ViewModel.SelectQuickEventTimeRange(startTime, endTime); ViewModel.SelectQuickEventTimeRange(startTime, endTime);
// WeakReferenceMessenger.Default.Send(new CalendarEventAdded(testCalendarItem)); QuickEventPopupDialog.IsOpen = true;
NewEventTip.IsOpen = true;
} }
private void CellUnselected(object sender, TimelineCellUnselectedArgs e) private void CellUnselected(object sender, TimelineCellUnselectedArgs e)
{ {
NewEventTip.IsOpen = false; QuickEventPopupDialog.IsOpen = false;
ViewModel.SelectedQuickEventDate = null;
}
private void CreateEventTipClosed(TeachingTip sender, TeachingTipClosedEventArgs args)
{
// Reset the timeline selection when the tip is closed.
CalendarControl.ResetTimelineSelection();
} }
private void QuickEventAccountSelectorSelectionChanged(object sender, SelectionChangedEventArgs e) private void QuickEventAccountSelectorSelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -100,12 +77,40 @@ namespace Wino.Calendar.Views
QuickEventAccountSelectorFlyout.Hide(); QuickEventAccountSelectorFlyout.Hide();
} }
public void Receive(CalendarDisplayTypeChangedMessage message) private void QuickEventPopupClosed(object sender, object e)
{ {
// It makes sense to show the quick event flyout horizontally for week view. // Reset the timeline selection when the tip is closed.
// But for daily view, it should be vertical. CalendarControl.ResetTimelineSelection();
}
NewEventTip.PreferredPlacement = message.NewDisplayType == CalendarDisplayType.Day ? TeachingTipPlacementMode.Top : TeachingTipPlacementMode.Right; private void QuickEventPopupPlacementChanged(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)
{
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;
}
}
private void ComboBox_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
{
ViewModel.SelectedStartTimeString = args.Text;
} }
} }
} }

View File

@@ -15,14 +15,11 @@ namespace Wino.Core.Domain.Models.Calendar
{ {
public TimeSpan? GetTimeSpan(string selectedTime) public TimeSpan? GetTimeSpan(string selectedTime)
{ {
var format = DayHeaderDisplayType switch // Regardless of the format, we need to parse the time to a TimeSpan.
{ // User may list as 14:00 but enters 2:00 PM by input.
DayHeaderDisplayType.TwelveHour => "h:mm tt", // Be flexible, not annoying.
DayHeaderDisplayType.TwentyFourHour => "HH:mm",
_ => throw new ArgumentOutOfRangeException(nameof(DayHeaderDisplayType))
};
if (DateTime.TryParseExact(selectedTime, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime parsedTime)) if (DateTime.TryParse(selectedTime, out DateTime parsedTime))
{ {
return parsedTime.TimeOfDay; return parsedTime.TimeOfDay;
} }
@@ -34,6 +31,9 @@ namespace Wino.Core.Domain.Models.Calendar
public string GetTimeString(TimeSpan timeSpan) public string GetTimeString(TimeSpan timeSpan)
{ {
// Here we don't need to be flexible cuz we're saving back the value to the combos.
// They are populated based on the format and must be returned with the format.
var format = DayHeaderDisplayType switch var format = DayHeaderDisplayType switch
{ {
DayHeaderDisplayType.TwelveHour => "h:mm tt", DayHeaderDisplayType.TwelveHour => "h:mm tt",
@@ -41,7 +41,6 @@ namespace Wino.Core.Domain.Models.Calendar
_ => throw new ArgumentOutOfRangeException(nameof(DayHeaderDisplayType)) _ => throw new ArgumentOutOfRangeException(nameof(DayHeaderDisplayType))
}; };
var dateTime = DateTime.Today.Add(timeSpan); var dateTime = DateTime.Today.Add(timeSpan);
return dateTime.ToString(format, CultureInfo.InvariantCulture); return dateTime.ToString(format, CultureInfo.InvariantCulture);
} }

View File

@@ -7,6 +7,7 @@ using Windows.UI;
using Windows.UI.Text; using Windows.UI.Text;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Markup; using Windows.UI.Xaml.Markup;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
using Wino.Core.Domain; using Wino.Core.Domain;
@@ -27,12 +28,12 @@ namespace Wino.Helpers
public static bool IsMultiple(int count) => count > 1; public static bool IsMultiple(int count) => count > 1;
public static bool ReverseIsMultiple(int count) => count < 1; public static bool ReverseIsMultiple(int count) => count < 1;
public static TeachingTipPlacementMode GetPlaccementModeForCalendarType(CalendarDisplayType type) public static PopupPlacementMode GetPlaccementModeForCalendarType(CalendarDisplayType type)
{ {
return type switch return type switch
{ {
CalendarDisplayType.Week => TeachingTipPlacementMode.Right, CalendarDisplayType.Week => PopupPlacementMode.Right,
_ => TeachingTipPlacementMode.Bottom, _ => PopupPlacementMode.Bottom,
}; };
} }
public static ICalendarItem GetFirstAllDayEvent(CalendarEventCollection collection) public static ICalendarItem GetFirstAllDayEvent(CalendarEventCollection collection)