airbnb / HorizonCalendar

A declarative, performant, iOS calendar UI component that supports use cases ranging from simple date pickers all the way up to fully-featured calendar apps.
Apache License 2.0
2.83k stars 235 forks source link

SwiftUI toolbar and title disappears when CalendarViewRepresentable present #215

Open dorianpavetic opened 1 year ago

dorianpavetic commented 1 year ago

I have tried creating a calendar with exact as from your PR with example.

Works great, but I have noticed that when put inside a NavigationStack, title and toolbar disappears. I have tried some alternatives and figured out that toolbar and title appears when I remove both monthHeaderItemProvider and dayItemProvider.

WITH month and day providers

WITH month and day providers

WITHOUT month and day providers

WITHOUT month and day providers

Am I doing something wrong? Is there some kind of a workaround or fix for this?

bryankeller commented 1 year ago

This is really weird - did you ever find a workaround? I'll play around with this later today to see what's up.

alex-taras commented 1 year ago

Can confirm the same behavior. Not even forcing navigationBarHidden false fixes it. As soon as we add any providers to the CalendarViewRepresentable, the nav bar goes away for good. Couldn't find a workaround.

alex-taras commented 1 year ago

small update, tried on iOS15 and it seems to work there, so something changed in iOS16 that breaks this.

alex-taras commented 1 year ago

Small update, my app is a tabbed app, I've noticed that when I switch to another tab and back to the calendar tab, the nav bar appears. So looks like a timing issue, a hacky workaround is to force a tab change at app start...however, when scrolling to another month (horizontal layout), the nav bar dissappears again for that month. Switching tabs fixes it for that month for good so it looks like the issue appears when first displaying a month.

jazek-c commented 10 months ago

Any updates on This? Seems like it's still happening in iOS 16

JOyo246 commented 7 months ago

any updates on this? Seems like it pretty much blocks HorizonCalendar from being used in a SwiftUI context

jl-mobitech commented 4 months ago

@bryankeller, any updates for this? Using the providers makes the navigation title hidden, which is just like the OP said.

thisIsTheFoxe commented 4 months ago

I'm assuming the issue is related to the CalendarViewRepresentable being a ScrollView which messes with the large navigation title or something..? Whatever it is a simple workaround is to remove it from navigation stack hirachy. Simple way of doing that is overlaying it on top of a placeholder view:

var body: some View {
    NavigationStack {
        VStack {
            Color.clear.overlay {
                CalendarViewRepresentable(calendar: .current, [...])
            }
        }
    }
}
IraklisElef commented 3 months ago

I face the exact same problem. When using the days or months providers, the navigation bar disappears. Have you found any solutions?

theoks commented 2 days ago

Same issue here, and it's a real pain. We use the calendar in only 2 views and we have the same issue in both. Are there any updated on the issue?

JOyo246 commented 1 day ago

Probably not the best solution, but I've fixed this in my apps by wrapping each Calendar in an extra NavigationView

IraklisElef commented 1 day ago

Probably not the best solution, but I've fixed this in my apps by wrapping each Calendar in an extra NavigationView

I tried to do that but it did not work. Could you show me the code snippet of your project?