1 |
efrain |
1 |
//
|
|
|
2 |
// AppData.swift
|
|
|
3 |
// twogetskills
|
|
|
4 |
//
|
|
|
5 |
// Created by Efrain Yanez Recanatini on 8/7/22.
|
|
|
6 |
//
|
|
|
7 |
|
|
|
8 |
import Foundation
|
|
|
9 |
|
|
|
10 |
class AppData {
|
12 |
efrain |
11 |
private let standardPreference = UserDefaults.standard
|
1 |
efrain |
12 |
|
12 |
efrain |
13 |
|
|
|
14 |
|
1 |
efrain |
15 |
var deviceUuid : String = ""
|
|
|
16 |
var devicePassword : String = ""
|
|
|
17 |
var deviceAes : String = ""
|
|
|
18 |
|
|
|
19 |
var userUuid : String = ""
|
|
|
20 |
var userEmail : String = ""
|
|
|
21 |
var userFirstname : String = ""
|
|
|
22 |
var userLastname : String = ""
|
|
|
23 |
var userImage : String = ""
|
|
|
24 |
|
|
|
25 |
var topicUuidActive : String = ""
|
|
|
26 |
var capsuleUuidActive : String = ""
|
|
|
27 |
var capsuleUuidOld : String = ""
|
|
|
28 |
var slideUuidActive : String = ""
|
|
|
29 |
var companyUuidActive : String = ""
|
|
|
30 |
|
|
|
31 |
var fcmToken : String = ""
|
|
|
32 |
var lastCheckChanges : String = ""
|
|
|
33 |
var maxDateChanges : String = ""
|
|
|
34 |
var urlExternalDownloaded : String = ""
|
|
|
35 |
|
|
|
36 |
var refreshContentMessage : String = ""
|
|
|
37 |
var refreshContentMessageShowPending : Bool = false
|
|
|
38 |
var refreshContentActionRequired : Bool = false
|
|
|
39 |
var signoutActionRequired : Bool = false
|
|
|
40 |
|
|
|
41 |
|
13 |
efrain |
42 |
/*
|
|
|
43 |
private let appDao = AppDao.sharedInstance
|
1 |
efrain |
44 |
|
13 |
efrain |
45 |
*/
|
1 |
efrain |
46 |
static let sharedInstance: AppData = {
|
|
|
47 |
let instance = AppData()
|
|
|
48 |
|
|
|
49 |
return instance
|
13 |
efrain |
50 |
}()
|
1 |
efrain |
51 |
|
|
|
52 |
init() {
|
|
|
53 |
load()
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
func load() -> Void
|
|
|
57 |
{
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
12 |
efrain |
61 |
|
|
|
62 |
// let appModel = appDao.selectOne()
|
|
|
63 |
|
|
|
64 |
self.deviceUuid = standardPreference.string(forKey: Constants.PREFERENCE_DEVICE_UUID) ?? ""
|
|
|
65 |
self.devicePassword = standardPreference.string(forKey: Constants.PREFERENCE_DEVICE_PASSWORD) ?? ""
|
|
|
66 |
self.deviceAes = standardPreference.string(forKey: Constants.PREFERENCE_DEVICE_AES) ?? ""
|
|
|
67 |
|
|
|
68 |
self.userUuid = standardPreference.string(forKey: Constants.PREFERENCE_USER_UUID) ?? ""
|
|
|
69 |
self.userEmail = standardPreference.string(forKey: Constants.PREFERENCE_USER_EMAIL) ?? ""
|
|
|
70 |
self.userFirstname = standardPreference.string(forKey: Constants.PREFERENCE_USER_FIRSTNAME) ?? ""
|
|
|
71 |
self.userLastname = standardPreference.string(forKey: Constants.PREFERENCE_USER_LASTNAME) ?? ""
|
|
|
72 |
self.userImage = standardPreference.string(forKey: Constants.PREFERENCE_USER_IMAGE) ?? ""
|
1 |
efrain |
73 |
|
12 |
efrain |
74 |
self.topicUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_TOPIC_UUID_ACTIVE) ?? ""
|
|
|
75 |
self.capsuleUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_CAPSULE_UUID_ACTIVE) ?? ""
|
|
|
76 |
self.capsuleUuidOld = standardPreference.string(forKey: Constants.PREFERENCE_CAPSULE_UUID_OLD) ?? ""
|
|
|
77 |
self.slideUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_SLIDE_UUID_ACTIVE) ?? ""
|
|
|
78 |
self.companyUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_COMPANY_UUID_ACTIVE) ?? ""
|
1 |
efrain |
79 |
|
12 |
efrain |
80 |
self.fcmToken = standardPreference.string(forKey: Constants.PREFERENCE_FCM_TOKEN) ?? ""
|
|
|
81 |
self.lastCheckChanges = standardPreference.string(forKey: Constants.PREFERENCE_LAST_CHECK_CHANGES) ?? ""
|
|
|
82 |
self.maxDateChanges = standardPreference.string(forKey: Constants.PREFERENCE_MAX_DATE_CHANGES) ?? ""
|
|
|
83 |
self.urlExternalDownloaded = standardPreference.string(forKey: Constants.PREFERENCE_URL_EXTERNAL_DOWNLOADED) ?? ""
|
1 |
efrain |
84 |
|
12 |
efrain |
85 |
self.refreshContentMessage = standardPreference.string(forKey: Constants.PREFERENCE_REFRESH_CONTENT_MESSAGE) ?? ""
|
|
|
86 |
self.refreshContentMessageShowPending = standardPreference.bool(forKey: Constants.PREFERENCE_REFRESH_CONTENT_MESSAGE_SHOW_PENDING)
|
|
|
87 |
self.refreshContentActionRequired = standardPreference.bool(forKey: Constants.PREFERENCE_REFRESH_CONTENT_ACTION_REQUIRED)
|
1 |
efrain |
88 |
|
12 |
efrain |
89 |
self.signoutActionRequired = standardPreference.bool(forKey: Constants.PREFERENCE_SIGNOUT_ACTION_REQUIRED)
|
1 |
efrain |
90 |
|
|
|
91 |
/*
|
|
|
92 |
print("AppData Load Device UUID : \(self.deviceUuid)")
|
|
|
93 |
print("AppData Load Device AES : \(self.deviceAes)")
|
|
|
94 |
print("AppData Load Device Password : \(self.devicePassword)")
|
|
|
95 |
|
|
|
96 |
print("AppData Load User UUID: \(self.userUuid)")
|
|
|
97 |
print("AppData Load Email : \(self.userEmail)")
|
|
|
98 |
print("AppData Load First Name : \(self.userFirstname)")
|
|
|
99 |
print("AppData Load Last Name : \(self.userLastname)")
|
|
|
100 |
print("AppData Load Image : \(self.userImage)")
|
|
|
101 |
|
|
|
102 |
print("AppData Load Topic UUID Active : \(self.topicUuidActive)")
|
|
|
103 |
print("AppData Load Capsule UUID Active : \(self.capsuleUuidActive)")
|
|
|
104 |
print("AppData Load Slide UUID Active : \(self.slideUuidActive)")
|
|
|
105 |
print("AppData Load Capsule UUID OLD : \(self.capsuleUuidOld)")
|
|
|
106 |
print("AppData Load Company UUID Active: \(self.companyUuidActive)")
|
|
|
107 |
|
|
|
108 |
print("AppData Load FCM Token : \(self.fcmToken)")
|
|
|
109 |
print("AppData Load LastCheckChanges : \(self.lastCheckChanges)")
|
|
|
110 |
print("AppData Load MaxDateChanges : \(self.maxDateChanges)")
|
|
|
111 |
print("AppData Load UrlExternalDownloaded : \(self.urlExternalDownloaded)")
|
|
|
112 |
|
|
|
113 |
print("AppData Save RefreshContentMessage : \(self.refreshContentMessage)")
|
|
|
114 |
print("AppData Save RrefreshContentMessageShowPending : \(self.refreshContentMessageShowPending)")
|
|
|
115 |
print("AppData Save RefreshContentActionRequired : \(self.refreshContentActionRequired)")
|
|
|
116 |
*/
|
|
|
117 |
|
|
|
118 |
print("AppData Save SignoutActionRequired : \(self.signoutActionRequired)")
|
|
|
119 |
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
func save() -> Void
|
|
|
123 |
{
|
|
|
124 |
/*
|
|
|
125 |
print("AppData Save Device UUID : \(self.deviceUuid)")
|
|
|
126 |
print("AppData Save Device AES : \(self.deviceAes)")
|
|
|
127 |
print("AppData Save Device Password : \(self.devicePassword)")
|
|
|
128 |
|
|
|
129 |
print("AppData Save User UUID: \(self.userUuid)")
|
|
|
130 |
print("AppData Save Email : \(self.userEmail)")
|
|
|
131 |
print("AppData Save First Name : \(self.userFirstname)")
|
|
|
132 |
print("AppData Save Last Name : \(self.userLastname)")
|
|
|
133 |
print("AppData Save Image : \(self.userImage)")
|
|
|
134 |
|
|
|
135 |
print("AppData Save Topic UUID Active : \(self.topicUuidActive)")
|
|
|
136 |
print("AppData Save Capsule UUID Active : \(self.capsuleUuidActive)")
|
|
|
137 |
print("AppData Save Capsule UUID Old : \(self.capsuleUuidOld)")
|
|
|
138 |
print("AppData Save Slide UUID Active : \(self.slideUuidActive)")
|
|
|
139 |
print("AppData Save Company UUID Active: \(self.companyUuidActive)")
|
|
|
140 |
|
|
|
141 |
print("AppData Save FCM Token : \(self.fcmToken)")
|
|
|
142 |
print("AppData Save LastCheckChanges : \(self.lastCheckChanges)")
|
|
|
143 |
print("AppData Save MaxDateChanges : \(self.maxDateChanges)")
|
|
|
144 |
print("AppData Save UrlExternalDownloaded : \(self.urlExternalDownloaded)")
|
|
|
145 |
|
|
|
146 |
print("AppData Save RefreshContentMessage : \(self.refreshContentMessage)")
|
|
|
147 |
print("AppData Save RrefreshContentMessageShowPending : \(self.refreshContentMessageShowPending)")
|
|
|
148 |
print("AppData Save RefreshContentActionRequired : \(self.refreshContentActionRequired)")
|
|
|
149 |
|
|
|
150 |
print("AppData Save SignoutActionRequired : \(self.signoutActionRequired)")
|
|
|
151 |
*/
|
|
|
152 |
|
12 |
efrain |
153 |
|
|
|
154 |
standardPreference.set(self.deviceUuid, forKey: Constants.PREFERENCE_DEVICE_UUID)
|
1 |
efrain |
155 |
|
12 |
efrain |
156 |
standardPreference.set(self.devicePassword, forKey: Constants.PREFERENCE_DEVICE_PASSWORD)
|
|
|
157 |
standardPreference.set(self.deviceAes, forKey: Constants.PREFERENCE_DEVICE_AES)
|
|
|
158 |
standardPreference.set(self.userUuid, forKey: Constants.PREFERENCE_USER_UUID)
|
|
|
159 |
standardPreference.set(self.userEmail, forKey: Constants.PREFERENCE_USER_EMAIL)
|
|
|
160 |
standardPreference.set(self.userFirstname, forKey: Constants.PREFERENCE_USER_FIRSTNAME)
|
|
|
161 |
standardPreference.set(self.userLastname, forKey: Constants.PREFERENCE_USER_LASTNAME)
|
|
|
162 |
standardPreference.set(self.userImage, forKey: Constants.PREFERENCE_USER_IMAGE)
|
|
|
163 |
|
|
|
164 |
standardPreference.set(self.topicUuidActive, forKey: Constants.PREFERENCE_TOPIC_UUID_ACTIVE)
|
|
|
165 |
standardPreference.set(self.capsuleUuidActive, forKey: Constants.PREFERENCE_CAPSULE_UUID_ACTIVE)
|
|
|
166 |
standardPreference.set(self.capsuleUuidOld, forKey: Constants.PREFERENCE_CAPSULE_UUID_OLD)
|
|
|
167 |
standardPreference.set(self.slideUuidActive, forKey: Constants.PREFERENCE_SLIDE_UUID_ACTIVE)
|
|
|
168 |
standardPreference.set(self.companyUuidActive, forKey: Constants.PREFERENCE_COMPANY_UUID_ACTIVE)
|
|
|
169 |
standardPreference.set(self.fcmToken, forKey: Constants.PREFERENCE_FCM_TOKEN)
|
|
|
170 |
standardPreference.set(self.lastCheckChanges, forKey: Constants.PREFERENCE_LAST_CHECK_CHANGES)
|
|
|
171 |
standardPreference.set(self.maxDateChanges, forKey: Constants.PREFERENCE_MAX_DATE_CHANGES)
|
|
|
172 |
standardPreference.set(self.urlExternalDownloaded, forKey: Constants.PREFERENCE_URL_EXTERNAL_DOWNLOADED)
|
1 |
efrain |
173 |
|
12 |
efrain |
174 |
standardPreference.set(self.refreshContentMessage, forKey: Constants.PREFERENCE_REFRESH_CONTENT_MESSAGE)
|
|
|
175 |
standardPreference.set(self.refreshContentMessageShowPending, forKey: Constants.PREFERENCE_REFRESH_CONTENT_MESSAGE_SHOW_PENDING)
|
|
|
176 |
standardPreference.set(self.refreshContentActionRequired, forKey: Constants.PREFERENCE_REFRESH_CONTENT_ACTION_REQUIRED)
|
1 |
efrain |
177 |
|
12 |
efrain |
178 |
standardPreference.set(self.signoutActionRequired, forKey: Constants.PREFERENCE_SIGNOUT_ACTION_REQUIRED)
|
1 |
efrain |
179 |
}
|
|
|
180 |
}
|