@@ -23,6 +23,7 @@ import org.jetbrains.compose.resources.getString
23
23
import org.jetbrains.compose.resources.stringResource
24
24
import ru.packetdima.datascanner.resources.Error_FileOpen
25
25
import ru.packetdima.datascanner.resources.LocationWindow_Error
26
+ import ru.packetdima.datascanner.resources.LocationWindow_NotFound
26
27
import ru.packetdima.datascanner.resources.LocationWindow_Title
27
28
import ru.packetdima.datascanner.resources.Res
28
29
import ru.packetdima.datascanner.scan.common.files.Location
@@ -47,13 +48,17 @@ fun AttributeLocationWindow(
47
48
48
49
var errorSearching by remember { mutableStateOf(false ) }
49
50
51
+ var failedToFind by remember { mutableStateOf(false ) }
52
+
50
53
coroutineScope.launch {
51
54
searching = true
52
55
try {
53
56
locations = LocationFinder .findLocations(
54
57
filePath,
55
58
attribute
56
59
)
60
+ if (locations.isEmpty())
61
+ failedToFind = true
57
62
} catch (_: Exception ) {
58
63
errorSearching = true
59
64
}
@@ -163,63 +168,72 @@ fun AttributeLocationWindow(
163
168
if (searching) {
164
169
CircularProgressIndicator ()
165
170
} else {
166
- Scaffold (
167
- modifier = Modifier
168
- .fillMaxSize(),
169
- snackbarHost = { SnackbarHost (snackbarHostState) }
170
- ) {
171
- Box (
171
+ if (failedToFind) {
172
+ Spacer (Modifier .height(20 .dp))
173
+ Text (
174
+ text = stringResource(Res .string.LocationWindow_NotFound ),
175
+ style = MaterialTheme .typography.bodyLarge,
176
+ color = MaterialTheme .colorScheme.primary
177
+ )
178
+ } else {
179
+ Scaffold (
172
180
modifier = Modifier
173
- .fillMaxSize()
174
- .padding(8 .dp)
175
- .background(color = MaterialTheme .colorScheme.surface)
176
- .padding(vertical = 8 .dp)
181
+ .fillMaxSize(),
182
+ snackbarHost = { SnackbarHost (snackbarHostState) }
177
183
) {
178
-
179
- LazyColumn (
180
- verticalArrangement = Arrangement .spacedBy(12 .dp),
184
+ Box (
181
185
modifier = Modifier
182
- .padding(
183
- start = 8 .dp,
184
- end = if (scrollState.canScrollBackward || scrollState.canScrollForward) 20 .dp else 8 .dp
185
- ),
186
- state = scrollState
186
+ .fillMaxSize()
187
+ .padding(8 .dp)
188
+ .background(color = MaterialTheme .colorScheme.surface)
189
+ .padding(vertical = 8 .dp)
187
190
) {
188
- items(locations) { location ->
189
- Row (
190
- horizontalArrangement = Arrangement .spacedBy(12 .dp),
191
- modifier = Modifier
192
- .fillMaxWidth()
193
- ) {
194
- Text (
195
- modifier = Modifier
196
- .weight(0.8f )
197
- .fillMaxWidth(),
198
- text = location.entry,
199
- style = MaterialTheme .typography.bodySmall
200
- )
201
- Text (
191
+
192
+ LazyColumn (
193
+ verticalArrangement = Arrangement .spacedBy(12 .dp),
194
+ modifier = Modifier
195
+ .padding(
196
+ start = 8 .dp,
197
+ end = if (scrollState.canScrollBackward || scrollState.canScrollForward) 20 .dp else 8 .dp
198
+ ),
199
+ state = scrollState
200
+ ) {
201
+ items(locations) { location ->
202
+ Row (
203
+ horizontalArrangement = Arrangement .spacedBy(12 .dp),
202
204
modifier = Modifier
203
- .weight(0.2f )
204
- .fillMaxWidth(),
205
- text = location.location,
206
- style = MaterialTheme .typography.bodySmall
207
- )
205
+ .fillMaxWidth()
206
+ ) {
207
+ Text (
208
+ modifier = Modifier
209
+ .weight(0.8f )
210
+ .fillMaxWidth(),
211
+ text = location.entry,
212
+ style = MaterialTheme .typography.bodySmall
213
+ )
214
+ Text (
215
+ modifier = Modifier
216
+ .weight(0.2f )
217
+ .fillMaxWidth(),
218
+ text = location.location,
219
+ style = MaterialTheme .typography.bodySmall
220
+ )
221
+ }
208
222
}
209
223
}
210
- }
211
224
212
- VerticalScrollbar (
213
- adapter = rememberScrollbarAdapter(scrollState),
214
- modifier = Modifier
215
- .align(Alignment .CenterEnd )
216
- .padding(end = 6 .dp)
217
- .width(10 .dp),
218
- style = LocalScrollbarStyle .current.copy(
219
- hoverColor = MaterialTheme .colorScheme.primary,
220
- unhoverColor = MaterialTheme .colorScheme.secondary
225
+ VerticalScrollbar (
226
+ adapter = rememberScrollbarAdapter(scrollState),
227
+ modifier = Modifier
228
+ .align(Alignment .CenterEnd )
229
+ .padding(end = 6 .dp)
230
+ .width(10 .dp),
231
+ style = LocalScrollbarStyle .current.copy(
232
+ hoverColor = MaterialTheme .colorScheme.primary,
233
+ unhoverColor = MaterialTheme .colorScheme.secondary
234
+ )
221
235
)
222
- )
236
+ }
223
237
}
224
238
}
225
239
}
0 commit comments