HorizonCalendar icon indicating copy to clipboard operation
HorizonCalendar copied to clipboard

SwiftUI toolbar and title disappears when CalendarViewRepresentable present

Open dorianpavetic opened this issue 1 year ago • 9 comments

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?

dorianpavetic avatar Mar 10 '23 18:03 dorianpavetic

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

bryankeller avatar May 31 '23 21:05 bryankeller

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 avatar Jul 18 '23 20:07 alex-taras

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

alex-taras avatar Jul 19 '23 12:07 alex-taras

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.

alex-taras avatar Sep 27 '23 21:09 alex-taras

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

jazek-c avatar Jan 15 '24 04:01 jazek-c

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

JOyo246 avatar Mar 22 '24 23:03 JOyo246

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

jl-mobitech avatar Jun 18 '24 16:06 jl-mobitech

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, [...])
            }
        }
    }
}

thisIsTheFoxe avatar Jul 13 '24 07:07 thisIsTheFoxe

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

IraklisElef avatar Aug 13 '24 09:08 IraklisElef