From 68102ea6288a2c9390360023d87bd0521dbad8c4 Mon Sep 17 00:00:00 2001 From: Felix Date: Tue, 20 Aug 2019 16:37:32 +0100 Subject: [PATCH] orgs dialog button disables/enables properly --- ios/Podfile.lock | 4 +-- ios/Runner.xcodeproj/project.pbxproj | 2 +- lib/common/widgets/organisations_dialog.dart | 32 ++++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 8132310..a4e1203 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -6,13 +6,13 @@ PODS: - Flutter DEPENDENCIES: - - Flutter (from `.symlinks/flutter/ios-profile`) + - Flutter (from `.symlinks/flutter/ios`) - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) - url_launcher (from `.symlinks/plugins/url_launcher/ios`) EXTERNAL SOURCES: Flutter: - :path: ".symlinks/flutter/ios-profile" + :path: ".symlinks/flutter/ios" shared_preferences: :path: ".symlinks/plugins/shared_preferences/ios" url_launcher: diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index a0f8e33..5b4844c 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -281,7 +281,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../.symlinks/flutter/ios-profile/Flutter.framework", + "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( diff --git a/lib/common/widgets/organisations_dialog.dart b/lib/common/widgets/organisations_dialog.dart index 9a7b2e1..32a69eb 100644 --- a/lib/common/widgets/organisations_dialog.dart +++ b/lib/common/widgets/organisations_dialog.dart @@ -82,6 +82,8 @@ class FindOrganisations { } Future dialog(context) { + var focusNode = new FocusNode(); + bool _searchEnabled = false; bool _orgsFetched = false; TextEditingController searchBarText = new TextEditingController(); @@ -104,6 +106,8 @@ class FindOrganisations { barrierDismissible: true, builder: (BuildContext context) { + FocusScope.of(context).requestFocus(focusNode); + return StatefulBuilder( builder: (context, setState) { return @@ -122,6 +126,7 @@ class FindOrganisations { width: 150, height: 50, child: TextField( + focusNode: focusNode, controller: searchBarText, decoration: InputDecoration( hintText: "Payee Name", @@ -134,17 +139,15 @@ class FindOrganisations { } setState(() => {_searchEnabled}); }, - onSubmitted: ((_) { - if (_searchEnabled) { - SystemChannels.textInput.invokeMethod('TextInput.hide'); - var result = _submitSearch(searchBarText.text); - result.then((_) { - setState(() { - _orgsFetched = true; - }); + onSubmitted: _searchEnabled ? ((_) { + SystemChannels.textInput.invokeMethod('TextInput.hide'); + var result = _submitSearch(searchBarText.text); + result.then((_) { + setState(() { + _orgsFetched = true; }); - } - }), + }); + }) : null, ), ), @@ -153,8 +156,7 @@ class FindOrganisations { padding: EdgeInsets.fromLTRB(20, 0, 0, 0), child: RaisedButton( - onPressed: (() { - if (_searchEnabled) { + onPressed: _searchEnabled ? (() { SystemChannels.textInput.invokeMethod('TextInput.hide'); var result = _submitSearch(searchBarText.text); result.then((_) { @@ -162,12 +164,10 @@ class FindOrganisations { _orgsFetched = true; }); }); - } - }), + }) : null, child: Icon(Icons.search, color: Colors.white), - color: _searchEnabled ? Colors.blue : Colors.blue[200], - // make inactive when search in progress as activity indicator + color : Colors.blue, ), ), ],