Merge pull request #2262 from AlphaWallet/#2260

Vibrate after adding bookmark #2260
pull/2268/head
Hwee-Boon Yar 4 years ago committed by GitHub
commit 8551d9992c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 43
      AlphaWallet/Browser/Coordinators/DappBrowserCoordinator.swift

@ -333,11 +333,15 @@ final class DappBrowserCoordinator: NSObject, Coordinator {
}
private func addCurrentPageAsBookmark() {
guard let url = currentUrl?.absoluteString else { return }
guard let title = browserViewController.webView.title else { return }
let bookmark = Bookmark(url: url, title: title)
bookmarksStore.add(bookmarks: [bookmark])
refreshDapps()
if let url = currentUrl?.absoluteString, let title = browserViewController.webView.title {
let bookmark = Bookmark(url: url, title: title)
bookmarksStore.add(bookmarks: [bookmark])
refreshDapps()
UINotificationFeedbackGenerator.show(feedbackType: .success)
} else {
UINotificationFeedbackGenerator.show(feedbackType: .error)
}
}
private func scanQrCode() {
@ -373,6 +377,35 @@ final class DappBrowserCoordinator: NSObject, Coordinator {
}
}
enum NotificationFeedbackType {
case success
case warning
case error
var feedbackType: UINotificationFeedbackGenerator.FeedbackType {
switch self {
case .success:
return .success
case .warning:
return .warning
case .error:
return .error
}
}
}
extension UINotificationFeedbackGenerator {
static func show(feedbackType result: NotificationFeedbackType) {
let feedbackGenerator = UINotificationFeedbackGenerator()
feedbackGenerator.prepare()
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
feedbackGenerator.notificationOccurred(result.feedbackType)
}
}
}
extension DappBrowserCoordinator: BrowserViewControllerDelegate {
func didCall(action: DappAction, callbackID: Int, inBrowserViewController viewController: BrowserViewController) {
guard case .real(let account) = session.account.type else {

Loading…
Cancel
Save