ME-MarvinE / XCalendar

A plugin for .NET providing an API for representing a calendar along with fully customisable calendar controls for Xamarin Forms and .NET MAUI
MIT License
300 stars 36 forks source link

DaySelectedBackgroundColor - Circle not Rendering #99

Closed johnyenter-briars closed 1 year ago

johnyenter-briars commented 1 year ago

Describe the bug

Hi there!

Thanks for all the work you put into XCalendar!

I think I might be experiencing a bug in setting the color value for the dot that indicates the currently selected date.

Looking at the [Sample Code]() it looks to me like it should be set on the cx:DayView - where you assign it to a Color value.

I've done that like so:

<xc:DayView
    ...
    SelectedBackgroundColor="{StaticResource DaySelectedBackgroundColor}"
    ...
    >
</xc:DayView>

And then set the resource in App.xaml like

<Application.Resources>
    ...
    <Color x:Key="DaySelectedBackgroundColor">Green</Color>
    ...
</Application.Resources>

However, the selected indicator still does not populate. Screenshot: xcalendarissue

Are there other properties that I need to set to enable this feature?

Expected behavior

I would think there should be a green dot when selecting on a day.

Steps to reproduce OR link to code

I've uploaded my current code to this repo / branch

Xamarin Forms or .NET MAUI (If related to UI)

.NET MAUI

Additional context (Optional)

Device Info (Optional) Device Model: samsung galaxy s20 FE Android Version: 12, One UI version 4.1 IOS Version: Windows Version:

ME-MarvinE commented 1 year ago

When you say "Indicators", do you mean like one of the two red dots in your image? If so, there is no built in functionality for indicators. You will need to implement the logic yourself.

If you mean an actual day, the DayView has some properties you need to set in order to get the state-based properties working in different states. The Displaying Dates page lists them in the 'CalendarView' section. Usually you would just bind them to the properties of the same name from the binding context.

ME-MarvinE commented 1 year ago

Could you provide a link to the actual file the code is in as well as which branch? The link in the issue is to the 'master' branch which doesn't have XCalendar installed and I can locate the files in the 'bringing_in_calendarview' branch but don't know which part refers to your issue.

johnyenter-briars commented 1 year ago

Hey @ME-MarvinE - thanks for looking into this!

I'm pretty sure I linked to the exact branch / file in the ticket - but here is the exact full link: https://github.com/johnyenter-briars/cal/blob/dev/bring_in_xcalendar/CAL/Views/CalendarPage.xaml

The UI i'm referring to is the little dot that represents which dates are currently selected: xcalendarexample

In my code, my understanding is that setting

<xc:DayView
    ...
    SelectedBackgroundColor="Green"
    ...
    >
</xc:DayView>

should render that circle as green. Maybe I'm misunderstanding what that property does or maybe it's a separate property that I need too use. But regardless I'm unable to get the circle to render on my device.

ME-MarvinE commented 1 year ago

@johnyenter-briars I was opening the link through the Mobile app which kept leading me to the 'master' branch. The links work fine on PC.

Eventually I tried using a Calendar with CalendarDay instead of EventDay and it worked.

The EventDay and Event classes in the sample app (along with other classes) use the PropertyChanged.Fody nuget package to inject usage of the INotifyPropertyChanged interface into the shorthand setter ({ get; set; }) by adding the AddINotifyPropertyChangedInterface attribute to the 'BaseObservable' classes which they inherit from.

This package nor the attribute is present in the project and there was no replacement for its functionality. You will need to either implement the INotifyPropertyChanged Interface manually, or install the PropertyChanged.Fody nuget package and re-add the AddINotifyPropertyChangedInterface attribute wherever it was removed.

I implemented the interface manually into the EventDay class and everything seemed to work correctly.

Thanks for using XCalendar

ME-MarvinE commented 1 year ago

@johnyenter-briars Is your issue resolved?

johnyenter-briars commented 1 year ago

@ME-MarvinE Sorry, took me a while to find the time to implement your fix. It worked as expected.

Thank you so much! Closing the issue now.