Some improvements on the quick event tip.

This commit is contained in:
Burak Kaan Köse
2024-12-31 22:22:19 +01:00
parent d524143a53
commit 068369fca2
6 changed files with 152 additions and 22 deletions

View File

@@ -36,6 +36,18 @@ namespace Wino.Calendar.ViewModels
[ObservableProperty]
private DayRangeRenderModel _selectedDayRange;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(SelectedQuickEventAccountCalendarName))]
private AccountCalendarViewModel _selectedQuickEventAccountCalendar;
public string SelectedQuickEventAccountCalendarName
{
get
{
return SelectedQuickEventAccountCalendar == null ? "Pick a calendar" : SelectedQuickEventAccountCalendar.Name;
}
}
[ObservableProperty]
private bool _isCalendarEnabled = true;
@@ -43,7 +55,6 @@ namespace Wino.Calendar.ViewModels
private const int maxDayRangeSize = 10;
private readonly ICalendarService _calendarService;
private readonly IAccountCalendarStateService _accountCalendarStateService;
private readonly IPreferencesService _preferencesService;
// Store latest rendered options.
@@ -55,6 +66,7 @@ namespace Wino.Calendar.ViewModels
private CalendarSettings _currentSettings = null;
public IStatePersistanceService StatePersistanceService { get; }
public IAccountCalendarStateService AccountCalendarStateService { get; }
public CalendarPageViewModel(IStatePersistanceService statePersistanceService,
ICalendarService calendarService,
@@ -62,13 +74,13 @@ namespace Wino.Calendar.ViewModels
IPreferencesService preferencesService)
{
StatePersistanceService = statePersistanceService;
AccountCalendarStateService = accountCalendarStateService;
_calendarService = calendarService;
_accountCalendarStateService = accountCalendarStateService;
_preferencesService = preferencesService;
_accountCalendarStateService.AccountCalendarSelectionStateChanged += UpdateAccountCalendarRequested;
_accountCalendarStateService.CollectiveAccountGroupSelectionStateChanged += AccountCalendarStateCollectivelyChanged;
AccountCalendarStateService.AccountCalendarSelectionStateChanged += UpdateAccountCalendarRequested;
AccountCalendarStateService.CollectiveAccountGroupSelectionStateChanged += AccountCalendarStateCollectivelyChanged;
}
private void AccountCalendarStateCollectivelyChanged(object sender, GroupedAccountCalendarViewModel e)
@@ -81,7 +93,7 @@ namespace Wino.Calendar.ViewModels
{
var days = dayRangeRenderModels.SelectMany(a => a.CalendarDays);
days.ForEach(a => a.EventsCollection.FilterByCalendars(_accountCalendarStateService.ActiveCalendars.Select(a => a.Id)));
days.ForEach(a => a.EventsCollection.FilterByCalendars(AccountCalendarStateService.ActiveCalendars.Select(a => a.Id)));
}
// TODO: Replace when calendar settings are updated.
@@ -435,7 +447,7 @@ namespace Wino.Calendar.ViewModels
// Initialization is done for all calendars, regardless whether they are actively selected or not.
// This is because the filtering is cached internally of the calendar items in CalendarEventCollection.
var allCalendars = _accountCalendarStateService.GroupedAccountCalendars.SelectMany(a => a.AccountCalendars);
var allCalendars = AccountCalendarStateService.GroupedAccountCalendars.SelectMany(a => a.AccountCalendars);
foreach (var calendarViewModel in allCalendars)
{

View File

@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Wino.Calendar.ViewModels.Data;
using Wino.Core.Domain.Entities.Shared;
namespace Wino.Calendar.ViewModels.Interfaces
{
@@ -23,5 +25,6 @@ namespace Wino.Calendar.ViewModels.Interfaces
/// Enumeration of currently selected calendars.
/// </summary>
IEnumerable<AccountCalendarViewModel> ActiveCalendars { get; }
IEnumerable<IGrouping<MailAccount, AccountCalendarViewModel>> GroupedAccountCalendarsEnumerable { get; }
}
}

View File

