diff --git a/Wino.Calendar.ViewModels/CalendarPageViewModel.cs b/Wino.Calendar.ViewModels/CalendarPageViewModel.cs index eafc36c9..fc598419 100644 --- a/Wino.Calendar.ViewModels/CalendarPageViewModel.cs +++ b/Wino.Calendar.ViewModels/CalendarPageViewModel.cs @@ -93,19 +93,15 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel, #region Data Initialization [ObservableProperty] - private CalendarOrientation _calendarOrientation = CalendarOrientation.Horizontal; - + public partial CalendarOrientation CalendarOrientation { get; set; } = CalendarOrientation.Horizontal; [ObservableProperty] - private DayRangeCollection _dayRanges = []; - + public partial DayRangeCollection DayRanges { get; set; } = []; [ObservableProperty] - private int _selectedDateRangeIndex; - + public partial int SelectedDateRangeIndex { get; set; } [ObservableProperty] - private DayRangeRenderModel _selectedDayRange; - + public partial DayRangeRenderModel SelectedDayRange { get; set; } [ObservableProperty] - private bool _isCalendarEnabled = true; + public partial bool IsCalendarEnabled { get; set; } = true; #endregion @@ -113,9 +109,13 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel, public event EventHandler DetailsShowCalendarItemChanged; + public bool CanJoinOnline => DisplayDetailsCalendarItemViewModel != null && + !string.IsNullOrEmpty(DisplayDetailsCalendarItemViewModel.CalendarItem.HtmlLink); + [ObservableProperty] [NotifyPropertyChangedFor(nameof(IsEventDetailsVisible))] - private CalendarItemViewModel _displayDetailsCalendarItemViewModel; + [NotifyCanExecuteChangedFor(nameof(JoinOnlineCommand))] + public partial CalendarItemViewModel DisplayDetailsCalendarItemViewModel { get; set; } public bool IsEventDetailsVisible => DisplayDetailsCalendarItemViewModel != null; @@ -127,6 +127,7 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel, private readonly ICalendarService _calendarService; private readonly INavigationService _navigationService; private readonly IKeyPressService _keyPressService; + private readonly INativeAppService _nativeAppService; private readonly IPreferencesService _preferencesService; private readonly IWinoRequestDelegator _winoRequestDelegator; @@ -147,6 +148,7 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel, ICalendarService calendarService, INavigationService navigationService, IKeyPressService keyPressService, + INativeAppService nativeAppService, IAccountCalendarStateService accountCalendarStateService, IPreferencesService preferencesService, IWinoRequestDelegator winoRequestDelegator) @@ -157,6 +159,7 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel, _calendarService = calendarService; _navigationService = navigationService; _keyPressService = keyPressService; + _nativeAppService = nativeAppService; _preferencesService = preferencesService; _winoRequestDelegator = winoRequestDelegator; @@ -203,6 +206,14 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel, }); } + [RelayCommand(CanExecute = nameof(CanJoinOnline))] + private async Task JoinOnlineAsync() + { + if (DisplayDetailsCalendarItemViewModel == null || string.IsNullOrEmpty(DisplayDetailsCalendarItemViewModel.CalendarItem.HtmlLink)) return; + + await _nativeAppService.LaunchUriAsync(new Uri(DisplayDetailsCalendarItemViewModel.CalendarItem.HtmlLink)); + } + // TODO: Replace when calendar settings are updated. // Should be a field ideally. private BaseCalendarTypeDrawingStrategy GetDrawingStrategy(CalendarDisplayType displayType) diff --git a/Wino.Mail.WinUI/Views/Calendar/CalendarPage.xaml b/Wino.Mail.WinUI/Views/Calendar/CalendarPage.xaml index 7777a78e..a6e487fd 100644 --- a/Wino.Mail.WinUI/Views/Calendar/CalendarPage.xaml +++ b/Wino.Mail.WinUI/Views/Calendar/CalendarPage.xaml @@ -6,6 +6,7 @@ xmlns:animations="using:CommunityToolkit.WinUI.Animations" xmlns:calendarControls="using:Wino.Calendar.Controls" xmlns:calendarHelpers="using:Wino.Calendar.Helpers" + xmlns:collections="using:CommunityToolkit.Mvvm.Collections" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:data="using:Wino.Calendar.ViewModels.Data" xmlns:domain="using:Wino.Core.Domain" @@ -13,7 +14,7 @@ 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" xmlns:collections="using:CommunityToolkit.Mvvm.Collections" + xmlns:shared="using:Wino.Core.Domain.Entities.Shared" mc:Ignorable="d"> @@ -350,11 +351,12 @@ - + HorizontalAlignment="Right" + Command="{x:Bind ViewModel.JoinOnlineCommand}" + Visibility="{x:Bind ViewModel.CanJoinOnline, Mode=OneWay}">