Show as localization.

This commit is contained in:
Burak Kaan Köse
2026-01-04 13:25:08 +01:00
parent 4603b1fb14
commit 0b0f6b8d8e
3 changed files with 115 additions and 90 deletions
@@ -90,17 +90,10 @@ public partial class EventDetailsPageViewModel : CalendarBaseViewModel
#region Show As Options
public List<CalendarItemShowAs> ShowAsOptions { get; } =
[
CalendarItemShowAs.Free,
CalendarItemShowAs.Tentative,
CalendarItemShowAs.Busy,
CalendarItemShowAs.OutOfOffice,
CalendarItemShowAs.WorkingElsewhere
];
public ObservableCollection<ShowAsOption> ShowAsOptions { get; } = new ObservableCollection<ShowAsOption>();
[ObservableProperty]
public partial CalendarItemShowAs SelectedShowAs { get; set; } = CalendarItemShowAs.Busy;
public partial ShowAsOption SelectedShowAsOption { get; set; }
#endregion
@@ -162,6 +155,14 @@ public partial class EventDetailsPageViewModel : CalendarBaseViewModel
CurrentSettings = _preferencesService.GetCurrentCalendarSettings();
IsDarkWebviewRenderer = _underlyingThemeService.IsUnderlyingThemeDark();
// Initialize Show As options
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.Free));
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.Tentative));
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.Busy));
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.OutOfOffice));
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.WorkingElsewhere));
SelectedShowAsOption = ShowAsOptions[2]; // Default to Busy
// Initialize RSVP status options
RsvpStatusOptions.Add(new RsvpStatusOption(CalendarItemStatus.Accepted));
RsvpStatusOptions.Add(new RsvpStatusOption(CalendarItemStatus.Tentative));
@@ -202,30 +203,7 @@ public partial class EventDetailsPageViewModel : CalendarBaseViewModel
CurrentEvent = new CalendarItemViewModel(currentEventItem);
var attendees = await _calendarService.GetAttendeesAsync(currentEventItem.EventTrackingId);
// Check if organizer is in the attendees list
var hasOrganizerInList = attendees.Any(a => a.IsOrganizer);
// If the user is the organizer but not in attendees list, add them
if (!hasOrganizerInList && !string.IsNullOrEmpty(currentEventItem.OrganizerEmail))
{
var organizerAttendee = new CalendarEventAttendee
{
Id = Guid.NewGuid(),
CalendarItemId = currentEventItem.Id,
Name = currentEventItem.OrganizerDisplayName ?? currentEventItem.OrganizerEmail,
Email = currentEventItem.OrganizerEmail,
IsOrganizer = true,
AttendenceStatus = AttendeeStatus.Accepted
};
CurrentEvent.Attendees.Add(organizerAttendee);
}
foreach (var item in attendees)
{
CurrentEvent.Attendees.Add(item);
}
await LoadAttendeesAsync(currentEventItem.EventTrackingId, currentEventItem);
// Load reminders for this calendar item
Reminders = await _calendarService.GetRemindersAsync(currentEventItem.EventTrackingId);
@@ -240,6 +218,36 @@ public partial class EventDetailsPageViewModel : CalendarBaseViewModel
}
}
private async Task LoadAttendeesAsync(Guid eventTrackingId, CalendarItem calendarItem)
{
CurrentEvent.Attendees.Clear();
var attendees = await _calendarService.GetAttendeesAsync(eventTrackingId);
// Check if organizer is in the attendees list
var hasOrganizerInList = attendees.Any(a => a.IsOrganizer);
// If the user is the organizer but not in attendees list, add them
if (!hasOrganizerInList && !string.IsNullOrEmpty(calendarItem.OrganizerEmail))
{
var organizerAttendee = new CalendarEventAttendee
{
Id = Guid.NewGuid(),
CalendarItemId = calendarItem.Id,
Name = calendarItem.OrganizerDisplayName ?? calendarItem.OrganizerEmail,
Email = calendarItem.OrganizerEmail,
IsOrganizer = true,
AttendenceStatus = AttendeeStatus.Accepted
};
CurrentEvent.Attendees.Add(organizerAttendee);
}
foreach (var item in attendees)
{
CurrentEvent.Attendees.Add(item);
}
}
private async Task LoadAttachmentsAsync(Guid calendarItemId)
{
Attachments.Clear();
@@ -438,6 +446,9 @@ public partial class EventDetailsPageViewModel : CalendarBaseViewModel
await _winoRequestDelegator.ExecuteAsync(preparationRequest);
// Reload attendees to get the updated status from the server
await LoadAttendeesAsync(CurrentEvent.CalendarItem.EventTrackingId, CurrentEvent.CalendarItem);
OnPropertyChanged(nameof(CurrentRsvpText));
OnPropertyChanged(nameof(CurrentRsvpStatus));
@@ -616,6 +627,32 @@ public partial class ReminderOption : ObservableObject
}
}
public partial class ShowAsOption : ObservableObject
{
public CalendarItemShowAs ShowAs { get; }
public string DisplayText
{
get
{
return ShowAs switch
{
CalendarItemShowAs.Free => Translator.CalendarShowAs_Free,
CalendarItemShowAs.Tentative => Translator.CalendarShowAs_Tentative,
CalendarItemShowAs.Busy => Translator.CalendarShowAs_Busy,
CalendarItemShowAs.OutOfOffice => Translator.CalendarShowAs_OutOfOffice,
CalendarItemShowAs.WorkingElsewhere => Translator.CalendarShowAs_WorkingElsewhere,
_ => Translator.CalendarShowAs_Busy
};
}
}
public ShowAsOption(CalendarItemShowAs showAs)
{
ShowAs = showAs;
}
}
public partial class RsvpStatusOption : ObservableObject
{
public CalendarItemStatus Status { get; }
@@ -112,6 +112,11 @@
"CalendarEventDetails_ReadOnlyEvent": "Read-only event",
"CalendarEventDetails_Reminder": "Reminder",
"CalendarEventDetails_ShowAs": "Show as",
"CalendarShowAs_Free": "Free",
"CalendarShowAs_Tentative": "Tentative",
"CalendarShowAs_Busy": "Busy",
"CalendarShowAs_OutOfOffice": "Out of Office",
"CalendarShowAs_WorkingElsewhere": "Working Elsewhere",
"CalendarEventResponse_Accept": "Accept",
"CalendarEventResponse_AcceptedResponse": "Accepted",
"CalendarEventResponse_Decline": "Decline",
@@ -110,17 +110,6 @@
HorizontalSpacing="4"
VerticalSpacing="4">
<!-- Read Only Toggle -->
<ToggleButton
x:Name="ReadOnlyToggle"
IsChecked="True"
Style="{StaticResource TransparentActionButtonStyle}">
<StackPanel Orientation="Horizontal" Spacing="8">
<coreControls:WinoFontIcon FontSize="16" Icon="Blocked" />
<TextBlock VerticalAlignment="Center" Text="{x:Bind domain:Translator.CalendarEventDetails_ReadOnlyEvent}" />
</StackPanel>
</ToggleButton>
<!-- Save -->
<Button Command="{x:Bind ViewModel.SaveCommand}" Style="{StaticResource TransparentActionButtonStyle}">
<StackPanel Orientation="Horizontal" Spacing="8">
@@ -190,8 +179,9 @@
<ComboBox
Width="150"
VerticalAlignment="Center"
DisplayMemberPath="DisplayText"
ItemsSource="{x:Bind ViewModel.ShowAsOptions}"
SelectedItem="{x:Bind ViewModel.SelectedShowAs, Mode=TwoWay}" />
SelectedItem="{x:Bind ViewModel.SelectedShowAsOption, Mode=TwoWay}" />
</StackPanel>
<!-- Reminder -->
@@ -356,57 +346,50 @@
<TextBlock Style="{StaticResource EventDetailsPanelTitleStyle}" Text="{x:Bind domain:Translator.CalendarEventDetails_Details}" />
<Grid Grid.Row="1">
<!-- Read-Only Event -->
<!-- Read-Only Event -->
<Grid
x:Name="ReadOnlyDetailsGrid"
Grid.Row="1"
RowSpacing="6">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Title -->
<TextBlock
Style="{StaticResource SubheaderTextBlockStyle}"
Text="{x:Bind ViewModel.CurrentEvent.Title, Mode=OneWay}"
TextWrapping="Wrap" />
<!-- Date and Duration -->
<TextBlock
Grid.Row="1"
Text="{x:Bind calendarHelpers:CalendarXamlHelpers.GetEventDetailsDateString(ViewModel.CurrentEvent, ViewModel.CurrentSettings), Mode=OneWay}"
TextWrapping="Wrap" />
<!-- Recurrence Info -->
<Grid
x:Name="ReadOnlyDetailsGrid"
RowSpacing="6"
Visibility="{x:Bind ReadOnlyToggle.IsChecked, Mode=OneWay}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
Grid.Row="2"
ColumnSpacing="6"
Visibility="{x:Bind ViewModel.CurrentEvent.IsRecurringParent, Mode=OneWay}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Title -->
<coreControls:WinoFontIcon FontSize="14" Icon="CalendarEventRepeat" />
<TextBlock
Style="{StaticResource SubheaderTextBlockStyle}"
Text="{x:Bind ViewModel.CurrentEvent.Title, Mode=OneWay}"
Grid.Column="1"
VerticalAlignment="Center"
Text="{x:Bind calendarHelpers:CalendarXamlHelpers.GetRecurrenceString(ViewModel.CurrentEvent), Mode=OneWay}"
TextWrapping="Wrap" />
<!-- Date and Duration -->
<TextBlock
Grid.Row="1"
Text="{x:Bind calendarHelpers:CalendarXamlHelpers.GetEventDetailsDateString(ViewModel.CurrentEvent, ViewModel.CurrentSettings), Mode=OneWay}"
TextWrapping="Wrap" />
<!-- Recurrence Info -->
<Grid
Grid.Row="2"
ColumnSpacing="6"
Visibility="{x:Bind ViewModel.CurrentEvent.IsRecurringParent, Mode=OneWay}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<coreControls:WinoFontIcon FontSize="14" Icon="CalendarEventRepeat" />
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
Text="{x:Bind calendarHelpers:CalendarXamlHelpers.GetRecurrenceString(ViewModel.CurrentEvent), Mode=OneWay}"
TextWrapping="Wrap" />
</Grid>
<!-- WebView -->
<WebView2 x:Name="EventDetailsWebView" Grid.Row="3" />
</Grid>
<!-- Editable Event -->
<Grid Visibility="{x:Bind helpers:XamlHelpers.ReverseVisibilityConverter(ReadOnlyDetailsGrid.Visibility), Mode=OneWay}">
<TextBlock Text="{x:Bind domain:Translator.CalendarEventDetails_Editing}" />
</Grid>
<!-- WebView -->
<WebView2 x:Name="EventDetailsWebView" Grid.Row="3" />
</Grid>
</Grid>