Skip to content

Commit

Permalink
chore: 200ms delay when searching, for steady feel, #61
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Nov 13, 2023
1 parent 8395cde commit 0593c86
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/ui/pages/main_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:get/get.dart';

Expand Down Expand Up @@ -270,8 +272,11 @@ class NamidaSearchBar extends StatelessWidget {
},
onFieldSubmitted: _onSubmitted,
onChanged: (value) {
ClipboardController.inst.updateTextInControllerEmpty(value == '');
SearchSortController.inst.searchAll(value);
_searchFieldTimer?.cancel();
_searchFieldTimer = Timer(const Duration(milliseconds: 200), () {
ClipboardController.inst.updateTextInControllerEmpty(value == '');
SearchSortController.inst.searchAll(value);
});
},
// -- unfocusing produces weird bug while swiping for drawer
// -- leaving it will leave the pointer while entering miniplayer
Expand All @@ -282,6 +287,8 @@ class NamidaSearchBar extends StatelessWidget {
}
}

Timer? _searchFieldTimer;

class AlbumSearchResultsPage extends StatelessWidget {
const AlbumSearchResultsPage({super.key});

Expand Down

0 comments on commit 0593c86

Please sign in to comment.