Skip to content

Make the top views of the QE be reused by the scopes #615

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

Merged
merged 5 commits into from
Apr 29, 2025

Conversation

AdamGrzybkowski
Copy link
Contributor

Description

This PR adds QuickEditor composable component that will host the shared UI (top bar, email, and the profile card) and different editor scopes as content that will be added in the next PRs.

Some of the logic from the AvatarPickerViewModel was now moved to the new QuickEditorViewModel as the profile fetching will only happen there (plus some extra logic to force refresh the avatar).

Additionally, the alert banner that's shown the no avatar is selected was moved below the profile card, so that it stays in the avatar picker content space. Apart from this, there should be no UI change.

Testing Steps

As mentioned above, the UI should be unchanged (except for the alert banner position) but there are a few things worth testing:

Avatar updates in the profile card
Make sure the avatar is properly updated after each of the below:

  1. Selecting a different avatar
  2. Deleting the selected avatar

Refreshing after network failure

  1. Launch the demo app
  2. Disable the internet connection
  3. Open the QuickEditor (make sure you are logged in)
  4. You should see an error with a button to try again
  5. Enable the internet connection
  6. Tap the button to try again
  7. Confirm the Profile card and the rest was refreshed and rendered

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the editor UI to consolidate shared views into a new QuickEditor composable and moves profile fetching logic into QuickEditorViewModel.

  • Introduces QuickEditorViewModel and QuickEditor composable for shared header UI.
  • Removes redundant profile-related state and clock-based cache busting from AvatarPicker and its tests.
  • Adjusts layout, such as repositioning the alert banner, to consolidate the editor scopes.

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
QuickEditorViewModelTest.kt Tests updated for QuickEditorViewModel profile fetching and avatar cache refresh.
QuickEditorTest.kt Screenshot tests verify unchanged UI appearance except for alert banner placement.
AvatarPickerViewModelTest.kt Removes profile fetching tests and avatarCacheBuster expectations consistent with separation of concerns.
AvatarPickerTest.kt Removes profile-related properties in preview, reflecting new design.
QuickEditorViewModel.kt, QuickEditorUiState.kt, QuickEditorEvent.kt, QuickEditor.kt New implementation for the consolidated QuickEditor component and its supporting ViewModel, state and events.
GravatarQuickEditorPage.kt Updates navigation graph to use QuickEditor instead of AvatarPicker for the editor graph.
AvatarPickerViewModel.kt, AvatarPickerUiState.kt, AvatarPicker.kt Adjustments to remove outdated profile handling and clock updates in the AvatarPicker portion.
Comments suppressed due to low confidence (1)

gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/editor/GravatarQuickEditorPage.kt:158

  • The insertion of "it.viewModelStore" appears out-of-place and does not seem to be used in a meaningful way. Please verify whether this was intended or remove it if unnecessary.
it.viewModelStore

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Apr 24, 2025

📲 You can test the changes from this Pull Request in Gravatar Demo by scanning the QR code below to install the corresponding build.
App NameGravatar Demo
Commitd8d050c
Direct Downloadgravatar-demo-prototype-build-pr615-d8d050c.apk

internal fun QuickEditor(
gravatarQuickEditorParams: GravatarQuickEditorParams,
handleExpiredSession: Boolean,
onAvatarSelected: () -> Unit,
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing we decided to do on iOS is to have a general update() callback (we call it updateHandler(), and it has a parameter with the information of which kind of update it is.

https://github.com/Automattic/Gravatar-SDK-iOS/blob/57d6110c3671f0da74480680e6fcb5012637be5e/Sources/GravatarUI/SwiftUI/ProfileEditor/QuickEditor.swift#L59

https://github.com/Automattic/Gravatar-SDK-iOS/blob/57d6110c3671f0da74480680e6fcb5012637be5e/Sources/GravatarUI/SwiftUI/ProfileEditor/QuickEditor.swift#L23-L35

Maybe is not needed yet but it will possible become handy when we start to implement the About Info editor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! The API design is yet to be decided on, so I will definitely look at iOS.

Copy link
Contributor

@etoledom etoledom 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 👍
All manual testing steps passed 🟢

One comment on code, though not a blocker.

Base automatically changed from adam/GRA-25_picker to feature/quick_editor_about_info April 29, 2025 07:58
@AdamGrzybkowski AdamGrzybkowski merged commit ed14233 into feature/quick_editor_about_info Apr 29, 2025
14 checks passed
@AdamGrzybkowski AdamGrzybkowski deleted the adam/GRA-24 branch April 29, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Gravatar-Quickeditor Gravatar Quick Editor module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants