yurkinh / Plugin.Maui.Calendar

.NET MAUI port of XF calendar plugin
MIT License
131 stars 12 forks source link

Calendar view is empty if I use it in a Shell Tab. #63

Closed xibeat closed 3 months ago

xibeat commented 4 months ago

Hi, First of all, great work with the plugin. I was using the calendar in Week view Layout. I noticed that when I change tabs in a shell and comeback to the calendar, I can't see any dates.

<controls:Calendar CalendarLayout="Week" HorizontalOptions="Fill" ShowMonthPicker="False" SelectedDayBackgroundColor="Black" SelectedDayTextColor="White" TodayOutlineColor="Black" DaysTitleLabelStyle="{StaticResource LabelRegular16}" DaysLabelStyle="{StaticResource LabelRegular14}" ShowYearPicker="False" EventsScrollViewVisible="False" VerticalOptions="Fill" AnimateCalendar="False" ShownDate="{Binding Today}" />

Output after switching and coming back to Shell Tab:

Screenshot 2024-06-04 at 12 27 33 AM
yurkinh commented 4 months ago

Hi @xibeat Thanks for the kind words. Could you please provide some minimal repro sample for easier debugging?

xibeat commented 4 months ago

Sure. I am using the .net Maui Shell with two tabs. One of them is a page with the Calendar Plugin.

AppShell.xaml

<Shell
    x:Class="Project.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    Shell.FlyoutBehavior="Disabled">

    <TabBar>
        <ShellContent ContentTemplate="{DataTemplate local:HomePage}" Icon="dotted_circle_icon" />
        <ShellContent ContentTemplate="{DataTemplate local:CalendarPage}" Icon="dotted_circle_icon" />
    </TabBar>
</Shell>

CalendarPage.xaml

<controls:Calendar
                CalendarLayout="Week"
                HorizontalOptions="Fill" 
                ShowMonthPicker="False"
                SelectedDayBackgroundColor="Black"
                SelectedDayTextColor="White"
                TodayOutlineColor="Black"
                DaysTitleLabelStyle="{StaticResource LabelTextRegular16}"
                DaysLabelStyle="{StaticResource LabelTextRegular14}"
                ShowYearPicker="False"
                EventsScrollViewVisible="False"
                VerticalOptions="Fill"
                AnimateCalendar="False"
                ShownDate="{Binding Today}" />

Today is the Datetime.Today from the view model.

Steps to reproduce:

  1. Start App, and tap on Calendar Tab.(calendar working fine)
  2. Switch to Home Tab and return to Calendar Tab again (calendar is not rendering)
poochie89 commented 4 months ago

I have a similar bug on iOS, i can reproduce it with this minimal code

<ContentPage .......
    xmlns:plugin="clr-namespace:Plugin.Maui.Calendar.Controls;assembly=Plugin.Maui.Calendar" >
    <plugin:Calendar>
        <plugin:Calendar.GestureRecognizers>
            <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"></TapGestureRecognizer>
        </plugin:Calendar.GestureRecognizers>
        </plugin:Calendar>
</ContentPage>
    private async void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e)
    {
        EmptyPage emptyPage = new EmptyPage();
        await Navigation.PushModalAsync(emptyPage);
        await Task.Delay(1000);
        await Navigation.PopModalAsync();
    }

After the Empty Page is closed the calendar looks like this

Bildschirmfoto 2024-06-06 um 09 42 42

yungd1plomat commented 4 months ago

is there a temporary solution to fix this?

yurkinh commented 4 months ago

Hi @yungd1plomat Working on it. I hope to provide fix soon

StevenSmartAppDev commented 4 months ago

Encountering same issue when changing tab. Please find an issue, thanks

edgiardina commented 4 months ago

I also encountered this as well.

yurkinh commented 4 months ago

As a temporary workaround I would suggest downgrading to version 1.1.6 while I'm working on a solution for this issue. It's related to an events unsubscription that was changed.

StevenSmartAppDev commented 4 months ago

Indeed version 1.16 works great..thanks for the work around..hope a solution can be found but what's more important is that its working 👍

Muhesh02 commented 3 months ago

I Tried with version 1.1.6 still I have the same issue when I navigate back to calendar, the days are missing, please find the solution for this issue, and also sometimes I have issue with UpdateDays Method, please look at that as well if you have some time, and its look awesome package Man! Thanks

janousek commented 3 months ago

I discovered that the problem disappears when I remove this line: https://github.com/yurkinh/Plugin.Maui.Calendar/blob/3f6c126a3e15bc7141458fe1c664d4c389589202/src/Plugin.Maui.Calendar/Shared/Controls/MonthDaysView.cs#L1076

yurkinh commented 3 months ago

@janousek @Muhesh02 I have already fixed this issue and plan to do a release today (or tomorrow) with some other goodies from PR#69

edgiardina commented 3 months ago

https://github.com/yurkinh/Plugin.Maui.Calendar/assets/3627193/060db2e7-e5f5-4acc-ad70-d00ceae29512

Enclosed is a video of the behavior, as you can see, the 27th which has an event is white on initial load, but when I use the home button and return to the app, it is black.

Repository:

https://github.com/edgiardina/PluginMauiCalendar-67-repro