-
Notifications
You must be signed in to change notification settings - Fork 894
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add translate toast with settings button. Update onboarding.
- Loading branch information
Showing
10 changed files
with
205 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
ios/brave-ios/Sources/Brave/Frontend/Browser/Translate/TranslateToast.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// 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 BraveUI | ||
import SwiftUI | ||
|
||
struct TranslateToast: View { | ||
|
||
var languageInfo: BraveTranslateLanguageInfo | ||
|
||
var currentLanguageName: String { | ||
if let languageCode = languageInfo.currentLanguage.languageCode?.identifier, | ||
let languageName = Locale.current.localizedString(forLanguageCode: languageCode) | ||
{ | ||
return languageName | ||
} | ||
return "Unknown Language" | ||
} | ||
|
||
var pageLanguageName: String { | ||
if let languageCode = languageInfo.pageLanguage?.languageCode?.identifier, | ||
let languageName = Locale.current.localizedString(forLanguageCode: languageCode) | ||
{ | ||
return languageName | ||
} | ||
return "Unknown Language" | ||
} | ||
|
||
var body: some View { | ||
HStack { | ||
Image(braveSystemName: "leo.product.translate") | ||
.symbolRenderingMode(.monochrome) | ||
.foregroundStyle( | ||
LinearGradient( | ||
braveGradient: .init( | ||
stops: [ | ||
.init(color: UIColor(rgb: 0xFA7250), position: 0.0), | ||
.init(color: UIColor(rgb: 0xFF1893), position: 0.43), | ||
.init(color: UIColor(rgb: 0xA78AFF), position: 1.0), | ||
], | ||
angle: .figmaDegrees(314.42) | ||
) | ||
) | ||
) | ||
.padding(.trailing) | ||
VStack { | ||
Text("Page Translations") | ||
.font(.callout.weight(.semibold)) | ||
.foregroundColor(Color(braveSystemName: .textPrimary)) | ||
|
||
Text( | ||
"\(pageLanguageName) To \(currentLanguageName)" | ||
) | ||
.font(.callout) | ||
.foregroundColor(Color(braveSystemName: .textSecondary)) | ||
} | ||
.padding(.trailing) | ||
|
||
Spacer() | ||
|
||
Button { | ||
|
||
} 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 { | ||
|
||
} label: { | ||
Text("Undo") | ||
.foregroundStyle(Color(braveSystemName: .textInteractive)) | ||
} | ||
} | ||
.padding() | ||
} | ||
} | ||
|
||
extension TranslateToast: PopoverContentComponent { | ||
public var popoverBackgroundColor: UIColor { | ||
.braveBackground | ||
} | ||
} | ||
|
||
#Preview { | ||
TranslateToast(languageInfo: .init()) | ||
} |
133 changes: 0 additions & 133 deletions
133
ios/brave-ios/Sources/Brave/Frontend/Browser/TranslateToast.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
ios/brave-ios/Sources/Onboarding/Assets/Images.xcassets/Translate/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Oops, something went wrong.