Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hiding Keyboard on proceeding and loosing focus #47

Open
ublanke opened this issue Aug 9, 2021 · 0 comments
Open

Hiding Keyboard on proceeding and loosing focus #47

ublanke opened this issue Aug 9, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@ublanke
Copy link

ublanke commented Aug 9, 2021

Hi everyone,

technically not an issue. But for usability, it helps to hide the keyboard, when loosing focus.

Here is the code snippet. Also RPUIChoiceQuestionBody requires a change (on selecting non-freetext options).

RPUITask.dart
`
@OverRide
Widget build(BuildContext context) {
RPLocalizations? locale = RPLocalizations.of(context);

return WillPopScope(
  onWillPop: () => blocTask.sendStatus(RPStepStatus.Canceled),
  child: Scaffold(
      backgroundColor: Theme.of(context).backgroundColor,
      resizeToAvoidBottomInset: true,

// *****************************
// (1/2) added GestureDetector to remove keyboard on click
body: new GestureDetector(
onTap: () {
FocusScope.of(context).requestFocus(new FocusNode());
},
child: SafeArea(
// *****************************
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// top bar
_carouselBar(),
// Body
Expanded(
child: PageView.builder(
itemBuilder: (BuildContext context, int position) {
return _activeSteps[position].stepWidget;
},
itemCount: _activeSteps.length,
controller: _taskPageViewController,
physics: NeverScrollableScrollPhysics(),
),
),
// Bottom navigation
if (![
RPCompletionStep,
RPVisualConsentStep,
RPConsentReviewStep
].contains(_currentStep.runtimeType))
Padding(
padding: EdgeInsets.only(left: 15, right: 15, bottom: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// if first question or its a navigable task
_currentStepIndex == 0 || navigableTask
? Container()
: OutlinedButton(
onPressed: () =>
blocTask.sendStatus(RPStepStatus.Back),
child: Text(
locale?.translate('BACK') ?? 'BACK',
// style: TextStyle(
// color: Theme.of(context).primaryColor),
),
),
StreamBuilder(
stream: blocQuestion.questionReadyToProceed,
builder: (context, snapshot) {
if (snapshot.hasData) {
return ElevatedButton(
child: Text(
RPLocalizations.of(context)
?.translate('NEXT') ??
"NEXT",
style: Theme.of(context)
.accentTextTheme
.button,
),
onPressed: snapshot.data!
? () {
// *****************************
// (2/2) added GestureDetector to remove keyboard on proceed
FocusScope.of(context).unfocus();
// *****************************
blocTask.sendStatus(
RPStepStatus.Finished);
}
: null,
);
} else {
return Container();
}
},
),
],
),
),
],
),
),
)),
);
}`

@MadsVSChristensen MadsVSChristensen added the enhancement New feature or request label Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants