Skip to content

Commit

Permalink
Add "EventsSpacing", "EventsOrientation", and "EventCornerRadius" to …
Browse files Browse the repository at this point in the history
…DayView section of Property editor in sample app
  • Loading branch information
ME-MarvinE committed Mar 10, 2024
1 parent 9f7d056 commit e712b2d
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public static class PopupHelper
public static List<PageStartMode> AllPageStartModes { get; set; } = Enum.GetValues(typeof(PageStartMode)).Cast<PageStartMode>().ToList();
public static List<NavigationLoopMode> AllNavigationLoopModes { get; set; } = Enum.GetValues(typeof(NavigationLoopMode)).Cast<NavigationLoopMode>().ToList();
public static List<DayOfWeek> AllDaysOfWeek { get; set; } = DayOfWeek.Monday.GetWeekAsFirst();
public static List<StackOrientation> AllStackOrientations { get; set; } = Enum.GetValues(typeof(StackOrientation)).Cast<StackOrientation>().ToList();
#endregion

#region Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public class PlaygroundViewModel : BaseViewModel
public double DayHeightRequest { get; set; } = 45;
public double DayWidthRequest { get; set; } = -1;
public bool DayAutoSetStyleBasedOnDayState { get; set; } = true;
public double DayEventCornerRadius { get; set; } = 100;
public double DayEventsSpacing { get; set; } = 2.5;
public StackOrientation DayEventsOrientation { get; set; } = StackOrientation.Horizontal;
public int ForwardsNavigationAmount { get; set; } = 1;
public int BackwardsNavigationAmount { get; set; } = -1;
public string TargetCultureCode { get; set; } = CultureInfo.CurrentCulture?.Name ?? CultureInfo.DefaultThreadCurrentCulture?.Name ?? CultureInfo.CurrentUICulture?.Name ?? CultureInfo.DefaultThreadCurrentUICulture?.Name ?? "en";
Expand Down Expand Up @@ -99,6 +102,8 @@ public class PlaygroundViewModel : BaseViewModel
public ICommand ChangeDateSelectionCommand { get; set; }
public ICommand ChangeCalendarVisibilityCommand { get; set; }
public ICommand UpdateCurrentCultureCommand { get; set; }
public ICommand ShowDayEventsOrientationDialogCommand { get; set; }

#endregion

#region Constructors
Expand Down Expand Up @@ -130,6 +135,7 @@ public PlaygroundViewModel()
ChangeDateSelectionCommand = new Command<DateTime>(ChangeDateSelection);
ChangeCalendarVisibilityCommand = new Command<bool>(ChangeCalendarVisibility);
UpdateCurrentCultureCommand = new Command(UpdateCurrentCulture);
ShowDayEventsOrientationDialogCommand = new Command(ShowDayEventsOrientationDialog);

List<ColoredEvent> events = new List<ColoredEvent>()
{
Expand Down Expand Up @@ -374,6 +380,10 @@ public async void ShowDayInvalidTextColorDialog()
{
DayInvalidTextColor = await PopupHelper.ShowColorDialogAsync(DayInvalidTextColor);
}
public async void ShowDayEventsOrientationDialog()
{
DayEventsOrientation = await PopupHelper.ShowSelectItemDialogAsync(DayEventsOrientation, PopupHelper.AllStackOrientations);
}
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,58 @@
VerticalOptions="End"/>
</Grid>

<Grid>
<Label
Grid.Column="0"
FontSize="{StaticResource SmallFontSize}"
HorizontalTextAlignment="Center"
Text="EventCornerRadius"
VerticalTextAlignment="Center"/>
<Editor
Grid.Column="1"
HorizontalOptions="Center"
Keyboard="Numeric"
Text="{Binding DayEventCornerRadius}"
VerticalOptions="End"/>
</Grid>

<Grid>
<Label
Grid.Column="0"
FontSize="{StaticResource SmallFontSize}"
HorizontalTextAlignment="Center"
Text="EventsSpacing"
VerticalTextAlignment="Center"/>
<Editor
Grid.Column="1"
HorizontalOptions="Center"
Keyboard="Numeric"
Text="{Binding DayEventsSpacing}"
VerticalOptions="End"/>
</Grid>

<Grid>
<Label
Grid.Column="0"
FontSize="{StaticResource SmallFontSize}"
HorizontalTextAlignment="Center"
Text="EventsOrientation"
VerticalTextAlignment="Center"/>
<Label
Grid.Column="1"
FontSize="{StaticResource SmallFontSize}"
HorizontalTextAlignment="Center"
Text="{Binding DayEventsOrientation}"
TextColor="{StaticResource TappableSettingTextColor}"
VerticalTextAlignment="Center">

<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ShowDayEventsOrientationDialogCommand}"/>
</Label.GestureRecognizers>

</Label>
</Grid>

<Grid>
<Label
Grid.Column="0"
Expand Down Expand Up @@ -999,6 +1051,8 @@
AutoSetStyleBasedOnDayState="{Binding BindingContext.DayAutoSetStyleBasedOnDayState, Source={x:Reference This}}"
DateTime="{Binding DateTime}"
Events="{Binding Events}"
EventsOrientation="{Binding BindingContext.DayEventsOrientation, Source={x:Reference This}}"
EventsSpacing="{Binding BindingContext.DayEventsSpacing, Source={x:Reference This}}"
HeightRequest="{Binding BindingContext.DayHeightRequest, Source={x:Reference This}}"
IsCurrentMonth="{Binding IsCurrentMonth}"
IsInvalid="{Binding IsInvalid}"
Expand All @@ -1010,10 +1064,12 @@
<DataTemplate x:DataType="{x:Null}">
<Rectangle
Fill="{Binding Color}"
RadiusX="{Binding BindingContext.DayEventCornerRadius, Source={x:Reference This}}"
RadiusY="{Binding BindingContext.DayEventCornerRadius, Source={x:Reference This}}"
Style="{StaticResource DefaultEventIndicatorRectangleStyle}"/>
</DataTemplate>
</xc:DayView.EventTemplate>

<xc:DayView.CurrentMonthStyle>
<Style BasedOn="{StaticResource DefaultDayViewCurrentMonthStyle}" TargetType="{x:Type xc:DayView}">
<Setter Property="BackgroundColor" Value="{Binding BindingContext.DayCurrentMonthBackgroundColor, Source={x:Reference This}}"/>
Expand Down
1 change: 1 addition & 0 deletions XCalendarMauiSample/Helpers/PopupHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static class PopupHelper
public static List<PageStartMode> AllPageStartModes { get; set; } = Enum.GetValues(typeof(PageStartMode)).Cast<PageStartMode>().ToList();
public static List<NavigationLoopMode> AllNavigationLoopModes { get; set; } = Enum.GetValues(typeof(NavigationLoopMode)).Cast<NavigationLoopMode>().ToList();
public static List<DayOfWeek> AllDaysOfWeek { get; set; } = DayOfWeek.Monday.GetWeekAsFirst();
public static List<StackOrientation> AllStackOrientations { get; set; } = Enum.GetValues(typeof(StackOrientation)).Cast<StackOrientation>().ToList();
#endregion

#region Methods
Expand Down
9 changes: 9 additions & 0 deletions XCalendarMauiSample/ViewModels/PlaygroundViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public class PlaygroundViewModel : BaseViewModel
public double DayHeightRequest { get; set; } = 45;
public double DayWidthRequest { get; set; } = -1;
public bool DayAutoSetStyleBasedOnDayState { get; set; } = true;
public double DayEventCornerRadius { get; set; } = 100;
public double DayEventsSpacing { get; set; } = 2.5;
public StackOrientation DayEventsOrientation { get; set; } = StackOrientation.Horizontal;
public int ForwardsNavigationAmount { get; set; } = 1;
public int BackwardsNavigationAmount { get; set; } = -1;
public string TargetCultureCode { get; set; } = CultureInfo.CurrentCulture?.Name ?? CultureInfo.DefaultThreadCurrentCulture?.Name ?? CultureInfo.CurrentUICulture?.Name ?? CultureInfo.DefaultThreadCurrentUICulture?.Name ?? "en";
Expand Down Expand Up @@ -95,6 +98,7 @@ public class PlaygroundViewModel : BaseViewModel
public ICommand ChangeDateSelectionCommand { get; set; }
public ICommand ChangeCalendarVisibilityCommand { get; set; }
public ICommand UpdateCurrentCultureCommand { get; set; }
public ICommand ShowDayEventsOrientationDialogCommand { get; set; }
#endregion

#region Constructors
Expand Down Expand Up @@ -126,6 +130,7 @@ public PlaygroundViewModel()
ChangeDateSelectionCommand = new Command<DateTime>(ChangeDateSelection);
ChangeCalendarVisibilityCommand = new Command<bool>(ChangeCalendarVisibility);
UpdateCurrentCultureCommand = new Command(UpdateCurrentCulture);
ShowDayEventsOrientationDialogCommand = new Command(ShowDayEventsOrientationDialog);

List<ColoredEvent> events = new List<ColoredEvent>()
{
Expand Down Expand Up @@ -370,6 +375,10 @@ public async void ShowDayInvalidTextColorDialog()
{
DayInvalidTextColor = await PopupHelper.ShowColorDialogAsync(DayInvalidTextColor);
}
public async void ShowDayEventsOrientationDialog()
{
DayEventsOrientation = await PopupHelper.ShowSelectItemDialogAsync(DayEventsOrientation, PopupHelper.AllStackOrientations);
}
#endregion
}
}
86 changes: 86 additions & 0 deletions XCalendarMauiSample/Views/PlaygroundPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,88 @@
VerticalOptions="End"/>
</Grid>

<Grid>
<Label
Grid.Column="0"
FontSize="{StaticResource SmallFontSize}"
HorizontalTextAlignment="Center"
Text="EventCornerRadius"
VerticalTextAlignment="Center"/>
<Editor
Grid.Column="1"
HorizontalOptions="Center"
Keyboard="Numeric"
Text="{Binding DayEventCornerRadius}"
VerticalOptions="End"/>
</Grid>

<Grid>
<Label
Grid.Column="0"
FontSize="{StaticResource SmallFontSize}"
HorizontalTextAlignment="Center"
Text="EventsSpacing"
VerticalTextAlignment="Center"/>
<Editor
Grid.Column="1"
HorizontalOptions="Center"
Keyboard="Numeric"
Text="{Binding DayEventsSpacing}"
VerticalOptions="End"/>
</Grid>

<Grid>
<Label
Grid.Column="0"
FontSize="{StaticResource SmallFontSize}"
HorizontalTextAlignment="Center"
Text="EventsOrientation"
VerticalTextAlignment="Center"/>
<Label
Grid.Column="1"
FontSize="{StaticResource SmallFontSize}"
HorizontalTextAlignment="Center"
Text="{Binding DayEventsOrientation}"
TextColor="{StaticResource TappableSettingTextColor}"
VerticalTextAlignment="Center">

<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ShowDayEventsOrientationDialogCommand}"/>
</Label.GestureRecognizers>

</Label>
</Grid>

<Grid>
<Label
Grid.Column="0"
FontSize="{StaticResource SmallFontSize}"
HorizontalTextAlignment="Center"
Text="InvalidTextColor"
VerticalTextAlignment="Center"/>

<Border
Grid.Column="1"
Padding="0"
BackgroundColor="{Binding DayInvalidTextColor}"
HorizontalOptions="Center"
Stroke="Black"
StrokeThickness="1"
VerticalOptions="Center">

<Border.StrokeShape>
<RoundRectangle CornerRadius="10"/>
</Border.StrokeShape>

<BoxView HeightRequest="40" WidthRequest="40"/>

<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ShowDayInvalidTextColorDialogCommand}"/>
</Border.GestureRecognizers>

</Border>
</Grid>

<Grid>
<Label
Grid.Column="0"
Expand Down Expand Up @@ -1040,6 +1122,8 @@
AutoSetStyleBasedOnDayState="{Binding BindingContext.DayAutoSetStyleBasedOnDayState, Source={x:Reference This}}"
DateTime="{Binding DateTime}"
Events="{Binding Events}"
EventsOrientation="{Binding BindingContext.DayEventsOrientation, Source={x:Reference This}}"
EventsSpacing="{Binding BindingContext.DayEventsSpacing, Source={x:Reference This}}"
HeightRequest="{Binding BindingContext.DayHeightRequest, Source={x:Reference This}}"
IsCurrentMonth="{Binding IsCurrentMonth}"
IsInvalid="{Binding IsInvalid}"
Expand All @@ -1051,6 +1135,8 @@
<DataTemplate x:DataType="{x:Null}">
<Rectangle
Fill="{Binding Color}"
RadiusX="{Binding BindingContext.DayEventCornerRadius, Source={x:Reference This}}"
RadiusY="{Binding BindingContext.DayEventCornerRadius, Source={x:Reference This}}"
Style="{StaticResource DefaultEventIndicatorRectangleStyle}"/>
</DataTemplate>
</xc:DayView.EventTemplate>
Expand Down

0 comments on commit e712b2d

Please sign in to comment.