Skip to content

Commit

Permalink
WIP: small widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Bunn committed Dec 10, 2024
1 parent 9f401dd commit ba2f42e
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 23 deletions.
2 changes: 2 additions & 0 deletions Core/AppDeepLinkSchemes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public enum AppDeepLinkSchemes: String, CaseIterable {
case openVPN = "ddgOpenVPN"
case openPasswords = "ddgOpenPasswords"

case openAIChat = "ddgOpenAIChat"

public var url: URL {
URL(string: rawValue + "://")!
}
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/AppDelegate+AppDeepLinks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ extension AppDelegate {
mainViewController.launchAutofillLogins(openSearch: true, source: source)
}

case .openAIChat:
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) {
mainViewController.openAIChat()
}
default:
guard app.applicationState == .active,
let currentTab = mainViewController.currentTab else {
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ class MainViewController: UIViewController {
Pixel.fire(pixel: pixel, withAdditionalParameters: pixelParameters, includedParameters: [.atb])
}

private func openAIChat() {
func openAIChat() {
let logoImage = UIImage(named: "Logo")
let title = UserText.aiChatTitle

Expand Down
12 changes: 12 additions & 0 deletions Widgets/Assets.xcassets/chat-icon.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "chat-icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
12 changes: 12 additions & 0 deletions Widgets/Assets.xcassets/search-icon.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "search-icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
2 changes: 2 additions & 0 deletions Widgets/DeepLinks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ struct DeepLinks {

static let openVPN = AppDeepLinkSchemes.openVPN.url
static let openPasswords = AppDeepLinkSchemes.openPasswords.url
static let openAIChat = AppDeepLinkSchemes.openAIChat.url

}
54 changes: 32 additions & 22 deletions Widgets/WidgetViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,34 +222,44 @@ struct FavoritesWidgetView: View {

struct SearchWidgetView: View {
var entry: Provider.Entry
let imageSize: CGFloat = 52

var body: some View {
ZStack {
VStack(alignment: .center, spacing: 15) {

Image(.logo)
.resizable()
.useFullColorRendering()
.frame(width: 46, height: 46, alignment: .center)
.isHidden(false)
.accessibilityHidden(true)

ZStack(alignment: Alignment(horizontal: .trailing, vertical: .center)) {

RoundedRectangle(cornerSize: CGSize(width: 8, height: 8))
.fill(Color(designSystemColor: .container))
.frame(width: 126, height: 46)

Image(.findSearch20)
VStack {
HStack {
Image(.logo)
.resizable()
.useFullColorRendering()
.frame(width: 20, height: 20)
.padding(.leading)
.padding(.trailing, 13)
.isHidden(false)
.frame(width: imageSize,
height: imageSize,
alignment: .center)
.accessibilityHidden(true)
.foregroundColor(Color(designSystemColor: .textPrimary).opacity(0.5))
Spacer()
}
Spacer()
HStack {
Link(destination: DeepLinks.newSearch) {
Image(.searchIcon)
.resizable()
.useFullColorRendering()
.frame(width: imageSize,
height: imageSize,
alignment: .center)
.accessibilityHidden(true)
}

Spacer()
Link(destination: DeepLinks.openAIChat) {
Image(.chatIcon)
.resizable()
.useFullColorRendering()
.frame(width: imageSize,
height: imageSize,
alignment: .center)
.accessibilityHidden(true)
}
}
.accessibilityHidden(true)
}.accessibilityLabel(Text(UserText.searchDuckDuckGo))
}
.widgetContainerBackground(color: Color(designSystemColor: .backgroundSheets))
Expand Down

0 comments on commit ba2f42e

Please sign in to comment.