@@ -3,8 +3,7 @@ package ui.pane
33import androidx.compose.foundation.layout.*
44import androidx.compose.foundation.rememberScrollState
55import androidx.compose.foundation.verticalScroll
6- import androidx.compose.material3.MaterialTheme
7- import androidx.compose.material3.Text
6+ import androidx.compose.material3.*
87import androidx.compose.runtime.Composable
98import androidx.compose.runtime.getValue
109import androidx.compose.runtime.rememberUpdatedState
@@ -15,6 +14,7 @@ import data.HttpRequestState
1514import data.SnifferDB
1615import ui.component.*
1716
17+ @OptIn(ExperimentalMaterial3Api ::class )
1818@Composable
1919fun RequestPane (
2020 modifier : Modifier = Modifier ,
@@ -24,106 +24,117 @@ fun RequestPane(
2424 val transaction by rememberUpdatedState(record.firstOrNull { it.id == id } as ? HttpRequestState ? : return )
2525 val scrollState = rememberScrollState()
2626
27- Column (
28- modifier = modifier
29- .verticalScroll(scrollState)
30- .padding(horizontal = 16 .dp),
31- ) {
32- when (val tr = transaction) {
33- is HttpRequestState .Error -> {
34- ErrorItem (
35- modifier = Modifier .fillMaxWidth(),
36- contentPadding = PaddingValues (vertical = 16 .dp),
37- item = ErrorItemDisplay .from(tr)
38- ) {
27+ Scaffold (
28+ topBar = {
29+ Box (
30+ modifier = Modifier .statusBarsPadding()
31+ ) {
32+ when (val tr = transaction) {
33+ is HttpRequestState .Error -> {
34+ ErrorItem (
35+ modifier = Modifier .fillMaxWidth(),
36+ item = ErrorItemDisplay .from(tr)
37+ ) {
3938
40- }
41- }
39+ }
40+ }
4241
43- is HttpRequestState .Executing -> {
44- ExecutingItem (
45- modifier = Modifier .fillMaxWidth(),
46- contentPadding = PaddingValues (vertical = 16 .dp),
47- item = ExecutingItemDisplay .from(tr)
48- ) {
42+ is HttpRequestState .Executing -> {
43+ ExecutingItem (
44+ modifier = Modifier .fillMaxWidth(),
45+ item = ExecutingItemDisplay .from(tr)
46+ ) {
4947
50- }
51- }
48+ }
49+ }
5250
53- is HttpRequestState .Spoofed -> {
54- SpoofedItem (
55- modifier = Modifier .fillMaxWidth(),
56- contentPadding = PaddingValues (vertical = 16 .dp),
57- item = SpoofedItemDisplay .from(tr)
58- ) {
51+ is HttpRequestState .Spoofed -> {
52+ SpoofedItem (
53+ modifier = Modifier .fillMaxWidth(),
54+ item = SpoofedItemDisplay .from(tr)
55+ ) {
5956
60- }
61- }
57+ }
58+ }
6259
63- is HttpRequestState .Success -> {
64- SuccessItem (
65- modifier = Modifier .fillMaxWidth(),
66- contentPadding = PaddingValues (vertical = 16 .dp),
67- item = SuccessItemDisplay .from(tr)
68- ) {
60+ is HttpRequestState .Success -> {
61+ SuccessItem (
62+ modifier = Modifier .fillMaxWidth(),
63+ item = SuccessItemDisplay .from(tr)
64+ ) {
6965
66+ }
67+ }
7068 }
7169 }
7270 }
73- Spacer (modifier = Modifier .height(8 .dp))
74- Text (
75- text = " Request" ,
76- style = MaterialTheme .typography.titleLarge
77- )
78- Spacer (modifier = Modifier .height(16 .dp))
79- Text (
80- text = " Header" ,
81- style = MaterialTheme .typography.titleMedium
82- )
83- Spacer (modifier = Modifier .height(4 .dp))
84- Text (
85- modifier = Modifier .padding(horizontal = 16 .dp),
86- text = transaction.requestHeader.orEmpty(),
87- style = MaterialTheme .typography.bodySmall
88- )
89- Spacer (modifier = Modifier .height(16 .dp))
90- Text (
91- text = " Content" ,
92- style = MaterialTheme .typography.titleMedium,
93- )
94- Spacer (modifier = Modifier .height(4 .dp))
95- Text (
96- modifier = Modifier .padding(horizontal = 16 .dp),
97- text = transaction.requestBody.orEmpty(),
98- style = MaterialTheme .typography.bodySmall
99- )
100- Spacer (modifier = Modifier .height(24 .dp))
101- Text (
102- text = " Response" ,
103- style = MaterialTheme .typography.titleLarge
104- )
105- Spacer (modifier = Modifier .height(16 .dp))
106- Text (
107- text = " Header" ,
108- style = MaterialTheme .typography.titleMedium
109- )
110- Spacer (modifier = Modifier .height(4 .dp))
111- Text (
112- modifier = Modifier .padding(horizontal = 16 .dp),
113- text = transaction.responseHeader.orEmpty(),
114- style = MaterialTheme .typography.bodySmall
115- )
116- Spacer (modifier = Modifier .height(16 .dp))
117- Text (
118- text = " Content" ,
119- style = MaterialTheme .typography.titleMedium
120- )
121- Spacer (modifier = Modifier .height(4 .dp))
122- Text (
123- modifier = Modifier .padding(horizontal = 16 .dp),
124- text = transaction.responseBody.orEmpty(),
125- style = MaterialTheme .typography.bodySmall
126- )
127- Spacer (modifier = Modifier .height(4 .dp))
71+ ) {
72+ Surface (
73+ modifier = Modifier
74+ .fillMaxSize()
75+ .padding(it)
76+ ) {
77+ Column (
78+ modifier = Modifier
79+ .verticalScroll(scrollState)
80+ .padding(horizontal = 16 .dp),
81+ ) {
82+ Spacer (modifier = Modifier .height(8 .dp))
83+ Text (
84+ text = " Request" ,
85+ style = MaterialTheme .typography.titleLarge
86+ )
87+ Spacer (modifier = Modifier .height(16 .dp))
88+ Text (
89+ text = " Header" ,
90+ style = MaterialTheme .typography.titleMedium
91+ )
92+ Spacer (modifier = Modifier .height(4 .dp))
93+ Text (
94+ modifier = Modifier .padding(horizontal = 16 .dp),
95+ text = transaction.requestHeader.orEmpty(),
96+ style = MaterialTheme .typography.bodySmall
97+ )
98+ Spacer (modifier = Modifier .height(16 .dp))
99+ Text (
100+ text = " Content" ,
101+ style = MaterialTheme .typography.titleMedium,
102+ )
103+ Spacer (modifier = Modifier .height(4 .dp))
104+ Text (
105+ modifier = Modifier .padding(horizontal = 16 .dp),
106+ text = transaction.requestBody.orEmpty(),
107+ style = MaterialTheme .typography.bodySmall
108+ )
109+ Spacer (modifier = Modifier .height(24 .dp))
110+ Text (
111+ text = " Response" ,
112+ style = MaterialTheme .typography.titleLarge
113+ )
114+ Spacer (modifier = Modifier .height(16 .dp))
115+ Text (
116+ text = " Header" ,
117+ style = MaterialTheme .typography.titleMedium
118+ )
119+ Spacer (modifier = Modifier .height(4 .dp))
120+ Text (
121+ modifier = Modifier .padding(horizontal = 16 .dp),
122+ text = transaction.responseHeader.orEmpty(),
123+ style = MaterialTheme .typography.bodySmall
124+ )
125+ Spacer (modifier = Modifier .height(16 .dp))
126+ Text (
127+ text = " Content" ,
128+ style = MaterialTheme .typography.titleMedium
129+ )
130+ Spacer (modifier = Modifier .height(4 .dp))
131+ Text (
132+ modifier = Modifier .padding(horizontal = 16 .dp),
133+ text = transaction.responseBody.orEmpty(),
134+ style = MaterialTheme .typography.bodySmall
135+ )
136+ Spacer (modifier = Modifier .height(4 .dp))
137+ }
138+ }
128139 }
129140}
0 commit comments