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

Added Compose Previews for NFC, Onboarding & Companion Views #4239

Merged
merged 6 commits into from Apr 30, 2024

Conversation

vieck
Copy link
Contributor

@vieck vieck commented Mar 1, 2024

Summary

Adding in more compose previews for new (and experienced) devs to remember what the screens look like at a glance. Allows for easier font sizing, style checking, etc

Screenshots

ChooseEntityView DiscoveryView ManualSetupView NFCEditView NFCWelcomeView NFCWriteView Disabled NFCWriteView Enabled TagReaderView

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

* Compose Preview created for ChooseEntityView

* Nfc view previews added

* Added onboarding previews

* Fixed ktlint errors

* Author Test

---------
@vieck vieck changed the title Added Compose Previews for NFC, Onboarding & Companion Views #4238 Added Compose Previews for NFC, Onboarding & Companion Views Mar 1, 2024
Copy link
Member

@dshokouhi dshokouhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for the contribution!

Copy link
Member

@jpelgrom jpelgrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally this looks good! A couple of small suggestions to clean up the code and for consistency.

(Also, unless there is a merge conflict or requested, you don't need to rebase/merge the latest commits to the branch.)

Comment on lines 39 to 46
@Composable
fun DiscoveryView(
onboardingViewModel: OnboardingViewModel,
manualSetupClicked: () -> Unit,
instanceClicked: (instance: HomeAssistantInstance) -> Unit
) {
DiscoveryView(foundInstances = onboardingViewModel.foundInstances, manualSetupClicked = manualSetupClicked, instanceClicked = instanceClicked)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why keep this around? You can update the fragment to use the 'new'/updated function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpelgrom This is only for compose previews. Basically, if we use the second one we need to expand the parameters of un DiscoveryView(
onboardingViewModel: OnboardingViewModel,
manualSetupClicked: () -> Unit,
instanceClicked: (instance: HomeAssistantInstance) -> Unit
) {
to include everything that we use in onboardingViewModel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpelgrom Read here real quick https://developer.android.com/jetpack/compose/tooling/previews#preview-viewmodel
"If you want to preview a composable that uses a ViewModel, you should create another composable with the parameters from ViewModel passed as arguments of the composable. This way, you don't need to preview the composable that uses the ViewModel."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this is required for the Compose previews. My point was: if this is what we need, why keep the other function that uses a ViewModel as well instead of switching it to use this new constructor? I see little to no advantage, and with these changes you need to update both functions anyway.

if we use the second one we need to expand the parameters of un DiscoveryView (...) to include everything that we use in onboardingViewModel

You don't, as you've already proven with the function you've added. For DiscoveryView, you only need/use onboardingViewModel.foundInstances.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this as requested (or give more arguments to convince why not :)) to proceed.

Comment on lines 35 to 40
fun ManualSetupView(
onboardingViewModel: OnboardingViewModel,
connectedClicked: () -> Unit
) {
ManualSetupView(onboardingViewModel.manualUrl, onboardingViewModel::onManualUrlUpdated, onboardingViewModel.manualContinueEnabled, connectedClicked)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why keep this around? You can update the fragment to use the 'new'/updated function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vieck vieck requested a review from jpelgrom March 10, 2024 23:49
Comment on lines 39 to 46
@Composable
fun DiscoveryView(
onboardingViewModel: OnboardingViewModel,
manualSetupClicked: () -> Unit,
instanceClicked: (instance: HomeAssistantInstance) -> Unit
) {
DiscoveryView(foundInstances = onboardingViewModel.foundInstances, manualSetupClicked = manualSetupClicked, instanceClicked = instanceClicked)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this as requested (or give more arguments to convince why not :)) to proceed.

@home-assistant home-assistant bot marked this pull request as draft March 19, 2024 18:07
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@jpelgrom jpelgrom marked this pull request as ready for review April 30, 2024 17:43
@home-assistant home-assistant bot requested a review from jpelgrom April 30, 2024 17:43
@jpelgrom jpelgrom enabled auto-merge (squash) April 30, 2024 17:44
@jpelgrom jpelgrom merged commit cda6b01 into home-assistant:master Apr 30, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants