{"id":377856,"date":"2024-06-03T03:00:06","date_gmt":"2024-06-03T03:00:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=377856"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=377856","title":{"rendered":"<span>Shared Element Transition \u0432 Jetpack Compose<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u0440\u0442\u0435\u043c \u0438 \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043f\u043e\u0434 Android, \u0430 \u0435\u0449\u0435 \u0441 \u043d\u0435\u0434\u0430\u0432\u043d\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u044f \u0441\u0442\u0430\u043b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c.<\/p>\n<p>\u042d\u0442\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 <a href=\"https:\/\/youtu.be\/bbSQ3pvrHLk\" rel=\"noopener noreferrer nofollow\"><u>\u0432\u0438\u0434\u0435\u043e<\/u><\/a> \u043d\u0430 \u043c\u043e\u0435\u043c YouTube \u043a\u0430\u043d\u0430\u043b\u0435 <a href=\"https:\/\/www.youtube.com\/@Android_Insights\" rel=\"noopener noreferrer nofollow\"><u>Android Insights<\/u><\/a><\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u0436\u0438\u0432\u0438\u0442\u044c \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <strong>Shared Element Transition<\/strong>. <strong>Shared Element Transition <\/strong>\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043e\u043d\u0430 \u0438\u0437 \u0442\u0435\u0445 \u0444\u0438\u0448\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0449\u0438\u043c\u0441\u044f.<\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0444\u0438\u0447\u0430 \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u043e, \u0442\u0430\u043a \u0447\u0442\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u0441\u0438\u044f <strong>Jetpack Compose <\/strong>\u043d\u0435 \u043d\u0438\u0436\u0435 <strong>1.7.0-alpha07<\/strong>.<\/p>\n<p>\u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432 \u043d\u0435\u043c \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u044d\u043a\u0440\u0430\u043d\u0430. \u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u043a\u0440\u0430\u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a, \u0430 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c &#8212; \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u043e\u0431\u044a\u0435\u043a\u0442\u0435.  <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a81\/18e\/a82\/a8118ea82532839a281a169bb710af5b.gif\" alt=\"\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\" title=\"\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\" width=\"434\" height=\"894\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a81\/18e\/a82\/a8118ea82532839a281a169bb710af5b.gif\"\/><\/p>\n<div><figcaption>\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/figcaption><\/div>\n<\/figure>\n<\/div>\n<\/details>\n<p>\u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438. <\/p>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u043e\u0434 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 <strong>@Composable<\/strong> \u0444\u0443\u043d\u043a\u0446\u0438\u0438  <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">@Composable fun CatsContent(modifier: Modifier) {    var selectedCat: Cat? by remember { mutableStateOf(null) }     if (selectedCat != null) {        BackHandler { selectedCat = null }         CatDetails(            modifier = modifier.fillMaxSize(),            cat = selectedCat!!,        )    } else {        CatsList(            modifier = modifier.fillMaxSize(),            onCatClicked = { cat ->                selectedCat = cat            }        )    } }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e: \u043f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435, \u043e\u043d \u043a\u043b\u0430\u0434\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>selectedCat<\/strong>, \u0430 \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u043d\u0435 \u0440\u0430\u0432\u043d\u0430 <strong>null<\/strong>, \u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f <strong>@Composable <\/strong>\u0441 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439.  <\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>CatDetails <\/strong>\u0438 <strong>CatsList<\/strong> <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">@Composable fun CatDetails(    modifier: Modifier,    cat: Cat, ) {    Column(        modifier = modifier.verticalScroll(            state = rememberScrollState(),        ),        verticalArrangement = Arrangement.spacedBy(8.dp),    ) {        Image(            painter = painterResource(cat.iconRes),            contentDescription = null,        )         Text(            modifier = Modifier                .padding(                    horizontal = 8.dp,                ),            text = stringResource(cat.textRes)        )    } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">@Composable fun CatsList(    modifier: Modifier,    onCatClicked: (Cat) -> Unit, ) {    val cats = rememberCatsList()     Box(        modifier = modifier,    ) {        LazyColumn(            verticalArrangement = Arrangement.spacedBy(8.dp),        ) {            items(                items = cats,                key = { cat -> cat.iconRes },                contentType = { cat -> cat::class }            ) { item ->                Cat(                    modifier = Modifier                        .fillParentMaxWidth()                        .clickable {                            onCatClicked(item)                        }                        .padding(                            horizontal = 8.dp                        ),                    cat = item,                )            }        }    } }  @Composable fun Cat(    modifier: Modifier,    cat: Cat, ) {    Row(        modifier = modifier,        horizontalArrangement = Arrangement.spacedBy(8.dp),        verticalAlignment = Alignment.CenterVertically,    ) {        Image(            modifier = Modifier.size(128.dp),            painter = painterResource(cat.iconRes),            contentScale = ContentScale.Crop,            contentDescription = null,        )         Text(            modifier = Modifier,            text = stringResource(cat.textRes),            maxLines = 3,            overflow = TextOverflow.Ellipsis,        )    } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0439 \u043a\u043e\u0434 \u0432 \u0434\u0432\u0430 \u044d\u0442\u0430\u043f\u0430  <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">@OptIn(ExperimentalSharedTransitionApi::class) - \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u044c OptIn \u0442.\u043a. ExperimentalSharedTransitionApi \u043f\u043e\u043a\u0430 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u0435\u043d \u0438 \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f @Composable fun CatsContent(    modifier: Modifier ) {     var showCatDetails by remember { mutableStateOf(false) }      var selectedCat: Cat? by remember { mutableStateOf(null) }      SharedTransitionLayout {         AnimatedContent(             targetState = showCatDetails         ) { targetState ->             if (targetState) {                 BackHandler { showCatDetails = false }                  CatDetails(                     modifier = modifier.fillMaxSize(),                     cat = selectedCat!!,                     \/\/ \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 SharedTransitionScope, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435                     sharedTransitionScope = this@SharedTransitionLayout,                     \/\/ \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 AnimatedVisibilityScope, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435                     animatedVisibilityScope = this,                 )             } else {                 CatsList(                     modifier = modifier.fillMaxSize(),                     \/\/ \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 SharedTransitionScope, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435                     sharedTransitionScope = this@SharedTransitionLayout,                     \/\/ \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 AnimatedVisibilityScope, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435                     animatedVisibilityScope = this,                     onCatClicked = { cat ->                         selectedCat = cat                         showCatDetails = true                     }                 )             }         }     } } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>AnimatedContent<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>SharedTransitionLayout<\/strong>.<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3b7\/674\/264\/3b76742641073fc4c50ea69726172901.gif\" alt=\"\u0410\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438\" title=\"\u0410\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438\" width=\"414\" height=\"896\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3b7\/674\/264\/3b76742641073fc4c50ea69726172901.gif\"\/><\/p>\n<div><figcaption>\u0410\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438<\/figcaption><\/div>\n<\/figure>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438, \u0437\u0430 \u0441\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>AnimatedContent<\/strong>, \u043d\u043e \u044d\u0442\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e. <\/p>\n<p>\u041f\u043e\u0440\u0430 \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0441\u0442\u0430\u0432\u0448\u0443\u044e\u0441\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">@OptIn(ExperimentalSharedTransitionApi::class) @Composable fun CatsList(    modifier: Modifier,    onCatClicked: (Cat) -> Unit,    sharedTransitionScope: SharedTransitionScope,    animatedVisibilityScope: AnimatedVisibilityScope, ) {    val cats = rememberCatsList()     Box(        modifier = modifier,    ) {        LazyColumn(            verticalArrangement = Arrangement.spacedBy(8.dp),        ) {            items(                items = cats,                key = { cat -> cat.iconRes },                contentType = { cat -> cat::class }            ) { item ->                Cat(                    modifier = Modifier                        .fillParentMaxWidth()                        .clickable {                            onCatClicked(item)                        }                        .padding(                            horizontal = 8.dp                        ),                    cat = item,                    \/\/ \u043f\u0440\u043e\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c SharedTransitionScope                    sharedTransitionScope = sharedTransitionScope,                    \/\/ \u043f\u0440\u043e\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c AnimatedVisibilityScope                    animatedVisibilityScope = animatedVisibilityScope,                )            }        }    } }  @OptIn(ExperimentalSharedTransitionApi::class) @Composable fun Cat(    modifier: Modifier,    cat: Cat,    sharedTransitionScope: SharedTransitionScope,    animatedVisibilityScope: AnimatedVisibilityScope, ) {    with(sharedTransitionScope) {        Row(            modifier = modifier,            horizontalArrangement = Arrangement.spacedBy(8.dp),            verticalAlignment = Alignment.CenterVertically,        ) {            Image(                modifier = Modifier                    .size(128.dp)                    \/\/ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0439 Modifier sharedElement                    .sharedElement(                        state = rememberSharedContentState(                          key = cat.iconRes.toString()                        ),                        animatedVisibilityScope = animatedVisibilityScope,                    ),                painter = painterResource(cat.iconRes),                contentScale = ContentScale.Crop,                contentDescription = null,            )              Text(                modifier = Modifier,                text = stringResource(cat.textRes),                maxLines = 3,                overflow = TextOverflow.Ellipsis,            )        }    } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">@OptIn(ExperimentalSharedTransitionApi::class) @Composable fun CatDetails(     modifier: Modifier,     cat: Cat,     sharedTransitionScope: SharedTransitionScope,     animatedVisibilityScope: AnimatedVisibilityScope, ) {     with(sharedTransitionScope) {         Column(             modifier = modifier.verticalScroll(                 state = rememberScrollState(),             ),             verticalArrangement = Arrangement.spacedBy(8.dp),         ) {             Image(                 \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0439 Modifier sharedElement                 modifier = Modifier.sharedElement(                     state = rememberSharedContentState(key = cat.iconRes.toString()),                     animatedVisibilityScope = animatedVisibilityScope,                 ),                 painter = painterResource(cat.iconRes),                 contentDescription = null,             )              Text(                 modifier = Modifier                     .padding(                         horizontal = 8.dp,                     ),                 text = stringResource(cat.textRes)             )         }     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a, \u043a\u0430\u043a \u0438 \u0431\u044b\u043b\u043e \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043e, Image \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439  <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3ba\/d4e\/4b7\/3bad4e4b7c8a967e5c68e6d412e8170b.gif\" alt=\"shared element transition\" title=\"shared element transition\" width=\"422\" height=\"896\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3ba\/d4e\/4b7\/3bad4e4b7c8a967e5c68e6d412e8170b.gif\"\/><\/p>\n<div><figcaption>shared element transition<\/figcaption><\/div>\n<\/figure>\n<\/div>\n<\/details>\n<p>\u0427\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u0432 \u043a\u043e\u0434\u0435? \u0411\u044b\u043b\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Modifier\u2019a<\/p>\n<pre><code class=\"kotlin\">Modifier.sharedElement<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 Modifier, \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 <strong>SharedTransitionLayout<\/strong>, \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043c\u0430\u0433\u0438\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 <strong>SharedTransitionScope<\/strong>. \u0414\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<\/p>\n<pre><code class=\"kotlin\">\/\/ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e with\/run\/apply \u0438\u0442\u0434 with(sharedTransitionScope)  \/\/ \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u043a SharedTransitionScope fun SharedTransitionScope.Cat  \/\/ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c context receivers, \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0443\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0438 \/\/ AnimatedVisibilityScope, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c context(SharedTransitionScope, AnimatedVisibilityScope) @OptIn(ExperimentalSharedTransitionApi::class) @Composable fun Cat<\/code><\/pre>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 sharedElement \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b  <\/p>\n<pre><code class=\"kotlin\">sharedElement(    state = rememberSharedContentState(      key = cat.iconRes.toString()    ),    animatedVisibilityScope = animatedVisibilityScope, ),<\/code><\/pre>\n<p><strong>state<\/strong> &#8212; \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0442\u043e <strong>\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e <\/strong>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 <strong>key<\/strong> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 <strong>@Composable<\/strong>.<\/p>\n<p><strong>animatedVisibilityScope<\/strong> &#8212; \u0441\u043a\u043e\u0443\u043f \u0434\u043b\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c\u043e\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong>Modifier.sharedElement <\/strong>\u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434. \u041a\u043b\u044e\u0447 \u043d\u0430 \u0446\u0435\u043b\u0435\u0432\u043e\u043c \u044d\u043a\u0440\u0430\u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u0442\u0435\u043c, \u043e\u0442\u043a\u0443\u0434\u0430 \u043d\u0430\u0447\u0430\u043b\u0441\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434, \u0438\u043d\u0430\u0447\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 Shared Element Transition \u0432 Jetpack Compose \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c, \u0442\u043e \u0432\u0441\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <\/p>\n<pre><code class=\"kotlin\">@OptIn(ExperimentalSharedTransitionApi::class)<\/code><\/pre>\n<p>\u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u044d\u0442\u043e \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u043d\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Shared Element Transition. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0432\u0435\u0434\u0435\u043c \u043a\u0440\u0430\u0442\u043a\u0438\u0435 \u0438\u0442\u043e\u0433\u0438  <\/p>\n<h2>\u0418\u0442\u043e\u0433\u0438  <\/h2>\n<p>\u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Shared Element Transition \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c 3 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0448\u0430\u0433\u0430:  <\/p>\n<ol>\n<li>\n<p>\u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0435\u0440\u0441\u0438\u044f Jetpack Compose \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0435 \u043d\u0438\u0436\u0435 <strong>1.7.0-alpha08<\/strong><\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u0430\u0448\u0438 @Composable \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 <strong>SharedTransitionLayout<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043a\u043b\u044e\u0447\u0438, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0432 <strong>rememberSharedContentState<\/strong>, \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e @Composable, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0442\u0438\u0442\u0435 \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0430 \u0442\u0430\u043a\u0436\u0435, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u0442 \u0436\u0435 \u043a\u043b\u044e\u0447 \u0432 \u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u043a\u0443\u0434\u0430 \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434  <\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u0441\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u0432\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u0430!<\/p>\n<p>\u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043b\u0438 \u0432\u044b Shared Element Transition \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0440\u0430\u043d\u0435\u0435(\u0442.\u043a. \u043e\u043d\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u043b\u044f View \u0441\u0438\u0441\u0442\u0435\u043c\u044b)<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/818957\/\"> https:\/\/habr.com\/ru\/articles\/818957\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u0440\u0442\u0435\u043c \u0438 \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043f\u043e\u0434 Android, \u0430 \u0435\u0449\u0435 \u0441 \u043d\u0435\u0434\u0430\u0432\u043d\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u044f \u0441\u0442\u0430\u043b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c.<\/p>\n<p>\u042d\u0442\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 <a href=\"https:\/\/youtu.be\/bbSQ3pvrHLk\" rel=\"noopener noreferrer nofollow\"><u>\u0432\u0438\u0434\u0435\u043e<\/u><\/a> \u043d\u0430 \u043c\u043e\u0435\u043c YouTube \u043a\u0430\u043d\u0430\u043b\u0435 <a href=\"https:\/\/www.youtube.com\/@Android_Insights\" rel=\"noopener noreferrer nofollow\"><u>Android Insights<\/u><\/a><\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u0436\u0438\u0432\u0438\u0442\u044c \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <strong>Shared Element Transition<\/strong>. <strong>Shared Element Transition <\/strong>\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043e\u043d\u0430 \u0438\u0437 \u0442\u0435\u0445 \u0444\u0438\u0448\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0449\u0438\u043c\u0441\u044f.<\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0444\u0438\u0447\u0430 \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u043e, \u0442\u0430\u043a \u0447\u0442\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u0441\u0438\u044f <strong>Jetpack Compose <\/strong>\u043d\u0435 \u043d\u0438\u0436\u0435 <strong>1.7.0-alpha07<\/strong>.<\/p>\n<p>\u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432 \u043d\u0435\u043c \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u044d\u043a\u0440\u0430\u043d\u0430. \u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u043a\u0440\u0430\u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a, \u0430 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c &#8212; \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u043e\u0431\u044a\u0435\u043a\u0442\u0435.  <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\">\n<div><figcaption>\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/figcaption><\/div>\n<\/figure>\n<\/div>\n<\/details>\n<p>\u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438. <\/p>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u043e\u0434 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 <strong>@Composable<\/strong> \u0444\u0443\u043d\u043a\u0446\u0438\u0438  <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">@Composable fun CatsContent(modifier: Modifier) {    var selectedCat: Cat? by remember { mutableStateOf(null) }     if (selectedCat != null) {        BackHandler { selectedCat = null }         CatDetails(            modifier = modifier.fillMaxSize(),            cat = selectedCat!!,        )    } else {        CatsList(            modifier = modifier.fillMaxSize(),            onCatClicked = { cat ->                selectedCat = cat            }        )    } }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e: \u043f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435, \u043e\u043d \u043a\u043b\u0430\u0434\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>selectedCat<\/strong>, \u0430 \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u043d\u0435 \u0440\u0430\u0432\u043d\u0430 <strong>null<\/strong>, \u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f <strong>@Composable <\/strong>\u0441 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439.  <\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>CatDetails <\/strong>\u0438 <strong>CatsList<\/strong> <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">@Composable fun CatDetails(    modifier: Modifier,    cat: Cat, ) {    Column(        modifier = modifier.verticalScroll(            state = rememberScrollState(),        ),        verticalArrangement = Arrangement.spacedBy(8.dp),    ) {        Image(            painter = painterResource(cat.iconRes),            contentDescription = null,        )         Text(            modifier = Modifier                .padding(                    horizontal = 8.dp,                ),            text = stringResource(cat.textRes)        )    } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">@Composable fun CatsList(    modifier: Modifier,    onCatClicked: (Cat) -> Unit, ) {    val cats = rememberCatsList()     Box(        modifier = modifier,    ) {        LazyColumn(            verticalArrangement = Arrangement.spacedBy(8.dp),        ) {            items(                items = cats,                key = { cat -> cat.iconRes },                contentType = { cat -> cat::class }            ) { item ->                Cat(                    modifier = Modifier                        .fillParentMaxWidth()                        .clickable {                            onCatClicked(item)                        }                        .padding(                            horizontal = 8.dp                        ),                    cat = item,                )            }        }    } }  @Composable fun Cat(    modifier: Modifier,    cat: Cat, ) {    Row(        modifier = modifier,        horizontalArrangement = Arrangement.spacedBy(8.dp),        verticalAlignment = Alignment.CenterVertically,    ) {        Image(            modifier = Modifier.size(128.dp),            painter = painterResource(cat.iconRes),            contentScale = ContentScale.Crop,            contentDescription = null,        )         Text(            modifier = Modifier,            text = stringResource(cat.textRes),            maxLines = 3,            overflow = TextOverflow.Ellipsis,        )    } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0439 \u043a\u043e\u0434 \u0432 \u0434\u0432\u0430 \u044d\u0442\u0430\u043f\u0430  <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">@OptIn(ExperimentalSharedTransitionApi::class) - \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u044c OptIn \u0442.\u043a. ExperimentalSharedTransitionApi \u043f\u043e\u043a\u0430 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u0435\u043d \u0438 \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f @Composable fun CatsContent(    modifier: Modifier ) {     var showCatDetails by remember { mutableStateOf(false) }      var selectedCat: Cat? by remember { mutableStateOf(null) }      SharedTransitionLayout {         AnimatedContent(             targetState = showCatDetails         ) { targetState ->             if (targetState) {                 BackHandler { showCatDetails = false }                  CatDetails(                     modifier = modifier.fillMaxSize(),                     cat = selectedCat!!,                     \/\/ \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 SharedTransitionScope, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435                     sharedTransitionScope = this@SharedTransitionLayout,                     \/\/ \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 AnimatedVisibilityScope, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435                     animatedVisibilityScope = this,                 )             } else {                 CatsList(                     modifier = modifier.fillMaxSize(),                     \/\/ \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 SharedTransitionScope, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435                     sharedTransitionScope = this@SharedTransitionLayout,                     \/\/ \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 AnimatedVisibilityScope, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435                     animatedVisibilityScope = this,                     onCatClicked = { cat ->                         selectedCat = cat                         showCatDetails = true                     }                 )             }         }     } } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>AnimatedContent<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>SharedTransitionLayout<\/strong>.<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\">\n<div><figcaption>\u0410\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438<\/figcaption><\/div>\n<\/figure>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438, \u0437\u0430 \u0441\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>AnimatedContent<\/strong>, \u043d\u043e \u044d\u0442\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e. <\/p>\n<p>\u041f\u043e\u0440\u0430 \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0441\u0442\u0430\u0432\u0448\u0443\u044e\u0441\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">@OptIn(ExperimentalSharedTransitionApi::class) @Composable fun CatsList(    modifier: Modifier,    onCatClicked: (Cat) -> Unit,    sharedTransitionScope: SharedTransitionScope,    animatedVisibilityScope: AnimatedVisibilityScope, ) {    val cats = rememberCatsList()     Box(        modifier = modifier,    ) {        LazyColumn(            verticalArrangement = Arrangement.spacedBy(8.dp),        ) {            items(                items = cats,                key = { cat -> cat.iconRes },                contentType = { cat -> cat::class }            ) { item ->                Cat(                    modifier = Modifier                        .fillParentMaxWidth()                        .clickable {                            onCatClicked(item)                        }                        .padding(                            horizontal = 8.dp                        ),                    cat = item,                    \/\/ \u043f\u0440\u043e\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c SharedTransitionScope                    sharedTransitionScope = sharedTransitionScope,                    \/\/ \u043f\u0440\u043e\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c AnimatedVisibilityScope                    animatedVisibilityScope = animatedVisibilityScope,                )            }        }    } }  @OptIn(ExperimentalSharedTransitionApi::class) @Composable fun Cat(    modifier: Modifier,    cat: Cat,    sharedTransitionScope: SharedTransitionScope,    animatedVisibilityScope: AnimatedVisibilityScope, ) {    with(sharedTransitionScope) {        Row(            modifier = modifier,            horizontalArrangement = Arrangement.spacedBy(8.dp),            verticalAlignment = Alignment.CenterVertically,        ) {            Image(                modifier = Modifier                    .size(128.dp)                    \/\/ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0439 Modifier sharedElement                    .sharedElement(                        state = rememberSharedContentState(                          key = cat.iconRes.toString()                        ),                        animatedVisibilityScope = animatedVisibilityScope,                    ),                painter = painterResource(cat.iconRes),                contentScale = ContentScale.Crop,                contentDescription = null,            )              Text(                modifier = Modifier,                text = stringResource(cat.textRes),                maxLines = 3,                overflow = TextOverflow.Ellipsis,            )        }    } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">@OptIn(ExperimentalSharedTransitionApi::class) @Composable fun CatDetails(     modifier: Modifier,     cat: Cat,     sharedTransitionScope: SharedTransitionScope,     animatedVisibilityScope: AnimatedVisibilityScope, ) {     with(sharedTransitionScope) {         Column(             modifier = modifier.verticalScroll(                 state = rememberScrollState(),             ),             verticalArrangement = Arrangement.spacedBy(8.dp),         ) {             Image(                 \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0439 Modifier sharedElement                 modifier = Modifier.sharedElement(                     state = rememberSharedContentState(key = cat.iconRes.toString()),                     animatedVisibilityScope = animatedVisibilityScope,                 ),                 painter = painterResource(cat.iconRes),                 contentDescription = null,             )              Text(                 modifier = Modifier                     .padding(                         horizontal = 8.dp,                     ),                 text = stringResource(cat.textRes)             )         }     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a, \u043a\u0430\u043a \u0438 \u0431\u044b\u043b\u043e \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043e, Image \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439  <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\">\n<div><figcaption>shared element transition<\/figcaption><\/div>\n<\/figure>\n<\/div>\n<\/details>\n<p>\u0427\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u0432 \u043a\u043e\u0434\u0435? \u0411\u044b\u043b\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Modifier\u2019a<\/p>\n<pre><code class=\"kotlin\">Modifier.sharedElement<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 Modifier, \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 <strong>SharedTransitionLayout<\/strong>, \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043c\u0430\u0433\u0438\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 <strong>SharedTransitionScope<\/strong>. \u0414\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<\/p>\n<pre><code class=\"kotlin\">\/\/ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e with\/run\/apply \u0438\u0442\u0434 with(sharedTransitionScope)  \/\/ \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u043a SharedTransitionScope fun SharedTransitionScope.Cat  \/\/ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c context receivers, \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0443\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0438 \/\/ AnimatedVisibilityScope, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-377856","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/377856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=377856"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/377856\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=377856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=377856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=377856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}