@@ -33,10 +33,7 @@ import androidx.appcompat.app.AppCompatActivity
33
33
import androidx.compose.foundation.Icon
34
34
import androidx.compose.foundation.Text
35
35
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.*
40
37
import androidx.compose.runtime.Composable
41
38
import androidx.compose.ui.Modifier
42
39
import androidx.compose.ui.platform.setContent
@@ -63,15 +60,17 @@ class QuoteDetails : AppCompatActivity() {
63
60
JetQuotesTheme {
64
61
// A surface container using the 'background' color from the theme
65
62
Surface (color = MaterialTheme .colors.background) {
66
- DetailQuoteApp (quote = quote!! , author = author!! )
63
+ DetailQuoteApp (quote = quote!! , author = author!! ) {
64
+ onBackPressed()
65
+ }
67
66
}
68
67
}
69
68
}
70
69
}
71
70
}
72
71
73
72
@Composable
74
- fun DetailQuoteApp (quote : String , author : String ) {
73
+ fun DetailQuoteApp (quote : String , author : String , onback : () -> Unit ) {
75
74
Scaffold (topBar = {
76
75
TopAppBar (
77
76
title = {
@@ -83,7 +82,11 @@ fun DetailQuoteApp(quote: String, author: String) {
83
82
},
84
83
backgroundColor = MaterialTheme .colors.primary,
85
84
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
+ },
87
90
elevation = 0 .dp
88
91
)
89
92
}, bodyContent = {
0 commit comments