Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added OtherMonthSelectedDayColor property #75

Merged
merged 4 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Simple cross platform plugin for Calendar control featuring:
* Updated to .NET 8
* Added OnShownDateChangedCommand so we can take action when date is changed.
* Added Dispose method to force handlers disconnect call.
* Added new property **OtherMonthSelectedDayColor**


### Usage
Expand Down Expand Up @@ -190,6 +191,7 @@ SelectedTodayTextColor="Green"
TodayOutlineColor="Blue"
TodayFillColor="Silver"
TodayTextColor="Yellow"
OtherMonthSelectedDayColor="HotPink"
```

#### Available customization properties
Expand Down
2 changes: 1 addition & 1 deletion samples/SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.60" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Mopups" Version="1.3.1" />
</ItemGroup>
Expand Down
29 changes: 15 additions & 14 deletions samples/SampleApp/Views/SimplePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:SampleApp.ViewModels"
xmlns:plugin="clr-namespace:Plugin.Maui.Calendar.Controls;assembly=Plugin.Maui.Calendar"
Unloaded="UnloadedHandler"
x:Name="simpleCalendarPage">
x:Name="simpleCalendarPage"
Unloaded="UnloadedHandler">
<ContentPage.Resources>
<ResourceDictionary>
<Style x:Key="daysLabelStyle" TargetType="Label">
Expand All @@ -18,7 +18,7 @@
<Setter Property="Margin" Value="5,2" />
</Style>
<Style x:Key="daysTitleLabelStyle" TargetType="Label">
<Setter Property="FontSize" Value="18" />
<Setter Property="FontSize" Value="18" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
Expand All @@ -31,19 +31,20 @@

<plugin:Calendar
x:Name="calendar"
Padding="10,0"
ArrowsFontSize="Medium"
DayViewFontSize="Medium"
DaysLabelStyle="{StaticResource daysLabelStyle}"
DaysTitleColor="{AppThemeBinding Light={StaticResource Black},
Dark={StaticResource Yellow100Accent}}"
DaysTitleLabelStyle="{StaticResource daysTitleLabelStyle}"
Events="{Binding Events}"
HorizontalOptions="Fill"
MaximumDate="{Binding MaximumDate}"
MinimumDate="{Binding MinimumDate}"
Month="{Binding Month}"
Month="{Binding Month}"
OtherMonthSelectedDayColor="HotPink"
SelectedDate="{Binding SelectedDate}"
DayViewFontSize="Medium"
DaysLabelStyle="{StaticResource daysLabelStyle}"
DaysTitleLabelStyle="{StaticResource daysTitleLabelStyle}"
ArrowsFontSize="Medium"
DaysTitleColor = "{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource Yellow100Accent}}"
Year="{Binding Year}"
Padding="10,0"
HorizontalOptions="Fill"
VerticalOptions="Fill">
</plugin:Calendar>
VerticalOptions="Fill"
Year="{Binding Year}" />
</ContentPage>
2 changes: 1 addition & 1 deletion src/Plugin.Maui.Calendar/Plugin.Maui.Calendar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.60" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
1 change: 1 addition & 0 deletions src/Plugin.Maui.Calendar/Shared/Controls/Calendar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
MaximumDate="{Binding MaximumDate, Source={x:Reference calendar}}"
MinimumDate="{Binding MinimumDate, Source={x:Reference calendar}}"
OtherMonthDayColor="{Binding OtherMonthDayColor, Source={x:Reference calendar}}"
OtherMonthSelectedDayColor="{Binding OtherMonthSelectedDayColor, Source={x:Reference calendar}}"
OtherMonthDayIsVisible="{Binding OtherMonthDayIsVisible, Source={x:Reference calendar}}"
SelectedDates="{Binding SelectedDates, Source={x:Reference calendar}, Mode=TwoWay}"
SelectedDayBackgroundColor="{Binding SelectedDayBackgroundColor, Source={x:Reference calendar}}"
Expand Down
20 changes: 20 additions & 0 deletions src/Plugin.Maui.Calendar/Shared/Controls/Calendar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,26 @@ public Color OtherMonthDayColor
set => SetValue(OtherMonthDayColorProperty, value);
}

/// <summary>
/// Bindable property for OtherMonthSelectedDayColor
/// </summary>
public static readonly BindableProperty OtherMonthSelectedDayColorProperty = BindableProperty.Create(
nameof(OtherMonthSelectedDayColor),
typeof(Color),
typeof(Calendar),
Colors.Silver
);

/// <summary>
/// Specifies the color of selected days belonging to a month other than the selected one
/// </summary>
public Color OtherMonthSelectedDayColor
{
get => (Color)GetValue(OtherMonthSelectedDayColorProperty);
set => SetValue(OtherMonthSelectedDayColorProperty, value);
}


/// <summary>
/// Bindable property for OtherMonthDayIsVisible
/// </summary>
Expand Down
23 changes: 22 additions & 1 deletion src/Plugin.Maui.Calendar/Shared/Controls/MonthDaysView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,33 @@ public Color WeekendDayColor
);

/// <summary>
/// Color of text for for days not belonging to the current month
/// Color of text for (days not belonging to the current month
/// </summary>
public Color OtherMonthDayColor
{
get => (Color)GetValue(OtherMonthDayColorProperty);
set => SetValue(OtherMonthDayColorProperty, value);
}

/// <summary>
/// Bindable property for OtherMonthSelectedDayColor
/// </summary>
public static readonly BindableProperty OtherMonthSelectedDayColorProperty = BindableProperty.Create(
nameof(OtherMonthSelectedDayColor),
typeof(Color),
typeof(MonthDaysView),
Colors.Silver
);

/// <summary>
/// Color of text for selected days not belonging to the current month
/// </summary>
public Color OtherMonthSelectedDayColor
{
get => (Color)GetValue(OtherMonthSelectedDayColorProperty);
set => SetValue(OtherMonthSelectedDayColorProperty, value);
}

/// <summary>
/// Bindable property for OtherMonthDayIsVisible
/// </summary>
Expand Down Expand Up @@ -859,6 +878,7 @@ protected override void OnPropertyChanged([CallerMemberName] string propertyName
case nameof(SelectedDayTextColor):
case nameof(SelectedTodayTextColor):
case nameof(OtherMonthDayColor):
case nameof(OtherMonthSelectedDayColor):
case nameof(WeekendDayColor):
case nameof(DeselectedDayTextColor):
case nameof(SelectedDayBackgroundColor):
Expand Down Expand Up @@ -1016,6 +1036,7 @@ private void UpdateDaysColors()
dayModel.SelectedTextColor = SelectedDayTextColor;
dayModel.SelectedTodayTextColor = SelectedTodayTextColor;
dayModel.OtherMonthColor = OtherMonthDayColor;
dayModel.OtherMonthSelectedColor = OtherMonthSelectedDayColor;
dayModel.WeekendDayColor = WeekendDayColor;
dayModel.SelectedBackgroundColor = SelectedDayBackgroundColor;
dayModel.TodayOutlineColor = TodayOutlineColor;
Expand Down
7 changes: 6 additions & 1 deletion src/Plugin.Maui.Calendar/Shared/Models/DayModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ internal partial class DayModel : ObservableObject
[NotifyPropertyChangedFor(nameof(TextColor))]
Color otherMonthColor = Colors.Silver;

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(TextColor))]
Color otherMonthSelectedColor = Colors.Gray;


[ObservableProperty]
[NotifyPropertyChangedFor(nameof(TextColor))]
Color weekendDayColor = Colors.Transparent;
Expand Down Expand Up @@ -192,11 +197,11 @@ public Color TextColor
(false, true, true, true, _, _) => EventIndicatorSelectedTextColor,
(false, false, true, true, _, _) => EventIndicatorTextColor,
(false, false, _, false, _, _) => OtherMonthColor,
(false, true, _, false, _, _) => OtherMonthSelectedColor,
(false, false, false, true, true, _)
=> TodayTextColor == Colors.Transparent ? DeselectedTextColor : TodayTextColor,
(false, _, _, _, _, true) => WeekendDayColor,
(false, false, false, true, false, _) => DeselectedTextColor,
(_, _, _, _, _, _) => Colors.Black
};
}
}
Expand Down
Loading