Skip to content

Commit

Permalink
Send selected text from any apps #40
Browse files Browse the repository at this point in the history
  • Loading branch information
filimo committed Oct 22, 2019
1 parent 5964dc1 commit 7a5fd65
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ReaderTranslator/Components/ServiceProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ class ServiceProvider: NSObject {
return
}

store.translateAction = .translator(text: text)
self.store.translateAction = .translator(text: text)
openText(text: text)
}

private func openText(text: String) {
let defaultUrl = "https://translate.google.com"
guard var urlComponent = URLComponents(string: defaultUrl) else { return }
urlComponent.queryItems = [
.init(name: "text", value: text)
]

if let url = urlComponent.url { Safari.openSafari(url) }
}
}

0 comments on commit 7a5fd65

Please sign in to comment.