-
Notifications
You must be signed in to change notification settings - Fork 5
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
QE: Avatar Rating #589
QE: Avatar Rating #589
Conversation
📲 You can test the changes from this Pull Request in Gravatar Prototype Build by scanning the QR code below to install the corresponding build.
|
/// Transforms `Avatar.Rating` into `AvatarRating` | ||
/// This is only necessary while we maintain both enums. For our next major realease, `Avatar` will use the `AvatarRating` enum | ||
/// rather than defining its own. | ||
var avatarRating: AvatarRating { |
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.
We only need this in one place, currently, and only until we release a new major release. But I wonder if it still makes sense to move it to Gravatar
and use package
, to match the access of Avatar.Rating
.
@@ -1,24 +1,21 @@ | |||
import Foundation | |||
import SwiftUI | |||
|
|||
enum AvatarAction: String, CaseIterable, Identifiable { |
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.
Since we are laying out the menu manually, the CaseIterable
is no longer needed.
I'm using an enum with an associated value (rating(AvatarRating)
) in order to pass values back up the chain when a rating is tapped. So conforming to String
is no longer possible.
Sources/GravatarUI/SwiftUI/AvatarPicker/Views/AvatarPickerAvatarView.swift
Outdated
Show resolved
Hide resolved
Sources/GravatarUI/SwiftUI/AvatarPicker/AvatarPickerViewModel.swift
Outdated
Show resolved
Hide resolved
Sources/GravatarUI/SwiftUI/AvatarPicker/AvatarPickerViewModel.swift
Outdated
Show resolved
Hide resolved
if request.httpMethod == "POST" { | ||
if request.url?.absoluteString.contains(RequestType.avatars.rawValue) == true { | ||
return (Bundle.postAvatarSelectedJsonData, HTTPURLResponse.successResponse()) // Avatars data | ||
if request.isSetAvatarForEmailRequest { | ||
return (Bundle.postAvatarSelectedJsonData, HTTPURLResponse.successResponse()) // Avatars data | ||
} | ||
|
||
if request.isSetAvatarRatingRequest { | ||
if let returnErrorCode { | ||
return (Data("".utf8), HTTPURLResponse.errorResponse(code: returnErrorCode)) | ||
} else { | ||
return (Bundle.setRatingJsonData, HTTPURLResponse.successResponse()) // Avatar data | ||
} | ||
} | ||
if request.url?.absoluteString.contains(RequestType.profiles.rawValue) == true { | ||
|
||
if request.isProfilesRequest { | ||
return (Bundle.fullProfileJsonData, HTTPURLResponse.successResponse()) // Profile data | ||
} else if request.url?.absoluteString.contains(RequestType.avatars.rawValue) == true { | ||
} else if request.isAvatarsRequest == true { | ||
return (Bundle.getAvatarsJsonData, HTTPURLResponse.successResponse()) // Avatars data | ||
} |
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.
I broke this into helpers. Now that we're adding more capabilities, I think this will be easy to read and extend.
"Handle avatar rating change: Failure", | ||
arguments: [HTTPStatus.unauthorized, .forbidden] |
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.
I have been adding titles to tests as I write them.
And parameterized tests in Swift Testing are 🎉
81ddcf3
to
a840f86
Compare
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.
Looks great 🎉
@@ -419,6 +444,16 @@ extension AvatarPickerViewModel { | |||
value: "Oops, something didn't quite work out while trying to share your avatar.", | |||
comment: "This error message shows when the user attempts to share an avatar and fails." | |||
) | |||
static let avatarRatingUpdateSuccess = SDKLocalizedString( | |||
"AvatarPickerViewModel.RatingUpdate.Success", | |||
value: "Avatar rating was changed successfully", |
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.
let's put a .
at the end for consistency, wdyt?
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.
Definitely, thanks for catching.
Closes #546 #548
Description
Adds support for viewing and changing the rating of an avatar in the Quick Editor.
Testing Steps
Open Profile Editor with OAuth flow
...
Rating
menu appears in the menuRating
menu shows the current rating for the image:Rating: PG
Rating
menu has a icon of a half-filled star ⭐Rating
menu to show the sub-menuG (General)
)Try: