Proyectos de Subversion Iphone Microlearning - Inconcert

Rev

Rev 19 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 19 Rev 21
Línea 15... Línea 15...
15
    @Environment(\.scenePhase) var scenePhase
15
    @Environment(\.scenePhase) var scenePhase
Línea 16... Línea 16...
16
    
16
    
17
    
17
    
18
    @ObservedObject var syncForeground = SyncForegroundObservableObject()
18
    @ObservedObject var syncForeground = SyncForegroundObservableObject()
Línea 19... Línea 19...
19
    private let syncAdapter = SyncAdapter()
19
    private let syncAdapter = SyncAdapter()
20
    private var appData = AppData.sharedInstance
20
    private var appData = Environment(\.appData).wrappedValue
21
    
21
    
22
    init() {
22
    init() {
Línea 33... Línea 33...
33
 
33
 
Línea 34... Línea 34...
34
      UINavigationBar.appearance().tintColor = UIColor(Color("color_app_bar_foreground"))
34
      UINavigationBar.appearance().tintColor = UIColor(Color("color_app_bar_foreground"))
35
        
35
        
36
      UIPageControl.appearance().currentPageIndicatorTintColor = .systemBlue
-
 
37
      UIPageControl.appearance().pageIndicatorTintColor = .systemGray2
36
      UIPageControl.appearance().currentPageIndicatorTintColor = .systemBlue
38
      
-
 
39
        
-
 
40
 
-
 
41
 
-
 
42
        if let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
-
 
43
            
-
 
44
            let fileURL = dir.appendingPathComponent(Config.DEVICE_UUID_FILENAME)
-
 
45
            if !FileManager.default.fileExists(atPath: fileURL.path) {
-
 
46
                if appData.deviceUuid.isEmpty {
-
 
47
                    if let new_uuid = UIDevice.current.identifierForVendor?.uuidString {
-
 
48
                        do {
-
 
49
                            try new_uuid.write(to: fileURL, atomically: false, encoding: .utf8)
-
 
50
                            
-
 
51
                            var sync = SyncModel()
-
 
52
                            sync.data = new_uuid
-
 
53
                            sync.type = Constants.SYNC_ADAPTER_TYPE_DEVICE
-
 
54
                            
-
 
55
                            let syncDao = SyncDao()
-
 
56
                            let syncId = syncDao.insert(record: sync)
-
 
57
                            
-
 
58
                            if syncId > 0 {
-
 
59
                                appData.deviceUuid = new_uuid
-
 
60
                                appData.save()
-
 
61
                                
-
 
62
                                sync.id = syncId
-
 
63
                                
-
 
64
                                let syncAdapter = SyncAdapter()
-
 
65
                                syncAdapter.registerDevice(record: sync)
-
 
66
                            }
-
 
67
                        }
-
 
68
                        catch {/* error handling here */}
-
 
69
                    }
-
 
70
                } else {
-
 
71
                    do {
-
 
72
                        try appData.deviceUuid.write(to: fileURL, atomically: false, encoding: .utf8)
-
 
73
                    }
-
 
74
                    catch {/* error handling here */}
-
 
75
                }
-
 
76
            }
37
      UIPageControl.appearance().pageIndicatorTintColor = .systemGray2
Línea 77... Línea 38...
77
        }
38
 
Línea 78... Línea 39...
78
    }
39
    }