Skip to content

Commit

Permalink
Make cancel button configurable in the AppBar (#139)
Browse files Browse the repository at this point in the history
* added missing MultipleChoiceQuestionResult toJson

* Updated PlatformAppbar with default AppBar widget

* Updated IconButton -> BackButton

* Added other field in Multiple choice answers

* added Multiple choice autocomplete

* Customized the builder

* added comment

* DRY refactor

* Updated other field label behavior

* Added clear button and added tick mark check on dropdown

* Updated example

* Removed comment

* json file updated

* added default value for text question

* Boolean Answer defaultValue

* put back actual example_json.json

* Fixed consistent focus in non textfield views

There was a problem that keyboard was not hiding after navigating to
next question when the view is not text/double answer view

* added showCancelButton flag

* update build_runner dependency

* update flutter changes for android directory

* update flutter changes for ios directory

* update example pubspec.lock

* add missing JsonSerializable annotation for ImageQuestionResult

* re-run build_runner latest verson

* remove duplicate imports
  • Loading branch information
adar2378 authored Dec 14, 2023
1 parent deaa765 commit d0a2c79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions lib/src/configuration/app_bar_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ class AppBarConfiguration {
final bool? canBack;
final bool? showProgress;
final Widget? trailing;
final bool? showCancelButton;

const AppBarConfiguration({
required this.canBack,
required this.showProgress,
this.showCancelButton = true,
this.leading,
this.trailing,
});
Expand Down
21 changes: 11 additions & 10 deletions lib/src/views/widget/survey_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@ class SurveyAppBar extends StatelessWidget {
: Container(),
title: _showProgress ? SurveyProgress() : SizedBox.shrink(),
actions: [
TextButton(
child: appBarConfiguration.trailing ??
Text(
context.read<Map<String, String>?>()?['cancel'] ?? 'Cancel',
style: TextStyle(
color: Theme.of(context).primaryColor,
if (appBarConfiguration.showCancelButton ?? true)
TextButton(
child: appBarConfiguration.trailing ??
Text(
context.read<Map<String, String>?>()?['cancel'] ?? 'Cancel',
style: TextStyle(
color: Theme.of(context).primaryColor,
),
),
),
onPressed: () => surveyController.closeSurvey(
context: context,
onPressed: () => surveyController.closeSurvey(
context: context,
),
),
),
],
);
}
Expand Down

0 comments on commit d0a2c79

Please sign in to comment.