Skip to content

Commit 833b2aa

Browse files
authored
Merge pull request #1142 from tunjid/tj/simplify-notification-scaffold
Simplify NotificationPostScaffold
2 parents ed6f9c5 + 7956b66 commit 833b2aa

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

feature/notifications/src/commonMain/kotlin/com/tunjid/heron/notifications/ui/NotificationPostScaffold.kt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.tunjid.heron.notifications.ui
1818

19-
import androidx.compose.foundation.clickable
2019
import androidx.compose.foundation.layout.Arrangement.spacedBy
2120
import androidx.compose.foundation.layout.Box
2221
import androidx.compose.foundation.layout.Column
@@ -32,7 +31,6 @@ import androidx.compose.runtime.Composable
3231
import androidx.compose.runtime.remember
3332
import androidx.compose.ui.Alignment
3433
import androidx.compose.ui.Modifier
35-
import androidx.compose.ui.draw.clip
3634
import androidx.compose.ui.layout.ContentScale
3735
import androidx.compose.ui.unit.dp
3836
import com.tunjid.heron.data.core.models.Embed
@@ -52,8 +50,8 @@ import com.tunjid.heron.ui.AttributionLayout
5250
import com.tunjid.heron.ui.PaneTransitionScope
5351
import com.tunjid.heron.ui.UiTokens
5452
import com.tunjid.heron.ui.modifiers.rootShapedClickable
53+
import com.tunjid.heron.ui.modifiers.shapedClickable
5554
import com.tunjid.heron.ui.shapes.RoundedPolygonShape
56-
import com.tunjid.treenav.compose.UpdatedMovableStickySharedElementOf
5755
import kotlin.time.Instant
5856

5957
@Composable
@@ -158,27 +156,29 @@ private fun PostAttribution(
158156
val post = notification.associatedPost
159157
AttributionLayout(
160158
avatar = {
161-
UpdatedMovableStickySharedElementOf(
159+
PaneStickySharedElement(
162160
modifier = Modifier
163161
.size(UiTokens.avatarSize)
164-
.clip(avatarShape)
165-
.clickable { onProfileClicked(notification, post.author) },
162+
.shapedClickable(avatarShape) { onProfileClicked(notification, post.author) },
166163
sharedContentState = with(paneTransitionScope) {
167164
rememberSharedContentState(
168165
key = post.avatarSharedElementKey(sharedElementPrefix),
169166
)
170167
},
171-
state = remember(post.author.avatar) {
172-
ImageArgs(
173-
url = post.author.avatar?.uri,
174-
contentScale = ContentScale.Crop,
175-
contentDescription = post.author.displayName ?: post.author.handle.id,
176-
shape = avatarShape,
168+
content = {
169+
AsyncImage(
170+
modifier = Modifier
171+
.fillParentAxisIfFixedOrWrap(),
172+
args = remember(post.author.avatar) {
173+
ImageArgs(
174+
url = post.author.avatar?.uri,
175+
contentScale = ContentScale.Crop,
176+
contentDescription = post.author.displayName ?: post.author.handle.id,
177+
shape = avatarShape,
178+
)
179+
},
177180
)
178181
},
179-
sharedElement = { state, modifier ->
180-
AsyncImage(state, modifier)
181-
},
182182
)
183183
},
184184
label = {

feature/notifications/src/commonMain/kotlin/com/tunjid/heron/notifications/ui/NotificationRowScaffold.kt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import androidx.compose.runtime.setValue
4949
import androidx.compose.ui.Alignment
5050
import androidx.compose.ui.Modifier
5151
import androidx.compose.ui.draw.clip
52-
import androidx.compose.ui.draw.rotate
52+
import androidx.compose.ui.graphics.graphicsLayer
5353
import androidx.compose.ui.layout.ContentScale
5454
import androidx.compose.ui.text.LinkAnnotation
5555
import androidx.compose.ui.text.buildAnnotatedString
@@ -61,6 +61,7 @@ import com.tunjid.heron.images.AsyncImage
6161
import com.tunjid.heron.images.ImageArgs
6262
import com.tunjid.heron.ui.PaneTransitionScope
6363
import com.tunjid.heron.ui.UiTokens
64+
import com.tunjid.heron.ui.modifiers.shapedClickable
6465
import com.tunjid.heron.ui.shapes.RoundedPolygonShape
6566
import org.jetbrains.compose.resources.StringResource
6667
import org.jetbrains.compose.resources.stringResource
@@ -130,7 +131,10 @@ fun NotificationAggregateScaffold(
130131
with(paneTransitionScope) {
131132
Box(
132133
modifier = Modifier
133-
.animateBounds(lookaheadScope = this, boundsTransform = childBoundsTransform)
134+
.animateBounds(
135+
lookaheadScope = this,
136+
boundsTransform = childBoundsTransform,
137+
)
134138
.clip(ExpandableAvatarRowShape),
135139
) {
136140
if (isExpanded) Column(
@@ -171,14 +175,17 @@ private fun PaneTransitionScope.ExpandButton(
171175
isExpanded: Boolean,
172176
onExpansionToggled: (Boolean) -> Unit,
173177
) {
178+
val rotationState = animateFloatAsState(if (isExpanded) 180f else 0f)
174179
IconButton(
175180
modifier = Modifier
176181
.animateBounds(
177182
lookaheadScope = this@ExpandButton,
178183
boundsTransform = childBoundsTransform,
179184
)
180185
.size(32.dp)
181-
.rotate(animateFloatAsState(if (isExpanded) 180f else 0f).value),
186+
.graphicsLayer {
187+
rotationZ = rotationState.value
188+
},
182189
onClick = {
183190
onExpansionToggled(!isExpanded)
184191
},
@@ -208,16 +215,18 @@ private fun PaneTransitionScope.ExpandableProfiles(
208215
) {
209216
PaneStickySharedElement(
210217
modifier = Modifier
211-
.size(ExpandableAvatarSize),
218+
.size(ExpandableAvatarSize)
219+
.clip(CircleShape)
220+
.shapedClickable(CircleShape) {
221+
onProfileClicked(notification, profile)
222+
},
212223
sharedContentState = rememberSharedContentState(
213224
key = notification.avatarSharedElementKey(profile),
214225
),
215226
) {
216227
AsyncImage(
217228
modifier = Modifier
218-
.fillParentAxisIfFixedOrWrap()
219-
.clip(CircleShape)
220-
.clickable { onProfileClicked(notification, profile) },
229+
.fillParentAxisIfFixedOrWrap(),
221230
args = ImageArgs(
222231
url = profile.avatar?.uri,
223232
contentScale = ContentScale.Crop,

0 commit comments

Comments
 (0)