@@ -5,6 +5,7 @@ using System.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
using Wino.Calendar.ViewModels.Data;
using Wino.Calendar.ViewModels.Interfaces;
using Wino.Core.Domain.Entities.Shared;
namespace Wino.Calendar.Services
{
@@ -32,6 +33,17 @@ namespace Wino.Calendar.Services
}
}
public IEnumerable<IGrouping<MailAccount, AccountCalendarViewModel>> GroupedAccountCalendarsEnumerable
{
get
{
return GroupedAccountCalendars
.Select(a => a.AccountCalendars)
.SelectMany(b => b)
.GroupBy(c => c.Account);
}
}
public AccountCalendarStateService()
{
GroupedAccountCalendars = new ReadOnlyObservableCollection<GroupedAccountCalendarViewModel>(_internalGroupedAccountCalendars);

View File

@@ -249,8 +249,5 @@
</Setter>
</Style>
<!-- Teaching tip dialog sizing. -->
<x:Double x:Key="TeachingTipMinWidth">1000</x:Double>
<x:Double x:Key="TeachingTipMaxWidth">1000</x:Double>
</ResourceDictionary>

View File

@@ -5,15 +5,23 @@
xmlns:abstract="using:Wino.Calendar.Views.Abstract"
xmlns:calendarControls="using:Wino.Calendar.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:helpers="using:Wino.Helpers"
xmlns:local="using:Wino.Calendar.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:shared="using:Wino.Core.Domain.Entities.Shared"
mc:Ignorable="d">
<!--<Page.Resources>
<x:Double x:Key="TeachingTipMinWidth">500</x:Double>
<x:Double x:Key="TeachingTipMaxWidth">500</x:Double>
</Page.Resources>-->
<Page.Resources>
<!-- Teaching tip dialog sizing. -->
<x:Double x:Key="TeachingTipMinWidth">900</x:Double>
<x:Double x:Key="TeachingTipMaxWidth">900</x:Double>
<CollectionViewSource
x:Key="AQ"
IsSourceGrouped="True"
Source="{x:Bind ViewModel.AccountCalendarStateService.GroupedAccountCalendarsEnumerable, Mode=OneWay}" />
</Page.Resources>
<Border
Margin="0,0,7,7"
@@ -40,28 +48,120 @@
<!-- Single teaching tip to display create event dialog. -->
<muxc:TeachingTip
x:Name="NewEventTip"
Width="500"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
Closed="CreateEventTipClosed"
IsOpen="False"
PreferredPlacement="Right"
Target="{x:Bind TeachingTipPositionerGrid}">
<muxc:TeachingTip.Content>
<Grid Margin="0,24" RowSpacing="12">
<Grid
Margin="-12"
Padding="6,3,6,6"
RowSpacing="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="32" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TimePicker x:Name="EventTimePicker" ClockIdentifier="24HourClock" />
<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. -->
<Grid VerticalAlignment="Top" ColumnSpacing="6">
<Button
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
Background="Transparent">
<Button.Content>
<Grid ColumnSpacing="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Foreground="{x:Bind helpers:XamlHelpers.GetReadableTextColor(ViewModel.SelectedQuickEventAccountCalendar.BackgroundColorHex), Mode=OneWay}" Text="{x:Bind ViewModel.SelectedQuickEventAccountCalendar.Account.Name, Mode=OneWay}" />
<TextBlock
Grid.Column="1"
HorizontalAlignment="Right"
FontWeight="SemiBold"
Foreground="{x:Bind helpers:XamlHelpers.GetReadableTextColor(ViewModel.SelectedQuickEventAccountCalendar.BackgroundColorHex), Mode=OneWay}"
Text="{x:Bind ViewModel.SelectedQuickEventAccountCalendarName, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
<Viewbox Grid.Column="2" Width="12">
<PathIcon
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="F1 M 18.935547 4.560547 L 19.814453 5.439453 L 10 15.253906 L 0.185547 5.439453 L 1.064453 4.560547 L 10 13.496094 Z "
Foreground="{x:Bind helpers:XamlHelpers.GetReadableTextColor(ViewModel.SelectedQuickEventAccountCalendar.BackgroundColorHex), Mode=OneWay}" />
</Viewbox>
</Grid>
</Button.Content>
<Button.Flyout>
<Flyout x:Name="QuickEventAccountSelectorFlyout" Placement="Bottom">
<ListView
MaxHeight="300"
HorizontalAlignment="Stretch"
DisplayMemberPath="Name"
ItemsSource="{Binding Source={StaticResource AQ}}"
SelectedItem="{x:Bind ViewModel.SelectedQuickEventAccountCalendar, Mode=TwoWay}"
SelectionChanged="QuickEventAccountSelectorSelectionChanged">
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Key.Name}" />
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
</ListView>
</Flyout>
</Button.Flyout>
</Button>
<!--<ComboBox
HorizontalAlignment="Stretch"
DisplayMemberPath="Account.Name"
ItemsSource="{x:Bind ViewModel.AccountCalendarStateService.GroupedAccountCalendars}"
SelectedItem="{x:Bind ViewModel.SelectedQuickEventAccountCalendarGroup, Mode=TwoWay}" />-->
<!--<ComboBox
Grid.Column="1"
HorizontalAlignment="Stretch"
DisplayMemberPath="Name"
ItemsSource="{x:Bind ViewModel.SelectedQuickEventAccountCalendarGroup.AccountCalendars, Mode=OneWay}"
SelectedItem="{x:Bind ViewModel.SelectedQuickEventAccountCalendar, Mode=TwoWay}" />-->
</Grid>
<!-- Rest of the content -->
<Grid
Grid.Row="1"
Grid.ColumnSpan="2"
Height="200" />
<!--<TimePicker x:Name="EventTimePicker" ClockIdentifier="24HourClock" />-->
<!-- Create events dialog -->
<Button
<!--<Button
x:Name="AddEvent"
Grid.Row="1"
Click="AddEventClicked"
Content="Add Event" />
Content="Add Event" />-->
</Grid>
</muxc:TeachingTip.Content>
@@ -72,3 +172,4 @@
</abstract:CalendarPageAbstract>

View File

@@ -73,7 +73,7 @@ namespace Wino.Calendar.Views
Id = Guid.NewGuid()
};
WeakReferenceMessenger.Default.Send(new CalendarEventAdded(testCalendarItem));
//WeakReferenceMessenger.Default.Send(new CalendarEventAdded(testCalendarItem));
NewEventTip.IsOpen = true;
}
@@ -94,10 +94,15 @@ namespace Wino.Calendar.Views
{
if (selectedDateTime == null) return;
var eventEndDate = selectedDateTime.Value.Add(EventTimePicker.Time);
// var eventEndDate = selectedDateTime.Value.Add(EventTimePicker.Time);
// Create the event.
// WeakReferenceMessenger.Default.Send(new CalendarEventAdded(new CalendarItem(selectedDateTime.Value, eventEndDate)));
}
private void QuickEventAccountSelectorSelectionChanged(object sender, SelectionChangedEventArgs e)
{
QuickEventAccountSelectorFlyout.Hide();
}
}
}