Skip to content

Commit e712b2d

Browse files
committed
Add "EventsSpacing", "EventsOrientation", and "EventCornerRadius" to DayView section of Property editor in sample app
1 parent 9f7d056 commit e712b2d

File tree

6 files changed

+164
-1
lines changed

6 files changed

+164
-1
lines changed

XCalendarFormsSample/XCalendarFormsSample/Helpers/PopupHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public static class PopupHelper
1818
public static List<PageStartMode> AllPageStartModes { get; set; } = Enum.GetValues(typeof(PageStartMode)).Cast<PageStartMode>().ToList();
1919
public static List<NavigationLoopMode> AllNavigationLoopModes { get; set; } = Enum.GetValues(typeof(NavigationLoopMode)).Cast<NavigationLoopMode>().ToList();
2020
public static List<DayOfWeek> AllDaysOfWeek { get; set; } = DayOfWeek.Monday.GetWeekAsFirst();
21+
public static List<StackOrientation> AllStackOrientations { get; set; } = Enum.GetValues(typeof(StackOrientation)).Cast<StackOrientation>().ToList();
2122
#endregion
2223

2324
#region Methods

XCalendarFormsSample/XCalendarFormsSample/ViewModels/PlaygroundViewModel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public class PlaygroundViewModel : BaseViewModel
5252
public double DayHeightRequest { get; set; } = 45;
5353
public double DayWidthRequest { get; set; } = -1;
5454
public bool DayAutoSetStyleBasedOnDayState { get; set; } = true;
55+
public double DayEventCornerRadius { get; set; } = 100;
56+
public double DayEventsSpacing { get; set; } = 2.5;
57+
public StackOrientation DayEventsOrientation { get; set; } = StackOrientation.Horizontal;
5558
public int ForwardsNavigationAmount { get; set; } = 1;
5659
public int BackwardsNavigationAmount { get; set; } = -1;
5760
public string TargetCultureCode { get; set; } = CultureInfo.CurrentCulture?.Name ?? CultureInfo.DefaultThreadCurrentCulture?.Name ?? CultureInfo.CurrentUICulture?.Name ?? CultureInfo.DefaultThreadCurrentUICulture?.Name ?? "en";
@@ -99,6 +102,8 @@ public class PlaygroundViewModel : BaseViewModel
99102
public ICommand ChangeDateSelectionCommand { get; set; }
100103
public ICommand ChangeCalendarVisibilityCommand { get; set; }
101104
public ICommand UpdateCurrentCultureCommand { get; set; }
105+
public ICommand ShowDayEventsOrientationDialogCommand { get; set; }
106+
102107
#endregion
103108

104109
#region Constructors
@@ -130,6 +135,7 @@ public PlaygroundViewModel()
130135
ChangeDateSelectionCommand = new Command<DateTime>(ChangeDateSelection);
131136
ChangeCalendarVisibilityCommand = new Command<bool>(ChangeCalendarVisibility);
132137
UpdateCurrentCultureCommand = new Command(UpdateCurrentCulture);
138+
ShowDayEventsOrientationDialogCommand = new Command(ShowDayEventsOrientationDialog);
133139

134140
List<ColoredEvent> events = new List<ColoredEvent>()
135141
{
@@ -374,6 +380,10 @@ public async void ShowDayInvalidTextColorDialog()
374380
{
375381
DayInvalidTextColor = await PopupHelper.ShowColorDialogAsync(DayInvalidTextColor);
376382
}
383+
public async void ShowDayEventsOrientationDialog()
384+
{
385+
DayEventsOrientation = await PopupHelper.ShowSelectItemDialogAsync(DayEventsOrientation, PopupHelper.AllStackOrientations);
386+
}
377387
#endregion
378388
}
379389
}

XCalendarFormsSample/XCalendarFormsSample/Views/PlaygroundPage.xaml

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,58 @@
667667
VerticalOptions="End"/>
668668
</Grid>
669669

