Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding shared elements to Jetsnack 🎉 #1314

Open
wants to merge 45 commits into
base: compose-latest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5577a50
Adding Shared elements to Jetsnack
riggaroo Apr 4, 2024
b4b8bd0
Adding Shared elements to Jetsnack
riggaroo Apr 4, 2024
32bf222
Adding Shared elements to Jetsnack
riggaroo Apr 4, 2024
3393f6b
Throw IllegalStateException instead of IllegalArgumentException.
riggaroo Apr 5, 2024
d54a398
Place background on whole screen.
riggaroo Apr 5, 2024
03d9235
Cleanup
riggaroo Apr 5, 2024
e8bc672
disable predictive back for now.
riggaroo Apr 5, 2024
9db6c53
Added a debugPlaceholder for Previews.
riggaroo Apr 8, 2024
bcd5d1c
Set ExitTransition.None and using sharedBounds instead of sharedElement.
riggaroo Apr 8, 2024
61a9c94
Set ExitTransition.None and using sharedBounds instead of sharedElement.
riggaroo Apr 8, 2024
7852d36
Only display IconButton when the transition isn't active anymore.
riggaroo Apr 8, 2024
e326aaf
skipToLookaheadSize() for Text description to prevent reflowing of co…
riggaroo Apr 8, 2024
b532356
Added background back to the headings
riggaroo Apr 8, 2024
27a9d9d
Ordering cleanup
riggaroo Apr 9, 2024
e23e553
Change CompositionLocals to be individually provided
riggaroo Apr 10, 2024
3592280
Shared element tweaking
riggaroo Apr 10, 2024
844a8d6
change spring spec to expressive
riggaroo Apr 12, 2024
cc61fa7
Changed to expressive baseline
riggaroo Apr 12, 2024
70bd4c4
Fix previews.
riggaroo Apr 15, 2024
92fc2ba
Polish animation
riggaroo Apr 16, 2024
7c2574b
Polish animation
riggaroo Apr 16, 2024
bc49bbe
Slide TopAppBar up when shared element animates
riggaroo Apr 16, 2024
e4abbae
Update springs to use expressive
riggaroo Apr 16, 2024
515d402
Animate clipping as it goes.
riggaroo Apr 17, 2024
09f9a0b
Code clean up
riggaroo Apr 18, 2024
ed03bbd
Code clean up
riggaroo Apr 18, 2024
b218908
Code clean up
riggaroo Apr 19, 2024
9e481e8
Merge branch 'refs/heads/bugfix/fix-debug-keystores' into jetsnack/sh…
riggaroo Apr 29, 2024
61b7a5e
Switch to alpha version of compose
riggaroo Apr 29, 2024
c44327e
Formatting
riggaroo Apr 29, 2024
bd0b871
Formatting
riggaroo Apr 29, 2024
61883bc
Merge branch 'main' into jetsnack/shared-element
riggaroo Apr 29, 2024
10e0ad5
Update to new recommendations for async images.
riggaroo May 8, 2024
fa6a864
🤖 Apply Spotless
riggaroo May 8, 2024
0f4b958
Update Back icon animation.
riggaroo May 8, 2024
392262c
Tidied up the enter animations of non-shared items.
riggaroo May 8, 2024
45df731
Merge branch 'jetsnack/shared-element' of https://github.com/android/…
riggaroo May 8, 2024
a40c152
Spotless
riggaroo May 10, 2024
11313dd
🤖 Apply Spotless
riggaroo May 10, 2024
aa6246d
Add item animations to cart screen
riggaroo May 10, 2024
5250858
Merge branch 'jetsnack/shared-element' of https://github.com/android/…
riggaroo May 10, 2024
e7cecfc
🤖 Apply Spotless
riggaroo May 10, 2024
a58f230
Update to 1.7.0-beta01, and switch to ResizeMode.
riggaroo May 14, 2024
bc662ec
Merge branch 'jetsnack/shared-element' of https://github.com/android/…
riggaroo May 14, 2024
bbfa61e
🤖 Apply Spotless
riggaroo May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Jetsnack/app/build.gradle.kts
Expand Up @@ -99,6 +99,7 @@ dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.lifecycle.viewModelCompose)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.navigation.compose)
Expand All @@ -107,6 +108,7 @@ dependencies {
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.foundation)
implementation(libs.androidx.compose.foundation.layout)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.util)
implementation(libs.androidx.compose.material)
implementation(libs.androidx.compose.animation)
Expand Down
4 changes: 3 additions & 1 deletion Jetsnack/app/src/main/AndroidManifest.xml
Expand Up @@ -23,7 +23,9 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.Jetsnack">
android:theme="@style/Theme.Jetsnack"

>

<profileable android:shell="true" tools:targetApi="q" />

Expand Down
55 changes: 28 additions & 27 deletions Jetsnack/app/src/main/java/com/example/jetsnack/model/Snack.kt
Expand Up @@ -17,6 +17,7 @@
package com.example.jetsnack.model

import androidx.compose.runtime.Immutable
import kotlin.random.Random

