@@ -2,13 +2,12 @@ import androidx.compose.desktop.Window
2
2
import androidx.compose.foundation.*
3
3
import androidx.compose.foundation.layout.*
4
4
import androidx.compose.foundation.lazy.LazyColumn
5
+ import androidx.compose.foundation.lazy.LazyItemScope
6
+ import androidx.compose.foundation.lazy.LazyListScope
5
7
import androidx.compose.foundation.lazy.items
6
8
import androidx.compose.foundation.shape.RoundedCornerShape
7
9
import androidx.compose.material.*
8
- import androidx.compose.runtime.Composable
9
- import androidx.compose.runtime.mutableStateListOf
10
- import androidx.compose.runtime.mutableStateOf
11
- import androidx.compose.runtime.remember
10
+ import androidx.compose.runtime.*
12
11
import androidx.compose.runtime.snapshots.SnapshotStateList
13
12
import androidx.compose.ui.Alignment
14
13
import androidx.compose.ui.Modifier
@@ -19,7 +18,6 @@ import androidx.compose.ui.text.font.FontWeight
19
18
import androidx.compose.ui.text.platform.Font
20
19
import androidx.compose.ui.text.style.TextAlign
21
20
import androidx.compose.ui.unit.IntSize
22
- import androidx.compose.ui.unit.TextUnit
23
21
import androidx.compose.ui.unit.dp
24
22
import io.PersistenceHelper
25
23
import processes.Process
@@ -35,7 +33,6 @@ import javax.sound.sampled.Clip
35
33
import javax.sound.sampled.FloatControl
36
34
import kotlin.concurrent.fixedRateTimer
37
35
38
- @ExperimentalFoundationApi
39
36
class KotlinGUI {
40
37
private val icon: BufferedImage = try {
41
38
ImageIO .read(File (Path .of(" res" , " shield-alt-solid.png" ).toUri()))
@@ -94,11 +91,11 @@ class KotlinGUI {
94
91
fun getWindow () {
95
92
return Window (
96
93
title = " APT" ,
97
- size = IntSize (1280 , 720 ),
94
+ size = IntSize (800 , 600 ),
98
95
icon = icon,
99
96
onDismissRequest = windowCloseRequest,
100
97
) {
101
- val automaticallyKillDisallowed = remember { mutableStateOf(false ) }
98
+ val automaticallyKillDisallowed = mutableStateOf(false )
102
99
val processList: SnapshotStateList <Process > = mutableStateListOf()
103
100
processList.addAll(ProcessHandler .computeFilteredProcessList(true ))
104
101
daemonTimers.add(initializeProcessUpdateTimer(processList))
@@ -108,19 +105,29 @@ class KotlinGUI {
108
105
109
106
defaultTheme {
110
107
Box (modifier = Modifier .background(MaterialTheme .colors.background).fillMaxSize()) {
111
- Row (modifier = Modifier .fillMaxWidth().fillMaxHeight(1f )) {
108
+ Row (modifier = Modifier .fillMaxWidth().fillMaxHeight(0.8f )) {
112
109
LazyColumn (
113
110
Modifier .fillMaxWidth(0.5f ),
114
111
verticalArrangement = Arrangement .spacedBy(3 .dp),
115
112
horizontalAlignment = Alignment .CenterHorizontally ,
116
113
contentPadding = PaddingValues (10 .dp),
117
114
) {
118
- stickyHeader {
119
- defaultHeader(" All Processes" )
115
+ item {
116
+ Text (
117
+ text = " All Processes" ,
118
+ color = MaterialTheme .colors.secondary,
119
+ style = MaterialTheme .typography.h4,
120
+ fontWeight = FontWeight .Thin ,
121
+ textAlign = TextAlign .Center ,
122
+ modifier = Modifier .background(MaterialTheme .colors.surface),
123
+ )
124
+
120
125
}
121
- items(processList) { proc ->
122
- textBox(proc) {
123
- ProcessHandler .blacklisted.add(proc.command())
126
+ processList.forEach { proc ->
127
+ item {
128
+ textBox(proc) {
129
+ ProcessHandler .blacklisted.add(proc.command())
130
+ }
124
131
}
125
132
}
126
133
}
@@ -130,8 +137,15 @@ class KotlinGUI {
130
137
horizontalAlignment = Alignment .CenterHorizontally ,
131
138
contentPadding = PaddingValues (10 .dp),
132
139
) {
133
- stickyHeader {
134
- defaultHeader(" Blacklisted Processes" )
140
+ item {
141
+ Text (
142
+ text = " Blacklisted Processes" ,
143
+ color = MaterialTheme .colors.secondary,
144
+ style = MaterialTheme .typography.h4,
145
+ fontWeight = FontWeight .Thin ,
146
+ textAlign = TextAlign .Center ,
147
+ modifier = Modifier .background(MaterialTheme .colors.surface),
148
+ )
135
149
}
136
150
item {
137
151
Row (horizontalArrangement = Arrangement .SpaceEvenly ) {
@@ -153,25 +167,14 @@ class KotlinGUI {
153
167
}
154
168
}
155
169
}
170
+
156
171
}
157
172
158
173
}
159
174
}
160
175
}
161
176
}
162
177
163
- @Composable
164
- private fun defaultHeader (text : String ) {
165
- Text (
166
- text = text,
167
- color = MaterialTheme .colors.secondary,
168
- style = MaterialTheme .typography.h4,
169
- fontWeight = FontWeight .Thin ,
170
- textAlign = TextAlign .Center ,
171
- modifier = Modifier .background(MaterialTheme .colors.surface),
172
- )
173
- }
174
-
175
178
private fun initializeProcessUpdateTimer (list : SnapshotStateList <Process >): Timer {
176
179
return fixedRateTimer(" Update" , true , 1000L , 1000L ) {
177
180
val newList = ProcessHandler .computeFilteredProcessList(false )
0 commit comments