Browse plugin details from WordPress.org plugin directory#24072
Browse plugin details from WordPress.org plugin directory#24072crazytonyli merged 5 commits intotrunkfrom
Conversation
Generated by 🚫 Danger |
|
| App Name | WordPress Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr24072-3fc30bf | |
| Version | 25.7.1 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 3fc30bf | |
| App Center Build | WPiOS - One-Offs #11499 |
|
| App Name | Jetpack Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr24072-3fc30bf | |
| Version | 25.7.1 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 3fc30bf | |
| App Center Build | jetpack-installable-builds #10531 |
Not sure why it didn't show on the first run. I see the agent later disconnected, so maybe it was about to be terminated or something like that? 🤔 - `WordPress/Classes/Plugins/Views/PluginDetailsView.swift:367:24`: Arguments can be omitted when matching enums with associated values if they are not used (empty_enum_arguments) |
| let button: AnyView | ||
| switch self { | ||
| case let .install(_, action): | ||
| button = AnyView(Button("Install", action: action) |
| } | ||
|
|
||
| var actionButton: ActionButton { | ||
| if let plugin = viewModel.installed { |
There was a problem hiding this comment.
Create the buttons here directly? What's the point of ActionButton?
There was a problem hiding this comment.
I thought it'd be more apparent to see what buttons can be displayed on the screen (the enum cases). Using if-else statements may not be as clear.
| self.pluginInfo = .init(name: plugin.name, author: plugin.author, shortDescription: plugin.shortDescription) | ||
| self.service = service | ||
| _viewModel = StateObject(wrappedValue: .init(slug: slug, service: service)) | ||
| _viewModel = StateObject(wrappedValue: .init(slug: slug, plugin: nil, installed: plugin, service: service)) |
There was a problem hiding this comment.
Need to be careful with StateObject(wrappedValue:). If the view identity doesn't change, ti won't be re-created when you show a new slug.
There was a problem hiding this comment.
Sorry, I didn't get what you meant. Can you talk more about it? What is "view identity"? By "show a new slug", do you mean showing another plugin by refreshing the current PluginDetailsView instead of presenting a new one?
There was a problem hiding this comment.
Can you talk more about it?
Apple explains it here. I tend to avoid using @StateObject this way because of that limitation.
What is "view identity"?
I'm not sure it's completely up to date, but there was a great video about in in WWDC21: Demystify SwiftUI. I highly recommend WWDC videos on SwiftUI in general as they are often the only source of official information. I don't think there is a quick way to fully explain it.
In short, if you have a view like SomeView that gets re-initialized every time when it's container view body is called, how does SwiftUI know that it's the "same" view that needs to keep its @State? It's based on the view identity, which is based on type of the view and its place in a view hierarchy (also based on types).
struct SomeView {
@State var counter = 0
}There was a problem hiding this comment.
Gotcha. I'll address this concern in a separate PR.


The plugin details view is now used to display all plugin details, regardless of whether it's installed.
I haven't implemented all actions (like installing new plugins) yet. I'll create follow-up PRs for that.
Regression Notes
Potential unintended areas of impact
What I did to test those areas of impact (or what existing automated tests I relied on)
What automated tests I added (or what prevented me from doing so)
PR submission checklist:
RELEASE-NOTES.txtif necessary.Testing checklist: