hi, < /p>
Я новичок в Kotlin, Kotlin Multi Platform и JetPack Compose, но не в NOOB для программирования. Я нашел использование для проекта KMP и работал над созданием NavGraph и NavhostController , поэтому я могу создавать различные страницы на основе передачи состояния поднятого. Он работает нормально, без ошибок: < /p>
Код: Выделить всё
import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
@Composable
fun MyFun(){
// ...
NavHost(/* navController, startDestination, modifier */)
// ...
}
< /code>
NavHostВот 3 из них. Обратите внимание, как 2 не есть @deprecated аннотация:
Код: Выделить всё
@Deprecated(
message = "Deprecated in favor of NavHost that supports AnimatedContent",
level = DeprecationLevel.HIDDEN
)
@Composable
public fun NavHost(
navController: NavHostController,
startDestination: String,
modifier: Modifier = Modifier,
route: String? = null,
builder: NavGraphBuilder.() -> Unit
)
@Composable
public fun NavHost(
navController: NavHostController,
startDestination: String,
modifier: Modifier = Modifier,
contentAlignment: Alignment = Alignment.TopStart,
route: String? = null,
enterTransition:
(@JvmSuppressWildcards
AnimatedContentTransitionScope.() -> EnterTransition) =
DefaultNavTransitions.enterTransition,
exitTransition:
(@JvmSuppressWildcards
AnimatedContentTransitionScope.() -> ExitTransition) =
DefaultNavTransitions.exitTransition,
popEnterTransition:
(@JvmSuppressWildcards
AnimatedContentTransitionScope.() -> EnterTransition) =
enterTransition,
popExitTransition:
(@JvmSuppressWildcards
AnimatedContentTransitionScope.() -> ExitTransition) =
exitTransition,
sizeTransform:
(@JvmSuppressWildcards
AnimatedContentTransitionScope.() -> SizeTransform?)? =
DefaultNavTransitions.sizeTransform,
builder: NavGraphBuilder.() -> Unit
)
@Composable
public fun NavHost(
navController: NavHostController,
startDestination: KClass,
modifier: Modifier = Modifier,
contentAlignment: Alignment = Alignment.TopStart,
route: KClass? = null,
typeMap: Map = emptyMap(),
enterTransition:
(@JvmSuppressWildcards
AnimatedContentTransitionScope.() -> EnterTransition) =
DefaultNavTransitions.enterTransition,
exitTransition:
(@JvmSuppressWildcards
AnimatedContentTransitionScope.() -> ExitTransition) =
DefaultNavTransitions.exitTransition,
popEnterTransition:
(@JvmSuppressWildcards
AnimatedContentTransitionScope.() -> EnterTransition) =
enterTransition,
popExitTransition:
(@JvmSuppressWildcards
AnimatedContentTransitionScope.() -> ExitTransition) =
exitTransition,
sizeTransform:
(@JvmSuppressWildcards
AnimatedContentTransitionScope.() -> SizeTransform?)? =
DefaultNavTransitions.sizeTransform,
builder: NavGraphBuilder.() -> Unit
)
< /code>
[b]But if I were do this (keep in mind that publicКод: Выделить всё
fun ABC(){
println("ABC")
}
fun ABC(){
println("DEF")
}
fun ABC(){
println("GHI")
}
// +6 more
fun main() {
ABC()
}
< /code>
[b]Then I get these errors:[/b]
Conflicting overloads: fun ABC(): Unit fun ABC(): Unit
Conflicting overloads: fun ABC(): Unit fun ABC(): Unit
Conflicting overloads: fun ABC(): Unit fun ABC(): Unit
Overload resolution ambiguity between candidates: fun ABC(): Unit fun ABC(): Unit fun ABC(): Unit
< /code>
I've only ever done Python and JavaScript, and in those, anytime you rewrite the same variable name, function declaration, etc. below the original for any type of object: it rewrites it. So you don't do that in the same code block / file, unless you want that to happen.
QUESTIONS
[list]
[*]Is the NavHost.kt[*] Как/почему это работает ??? Опять же, abc () дает ошибки, если я не комментирую последние.
[*] Так что происходит? Как работает Navhost без ошибок? Почему я получаю ошибки с ABC () , но Navhost не ???
[/list]
Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/797 ... mporting-f
Мобильная версия