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 f9e7336bedf9..a1b2d247b970 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 @@ -9,6 +9,7 @@ import Foundation import Onboarding import Preferences import UIKit +import SwiftUI extension BrowserViewController: BraveTranslateScriptHandlerDelegate { func updateTranslateURLBar(tab: Tab?, state: TranslateURLBarButton.TranslateState) { @@ -103,7 +104,15 @@ extension BrowserViewController: BraveTranslateScriptHandlerDelegate { func presentToast(_ languageInfo: BraveTranslateLanguageInfo) { let popover = PopoverController( - content: TranslateToast(languageInfo: languageInfo), + 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") + }), 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 new file mode 100644 index 000000000000..2798dd9af9cc --- /dev/null +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/Translate/TranslateSettingsView.swift @@ -0,0 +1,71 @@ +// 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 ec914230c22b..386ad249e2ab 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/Translate/TranslateToast.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/Translate/TranslateToast.swift @@ -7,8 +7,12 @@ import BraveUI import SwiftUI struct TranslateToast: View { + @Environment(\.dismiss) + private var dismiss var languageInfo: BraveTranslateLanguageInfo + var presentSettings: (() -> Void)? + var revertTranslation: (() -> Void)? var currentLanguageName: String { if let languageCode = languageInfo.currentLanguage.languageCode?.identifier, @@ -61,7 +65,8 @@ struct TranslateToast: View { Spacer() Button { - + dismiss() + presentSettings?() } label: { Image(braveSystemName: "leo.settings") .foregroundStyle(Color(braveSystemName: .iconDefault)) @@ -73,7 +78,8 @@ struct TranslateToast: View { .padding([.leading, .trailing]) Button { - + dismiss() + revertTranslation?() } label: { Text("Undo") .foregroundStyle(Color(braveSystemName: .textInteractive))