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

Add builder api for EXTRA_SHOW_SUBMIT_BUTTON #1872

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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