Код: Выделить всё
> Unresolved reference 'sharedElement'
Код: Выделить всё
> Unresolved reference 'rememberSharedContentState'
И вот часть моего кода.
Код: Выделить всё
class MainActivity : ComponentActivity() {
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class, ExperimentalTextApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
FoxusTheme {
FoxusApp()
}
}
}
}
@Composable
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class, ExperimentalTextApi::class, ExperimentalSharedTransitionApi::class)
fun FoxusApp() {
val navController = rememberNavController()
SharedTransitionLayout {
NavHost(
navController = navController,
startDestination = "Main"
) {
composable("Main") {
MainWithScaffold(
navController = navController,
sharedTransitionScope = this@SharedTransitionLayout,
animatedVisibilityScope = this@composable
)
}
composable("Focusing") {
Focusing(
sharedTransitionScope = this@SharedTransitionLayout,
animatedVisibilityScope = this
)
}
}
}
}
@Composable
@OptIn(ExperimentalMaterial3Api::class)
fun AnimatedTopBar(title: String) {
/*...*/
}
@Composable
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class, ExperimentalTextApi::class,
ExperimentalSharedTransitionApi::class
)
fun MainWithScaffold(
navController: NavController,
sharedTransitionScope: SharedTransitionScope,
animatedVisibilityScope: AnimatedVisibilityScope
){
/*...define some values and variables...*/
Scaffold(
/*...*/
){ paddingValues ->
Box(
/*...*/
) {
AnimatedContent(
/*...*/
) {
index ->
SharedTransitionLayout {
when (index) {
0 -> FocusPage(
onStartClick = { navController.navigate("focusing") },
sharedTransitionScope = this@SharedTransitionLayout,
animatedVisibilityScope = this@AnimatedContent
)
1 -> TasksPage()
2 -> ProfilePage()
}
}
}
}
}
}
Код: Выделить всё
@OptIn(ExperimentalSharedTransitionApi::class)
@Composable
@ExperimentalMaterial3ExpressiveApi
fun FocusPage(
onStartClick: () -> Unit,
sharedTransitionScope: SharedTransitionScope,
animatedVisibilityScope: AnimatedVisibilityScope
) {
/*...define some values and variables...l*/
Column(
/*...*/
){
Card(
odmifier = Modifier
.fillMaxWidth()
.height(quickFocusCardHeight)
.clickable { onStartClick() }
.sharedElement(
rememberSharedContentState(key = "Focusing"),
animatedVisibilityScope = animatedVisibilityScope,
),
shape = RoundedCornerShape(30.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.primary
)
) {/*...specifics...*/}
}
}
@OptIn(ExperimentalSharedTransitionApi::class)
@Composable
@ExperimentalMaterial3ExpressiveApi
fun Focusing(
sharedTransitionScope: SharedTransitionScope,
animatedVisibilityScope: AnimatedVisibilityScope
){
/*...define some values and variables...l*/
Column(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.onPrimary)
.sharedElement(
rememberSharedContentState(key = sharedKey),
animatedVisibilityScope = animatedVisibilityScope
),
horizontalAlignment = Alignment.CenterHorizontally
){/*...specifics...*/}
}
Код: Выделить всё
dependencies {
implementation(platform("androidx.compose:compose-bom:2025.08.00"))
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2")
implementation("androidx.room:room-runtime:2.5.2")
kapt("androidx.room:room-compiler:2.5.2")
implementation("androidx.room:room-ktx:2.5.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
implementation("com.google.code.gson:gson:2.8.8")
implementation("androidx.datastore:datastore:1.0.0")
implementation("androidx.datastore:datastore-preferences:1.1.7")
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.androidx.constraintlayout)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
implementation("androidx.compose.material3:material3:1.3.2")
implementation("androidx.compose.material3:material3-window-size-class:1.3.2")
implementation("androidx.compose.material3:material3-adaptive-navigation-suite:1.5.0-alpha02")
implementation("androidx.compose.material:material-icons-core:1.5.4")
implementation("androidx.compose.material:material-icons-extended:1.5.4")
implementation("androidx.compose.ui:ui:1.5.4")
implementation("androidx.compose.ui:ui-text:1.5.4")
implementation("androidx.compose.material3:material3:1.1.2")
implementation("androidx.navigation:navigation-compose:2.9.3")
implementation("androidx.compose.animation:animation:1.9.0")
}
Согласно документации, модификатор.sharedelement (RememberSharedContentState (Key = "Image"), AnimatedVisibleScope = AnimatedVisibyScope) .>
Подробнее здесь: https://stackoverflow.com/questions/797 ... ck-compose