Skip to content

Commit

Permalink
Add builder api for EXTRA_SHOW_SUBMIT_BUTTON (#1872)
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya-07 committed Feb 15, 2023
1 parent 5c9a79f commit 0794d2a
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class QuestionnaireFragment : Fragment() {
*/
fun getQuestionnaireResponse() = viewModel.getQuestionnaireResponse()

/** Helper to create [Questionnaire] with appropriate [Bundle] arguments. */
/** Helper to create [QuestionnaireFragment] with appropriate [Bundle] arguments. */
class Builder {

private val args = mutableListOf<Pair<String, Any>>()
Expand Down Expand Up @@ -332,6 +332,11 @@ class QuestionnaireFragment : Fragment() {
matchersProviderFactory: String
) = apply { args.add(EXTRA_MATCHERS_FACTORY to matchersProviderFactory) }

/**
* A [Boolean] extra to show or hide the Submit button in the questionnaire. Default is true.
*/
fun setShowSubmitButton(value: Boolean) = apply { args.add(EXTRA_SHOW_SUBMIT_BUTTON to value) }

@VisibleForTesting fun buildArgs() = bundleOf(*args.toTypedArray())

/** @return A [QuestionnaireFragment] with provided [Bundle] arguments. */
Expand Down Expand Up @@ -406,11 +411,12 @@ class QuestionnaireFragment : Fragment() {

const val SUBMIT_REQUEST_KEY = "submit-request-key"

fun builder() = Builder()
/**
* A [Boolean] extra to show or hide the Submit button in the questionnaire. Default is true.
*/
const val EXTRA_SHOW_SUBMIT_BUTTON = "show-submit-button"
internal const val EXTRA_SHOW_SUBMIT_BUTTON = "show-submit-button"

fun builder() = Builder()
}

/**
Expand Down

0 comments on commit 0794d2a

Please sign in to comment.