Skip to content

Commit

Permalink
Merge pull request #115 from enrique-lozano/hot-fixes
Browse files Browse the repository at this point in the history
Improve the transaction search behavior
  • Loading branch information
enrique-lozano authored Feb 5, 2024
2 parents 48f0c0d + 483269c commit 5c2e7a9
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions lib/app/transactions/transactions.page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:monekin/i18n/translations.g.dart';

@RoutePage()
class TransactionsPage extends StatefulWidget {
const TransactionsPage({Key? key, this.filters}) : super(key: key);
const TransactionsPage({super.key, this.filters});

final TransactionFilters? filters;

Expand All @@ -37,7 +37,8 @@ class _TransactionsPageState extends State<TransactionsPage> {
filters = widget.filters ?? const TransactionFilters();

searchFocusNode.addListener(() {
if (!searchFocusNode.hasFocus) {
if (!searchFocusNode.hasFocus &&
(searchValue == null || searchValue!.isEmpty)) {
setState(() {
searchActive = false;
});
Expand All @@ -55,14 +56,24 @@ class _TransactionsPageState extends State<TransactionsPage> {
Widget build(BuildContext context) {
final t = Translations.of(context);

return WillPopScope(
onWillPop: () async {
if (searchFocusNode.hasFocus) {
return PopScope(
canPop: !searchActive,
onPopInvoked: (didPop) {
// if (didPop) return;

if (searchFocusNode.hasFocus &&
(searchValue != null && searchValue!.isNotEmpty)) {
searchFocusNode.unfocus();
return false;
return;
} else if (searchActive && !searchFocusNode.hasFocus) {
setState(() {
searchActive = false;
});

return;
}

return true;
Navigator.pop(context);
},
child: Scaffold(
appBar: AppBar(
Expand Down

0 comments on commit 5c2e7a9

Please sign in to comment.