-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathConstants.swift
113 lines (101 loc) · 3.99 KB
/
Constants.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
// Constants.swift
// OCKSample
//
// Created by Corey Baker on 11/27/20.
// Copyright © 2020 Network Reconnaissance Lab. All rights reserved.
//
import Foundation
import CareKit
import CareKitStore
import ParseSwift
/**
Set to **true** to sync with ParseServer, *false** to sync with iOS/watchOS.
*/
let isSyncingWithCloud = true
/**
Set to **true** to use WCSession to notify watchOS about updates, **false** to not notify.
A change in watchOS 9 removes the ability to use Websockets on real Apple Watches,
preventing auto updates from the Parse Server. See the link for
details: https://developer.apple.com/forums/thread/715024
*/
let isSendingPushUpdatesToWatch = true
enum AppError: Error {
case couldntCast
case couldntBeUnwrapped
case valueNotFoundInUserInfo
case remoteClockIDNotAvailable
case emptyTaskEvents
case invalidIndexPath(_ indexPath: IndexPath)
case noOutcomeValueForEvent(_ event: OCKAnyEvent, index: Int)
case cannotMakeOutcomeFor(_ event: OCKAnyEvent)
case parseError(_ error: ParseError)
case error(_ error: Error)
case errorString(_ string: String)
}
extension AppError: LocalizedError {
public var errorDescription: String? {
switch self {
case .couldntCast:
return NSLocalizedString("OCKSampleError: Could not cast to required type.",
comment: "Casting error")
case .couldntBeUnwrapped:
return NSLocalizedString("OCKSampleError: Could not unwrap a required type.",
comment: "Unwrapping error")
case .valueNotFoundInUserInfo:
return NSLocalizedString("OCKSampleError: Could not find the required value in userInfo.",
comment: "Value not found error")
case .remoteClockIDNotAvailable:
return NSLocalizedString("OCKSampleError: Could not get remote clock ID.",
comment: "Value not available error")
case .emptyTaskEvents: return "Task events is empty"
case let .noOutcomeValueForEvent(event, index): return "Event has no outcome value at index \(index): \(event)"
case .invalidIndexPath(let indexPath): return "Invalid index path \(indexPath)"
case .cannotMakeOutcomeFor(let event): return "Cannot make outcome for event: \(event)"
case .parseError(let error): return "\(error)"
case .error(let error): return "\(error)"
case .errorString(let string): return string
}
}
}
enum Constants {
static let parseConfigFileName = "ParseCareKit"
static let iOSParseCareStoreName = "iOSParseStore"
static let iOSLocalCareStoreName = "iOSLocalStore"
static let watchOSParseCareStoreName = "watchOSParseStore"
static let watchOSLocalCareStoreName = "watchOSLocalStore"
static let noCareStoreName = "none"
static let parseUserSessionTokenKey = "requestParseSessionToken"
static let requestSync = "requestSync"
static let progressUpdate = "progressUpdate"
static let finishedAskingForPermission = "finishedAskingForPermission"
static let shouldRefreshView = "shouldRefreshView"
static let userLoggedIn = "userLoggedIn"
static let userTypeKey = "userType"
static let appName = "ParseCareKitSample"
}
enum MainViewPath {
case tabs
}
enum TaskID {
static let doxylamine = "doxylamine"
static let nausea = "nausea"
static let stretch = "stretch"
static let kegels = "kegels"
static let steps = "steps"
static var ordered: [String] {
[Self.steps, Self.doxylamine, Self.kegels, Self.stretch, Self.nausea]
}
}
enum UserType: String, Codable {
case patient = "Patient"
case none = "None"
// Return all types as an array, make sure to maintain order above
func allTypesAsArray() -> [String] {
return [UserType.patient.rawValue,
UserType.none.rawValue]
}
}
enum InstallationChannel: String {
case global
}