@Immutable
data class Snack(
Expand All @@ -41,183 +42,183 @@ val snacks = listOf(
price = 299
),
Snack(
id = 2L,
id = Random.nextLong(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cupcake above still has a fixed ID. Do these IDs need to be random? Also, isn't it now possible (albeit very improbable) that two snacks end up with the same ID?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its for preview purposes to be able to query for a certain snack. yes it is somewhat possible, but this is fake mock data so I dont think its worth the hassle of making it more robust.

name = "Donut",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/Yc5sL-ejk6U",
price = 299
),
Snack(
id = 3L,
id = Random.nextLong(),
name = "Eclair",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/-LojFX9NfPY",
price = 299
),
Snack(
id = 4L,
id = Random.nextLong(),
name = "Froyo",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/3U2V5WqK1PQ",
price = 299
),
Snack(
id = 5L,
id = Random.nextLong(),
name = "Gingerbread",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/Y4YR9OjdIMk",
price = 499
),
Snack(
id = 6L,
id = Random.nextLong(),
name = "Honeycomb",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/bELvIg_KZGU",
price = 299
),
Snack(
id = 7L,
id = Random.nextLong(),
name = "Ice Cream Sandwich",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/YgYJsFDd4AU",
price = 1299
),
Snack(
id = 8L,
id = Random.nextLong(),
name = "Jellybean",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/0u_vbeOkMpk",
price = 299
),
Snack(
id = 9L,
id = Random.nextLong(),
name = "KitKat",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/yb16pT5F_jE",
price = 549
),
Snack(
id = 10L,
id = Random.nextLong(),
name = "Lollipop",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/AHF_ZktTL6Q",
price = 299
),
Snack(
id = 11L,
id = Random.nextLong(),
name = "Marshmallow",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/rqFm0IgMVYY",
price = 299
),
Snack(
id = 12L,
id = Random.nextLong(),
name = "Nougat",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/qRE_OpbVPR8",
price = 299
),
Snack(
id = 13L,
id = Random.nextLong(),
name = "Oreo",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/33fWPnyN6tU",
price = 299
),
Snack(
id = 14L,
id = Random.nextLong(),
name = "Pie",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/aX_ljOOyWJY",
price = 299
),
Snack(
id = 15L,
id = Random.nextLong(),
name = "Chips",
imageUrl = "https://source.unsplash.com/UsSdMZ78Q3E",
price = 299
),
Snack(
id = 16L,
id = Random.nextLong(),
name = "Pretzels",
imageUrl = "https://source.unsplash.com/7meCnGCJ5Ms",
price = 299
),
Snack(
id = 17L,
id = Random.nextLong(),
name = "Smoothies",
imageUrl = "https://source.unsplash.com/m741tj4Cz7M",
price = 299
),
Snack(
id = 18L,
id = Random.nextLong(),
name = "Popcorn",
imageUrl = "https://source.unsplash.com/iuwMdNq0-s4",
price = 299
),
Snack(
id = 19L,
id = Random.nextLong(),
name = "Almonds",
imageUrl = "https://source.unsplash.com/qgWWQU1SzqM",
price = 299
),
Snack(
id = 20L,
id = Random.nextLong(),
name = "Cheese",
imageUrl = "https://source.unsplash.com/9MzCd76xLGk",
price = 299
),
Snack(
id = 21L,
id = Random.nextLong(),
name = "Apples",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/1d9xXWMtQzQ",
price = 299
),
Snack(
id = 22L,
id = Random.nextLong(),
name = "Apple sauce",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/wZxpOw84QTU",
price = 299
),
Snack(
id = 23L,
id = Random.nextLong(),
name = "Apple chips",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/okzeRxm_GPo",
price = 299
),
Snack(
id = 24L,
id = Random.nextLong(),
name = "Apple juice",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/l7imGdupuhU",
price = 299
),
Snack(
id = 25L,
id = Random.nextLong(),
name = "Apple pie",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/bkXzABDt08Q",
price = 299
),
Snack(
id = 26L,
id = Random.nextLong(),
name = "Grapes",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/y2MeW00BdBo",
price = 299
),
Snack(
id = 27L,
id = Random.nextLong(),
name = "Kiwi",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/1oMGgHn-M8k",
price = 299
),
Snack(
id = 28L,
id = Random.nextLong(),
name = "Mango",
tagline = "A tag line",
imageUrl = "https://source.unsplash.com/TIGDsyy0TK4",
Expand Down
Expand Up @@ -17,6 +17,7 @@
package com.example.jetsnack.model

import androidx.compose.runtime.Immutable
import kotlin.random.Random

@Immutable
data class SnackCollection(
Expand Down Expand Up @@ -57,33 +58,33 @@ private val tastyTreats = SnackCollection(
)

private val popular = SnackCollection(
id = 2L,
id = Random.nextLong(),
name = "Popular on Jetsnack",
snacks = snacks.subList(14, 19)
)

private val wfhFavs = tastyTreats.copy(
id = 3L,
id = Random.nextLong(),
name = "WFH favourites"
)

private val newlyAdded = popular.copy(
id = 4L,
id = Random.nextLong(),
name = "Newly Added"
)

private val exclusive = tastyTreats.copy(
id = 5L,
id = Random.nextLong(),
name = "Only on Jetsnack"
)

private val also = tastyTreats.copy(
id = 6L,
id = Random.nextLong(),
name = "Customers also bought"
)

private val inspiredByCart = tastyTreats.copy(
id = 7L,
id = Random.nextLong(),
name = "Inspired by your cart"
)

Expand All @@ -96,8 +97,8 @@ private val snackCollections = listOf(
)

private val related = listOf(
also,
popular
also.copy(id = Random.nextLong()),
popular.copy(id = Random.nextLong())
)

private val cart = listOf(
Expand Down