Skip to content

Commit 4c50776

Browse files
committed
Addtional integration of LaunchList UI components with other fields of query; Part I of tutorial complete
1 parent 8c465fe commit 4c50776

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

start/app/src/main/graphql/LaunchList.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ query LaunchList {
55
launches {
66
id
77
site
8+
mission {
9+
name
10+
missionPatch(size: SMALL)
11+
}
812
}
913
}
1014
}

start/app/src/main/kotlin/com/example/rocketreserver/LaunchList.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import androidx.compose.ui.Alignment
2626
import androidx.compose.ui.Modifier
2727
import androidx.compose.ui.res.painterResource
2828
import androidx.compose.ui.unit.dp
29+
import coil.compose.AsyncImage
2930

3031
@Composable
3132
fun LaunchList(onLaunchClick: (launchId: String) -> Unit) {
@@ -47,18 +48,20 @@ private fun LaunchItem(launch: LaunchListQuery.Launch, onClick: (launchId: Strin
4748
modifier = Modifier.clickable { onClick(launch.id) },
4849
headlineContent = {
4950
// Mission name
50-
Text(text = "Launch ${launch.id}")
51+
Text(text = launch.mission?.name ?: "Mission N/A")
5152
},
5253
supportingContent = {
5354
// Site
54-
Text(text = "Site...")
55+
Text(text = launch.site ?: "Site N/A")
5556
},
5657
leadingContent = {
5758
// Mission patch
58-
Image(
59+
AsyncImage(
5960
modifier = Modifier.size(68.dp, 68.dp),
60-
painter = painterResource(R.drawable.ic_placeholder),
61-
contentDescription = "Mission patch"
61+
model = launch.mission?.missionPatch,
62+
placeholder = painterResource(R.drawable.ic_placeholder),
63+
error = painterResource(R.drawable.ic_placeholder),
64+
contentDescription = "Mission Patch"
6265
)
6366
}
6467
)

0 commit comments

Comments
 (0)