Skip to content

Commit 08cb181

Browse files
committed
Update Back navigation in QuoteDetails.kt
Signed-off-by: Sanju S <[email protected]>
1 parent fd1169e commit 08cb181

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

app/src/main/java/www/spikeysanju/jetquotes/view/QuoteDetails.kt

+10-7
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ import androidx.appcompat.app.AppCompatActivity
3333
import androidx.compose.foundation.Icon
3434
import androidx.compose.foundation.Text
3535
import androidx.compose.foundation.layout.fillMaxWidth
36-
import androidx.compose.material.MaterialTheme
37-
import androidx.compose.material.Scaffold
38-
import androidx.compose.material.Surface
39-
import androidx.compose.material.TopAppBar
36+
import androidx.compose.material.*
4037
import androidx.compose.runtime.Composable
4138
import androidx.compose.ui.Modifier
4239
import androidx.compose.ui.platform.setContent
@@ -63,15 +60,17 @@ class QuoteDetails : AppCompatActivity() {
6360
JetQuotesTheme {
6461
// A surface container using the 'background' color from the theme
6562
Surface(color = MaterialTheme.colors.background) {
66-
DetailQuoteApp(quote = quote!!, author = author!!)
63+
DetailQuoteApp(quote = quote!!, author = author!!) {
64+
onBackPressed()
65+
}
6766
}
6867
}
6968
}
7069
}
7170
}
7271

7372
@Composable
74-
fun DetailQuoteApp(quote: String, author: String) {
73+
fun DetailQuoteApp(quote: String, author: String, onback: () -> Unit) {
7574
Scaffold(topBar = {
7675
TopAppBar(
7776
title = {
@@ -83,7 +82,11 @@ fun DetailQuoteApp(quote: String, author: String) {
8382
},
8483
backgroundColor = MaterialTheme.colors.primary,
8584
contentColor = MaterialTheme.colors.onPrimary,
86-
navigationIcon = { Icon(asset = vectorResource(id = R.drawable.ic_back)) },
85+
navigationIcon = {
86+
IconButton(onClick = onback) {
87+
Icon(asset = vectorResource(id = R.drawable.ic_back))
88+
}
89+
},
8790
elevation = 0.dp
8891
)
8992
}, bodyContent = {

0 commit comments

Comments
 (0)