From 0593c8675670a040dda9a27fc5ec426ddc67ed81 Mon Sep 17 00:00:00 2001 From: MSOB7YY Date: Tue, 14 Nov 2023 00:52:21 +0200 Subject: [PATCH] chore: 200ms delay when searching, for steady feel, #61 --- lib/ui/pages/main_page.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/ui/pages/main_page.dart b/lib/ui/pages/main_page.dart index 5fd9e4b1..654bfd00 100644 --- a/lib/ui/pages/main_page.dart +++ b/lib/ui/pages/main_page.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -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 @@ -282,6 +287,8 @@ class NamidaSearchBar extends StatelessWidget { } } +Timer? _searchFieldTimer; + class AlbumSearchResultsPage extends StatelessWidget { const AlbumSearchResultsPage({super.key});