Initial setup for navigation display with nav3
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
parent
909bd347a7
commit
89d55ede72
7 changed files with 107 additions and 4 deletions
11
shared/src/androidMain/kotlin/net/newpipe/Constants.kt
Normal file
11
shared/src/androidMain/kotlin/net/newpipe/Constants.kt
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package net.newpipe
|
||||
|
||||
object Constants {
|
||||
|
||||
const val INTENT_SCREEN_KEY = "SCREEN"
|
||||
}
|
||||
|
|
@ -9,6 +9,9 @@ import android.os.Bundle
|
|||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import kotlinx.serialization.json.Json
|
||||
import net.newpipe.Constants
|
||||
import net.newpipe.app.navigation.Screen
|
||||
|
||||
/**
|
||||
* Entry point for compose-related UI components on Android
|
||||
|
|
@ -19,7 +22,12 @@ class ComposeActivity : ComponentActivity() {
|
|||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContent {
|
||||
App()
|
||||
App(
|
||||
// TODO: Change when everything is in compose and this is the primary activity
|
||||
startDestination = Json.decodeFromString<Screen>(
|
||||
intent.getStringExtra(Constants.INTENT_SCREEN_KEY)!!
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package net.newpipe.app.extensions
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import kotlin.jvm.java
|
||||
import kotlinx.serialization.json.Json
|
||||
import net.newpipe.Constants
|
||||
import net.newpipe.app.ComposeActivity
|
||||
import net.newpipe.app.navigation.Screen
|
||||
|
||||
/**
|
||||
* Navigates to a given compose destination
|
||||
*/
|
||||
fun Context.navigateTo(screen: Screen) = Intent(this, ComposeActivity::class.java).also { intent ->
|
||||
intent.putExtra(Constants.INTENT_SCREEN_KEY, Json.encodeToString(screen))
|
||||
startActivity(intent)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue