From 21dc2b703d26bb1148652f7db1871c0a26baff8a Mon Sep 17 00:00:00 2001
From: Abhishek Banthia <8280282+n0shake@users.noreply.github.com>
Date: Sat, 20 May 2023 16:38:59 -0400
Subject: [PATCH] Add permissions view for location.
---
Clocker/Onboarding/Onboarding.storyboard | 95 ++++++++++++++-----
.../OnboardingPermissionsViewController.swift | 40 +++++---
2 files changed, 97 insertions(+), 38 deletions(-)
diff --git a/Clocker/Onboarding/Onboarding.storyboard b/Clocker/Onboarding/Onboarding.storyboard
index b81f1c0..659ce34 100644
--- a/Clocker/Onboarding/Onboarding.storyboard
+++ b/Clocker/Onboarding/Onboarding.storyboard
@@ -167,19 +167,11 @@ DQ
-
-
-
-
-
-
-
-
-
+
-
+
@@ -187,7 +179,7 @@ DQ
-
+
@@ -205,7 +197,7 @@ DQ
-
+
@@ -216,17 +208,17 @@ DQ
-
+
-
+
-
+
@@ -234,7 +226,7 @@ DQ
-
+
@@ -242,7 +234,7 @@ DQ
-
+
@@ -250,7 +242,7 @@ DQ
-
+
@@ -274,7 +266,7 @@ DQ
-
+
@@ -305,23 +297,70 @@ DQ
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
-
+
+
-
@@ -332,8 +371,12 @@ DQ
+
+
+
+
+
-
diff --git a/Clocker/Onboarding/OnboardingPermissionsViewController.swift b/Clocker/Onboarding/OnboardingPermissionsViewController.swift
index f321f04..03d53c2 100644
--- a/Clocker/Onboarding/OnboardingPermissionsViewController.swift
+++ b/Clocker/Onboarding/OnboardingPermissionsViewController.swift
@@ -6,6 +6,7 @@ import CoreLoggerKit
class OnboardingPermissionsViewController: NSViewController {
@IBOutlet var reminderGrantButton: NSButton!
@IBOutlet var calendarGrantButton: NSButton!
+ @IBOutlet var locationGrantButton: NSButton!
@IBOutlet var reminderView: NSView!
@IBOutlet var calendarView: NSView!
@@ -31,7 +32,7 @@ class OnboardingPermissionsViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
- [calendarView, reminderView].forEach { $0?.applyShadow() }
+ [calendarView, reminderView, locationView].forEach { $0?.applyShadow() }
setup()
}
@@ -52,23 +53,25 @@ class OnboardingPermissionsViewController: NSViewController {
calendarHeaderLabel.stringValue = NSLocalizedString("Calendar Access Title",
comment: "Title for Calendar access label")
calendarDetailLabel.stringValue = "Calendar Detail".localized()
-
- privacyLabel.stringValue = CLEmptyString
+
+ locationHeaderLabel.stringValue = "Location Access"
+ locationDetailLabel.stringValue = "Accurately track your local time; especially useful if you travel."
[calendarHeaderLabel, calendarDetailLabel, privacyLabel, reminderDetailLabel, reminderHeaderLabel, onboardingTypeLabel, appLabel].forEach { $0?.textColor = Themer.shared().mainTextColor()
}
}
private func setupButtons() {
-// if LocationController.sharedInstance.locationAccessGranted() {
-// locationButton.title = "Granted"
-// } else if LocationController.sharedInstance.locationAccessDenied() {
-// locationButton.title = "Denied"
-// } else if LocationController.sharedInstance.locationAccessNotDetermined() {
-// locationButton.title = "Grant"
-// } else {
-// locationButton.title = "Unexpected"
-// }
+ let locationController = LocationController.shared()
+ if locationController.locationAccessGranted() {
+ locationGrantButton.title = "Granted"
+ } else if locationController.locationAccessDenied() {
+ locationGrantButton.title = "Denied"
+ } else if locationController.locationAccessNotDetermined() {
+ locationGrantButton.title = "Grant"
+ } else {
+ locationGrantButton.title = "Unexpected"
+ }
if EventCenter.sharedCenter().calendarAccessGranted() {
calendarGrantButton.title = "Granted".localized()
@@ -153,4 +156,17 @@ class OnboardingPermissionsViewController: NSViewController {
reminderGrantButton.title = "Denied".localized()
}
}
+
+ @IBAction func locationAction(_: NSButton) {
+ let locationController = LocationController.shared()
+ if locationController.locationAccessNotDetermined() {
+ locationActivityIndicator.startAnimation(nil)
+ locationController.determineAndRequestLocationAuthorization()
+ } else if locationController.locationAccessDenied() {
+ locationGrantButton.title = "Denied".localized()
+ } else if locationController.locationAccessGranted() {
+ locationGrantButton.title = "Granted".localized()
+ }
+
+ }
}