-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Site Settings in SwiftUI: Initial #20838
Conversation
@ViewBuilder | ||
func refreshable(action: @Sendable @escaping () async -> Void) -> some View { | ||
if #available(iOS 15, *) { | ||
view.refreshable(action: action) |
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 will remove it once iOS 14 support is dropped.
📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
|
|
||
private extension SiteSettingsView { | ||
enum Strings { | ||
static let title = NSLocalizedString("Settings", comment: "Title for screen that allows configuration of your blog/site settings.") |
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.
Could you please use reverse DNS keys for localized strings? We lack a way to enforce them at the moment, but the rationale is that they help us disambiguate duplicated strings used in different contexts. More at #19028
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.
Yes, that is a good point. I was reluctant to do that in the same PR because these are the existing keys from settings, and changing them will require updating all the localizable strings files (presumable we want to keep the localizations?).
I'm not sure how to approach it. I'm not removing the SiteSettingsViewController
just yet, and I'd rather avoid updating it to use the new keys. You also have to be careful in case other screens use the same keys since they are not namespaced.
I think it may be worth updating the keys at the end if I have time by the end of the week. I'm trying to reduce the scope because it's already a big task.
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.
these are the existing keys from settings, and changing them will require updating all the localizable strings files (presumable we want to keep the localizations?).
So I'm guessing these are duplicated here for usage convenience in SwiftUI? E.g. this is the "original" title localized string:
WordPress-iOS/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController.m
Line 124 in e4db21b
self.navigationItem.title = NSLocalizedString(@"Settings", @"Title for screen that allows configuration of your blog/site settings."); |
For what is worth, localizations are cheap to change, and it wouldn't be a problem, IMHO, if this added more strings to localize.
For context, we generate new .strings
via custom genstrings
wrappers during code freeze. These are sent to GlotPress for translations, and every time we build a binary for deployment we download up-to-date strings.
You also have to be careful in case other screens use the same keys since they are not namespaced.
Exactly. Updating to use a reverse-DNS key will create a unique* localized string, e.g.:
static let title = NSLocalizedString("Settings", comment: "Title for screen that allows configuration of your blog/site settings.") | |
static let title = NSLocalizedString("sitesettings.title", value: "Settings", comment: "Title for screen that allows configuration of your blog/site settings.") |
Whereas currently the "Settings" key+value is shared by four instances:
WordPress-iOS/WordPress/Resources/en.lproj/Localizable.strings
Lines 7725 to 7730 in e4db21b
/* Link to plugin's Settings | |
Section title | |
The menu item to select during a guided tour. | |
Title for screen that allows configuration of your blog/site settings. | |
Title for the Jetpack Security Settings Screen */ | |
"Settings" = "Settings"; |
*
- genstrings
is capable of detecting duplicated key usages, but doesn't fail when that happens. We have it in the roadmap to at some point address that.
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.
There aren't going to be too many new strings, so I'll add new ones, as you suggest. Updated: https://github.com/wordpress-mobile/WordPress-aiOS/pull/20838/commits/b16704dbc6fc41516b9bc71a2b39c3ef6983ad41.
WordPress/Classes/ViewRelated/Blog/Settings/SiteSettingsView.swift
Outdated
Show resolved
Hide resolved
4fff31c
to
8044c30
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.
Works as described!
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-06-14.at.16.01.13.mp4
|
||
let onDismissableError = PassthroughSubject<String, Never>() | ||
|
||
init(blog: Blog) { |
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.
Wdyt of injecting the service?
init(blog: Blog) { | |
init(blog: Blog, service: BlogService = BlogService(coreDataStack: ContextManager.shared)) { |
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.
Good point – gotta keep is testable. Updated.
I'm prioritizing updating the UI. The original implementation had no tests, but I'll try to add some (and make it more testable).
HACK week: update Site Settings to use SwiftUI
To test:
Regression Notes
PR submission checklist:
RELEASE-NOTES.txt
if necessary.UI Changes testing checklist: