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
[Jetsurvey] Simplification of survey screens #1058
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This eliminates the survey repository and related data models in favor of simplifying the code base. Each of the different question types has a generic composable such as MultipleChoiceQuestion, which takes all of the relevant strings/resources to generate the UI. The actual survey data is baked into a specific composable in Survey.kt, such as FreeTimeQuestion, instead of coming from a data model. The SurveyViewModel is now much more explicit with methods for each question such as onFreeTimeResponse. In a production app, you'd likely want this to be more flexible to handle server-side questions, but this code pattern makes the sample easier to skim. Every response is maintained in SurveyViewModel as a separate state. This increases verbosity in favor of better readability. This also appears to fix the issue of photos not working on API 21, though I'm not sure what specific change fixed it. I verified on a Nexus 4 running Android 5.1.1. Note: This does not animate between the final survey question and the survey results. When the work to move the app to Compose Navigation is done, the results will be a separate destination that is navigated to and animated that way. This fixes #1054.
JolandaVerhoef
requested changes
Dec 30, 2022
Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/Survey.kt
Outdated
Show resolved
Hide resolved
Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyFragment.kt
Outdated
Show resolved
Hide resolved
Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyFragment.kt
Show resolved
Hide resolved
Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyFragment.kt
Outdated
Show resolved
Hide resolved
Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyViewModel.kt
Outdated
Show resolved
Hide resolved
Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyQuestions.kt
Outdated
Show resolved
Hide resolved
Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyQuestions.kt
Outdated
Show resolved
Hide resolved
Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyQuestions.kt
Outdated
Show resolved
Hide resolved
Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyQuestions.kt
Outdated
Show resolved
Hide resolved
Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyQuestions.kt
Outdated
Show resolved
Hide resolved
JolandaVerhoef
approved these changes
Jan 4, 2023
Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/QuestionWrapper.kt
Outdated
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This eliminates the survey repository and related data models in favor of simplifying the code base. Each of the different question types has a generic composable such as MultipleChoiceQuestion, which takes all of the relevant strings/resources to generate the UI. The actual survey data is baked into a specific composable in Survey.kt, such as FreeTimeQuestion, instead of coming from a data model.
The SurveyViewModel is now much more explicit with methods for each question such as onFreeTimeResponse. In a production app, you'd likely want this to be more flexible to handle server-side questions, but this code pattern makes the sample easier to skim. Every response is maintained in SurveyViewModel as a separate state. This increases verbosity in favor of better readability.
This also appears to fix the issue of photos not working on API 21, though I'm not sure what specific change fixed it. I verified on a Nexus 4 running Android 5.1.1.
Note: This does not animate between the final survey question and the survey results. When the work to move the app to Compose Navigation is done, the results will be a separate destination that is navigated to and animated that way.
This fixes #1054.