-
Notifications
You must be signed in to change notification settings - Fork 21
Refactors detail view to use ViewModel #37
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
Conversation
mariobodemann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work, thank you. 👍
One naming stood out to me, but otherwise, I really enjoy your work.
🤓👍
| patchable | ||
| onBitmapUpdated = viewModel::updateBitmap, | ||
| onColorCountUpdated = viewModel::updateColorCount, | ||
| computeReducedBitmap = viewModel::computeReducedBitmap, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: should that also be onComputeReducedBitmap? Consistency with the other names, or does work differently, hence the difference in naming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for onBitmapUpdated and onColorCountUpdated we ask the composable to do something and it calls these methods when it completes the task.
on the other hand the computeReducedBitmap is an imperative action which we are asking and external function to perform, in this case the ViewModel.
BUT I see a nit myself, I am not consistently using color vs colour. very irritating, I will fix it. Fake news it is ok
| import kotlinx.coroutines.launch | ||
|
|
||
| /** | ||
| * ViewModel to manage the Wizard screen state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧙♀️👍
Allow SafeArea to Capture the Bitmap
Introduces `WizardViewModel` to manage the state and logic of the `WizardScreen`. This change centralizes state management and improves the testability of the screen. Refactor WizardScreen to use ViewModel Refactor WizardScreen to use ViewModel Introduces `WizardViewModel` to manage the state and logic of the `WizardScreen`. This change centralizes state management and improves the testability of the screen.
4971c5e to
45f1c63
Compare
Refactors the detail view to utilize a
WizardViewModelfor managing state, improving separation of concerns and testability.Key changes:
WizardViewModelto handle UI state, including bitmap processing, color reduction, and embroidery creation.PatchableDetailcomposable to useWizardViewModeland collect state usingcollectAsStateWithLifecycle.resetfunctionality toWizardViewModelto clear the state when a different patchable is selected.PatchablePreviewModeenum to handle preview modes.