Sha256: 0e46545398c227cdb1b684f7773d2b43d424883dbe50e5575c6a2e9af83ddf90
Contents?: true
Size: 1.85 KB
Versions: 9
Compression:
Stored size: 1.85 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.strada.KotlinXJsonConverter import dev.hotwire.strada.Strada import dev.hotwire.turbo.activities.TurboActivity import dev.hotwire.turbo.delegates.TurboActivityDelegate import <%= package_name %>.R class MainActivity : AppCompatActivity(), TurboActivity { private val viewFliper: ViewFlipper get() = findViewById(R.id.view_flipper) private val bottomNavigationView: BottomNavigationView get() = findViewById(R.id.bottom_navigation_view) 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) Strada.config.jsonConverter = KotlinXJsonConverter() setupBottomNavigationView() } private fun setupBottomNavigationView() { bottomNavigationView.setOnItemSelectedListener { when (it.itemId) { R.id.tab_item_one -> { delegate.currentNavHostFragmentId = R.id.tab_one_nav_host viewFliper.displayedChild = 0 true } R.id.tab_item_two -> { delegate.currentNavHostFragmentId = R.id.tab_two_nav_host viewFliper.displayedChild = 1 true } else -> { throw RuntimeException("Invalid tab") } } } } }
Version data entries
9 entries across 9 versions & 1 rubygems