How to hide app's title toolbar(? in turbo native app

I’ve been trying to hide this

Can’t find a solution

Note this is not the app’s toolbar, it is already hidden

did you try hiding it with stimulus controller on connect ?

no, how do i do that?

Just to be clear, when you say “Note this is not the app’s toolbar”, what is it actually? Is it some div you added or is it coming from Android (or iOS) view?

when u setup the android app you first have two “navs” one has the native app title and the other the web app title. the one that has the native app title is the toolbar, the other one (i believe) comes from the TurboNavHostFragment class

Hi, did you find a solution? I’m stuck with the same title bar

i haven’t. u find the solution u tell me pls

1 Like

I also wanted no title at top of my app - seems this would be a common request! Wanted to control the entire screen.

I was able to solve this by cloning the turbo navigator branch of Turbo-iOS Native - apparently the most current - onto my local system. I removed the remote (GitHub) package of Turbo-ios in my Xcode project and instead added my local copy as the package source (click “local”). Xcode found Turbo-ios (local) and added it. My project worked fine after this change.

Next, I using Xcode, opened this file within the local copy of the Turbo-iOS package: Source/Visitable/VisitableViewController. It’s not a big file. Changed the viewWillAppear override as below - just added one line.

Hope this helps others!

    open override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        // Add the line below to hide the WKWebView navigation bar
        // which is used to display the page title in the main
        // Turbo sources
        self.navigationController?.setNavigationBarHidden(true, animated: false)
        // and done.
        
        visitableDelegate?.visitableViewWillAppear(self)
    }

I think you went a bit far here :smile:

All I needed to do was add the following line to the function scene in the main SceneDelegate class:

        navigationController.setNavigationBarHidden(true, animated: false)

I put it just before the line that sets the navigation controller for the window.

1 Like

Well that would have been helpful to know. Is that documented anywhere that I missed?

I guessed it after reading your post :slight_smile:

Realised that we have the global navigation controller in SceneDelegate, so call that method on it and it worked.

For those of you trying to do this in Android there doesn’t seem to be a function call or config like setNavigationBarHidden I could find. I got there by going into layouts and creating my own turbo_fragment_web.xml file. I took a copy of the one that ships with Turbo Android and removed the section that creates the app bar, giving me this:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include
        layout="@layout/turbo_view"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/app_bar" />

</androidx.constraintlayout.widget.ConstraintLayout>

When the app loads it finds my version of the layout that has no toolbar. This feels like a hack, but it works.

1 Like

Using self.navigator.rootViewController.setNavigationBarHidden(true, animated: false) worked for me with Hotwire Native

2 Likes

I grepped the code and couldn’t find the method. Thanks for this.

(Later)

Ah, this isn’t the droid I was looking for. :smiley:

1 Like