From 6ccdca19b2d68f81d00e74203f8d5392e3f8f931 Mon Sep 17 00:00:00 2001 From: Alex Fernandez Date: Thu, 15 Jan 2026 03:15:21 -0500 Subject: [PATCH 1/3] fix some long standing bugs --- CHANGELOG.md | 8 ++++++++ analysis_options.yaml | 3 +++ lib/src/components/search_field.dart | 4 ++++ lib/src/components/tab_view.dart | 14 ++++++++++++-- lib/src/providers/app_bar_provider.dart | 4 ++++ pubspec.yaml | 2 +- 6 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d196570..20a6785 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.0.2 + +- fix: freeze when you type just white space into the input field when categories are visible +- fix: infinite loading when you type just white space into emoji/stickers +- fix: cursor jumping to the end of the input if you type anywhere but the end + +[All Code Changes](https://github.com/Flyclops/klipy_flutter/compare/0.0.1...0.0.2) + ## 0.0.1 - refactor: [tenor_flutter](https://pub.dev/packages/tenor_flutter) so that it supports the KLIPY API via their [migration docs](https://docs.klipy.com/migrate-from-tenor). diff --git a/analysis_options.yaml b/analysis_options.yaml index b825346..db98472 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -7,3 +7,6 @@ analyzer: linter: rules: require_trailing_commas: true + +formatter: + trailing_commas: preserve \ No newline at end of file diff --git a/lib/src/components/search_field.dart b/lib/src/components/search_field.dart index e6ff8c9..e91252e 100644 --- a/lib/src/components/search_field.dart +++ b/lib/src/components/search_field.dart @@ -244,6 +244,10 @@ class _KlipySearchFieldState extends State { // listener query void _listenerQuery() { + // Update only when the text is different. For instance if you tap + // on a category. Without this check the cursor will jump to the end. + if (_textEditingController.text == _appBarProvider.queryText) return; + _textEditingController.text = _appBarProvider.queryText; } } diff --git a/lib/src/components/tab_view.dart b/lib/src/components/tab_view.dart index 7bb2dbf..493ae11 100644 --- a/lib/src/components/tab_view.dart +++ b/lib/src/components/tab_view.dart @@ -148,7 +148,7 @@ class _KlipyTabViewState extends State return const Center(child: CircularProgressIndicator()); } - if (_appBarProvider.queryText.isEmpty && + if (_appBarProvider.queryText.trim().isEmpty && _appBarProvider.selectedCategory == null && widget.showCategories) { return Padding( @@ -327,7 +327,7 @@ class _KlipyTabViewState extends State if (widget.onLoad != null) { final response = await widget.onLoad?.call( - _appBarProvider.queryText, + _appBarProvider.queryText.trim(), offset, requestLimit, _appBarProvider.selectedCategory, @@ -395,6 +395,16 @@ class _KlipyTabViewState extends State // When the text in the search input changes void _appBarProviderListener() { + final queryText = _appBarProvider.queryText; + final trimmedQueryText = _appBarProvider.queryText.trim(); + final trimmedPreviousQueryText = _appBarProvider.previousQueryText.trim(); + + // do nothing if the text did not change + if (trimmedQueryText == trimmedPreviousQueryText) return; + + // Prevent searches with only spaces + if (queryText.isNotEmpty && trimmedQueryText.isEmpty) return; + setState(() { _list = []; _collection = null; diff --git a/lib/src/providers/app_bar_provider.dart b/lib/src/providers/app_bar_provider.dart index 2bc85b6..804c7c7 100644 --- a/lib/src/providers/app_bar_provider.dart +++ b/lib/src/providers/app_bar_provider.dart @@ -6,12 +6,15 @@ class KlipyAppBarProvider with ChangeNotifier { String _queryText = ''; String get queryText => _queryText; + String _previousQueryText = ''; + String get previousQueryText => _previousQueryText; KlipyCategoryObject? _selectedCategory; Duration _debounce = Duration.zero; Duration get debounce => _debounce; set queryText(String queryText) { + _previousQueryText = _queryText; _queryText = queryText; // reset selected category if (_queryText.isEmpty) { @@ -28,6 +31,7 @@ class KlipyAppBarProvider with ChangeNotifier { }) : _selectedCategory = selectedCategory, super() { _queryText = queryText; + _previousQueryText = queryText; _debounce = debounce; } diff --git a/pubspec.yaml b/pubspec.yaml index 315ada8..2eccd5e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: klipy_flutter -version: 0.0.1 +version: 0.0.2 description: An opinionated yet customizable Flutter package for searching and selecting from a list of GIFs/Stickers from the KLIPY GIF search API. homepage: https://github.com/flyclops repository: https://github.com/flyclops/klipy_flutter From 088ae491056e08811de4dd93331467bb672ad3a6 Mon Sep 17 00:00:00 2001 From: Alex Fernandez Date: Thu, 15 Jan 2026 03:46:29 -0500 Subject: [PATCH 2/3] tweak media --- lib/src/components/media_widget.dart | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/src/components/media_widget.dart b/lib/src/components/media_widget.dart index 60f113f..75b7530 100644 --- a/lib/src/components/media_widget.dart +++ b/lib/src/components/media_widget.dart @@ -3,8 +3,17 @@ import 'package:flutter/widgets.dart'; class KlipyMediaWidget extends StatelessWidget { final Widget media; + final double watermarkXOffset; + final double watermarkYOffset; + final double watermarkHeight; - const KlipyMediaWidget({required this.media, super.key}); + const KlipyMediaWidget({ + required this.media, + this.watermarkHeight = 10, + this.watermarkXOffset = 4, + this.watermarkYOffset = 4, + super.key, + }); @override Widget build(BuildContext context) { @@ -12,12 +21,13 @@ class KlipyMediaWidget extends StatelessWidget { children: [ media, Positioned( - bottom: 2, - left: 2, + bottom: watermarkYOffset, + left: watermarkXOffset, child: Image.asset( 'assets/media_watermark.png', + height: watermarkHeight, package: 'klipy_flutter', - height: 10, + semanticLabel: 'KLIPY', ), ), ], From 82cf47570b60b3cff50d742ec3d41426ffc8436f Mon Sep 17 00:00:00 2001 From: Alex Fernandez Date: Thu, 15 Jan 2026 12:25:45 -0500 Subject: [PATCH 3/3] remove previous query check --- lib/src/components/tab_view.dart | 12 ++++-------- lib/src/providers/app_bar_provider.dart | 4 ---- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/src/components/tab_view.dart b/lib/src/components/tab_view.dart index 493ae11..405dd6a 100644 --- a/lib/src/components/tab_view.dart +++ b/lib/src/components/tab_view.dart @@ -395,15 +395,11 @@ class _KlipyTabViewState extends State // When the text in the search input changes void _appBarProviderListener() { - final queryText = _appBarProvider.queryText; - final trimmedQueryText = _appBarProvider.queryText.trim(); - final trimmedPreviousQueryText = _appBarProvider.previousQueryText.trim(); - - // do nothing if the text did not change - if (trimmedQueryText == trimmedPreviousQueryText) return; - // Prevent searches with only spaces - if (queryText.isNotEmpty && trimmedQueryText.isEmpty) return; + if (_appBarProvider.queryText.isNotEmpty && + _appBarProvider.queryText.trim().isEmpty) { + return; + } setState(() { _list = []; diff --git a/lib/src/providers/app_bar_provider.dart b/lib/src/providers/app_bar_provider.dart index 804c7c7..2bc85b6 100644 --- a/lib/src/providers/app_bar_provider.dart +++ b/lib/src/providers/app_bar_provider.dart @@ -6,15 +6,12 @@ class KlipyAppBarProvider with ChangeNotifier { String _queryText = ''; String get queryText => _queryText; - String _previousQueryText = ''; - String get previousQueryText => _previousQueryText; KlipyCategoryObject? _selectedCategory; Duration _debounce = Duration.zero; Duration get debounce => _debounce; set queryText(String queryText) { - _previousQueryText = _queryText; _queryText = queryText; // reset selected category if (_queryText.isEmpty) { @@ -31,7 +28,6 @@ class KlipyAppBarProvider with ChangeNotifier { }) : _selectedCategory = selectedCategory, super() { _queryText = queryText; - _previousQueryText = queryText; _debounce = debounce; }