diff --git a/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+TabManagerDelegate.swift b/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+TabManagerDelegate.swift index 4c0737d0f8dc..6c0e72710089 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+TabManagerDelegate.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+TabManagerDelegate.swift @@ -156,12 +156,11 @@ extension BrowserViewController: TabManagerDelegate { topToolbar.updateReaderModeState(.unavailable) } - if let translateScriptHandler = selected?.getContentScript( + if ((selected?.getContentScript( name: BraveTranslateScriptHandler.scriptName - ) - as? BraveTranslateScriptHandler + ) as? BraveTranslateScriptHandler) != nil) { - topToolbar.updateTranslateButtonState(selected?.translationState ?? .unavailable) + updateTranslateURLBar(tab: selected, state: selected?.translationState ?? .unavailable) updatePlaylistURLBar( tab: selected, state: selected?.playlistItemState ?? .none, diff --git a/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ToolbarDelegate.swift b/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ToolbarDelegate.swift index 6e5b764b7aea..afb106a3c93d 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ToolbarDelegate.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ToolbarDelegate.swift @@ -270,10 +270,7 @@ extension BrowserViewController: TopToolbarDelegate { if tab.translationState == .active { scriptHandler.revertTranslation() } else if tab.translationState != .active { - showTranslateOnboarding(tab: tab) { - [weak scriptHandler] translateEnabled in - scriptHandler?.startTranslation() - } + scriptHandler.startTranslation() } } } diff --git a/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Translate.swift b/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Translate.swift index a1b2d247b970..62c810d4b4d4 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Translate.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Translate.swift @@ -20,6 +20,16 @@ extension BrowserViewController: BraveTranslateScriptHandlerDelegate { // translateActivity(info: state == .existingItem ? item : nil) topToolbar.updateTranslateButtonState(state) + + showTranslateOnboarding(tab: tab) { [weak tab] translateEnabled in + if let scriptHandler = tab?.getContentScript( + name: BraveTranslateScriptHandler.scriptName + ) + as? BraveTranslateScriptHandler + { + scriptHandler.startTranslation() + } + } } } @@ -31,7 +41,6 @@ extension BrowserViewController: BraveTranslateScriptHandlerDelegate { selectedTab === tab, selectedTab.translationState == .available else { - completion(Preferences.Translate.translateEnabled.value) return } @@ -97,22 +106,12 @@ extension BrowserViewController: BraveTranslateScriptHandlerDelegate { } shouldShowTranslationOnboardingThisSession = false - } else if Preferences.Translate.translateEnabled.value { - completion(true) } } func presentToast(_ languageInfo: BraveTranslateLanguageInfo) { let popover = PopoverController( - content: TranslateToast(languageInfo: languageInfo, presentSettings: { [weak self] in - guard let self = self else { return } - - let popup = PopupViewController(rootView: TranslateSettingsView(), isDismissable: true) - self.present(popup, animated: true) - }, revertTranslation: { [weak self] in - guard let self = self else { return } - print("Dismissing") - }), + content: TranslateToast(languageInfo: languageInfo), autoLayoutConfiguration: .phoneWidth ) diff --git a/ios/brave-ios/Sources/Brave/Frontend/Browser/Translate/TranslateSettingsView.swift b/ios/brave-ios/Sources/Brave/Frontend/Browser/Translate/TranslateSettingsView.swift deleted file mode 100644 index 2798dd9af9cc..000000000000 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/Translate/TranslateSettingsView.swift +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2024 The Brave Authors. All rights reserved. -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at https://mozilla.org/MPL/2.0/. - -import SwiftUI - -struct TranslateSettingsView: View { - - var body: some View { - NavigationStack { - List { - Section { - NavigationLink { - - } label: { - LabeledContent("From", value: "Selected Language") - } - - NavigationLink { - - } label: { - LabeledContent("To", value: "Selected Language") - } - } footer: { - VStack { - Button { - - } label: { - Text("Translate") - .font(.body.weight(.semibold)) - .padding() - .frame(maxWidth: .infinity) - .foregroundStyle(Color(braveSystemName: .schemesOnPrimary)) - .background( - ContainerRelativeShape() - .fill(Color(braveSystemName: .buttonBackground)) - ) - .containerShape(RoundedRectangle(cornerRadius: 8.0, style: .continuous)) - } - .buttonStyle(.plain) - - Button { - - } label: { - Text("Show Original") - .font(.body.weight(.semibold)) - .padding() - .frame(maxWidth: .infinity) - .foregroundStyle(Color(braveSystemName: .textSecondary)) - .background( - ContainerRelativeShape() - .fill(Color(.clear)) - ) - .containerShape(RoundedRectangle(cornerRadius: 8.0, style: .continuous)) - } - .buttonStyle(.plain) - } - .listRowInsets(.init()) - .padding(.top) - } - .navigationBarTitle("Translate") - .navigationBarTitleDisplayMode(.inline) - } - } - } -} - -#Preview { - TranslateSettingsView() -} diff --git a/ios/brave-ios/Sources/Brave/Frontend/Browser/Translate/TranslateToast.swift b/ios/brave-ios/Sources/Brave/Frontend/Browser/Translate/TranslateToast.swift index 386ad249e2ab..74cbf3681a07 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/Translate/TranslateToast.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/Translate/TranslateToast.swift @@ -11,8 +11,6 @@ struct TranslateToast: View { private var dismiss var languageInfo: BraveTranslateLanguageInfo - var presentSettings: (() -> Void)? - var revertTranslation: (() -> Void)? var currentLanguageName: String { if let languageCode = languageInfo.currentLanguage.languageCode?.identifier, @@ -60,30 +58,6 @@ struct TranslateToast: View { .font(.callout) .foregroundColor(Color(braveSystemName: .textSecondary)) } - .padding(.trailing) - - Spacer() - - Button { - dismiss() - presentSettings?() - } label: { - Image(braveSystemName: "leo.settings") - .foregroundStyle(Color(braveSystemName: .iconDefault)) - } - - Color(braveSystemName: .dividerSubtle) - .frame(width: 1.0) - .padding([.top, .bottom], 8.0) - .padding([.leading, .trailing]) - - Button { - dismiss() - revertTranslation?() - } label: { - Text("Undo") - .foregroundStyle(Color(braveSystemName: .textInteractive)) - } } .padding() }