670+
<Grid>
671+
<Label
672+
Grid.Column="0"
673+
FontSize="{StaticResource SmallFontSize}"
674+
HorizontalTextAlignment="Center"
675+
Text="EventCornerRadius"
676+
VerticalTextAlignment="Center"/>
677+
<Editor
678+
Grid.Column="1"
679+
HorizontalOptions="Center"
680+
Keyboard="Numeric"
681+
Text="{Binding DayEventCornerRadius}"
682+
VerticalOptions="End"/>
683+
</Grid>
684+
685+
<Grid>
686+
<Label
687+
Grid.Column="0"
688+
FontSize="{StaticResource SmallFontSize}"
689+
HorizontalTextAlignment="Center"
690+
Text="EventsSpacing"
691+
VerticalTextAlignment="Center"/>
692+
<Editor
693+
Grid.Column="1"
694+
HorizontalOptions="Center"
695+
Keyboard="Numeric"
696+
Text="{Binding DayEventsSpacing}"
697+
VerticalOptions="End"/>
698+
</Grid>
699+
700+
<Grid>
701+
<Label
702+
Grid.Column="0"
703+
FontSize="{StaticResource SmallFontSize}"
704+
HorizontalTextAlignment="Center"
705+
Text="EventsOrientation"
706+
VerticalTextAlignment="Center"/>
707+
<Label
708+
Grid.Column="1"
709+
FontSize="{StaticResource SmallFontSize}"
710+
HorizontalTextAlignment="Center"
711+
Text="{Binding DayEventsOrientation}"
712+
TextColor="{StaticResource TappableSettingTextColor}"
713+
VerticalTextAlignment="Center">
714+
715+
<Label.GestureRecognizers>
716+
<TapGestureRecognizer Command="{Binding ShowDayEventsOrientationDialogCommand}"/>
717+
</Label.GestureRecognizers>
718+
719+
</Label>
720+
</Grid>
721+
670722
<Grid>
671723
<Label
672724
Grid.Column="0"
@@ -999,6 +1051,8 @@
9991051
AutoSetStyleBasedOnDayState="{Binding BindingContext.DayAutoSetStyleBasedOnDayState, Source={x:Reference This}}"
10001052
DateTime="{Binding DateTime}"
10011053
Events="{Binding Events}"
1054+
EventsOrientation="{Binding BindingContext.DayEventsOrientation, Source={x:Reference This}}"
1055+
EventsSpacing="{Binding BindingContext.DayEventsSpacing, Source={x:Reference This}}"
10021056
HeightRequest="{Binding BindingContext.DayHeightRequest, Source={x:Reference This}}"
10031057
IsCurrentMonth="{Binding IsCurrentMonth}"
10041058
IsInvalid="{Binding IsInvalid}"
@@ -1010,10 +1064,12 @@
10101064
<DataTemplate x:DataType="{x:Null}">
10111065
<Rectangle
10121066
Fill="{Binding Color}"
1067+
RadiusX="{Binding BindingContext.DayEventCornerRadius, Source={x:Reference This}}"
1068+
RadiusY="{Binding BindingContext.DayEventCornerRadius, Source={x:Reference This}}"
10131069
Style="{StaticResource DefaultEventIndicatorRectangleStyle}"/>
10141070
</DataTemplate>
10151071
</xc:DayView.EventTemplate>
1016-
1072+
10171073
<xc:DayView.CurrentMonthStyle>
10181074
<Style BasedOn="{StaticResource DefaultDayViewCurrentMonthStyle}" TargetType="{x:Type xc:DayView}">
10191075
<Setter Property="BackgroundColor" Value="{Binding BindingContext.DayCurrentMonthBackgroundColor, Source={x:Reference This}}"/>

XCalendarMauiSample/Helpers/PopupHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public static class PopupHelper
1313
public static List<PageStartMode> AllPageStartModes { get; set; } = Enum.GetValues(typeof(PageStartMode)).Cast<PageStartMode>().ToList();
1414
public static List<NavigationLoopMode> AllNavigationLoopModes { get; set; } = Enum.GetValues(typeof(NavigationLoopMode)).Cast<NavigationLoopMode>().ToList();
1515
public static List<DayOfWeek> AllDaysOfWeek { get; set; } = DayOfWeek.Monday.GetWeekAsFirst();
16+
public static List<StackOrientation> AllStackOrientations { get; set; } = Enum.GetValues(typeof(StackOrientation)).Cast<StackOrientation>().ToList();
1617
#endregion
1718

1819
#region Methods

XCalendarMauiSample/ViewModels/PlaygroundViewModel.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public class PlaygroundViewModel : BaseViewModel
4848
public double DayHeightRequest { get; set; } = 45;
4949
public double DayWidthRequest { get; set; } = -1;
5050
public bool DayAutoSetStyleBasedOnDayState { get; set; } = true;
51+
public double DayEventCornerRadius { get; set; } = 100;
52+
public double DayEventsSpacing { get; set; } = 2.5;
53+
public StackOrientation DayEventsOrientation { get; set; } = StackOrientation.Horizontal;
5154
public int ForwardsNavigationAmount { get; set; } = 1;
5255
public int BackwardsNavigationAmount { get; set; } = -1;
5356
public string TargetCultureCode { get; set; } = CultureInfo.CurrentCulture?.Name ?? CultureInfo.DefaultThreadCurrentCulture?.Name ?? CultureInfo.CurrentUICulture?.Name ?? CultureInfo.DefaultThreadCurrentUICulture?.Name ?? "en";
@@ -95,6 +98,7 @@ public class PlaygroundViewModel : BaseViewModel
9598
public ICommand ChangeDateSelectionCommand { get; set; }
9699
public ICommand ChangeCalendarVisibilityCommand { get; set; }
97100
public ICommand UpdateCurrentCultureCommand { get; set; }
101+
public ICommand ShowDayEventsOrientationDialogCommand { get; set; }
98102
#endregion
99103

100104
#region Constructors
@@ -126,6 +130,7 @@ public PlaygroundViewModel()
126130
ChangeDateSelectionCommand = new Command<DateTime>(ChangeDateSelection);
127131
ChangeCalendarVisibilityCommand = new Command<bool>(ChangeCalendarVisibility);
128132
UpdateCurrentCultureCommand = new Command(UpdateCurrentCulture);
133+
ShowDayEventsOrientationDialogCommand = new Command(ShowDayEventsOrientationDialog);
129134

130135
List<ColoredEvent> events = new List<ColoredEvent>()
131136
{
@@ -370,6 +375,10 @@ public async void ShowDayInvalidTextColorDialog()
370375
{
371376
DayInvalidTextColor = await PopupHelper.ShowColorDialogAsync(DayInvalidTextColor);
372377
}
378+
public async void ShowDayEventsOrientationDialog()
379+
{
380+
DayEventsOrientation = await PopupHelper.ShowSelectItemDialogAsync(DayEventsOrientation, PopupHelper.AllStackOrientations);
381+
}
373382
#endregion
374383
}
375384
}

XCalendarMauiSample/Views/PlaygroundPage.xaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,88 @@
693693
VerticalOptions="End"/>
694694
</Grid>
695695

