-
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
Merged
Merged
QE: Avatar Rating #589
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
0d83dd4
Update OpenAPI spec
andrewdmontgomery 83f1de6
Add setRating function
andrewdmontgomery 242ccf1
Update OpenAPI spec: Avatar.Rating --> AvatarRating
andrewdmontgomery b948f51
Add Rating functionality
andrewdmontgomery c287476
Revert "Update OpenAPI spec: Avatar.Rating --> AvatarRating"
andrewdmontgomery eade506
Bridge `Avatar.Rating` --> `AvatarRating`
andrewdmontgomery b2dfa18
Change icon for Rating menu item
andrewdmontgomery 32698cc
Refactor into helper functions
andrewdmontgomery 9cd0a37
Handle errors
andrewdmontgomery 338c965
Add unit tests
andrewdmontgomery ed91a63
Fix typo in localized string comment
andrewdmontgomery 8f690dd
Use animation when updating the grid after setting the avatar rating
andrewdmontgomery 4d8222d
Add toast message when avatar rating update succeeds
andrewdmontgomery 18701f3
Fix typo in `rating` query item
andrewdmontgomery 5cd6c41
Add unit tests AvatarPickerViewModel
andrewdmontgomery 2eb1a9b
Remove unused queryItem
andrewdmontgomery a840f86
Refactor data for URLSessionAvatarPickerMock
andrewdmontgomery 89751be
Fix typo in localized string source
andrewdmontgomery 72329da
Update strings in base locale
andrewdmontgomery b535bac
Merge branch 'trunk' into andrewdmontgomery/qe-avatar-rating
andrewdmontgomery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
extension Avatar { | ||
/// 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 { | ||
switch self.rating { | ||
case .g: .g | ||
case .pg: .pg | ||
case .r: .r | ||
case .x: .x | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Since we are laying out the menu manually, the I'm using an enum with an associated value ( |
||
enum AvatarAction: Identifiable { | ||
case share | ||
case delete | ||
case rating(AvatarRating) | ||
case playground | ||
|
||
static var allCases: [AvatarAction] { | ||
var cases: [AvatarAction] = [] | ||
if #available(iOS 18.2, *) { | ||
if EnvironmentValues().supportsImagePlayground { | ||
cases.append(.playground) | ||
} | ||
var id: String { | ||
switch self { | ||
case .share: "share" | ||
case .delete: "delete" | ||
case .rating(let rating): rating.rawValue | ||
case .playground: "playground" | ||
} | ||
cases.append(contentsOf: [.share, .delete]) | ||
return cases | ||
} | ||
|
||
var id: String { rawValue } | ||
|
||
var icon: Image { | ||
switch self { | ||
case .delete: | ||
|
@@ -27,6 +24,8 @@ enum AvatarAction: String, CaseIterable, Identifiable { | |
Image(systemName: "square.and.arrow.up") | ||
case .playground: | ||
Image(systemName: "apple.image.playground") | ||
case .rating: | ||
Image(systemName: "star.leadinghalf.filled") | ||
} | ||
} | ||
|
||
|
@@ -50,14 +49,23 @@ enum AvatarAction: String, CaseIterable, Identifiable { | |
value: "Playground", | ||
comment: "An option to show the image playground" | ||
) | ||
case .rating(let rating): | ||
String( | ||
format: SDKLocalizedString( | ||
"AvatarPicker.AvatarAction.rate", | ||
value: "Rating: %@", | ||
comment: "An option in the avatar menu that shows the current rating, and allows the user to change that rating. The rating is used to indicate the appropriateness of an avatar for different audiences, and follows the US system of Motion Picture ratings: G, PG, R, and X." | ||
), | ||
rating.rawValue | ||
) | ||
} | ||
} | ||
|
||
var role: ButtonRole? { | ||
switch self { | ||
case .delete: | ||
.destructive | ||
case .share, .playground: | ||
case .share, .rating, .playground: | ||
nil | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 usepackage
, to match the access ofAvatar.Rating
.