Skip to content

Commit d0a2c79

Browse files
authored
Make cancel button configurable in the AppBar (#139)
* 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
1 parent deaa765 commit d0a2c79

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

lib/src/configuration/app_bar_configuration.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ class AppBarConfiguration {
55
final bool? canBack;
66
final bool? showProgress;
77
final Widget? trailing;
8+
final bool? showCancelButton;
89

910
const AppBarConfiguration({
1011
required this.canBack,
1112
required this.showProgress,
13+
this.showCancelButton = true,
1214
this.leading,
1315
this.trailing,
1416
});

lib/src/views/widget/survey_app_bar.dart

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,19 @@ class SurveyAppBar extends StatelessWidget {
3434
: Container(),
3535
title: _showProgress ? SurveyProgress() : SizedBox.shrink(),
3636
actions: [
37-
TextButton(
38-
child: appBarConfiguration.trailing ??
39-
Text(
40-
context.read<Map<String, String>?>()?['cancel'] ?? 'Cancel',
41-
style: TextStyle(
42-
color: Theme.of(context).primaryColor,
37+
if (appBarConfiguration.showCancelButton ?? true)
38+
TextButton(
39+
child: appBarConfiguration.trailing ??
40+
Text(
41+
context.read<Map<String, String>?>()?['cancel'] ?? 'Cancel',
42+
style: TextStyle(
43+
color: Theme.of(context).primaryColor,
44+
),
4345
),
44-
),
45-
onPressed: () => surveyController.closeSurvey(
46-
context: context,
46+
onPressed: () => surveyController.closeSurvey(
47+
context: context,
48+
),
4749
),
48-
),
4950
],
5051
);
5152
}

0 commit comments

Comments
 (0)