@@ -11,101 +11,109 @@ import androidx.compose.ui.unit.dp
1111import androidx.lifecycle.compose.collectAsStateWithLifecycle
1212import data.HttpRequestState
1313import data.SnifferDB
14+ import io.github.stefanusayudha.spoof.lib.generated.resources.Res
15+ import io.github.stefanusayudha.spoof.lib.generated.resources.ic_arrow_back_24
16+ import org.jetbrains.compose.resources.painterResource
1417import ui.component.*
1518
1619@OptIn(ExperimentalMaterial3Api ::class )
1720@Composable
1821fun RequestPane (
19- modifier : Modifier = Modifier ,
20- id : String
22+ id : String ,
23+ onBack : () -> Unit
2124) {
2225 val record by SnifferDB .httpRequests.collectAsStateWithLifecycle(emptyList())
2326 val transaction by rememberUpdatedState(record.firstOrNull { it.id == id } as ? HttpRequestState ? : return )
2427
2528 Scaffold (
2629 topBar = {
27- Column (
28- modifier = Modifier .statusBarsPadding()
29- ) {
30- when (val tr = transaction) {
31- is HttpRequestState .Error -> {
32- ErrorItem (
33- modifier = Modifier .fillMaxWidth(),
34- contentPadding = PaddingValues (top = 16 .dp, start = 16 .dp, end = 16 .dp),
35- item = ErrorItemDisplay .from(tr),
36- onShare = {
37-
38- },
39- onDelete = {
30+ TopAppBar (
31+ navigationIcon = {
32+ IconButton (
33+ onClick = onBack
34+ ) {
35+ Icon (
36+ painter = painterResource(Res .drawable.ic_arrow_back_24),
37+ contentDescription = null
38+ )
39+ }
40+ },
41+ title = {
42+ Text (" Transaction" )
43+ }
44+ )
45+ },
46+ bottomBar = {
47+ Box (modifier = Modifier .navigationBarsPadding())
48+ }
49+ ) {
50+ Column (
51+ modifier = Modifier
52+ .fillMaxSize()
53+ .padding(it)
54+ ) {
55+ when (val tr = transaction) {
56+ is HttpRequestState .Error -> {
57+ ErrorItem (
58+ modifier = Modifier .fillMaxWidth(),
59+ contentPadding = PaddingValues (start = 16 .dp, end = 16 .dp),
60+ item = ErrorItemDisplay .from(tr),
61+ onShare = {
4062
41- }
42- ) {
63+ },
64+ onDelete = {
4365
4466 }
45- }
46-
47- is HttpRequestState .Executing -> {
48- ExecutingItem (
49- modifier = Modifier .fillMaxWidth(),
50- contentPadding = PaddingValues (top = 16 .dp, start = 16 .dp, end = 16 .dp),
51- item = ExecutingItemDisplay .from(tr),
52- onShare = {
67+ )
68+ }
5369
54- },
55- onDelete = {
70+ is HttpRequestState .Executing -> {
71+ ExecutingItem (
72+ modifier = Modifier .fillMaxWidth(),
73+ contentPadding = PaddingValues (start = 16 .dp, end = 16 .dp),
74+ item = ExecutingItemDisplay .from(tr),
75+ onShare = {
5676
57- }
58- ) {
77+ },
78+ onDelete = {
5979
6080 }
61- }
62-
63- is HttpRequestState .Spoofed -> {
64- SpoofedItem (
65- modifier = Modifier .fillMaxWidth(),
66- contentPadding = PaddingValues (top = 16 .dp, start = 16 .dp, end = 16 .dp),
67- item = SpoofedItemDisplay .from(tr),
68- onShare = {
81+ )
82+ }
6983
70- },
71- onDelete = {
84+ is HttpRequestState .Spoofed -> {
85+ SpoofedItem (
86+ modifier = Modifier .fillMaxWidth(),
87+ contentPadding = PaddingValues (start = 16 .dp, end = 16 .dp),
88+ item = SpoofedItemDisplay .from(tr),
89+ onShare = {
7290
73- }
74- ) {
91+ },
92+ onDelete = {
7593
7694 }
77- }
95+ ) {
7896
79- is HttpRequestState .Success -> {
80- SuccessItem (
81- modifier = Modifier .fillMaxWidth(),
82- contentPadding = PaddingValues (top = 16 .dp, start = 16 .dp, end = 16 .dp),
83- item = SuccessItemDisplay .from(tr),
84- onShare = {
97+ }
98+ }
8599
86- },
87- onDelete = {
100+ is HttpRequestState .Success -> {
101+ SuccessItem (
102+ modifier = Modifier .fillMaxWidth(),
103+ contentPadding = PaddingValues (start = 16 .dp, end = 16 .dp),
104+ item = SuccessItemDisplay .from(tr),
105+ onShare = {
88106
89- }
90- ) {
107+ },
108+ onDelete = {
91109
92110 }
93- }
111+ )
94112 }
95113 }
96- },
97- bottomBar = {
98- Box (modifier = Modifier .navigationBarsPadding())
99- }
100- ) {
101- Surface (
102- modifier = Modifier
103- .fillMaxSize()
104- .padding(it)
105- ) {
106114 LazyColumn (
107- modifier = Modifier
108- .padding (horizontal = 16 .dp),
115+ modifier = Modifier ,
116+ contentPadding = PaddingValues (horizontal = 16 .dp)
109117 ) {
110118 stickyHeader {
111119 Surface {
0 commit comments