Sha256: dbf2dbad42f3f26d5311f275a5aaa2637d4442f3560470b6636671a3a7b9c44c
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
package <%= package_name %>.main import android.os.Bundle import android.widget.ViewFlipper import androidx.appcompat.app.AppCompatActivity import com.google.android.material.bottomnavigation.BottomNavigationView import dev.hotwire.turbo.activities.TurboActivity import dev.hotwire.turbo.delegates.TurboActivityDelegate import <%= package_name %>.R class MainActivity : AppCompatActivity(), TurboActivity { override lateinit var delegate: TurboActivityDelegate override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) delegate = TurboActivityDelegate(this, R.id.tab_one_nav_host) delegate.registerNavHostFragment(R.id.tab_one_nav_host) delegate.registerNavHostFragment(R.id.tab_two_nav_host) setupBottomNavigationView() } private fun setupBottomNavigationView() { val viewFliper = findViewById<ViewFlipper>(R.id.view_flipper) val bottomNavigationView = findViewById<BottomNavigationView>(R.id.bottom_navigation_view) bottomNavigationView.setOnItemSelectedListener { when (it.itemId) { R.id.tab_item_one -> { viewFliper.displayedChild = 0 delegate.currentNavHostFragmentId = R.id.tab_one_nav_host true } R.id.tab_item_two -> { viewFliper.displayedChild = 1 delegate.currentNavHostFragmentId = R.id.tab_two_nav_host true } else -> { throw RuntimeException("Invalid tab") } } } } }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
turbo-native-initializer-0.0.1 | lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/main/MainActivity.kt.tt |