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

[Jetsurvey] Simplification of survey screens #1058

Merged
merged 8 commits into from Jan 4, 2023

Conversation

IanGClifton
Copy link
Contributor

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.

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.
@IanGClifton IanGClifton marked this pull request as ready for review December 28, 2022 01:43
@IanGClifton IanGClifton requested a review from a team as a code owner December 28, 2022 01:43
@IanGClifton IanGClifton removed the request for review from simona-anomis January 4, 2023 18:25
@IanGClifton IanGClifton merged commit 203a397 into main Jan 4, 2023
@IanGClifton IanGClifton deleted the iangclifton/simplification branch January 4, 2023 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Jetsurvey]: Tapping the survey title closes the survey
2 participants