Bugfix FXIOS-15212 #32729 [Translations Phase 2] "Automatically translate pages when available?" prompt is not displayed on supported webpages#32784
Conversation
|
This pull request has conflicts when rebasing. Could you fix it @razvanlitianu? 🙏 |
f5b8764 to
54b7bee
Compare
✍️ Strings UpdatedDetected changes in 💪 Quality guardian2 tests files modified. You're a champion of test coverage! 🚀 🧩 Neat PieceThis PR changes 524 lines. It's a substantial update, 💬 Description craftsmanGreat PR description! Reviewers salute you 🫡 🦊 BrowserViewController CheckWe’re tracking the size of
Client.app: Coverage: 39.37
Shared: Coverage: 61.51
Generated by 🚫 Danger Swift against 2046a74 |
|
|
||
| private func handleAutoTranslatePrompt(state: BrowserViewControllerState) { | ||
| if state.autoTranslatePromptState.showPrompt { | ||
| guard autoTranslatePrompt == nil else { return } |
There was a problem hiding this comment.
nit: we could move this guard up
There was a problem hiding this comment.
Moved the guard into showAutoTranslatePrompt() directly.
|
|
||
| if isBottomSearchBar { | ||
| overKeyboardContainer.addArrangedViewToTop(prompt, animated: false, completion: { | ||
| self.view.layoutIfNeeded() |
There was a problem hiding this comment.
do we need to layout the entire view here ? shouldn't the stack view handles it already ?
There was a problem hiding this comment.
Removed, the stack view handles this.
| }) | ||
| } else { | ||
| bottomContainer.addArrangedViewToTop(prompt, animated: false, completion: { | ||
| self.view.layoutIfNeeded() |
| switch notification.name { | ||
| case UIContentSizeCategory.didChangeNotification: | ||
| ensureMainThread { | ||
| self.messageLabel.font = FXFontStyles.Regular.body.scaledFont() |
There was a problem hiding this comment.
instead of having this method here setting up the font when size category changes, we could just specify in the setup of the labels the property adjustFontForContentSizeCategory to true
There was a problem hiding this comment.
Both labels already had this set at init, so removed the notification observer entirely.
|
|
||
| public struct AutoTranslatePrompt { | ||
| public static let Message = MZLocalizedString( | ||
| key: "", // Translations.AutoTranslatePrompt.Message.v151 |
There was a problem hiding this comment.
why the keys are empty, you don't want to export already the translations ?
There was a problem hiding this comment.
Filled in the keys now. I was planning a later PR to enable all but let's do it here also.
|
This pull request has conflicts when rebasing. Could you fix it @razvanlitianu? 🙏 |
FilippoZazzeroni
left a comment
There was a problem hiding this comment.
Hi @razvanlitianu just added another couple of comments worth checking before merging the rest looks good to me. i'd wait also for @lmarceau 's input before merging
| guard autoTranslatePrompt == nil else { return } | ||
| showAutoTranslatePrompt() | ||
| } else { | ||
| guard autoTranslatePrompt != nil else { return } |
There was a problem hiding this comment.
nit: at this point we can remove this since it is already handled in removeAutoTranslatePrompt
There was a problem hiding this comment.
I agree, that is redundant.
There was a problem hiding this comment.
do you think we need to update the constraints here ? same in removeAutoTranslatePrompt. theoretically the views should auto resize according to the subviews. Could you check this before merging ?
There was a problem hiding this comment.
The updateViewConstraints() calls match the microsurvey prompt pattern exactly (lines 2120 and 2144 in BVC). I took the microsurvey as the established reference for this kind of bottom-bar prompt, and kept the same pattern here.
There was a problem hiding this comment.
Could you try removing it to see if does something cause it seems redundant to me, and also it is quite expansive to update all the constraints to just remove a view
There was a problem hiding this comment.
Tested it, the stack view handles the layout correctly without the explicit constraint update, so removed both calls.
|
Thanks for the input, @FilippoZazzeroni! I've addressed all the comments and will now wait for @lmarceau's feedback. |
|
@mergify rebase |
❌ Base branch update has failedDetailsrebase conflict between base and head |
|
Adding |
- Add `translationAutoTranslate` pref key - Add `toggleAutoTranslate` action type and `isAutoTranslateEnabled` middleware payload - Add `isAutoTranslateEnabled` to state and reducer - Add `autoTranslate` section/item to DiffableDataSource - Add auto-translate toggle cell in TranslationPickerSettingsViewController - Add strings: AutoTranslate.Title, AutoTranslate.Footer
- Move auto-translate section below preferred languages - Add initialize action to read isTranslationsEnabled and isAutoTranslateEnabled synchronously before async fetch, preventing toggles from briefly showing incorrect state on load
…ranslation Shows a one-time persistent prompt above the address bar after the user's first manual translation (picker flag only), asking if they want to enable auto-translate. Tapping Enable writes the pref and dismisses; tapping X dismisses without enabling. Prompt is never shown again once seen, and is suppressed if auto-translate is already on. Also fixes a side effect where tapping the active translate icon to restore the original page would immediately re-translate due to auto-translate being enabled — the restore reload is now skipped for that one cycle.
- Add accessibilityIdentifier to messageLabel and explicit accessibilityLabel/identifier to enableButton - Remove Notifiable conformance; adjustsFontForContentSizeCategory already handles Dynamic Type - Move guard into showAutoTranslatePrompt(); remove layoutIfNeeded from completion closures - Move @mainactor to class level in AutoTranslatePromptStateTests - Add three tests for maybeShowAutoTranslatePrompt in TranslationsMiddlewareTests - Fill in l10n string keys for AutoTranslatePrompt.Message and EnableButton
f22fb65 to
2046a74
Compare
|
🚀 PR merged to |
📜 Tickets
Jira ticket
Github issue
💡 Description
After a user manually translates a page for the first time, a prompt appears at the bottom of the browser offering to enable auto-translate for future pages.
🎥 Demos
Demo
📝 Checklist