carp-dk / carp-dk/research.package
Hiding Keyboard on proceeding and loosing focus
- Dominant language
- Dart
- Stars
- 52
- Forks
- 47
- Avg merge
- 5h 35m
- Merged PRs (30d)
- 4
Description
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();
}
},
),
],
),
),
],
),
),
)),
);
}`
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with RPUITask.dart and inspect the focus behavior around the task page and its Next action. Then review RPUIChoiceQuestionBody for the non-freetext selection path. Done means the keyboard is dismissed when focus is lost, when proceeding, and after selecting non-freetext options.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile-dev
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- Half a day
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100