Skip to content

Commit

Permalink
Improve CalendarView layout performance
Browse files Browse the repository at this point in the history
Just a small layout optimisation.
  • Loading branch information
ME-MarvinE committed Jan 9, 2025
1 parent e6ca999 commit af36a3b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
19 changes: 13 additions & 6 deletions XCalendar.Forms/Views/CalendarView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@
x:Name="CalendarView_Unique"
x:DataType="{x:Type xc:CalendarView}">

<StackLayout Spacing="0">
<StackLayout.Resources>
<System:Boolean x:Key="FalseValue">False</System:Boolean>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<Grid.Resources>
<System:Boolean x:Key="FalseValue">False</System:Boolean>
<Converters:IsNullOrEmptyConverter x:Key="IsNullOrEmptyConverter"/>
<Converters:LocalizeDayOfWeekAndCharLimitConverter x:Key="LocalizeDayOfWeekAndCharLimitConverter"/>
</StackLayout.Resources>
</Grid.Resources>

<xc:NavigationView
Grid.Row="0"
ControlTemplate="{Binding NavigationViewTemplate, Source={x:Reference CalendarView_Unique}}"
DateTime="{Binding NavigatedDate, Source={x:Reference CalendarView_Unique}}"
LeftArrowCommand="{Binding LeftArrowCommand, Source={x:Reference CalendarView_Unique}}"
Expand All @@ -26,7 +32,7 @@
RightArrowCommandParameter="{Binding RightArrowCommandParameter, Source={x:Reference CalendarView_Unique}}"/>

<!--#region DayNames-->
<ContentView ControlTemplate="{Binding DayNamesTemplate, Source={x:Reference CalendarView_Unique}}">
<ContentView Grid.Row="1" ControlTemplate="{Binding DayNamesTemplate, Source={x:Reference CalendarView_Unique}}">
<CollectionView
x:Name="MainDaysOfWeekView"
Margin="0,5,0,0"
Expand Down Expand Up @@ -71,11 +77,12 @@

<xc:DaysView
x:Name="MainDaysView"
Grid.Row="2"
ControlTemplate="{Binding DaysViewTemplate, Source={x:Reference CalendarView_Unique}}"
DayTemplate="{Binding DayTemplate, Source={x:Reference CalendarView_Unique}}"
DaysOfWeek="{Binding DaysOfWeek, Source={x:Reference CalendarView_Unique}}"
HeightRequest="{Binding DaysViewHeightRequest, Source={x:Reference CalendarView_Unique}}"/>

</StackLayout>
</Grid>

</ContentView>
20 changes: 14 additions & 6 deletions XCalendar.Maui/Views/CalendarView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@
x:Name="CalendarView_Unique"
x:DataType="{x:Type xc:CalendarView}">

<VerticalStackLayout Spacing="0">
<VerticalStackLayout.Resources>
<System:Boolean x:Key="FalseValue">False</System:Boolean>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<Grid.Resources>
<System:Boolean x:Key="FalseValue">False</System:Boolean>
<Converters:IsNullOrEmptyConverter x:Key="IsNullOrEmptyConverter"/>
<Converters:LocalizeDayOfWeekAndCharLimitConverter x:Key="LocalizeDayOfWeekAndCharLimitConverter"/>
</VerticalStackLayout.Resources>
</Grid.Resources>

<xc:NavigationView
Grid.Row="0"
ControlTemplate="{Binding NavigationViewTemplate, Source={x:Reference CalendarView_Unique}}"
DateTime="{Binding NavigatedDate, Source={x:Reference CalendarView_Unique}}"
LeftArrowCommand="{Binding LeftArrowCommand, Source={x:Reference CalendarView_Unique}}"
Expand All @@ -28,7 +35,7 @@
RightArrowCommandParameter="{Binding RightArrowCommandParameter, Source={x:Reference CalendarView_Unique}}"/>

<!--#region DayNames-->
<ContentView ControlTemplate="{Binding DayNamesTemplate, Source={x:Reference CalendarView_Unique}}">
<ContentView Grid.Row="1" ControlTemplate="{Binding DayNamesTemplate, Source={x:Reference CalendarView_Unique}}">
<CollectionView
x:Name="MainDaysOfWeekView"
Margin="0,5,0,0"
Expand Down Expand Up @@ -74,11 +81,12 @@

<xc:DaysView
x:Name="MainDaysView"
Grid.Row="2"
ControlTemplate="{Binding DaysViewTemplate, Source={x:Reference CalendarView_Unique}}"
DayTemplate="{Binding DayTemplate, Source={x:Reference CalendarView_Unique}}"
DaysOfWeek="{Binding DaysOfWeek, Source={x:Reference CalendarView_Unique}}"
HeightRequest="{Binding DaysViewHeightRequest, Source={x:Reference CalendarView_Unique}}"/>

</VerticalStackLayout>
</Grid>

</ContentView>

0 comments on commit af36a3b

Please sign in to comment.