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

Hiding Home Indicator Issues #34

Closed
LePips opened this issue Oct 24, 2021 · 3 comments
Closed

Hiding Home Indicator Issues #34

LePips opened this issue Oct 24, 2021 · 3 comments

Comments

@LePips
Copy link
Collaborator

LePips commented Oct 24, 2021

An app that I am contributing to has a video player that must have the home indicator hidden. It was working before but implementing Stinsen has broken it. It is done in SwiftUI and we use this somewhat popular workaround.

I have provided the sample project: https://github.com/LePips/StinsenHideBar2

I ask that the project is checked out. This project has a view A that presents a view B. B should have the home indicator hidden. I am currently attempting to hide the home indicator on every view that I possibly can, even through customize(). I currently find it weird that only view A has the home indicator hidden.

If I could get some help that would be great but I understand issues can't be addressed ad hoc. Or, if I should be doing something else with Stinsen, guidance would be helpful.

Thanks!

@rundfunk47
Copy link
Owner

rundfunk47 commented Oct 24, 2021

Hi! Always exciting to see projects using Stinsen 👍🏽 Are we sure this is a Stinsen issue? For instance

@main
struct TestApp: App {
    var body: some Scene {
        WindowGroup {
            EmptyView()
                .withHostingWindow { window in
                    window?.rootViewController = PreferenceUIHostingController(wrappedView: ContentView())
                }
        }
    }
}

// Just a view to navigate to the emulated video player view
struct ContentView: View {
    @State var active: Bool = false

    var body: some View {
        Button {
            active = true
        } label: {
            Text("Present BlackView")
        }
        .prefersHomeIndicatorAutoHidden(true) // Hides the home indicator
        .fullScreenCover(
            isPresented: $active,
            onDismiss: nil,
            content: { BlackView() }
        )
    }
}

// Emulates a video player view, should have home indicator hidden
struct BlackView: View {
    var body: some View {
        ZStack {
            Color.black.ignoresSafeArea()
        }
        .prefersHomeIndicatorAutoHidden(true) // Doesn't hide home indicator
    }
}

seems to trigger this issue as well. This is essentially what Stinsen uses under the hood to present the full screen modal.

I might be doing something wrong, though, with the home button hiding code

@LePips
Copy link
Collaborator Author

LePips commented Oct 25, 2021

Thank you for the prompt response and showing how this works under the hood. I had just thought that it was a problem arising from Stinsen but now after running your example that it may be a limitation of SwiftUI. I'll have to look back at how we did it before (I think it was just a NavigationLink) and possible just have to redo how we route/root to this specific screen. Having it as a root option on our MainCoordinator also fixes the issue, but also has some weird results. Thanks!

@LePips LePips closed this as completed Oct 25, 2021
@rundfunk47
Copy link
Owner

Glad to be of help! Perhaps using the swizzling-method would solve your issue? I often use it myself when needing to change the underlying UIKit-components in SwiftUI.

Thanks! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants