Skip to content

Commit

Permalink
Add options sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
ziulev committed Nov 22, 2022
1 parent ca49325 commit b2fcac9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Maintainer: Denis Ziulev <[email protected]>
pkgname=spotter
pkgver=1.9.11
pkgver=1.9.12
pkgrel=1
pkgdesc="Simple and powerful tool to launch everything"
arch=('x86_64')
Expand Down
29 changes: 22 additions & 7 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ import 'package:package_info_plus/package_info_plus.dart';
import 'plugin_service.dart';
import 'window_service.dart';

List<String> plugins = [
'spotter-application/applications-plugin',
'spotter-application/calculator-plugin',
'spotter-application/ml-plugin',
'spotter-application/projects-plugin'
];

typedef ScaleFunc = ffi.Double Function();
typedef Scale = double Function();
double deviceScale = 1;
Expand Down Expand Up @@ -173,12 +180,6 @@ class _SpotterState extends State<Spotter> {

bool loading = false;

List<String> plugins = [
'spotter-application/applications-plugin',
'spotter-application/calculator-plugin',
'spotter-application/ml-plugin',
];

final textFieldFocusNode = FocusNode();

@override
Expand Down Expand Up @@ -628,7 +629,21 @@ class _SpotterState extends State<Spotter> {
// option.name
// .toLowerCase()
// .contains(textFieldController.text.toLowerCase()))
.toList();
.toList()
..sort((a, b) {
String query = textFieldController.text.toLowerCase();
String aName = a.name.toLowerCase();
String bName = b.name.toLowerCase();
if (aName.startsWith(query) && !bName.startsWith(query)) {
return -1;
}

if (bName.startsWith(query) && !aName.startsWith(query)) {
return 1;
}

return aName.compareTo(bName);
});
// if (textFieldController.text.isEmpty) {
// filteredOptions = [];
// return;
Expand Down

0 comments on commit b2fcac9

Please sign in to comment.