Skip to content

Commit

Permalink
Add SpeechKit & icon in example app
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvorobei committed Nov 12, 2018
1 parent 75ee374 commit 4626687
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 1 deletion.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion SPPermission.podspec
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "SPPermission"
s.version = "2.0.1"
s.version = "2.0.2"
s.summary = "Simpple request permissions with dialog alert"
s.swift_version = '4.2'

Expand Down
Binary file modified sparrow/.DS_Store
Binary file not shown.
Binary file modified sparrow/permission/.DS_Store
Binary file not shown.
23 changes: 23 additions & 0 deletions sparrow/permission/SPPermission.swift
Expand Up @@ -26,6 +26,7 @@ import Photos
import MapKit
import EventKit
import Contacts
import Speech

public struct SPPermission {

Expand Down Expand Up @@ -69,6 +70,8 @@ extension SPPermission {
return SPContactsPermission()
case .reminders:
return SPRemindersPermission()
case .speech:
return SPSpeechPermission()
}
}
}
Expand Down Expand Up @@ -269,4 +272,24 @@ extension SPPermission {
})
}
}

fileprivate struct SPSpeechPermission: SPPermissionInterface {

func isAuthorized() -> Bool {
guard #available(iOS 10.0, *) else { return false }
return SFSpeechRecognizer.authorizationStatus() == .authorized
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {
guard #available(iOS 10.0, *) else {
fatalError("ios 10 or higher required")
}

SFSpeechRecognizer.requestAuthorization { status in
DispatchQueue.main.async {
complectionHandler()
}
}
}
}
}
2 changes: 2 additions & 0 deletions sparrow/permission/dialog/SPPermissionDialogController.swift
Expand Up @@ -222,6 +222,8 @@ extension SPPermissionDialogController {
return "Access for save photos in your gallery"
case .reminders:
return "Application can create new task"
case .speech:
return "Allow check you voice"
}
}
}
2 changes: 2 additions & 0 deletions sparrow/permission/dialog/SPPermissionDialogView.swift
Expand Up @@ -174,6 +174,8 @@ class SPPermissionDialogLineView: UIView {
self.iconView.type = .photoLibrary
case .reminders:
self.iconView.type = .calendar
case .speech:
self.iconView.type = .micro
}
self.commonInit()
}
Expand Down
3 changes: 3 additions & 0 deletions sparrow/types/SPTypes.swift
Expand Up @@ -71,6 +71,7 @@ public enum SPSeparatorInsetStyle {
case calendar = 4
case contacts = 5
case reminders = 6
case speech = 7

var name: String {
switch self {
Expand All @@ -88,6 +89,8 @@ public enum SPSeparatorInsetStyle {
return "Contacts"
case .reminders:
return "Reminders"
case .speech:
return "Speech"
}
}
}
Expand Down

0 comments on commit 4626687

Please sign in to comment.