696+
<Grid>
697+
<Label
698+
Grid.Column="0"
699+
FontSize="{StaticResource SmallFontSize}"
700+
HorizontalTextAlignment="Center"
701+
Text="EventCornerRadius"
702+
VerticalTextAlignment="Center"/>
703+
<Editor
704+
Grid.Column="1"
705+
HorizontalOptions="Center"
706+
Keyboard="Numeric"
707+
Text="{Binding DayEventCornerRadius}"
708+
VerticalOptions="End"/>
709+
</Grid>
710+
711+
<Grid>
712+
<Label
713+
Grid.Column="0"
714+
FontSize="{StaticResource SmallFontSize}"
715+
HorizontalTextAlignment="Center"
716+
Text="EventsSpacing"
717+
VerticalTextAlignment="Center"/>
718+
<Editor
719+
Grid.Column="1"
720+
HorizontalOptions="Center"
721+
Keyboard="Numeric"
722+
Text="{Binding DayEventsSpacing}"
723+
VerticalOptions="End"/>
724+
</Grid>
725+
726+
<Grid>
727+
<Label
728+
Grid.Column="0"
729+
FontSize="{StaticResource SmallFontSize}"
730+
HorizontalTextAlignment="Center"
731+
Text="EventsOrientation"
732+
VerticalTextAlignment="Center"/>
733+
<Label
734+
Grid.Column="1"
735+
FontSize="{StaticResource SmallFontSize}"
736+
HorizontalTextAlignment="Center"
737+
Text="{Binding DayEventsOrientation}"
738+
TextColor="{StaticResource TappableSettingTextColor}"
739+
VerticalTextAlignment="Center">
740+
741+
<Label.GestureRecognizers>
742+
<TapGestureRecognizer Command="{Binding ShowDayEventsOrientationDialogCommand}"/>
743+
</Label.GestureRecognizers>
744+
745+
</Label>
746+
</Grid>
747+
748+
<Grid>
749+
<Label
750+
Grid.Column="0"
751+
FontSize="{StaticResource SmallFontSize}"
752+
HorizontalTextAlignment="Center"
753+
Text="InvalidTextColor"
754+
VerticalTextAlignment="Center"/>
755+
756+
<Border
757+
Grid.Column="1"
758+
Padding="0"
759+
BackgroundColor="{Binding DayInvalidTextColor}"
760+
HorizontalOptions="Center"
761+
Stroke="Black"
762+
StrokeThickness="1"
763+
VerticalOptions="Center">
764+
765+
<Border.StrokeShape>
766+
<RoundRectangle CornerRadius="10"/>
767+
</Border.StrokeShape>
768+
769+
<BoxView HeightRequest="40" WidthRequest="40"/>
770+
771+
<Border.GestureRecognizers>
772+
<TapGestureRecognizer Command="{Binding ShowDayInvalidTextColorDialogCommand}"/>
773+
</Border.GestureRecognizers>
774+
775+
</Border>
776+
</Grid>
777+
696778
<Grid>
697779
<Label
698780
Grid.Column="0"
@@ -1040,6 +1122,8 @@
10401122
AutoSetStyleBasedOnDayState="{Binding BindingContext.DayAutoSetStyleBasedOnDayState, Source={x:Reference This}}"
10411123
DateTime="{Binding DateTime}"
10421124
Events="{Binding Events}"
1125+
EventsOrientation="{Binding BindingContext.DayEventsOrientation, Source={x:Reference This}}"
1126+
EventsSpacing="{Binding BindingContext.DayEventsSpacing, Source={x:Reference This}}"
10431127
HeightRequest="{Binding BindingContext.DayHeightRequest, Source={x:Reference This}}"
10441128
IsCurrentMonth="{Binding IsCurrentMonth}"
10451129
IsInvalid="{Binding IsInvalid}"
@@ -1051,6 +1135,8 @@
10511135
<DataTemplate x:DataType="{x:Null}">
10521136
<Rectangle
10531137
Fill="{Binding Color}"
1138+
RadiusX="{Binding BindingContext.DayEventCornerRadius, Source={x:Reference This}}"
1139+
RadiusY="{Binding BindingContext.DayEventCornerRadius, Source={x:Reference This}}"
10541140
Style="{StaticResource DefaultEventIndicatorRectangleStyle}"/>
10551141
</DataTemplate>
10561142
</xc:DayView.EventTemplate>

0 commit comments

Comments
 (0)