This file contains hidden or 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
func showNilError() { | |
let alert = UIAlertController(title: "No Heart Rate Data Found", message: "There was no heart rate data found for the selected dates. If you expected to see data, it may be that ARTRate is not authorised to read you heart rate data. Please go to the settings app (Privacy -> HealthKit) to change this.", preferredStyle: UIAlertControllerStyle.alert) | |
alert.addAction(UIAlertAction(title: "Okay", style: .cancel, handler: nil)) | |
alert.addAction(UIAlertAction(title: "Go to settings", style: .default, handler: { action in | |
if let url = URL(string:UIApplicationOpenSettingsURLString) { | |
if UIApplication.shared.canOpenURL(url) { | |
UIApplication.shared.open(url, options: [:], completionHandler: nil) | |
} | |
} })) | |
self.present(alert, animated: true, completion: nil) |
This file contains hidden or 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
let health = HKHealthStore() | |
let heartRateType:HKQuantityType = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.heartRate)! | |
var shownWarning : Bool = false | |
func getHeartRateData() | |
{ | |
let startDate = Calendar.current.date(byAdding: .day, value: -5, to: Date())! | |
let endDate = Date() | |
let predicate = HKQuery.predicateForSamples(withStart: startDate, end: endDate, options: []) | |
let sortDescriptors = [ |
This file contains hidden or 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
let heartRateType:HKQuantityType = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.heartRate)! | |
HKHealthStore().requestAuthorization(toShare: nil, read: [heartRateType]) {(success, error) in | |
print(success) | |
//Success will always be equal to true unless a genuine error occurs | |
} |
This file contains hidden or 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
extension LABiometryType { | |
var toString : String { | |
switch self { | |
case .none: | |
return "your iPhone pin" | |
case .faceID: | |
return "FaceID" | |
case .touchID: | |
return "TouchID" | |
} |
This file contains hidden or 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
extension LABiometryType { | |
var toString : String { | |
switch self { | |
case .none: | |
return "your iPhone pin" | |
case .faceID: | |
return "FaceID" | |
case .touchID: | |
return "TouchID" | |
} |
This file contains hidden or 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
func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? { | |
guard let ci = customInteractor else { return nil } | |
return ci.transitionInProgress ? customInteractor : nil | |
} |
This file contains hidden or 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
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? { | |
guard let frame = self.selectedFrame else { return nil } | |
guard let song = self.selectedSong else { return nil } | |
switch operation { | |
case .push: | |
self.customInteractor = CustomInteractor(attachTo: toVC) | |
return CustomAnimator(duration: TimeInterval(UINavigationControllerHideShowBarDuration), isPresenting: true, originFrame: frame, image: song.artwork) | |
default: | |
return CustomAnimator(duration: TimeInterval(UINavigationControllerHideShowBarDuration), isPresenting: false, originFrame: frame, image: song.artwork) |
This file contains hidden or 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
@objc private func handleBackGesture(_ gesture : UIScreenEdgePanGestureRecognizer) { | |
let viewTranslation = gesture.translation(in: gesture.view?.superview) | |
var progress = viewTranslation.x / self.navigationController.view.frame.width | |
switch gesture.state { | |
case .began: | |
transitionInProgress = true | |
navigationController.popViewController(animated: true) | |
break | |
case .changed: |
This file contains hidden or 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
let viewTranslation = gesture.translation(in: gesture.view?.superview) | |
var progress = viewTranslation.x / self.navigationController.view.frame.width |
This file contains hidden or 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
private func setupBackGesture(view : UIView) { | |
let swipeBackGesture = UIScreenEdgePanGestureRecognizer(target: self, action: #selector(handleBackGesture(_:))) | |
swipeBackGesture.edges = .left | |
view.addGestureRecognizer(swipeBackGesture) | |
} | |
@objc private func handleBackGesture(_ gesture : UIScreenEdgePanGestureRecognizer) { | |
} |
NewerOlder