Monthly calendar basics.
This commit is contained in:
48
Wino.Calendar.ViewModels/AccountDetailsPageViewModel.cs
Normal file
48
Wino.Calendar.ViewModels/AccountDetailsPageViewModel.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Wino.Calendar.ViewModels.Interfaces;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.Navigation;
|
||||
using Wino.Core.ViewModels;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
using Wino.Messaging.UI;
|
||||
|
||||
namespace Wino.Calendar.ViewModels
|
||||
{
|
||||
public partial class AccountDetailsPageViewModel : CalendarBaseViewModel
|
||||
{
|
||||
private readonly IAccountService _accountService;
|
||||
|
||||
public AccountProviderDetailViewModel Account { get; private set; }
|
||||
public ICalendarDialogService CalendarDialogService { get; }
|
||||
public IAccountCalendarStateService AccountCalendarStateService { get; }
|
||||
|
||||
public AccountDetailsPageViewModel(ICalendarDialogService calendarDialogService, IAccountService accountService, IAccountCalendarStateService accountCalendarStateService)
|
||||
{
|
||||
CalendarDialogService = calendarDialogService;
|
||||
_accountService = accountService;
|
||||
AccountCalendarStateService = accountCalendarStateService;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task RenameAccount()
|
||||
{
|
||||
if (Account == null)
|
||||
return;
|
||||
|
||||
var updatedAccount = await CalendarDialogService.ShowEditAccountDialogAsync(Account.Account);
|
||||
|
||||
if (updatedAccount != null)
|
||||
{
|
||||
await _accountService.UpdateAccountAsync(updatedAccount);
|
||||
|
||||
ReportUIChange(new AccountUpdatedMessage(updatedAccount));
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnNavigatedTo(NavigationMode mode, object parameters)
|
||||
{
|
||||
base.OnNavigatedTo(mode, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,11 @@ using Wino.Calendar.ViewModels.Data;
|
||||
using Wino.Calendar.ViewModels.Interfaces;
|
||||
using Wino.Core.Domain.Collections;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Extensions;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.Calendar;
|
||||
using Wino.Core.Domain.Models.Navigation;
|
||||
using Wino.Core.Domain.Models.Synchronization;
|
||||
using Wino.Core.Extensions;
|
||||
using Wino.Core.ViewModels;
|
||||
using Wino.Messaging.Client.Calendar;
|
||||
using Wino.Messaging.Client.Navigation;
|
||||
@@ -67,9 +67,6 @@ namespace Wino.Calendar.ViewModels
|
||||
[ObservableProperty]
|
||||
private int _selectedDateNavigationHeaderIndex;
|
||||
|
||||
|
||||
|
||||
|
||||
public bool IsVerticalCalendar => StatePersistenceService.CalendarDisplayType == CalendarDisplayType.Month;
|
||||
|
||||
// For updating account calendars asynchronously.
|
||||
@@ -209,7 +206,7 @@ namespace Wino.Calendar.ViewModels
|
||||
ForceNavigateCalendarDate();
|
||||
break;
|
||||
case 0:
|
||||
NavigationService.Navigate(WinoPage.AccountManagementPage);
|
||||
NavigationService.Navigate(WinoPage.ManageAccountsPage);
|
||||
break;
|
||||
case 1:
|
||||
NavigationService.Navigate(WinoPage.SettingsPage);
|
||||
|
||||
@@ -31,7 +31,9 @@ namespace Wino.Calendar.ViewModels
|
||||
IRecipient<CalendarSettingsUpdatedMessage>,
|
||||
IRecipient<CalendarItemTappedMessage>,
|
||||
IRecipient<CalendarItemDoubleTappedMessage>,
|
||||
IRecipient<CalendarItemRightTappedMessage>
|
||||
IRecipient<CalendarItemRightTappedMessage>,
|
||||
IRecipient<CalendarDisplayTypeChangedMessage>
|
||||
|
||||
{
|
||||
#region Quick Event Creation
|
||||
|
||||
@@ -92,6 +94,8 @@ namespace Wino.Calendar.ViewModels
|
||||
|
||||
#region Data Initialization
|
||||
|
||||
public bool IsVerticalCalendar => StatePersistanceService.CalendarDisplayType == CalendarDisplayType.Month;
|
||||
|
||||
[ObservableProperty]
|
||||
private DayRangeCollection _dayRanges = [];
|
||||
|
||||
@@ -161,13 +165,16 @@ namespace Wino.Calendar.ViewModels
|
||||
private void UpdateAccountCalendarRequested(object sender, AccountCalendarViewModel e)
|
||||
=> FilterActiveCalendars(DayRanges);
|
||||
|
||||
private void FilterActiveCalendars(IEnumerable<DayRangeRenderModel> dayRangeRenderModels)
|
||||
private async void FilterActiveCalendars(IEnumerable<DayRangeRenderModel> dayRangeRenderModels)
|
||||
{
|
||||
var days = dayRangeRenderModels.SelectMany(a => a.CalendarDays);
|
||||
await ExecuteUIThread(() =>
|
||||
{
|
||||
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)));
|
||||
|
||||
DisplayDetailsCalendarItemViewModel = null;
|
||||
DisplayDetailsCalendarItemViewModel = null;
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: Replace when calendar settings are updated.
|
||||
@@ -178,6 +185,7 @@ namespace Wino.Calendar.ViewModels
|
||||
{
|
||||
CalendarDisplayType.Day => new DayCalendarDrawingStrategy(CurrentSettings),
|
||||
CalendarDisplayType.Week => new WeekCalendarDrawingStrategy(CurrentSettings),
|
||||
CalendarDisplayType.Month => new MonthCalendarDrawingStrategy(CurrentSettings),
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
}
|
||||
@@ -831,5 +839,7 @@ namespace Wino.Calendar.ViewModels
|
||||
// var calendarItems = GetCalendarItems(deletedItem.Id);
|
||||
});
|
||||
}
|
||||
|
||||
public void Receive(CalendarDisplayTypeChangedMessage message) => OnPropertyChanged(nameof(IsVerticalCalendar));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user