Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

Rev 19 | Rev 25 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 19 Rev 24
Línea 96... Línea 96...
96
                        .background(Color("color_error_background"))
96
                        .background(Color("color_error_background"))
97
                        .foregroundColor(Color("color_error_foreground"))
97
                        .foregroundColor(Color("color_error_foreground"))
98
                        .font(.callout)
98
                        .font(.callout)
99
                    }*/
99
                    }*/
100
            }
100
            }
-
 
101
        }
-
 
102
        .onAppear {
-
 
103
            if appData.refreshContentPending {
-
 
104
                let snackbar = TTGSnackbar(message:  appData.refreshContentMessage, duration: .long)
-
 
105
                snackbar.show()
-
 
106
                
-
 
107
                appData.refreshContentMessage = ""
-
 
108
                appData.refreshContentPending = false
-
 
109
                appData.save()
-
 
110
            }
-
 
111
        }
101
        } .onReceive(NotificationCenter.default.publisher(for: Constants.NOTIFICATION_NAME_COMMAND_REFRESH_CONTENT))
112
        .onReceive(NotificationCenter.default.publisher(for: Constants.NOTIFICATION_NAME_COMMAND_REFRESH_CONTENT))
102
        { data in
113
        { data in
103
            if data.userInfo != nil {
114
            if data.userInfo != nil {
104
                let newCapsules = Int(data.userInfo?["new_capsules"]! as? String ?? "0") ?? 0
115
                let newCapsules = Int(data.userInfo?["new_capsules"]! as? String ?? "0") ?? 0
105
                let isForeground = (Int(data.userInfo?["is_foreground"]! as? String ?? "0") ?? 0) == 1
116
                let isForeground = (Int(data.userInfo?["is_foreground"]! as? String ?? "0") ?? 0) == 1
Línea 109... Línea 120...
109
                    let message = newCapsules == 1 ? Config.LANG_MESSAGE_NEW_CONTENT_THERE_IS_ONE_CAPSULE : Config.LANG_MESSAGE_NEW_CONTENT_THERE_ARE_MULTIPLE_CAPSULES.replacingOccurrences(of: "%s", with: String(newCapsules))
120
                    let message = newCapsules == 1 ? Config.LANG_MESSAGE_NEW_CONTENT_THERE_IS_ONE_CAPSULE : Config.LANG_MESSAGE_NEW_CONTENT_THERE_ARE_MULTIPLE_CAPSULES.replacingOccurrences(of: "%s", with: String(newCapsules))
Línea 110... Línea 121...
110
                    
121
                    
111
                    if isForeground {
122
                    if isForeground {
112
                        let snackbar = TTGSnackbar(message:  message, duration: .long)
123
                        let snackbar = TTGSnackbar(message:  message, duration: .long)
113
                        snackbar.show()
124
                        snackbar.show()
114
                    } else {
125
                    }  else {
-
 
126
                        appData.refreshContentMessage = message
-
 
127
                        appData.refreshContentPending = true
115
                        localNotification.sendNotification(title: Config.LANG_TITLE_NEW_CONTENT, subtitle: "", body: message, launchIn: 0)
128
                        appData.save()
116
                    }
129
                    }
117
                }
130
                }
Línea 118... Línea 131...
118
            }
131
            }
Línea 128... Línea 141...
128
           appData.userImage = ""
141
           appData.userImage = ""
129
           appData.save()
142
           appData.save()
Línea 130... Línea 143...
130
           
143
           
Línea -... Línea 144...
-
 
144
           appNavigation.pageActive = .goodbye
-
 
145
 
-
 
146
       }.onReceive(NotificationCenter.default.publisher(for: Constants.NOTIFICATION_NAME_PUSH))
-
 
147
        { data in
-
 
148
            
-
 
149
            let title = data.userInfo?["title"]! as? String ?? ""
-
 
150
            let body = data.userInfo?["body"]! as? String ?? ""
-
 
151
            let url = data.userInfo?["url"]! as? String ?? ""
-
 
152
            
-
 
153
            if !title.isEmpty && !body.isEmpty {
-
 
154
                let now = Date()
-
 
155
                let dateFormatter = DateFormatter()
-
 
156
                dateFormatter.dateFormat = Constants.FORMAT_DATE_YMD
-
 
157
                
-
 
158
                let timeFormatter = DateFormatter()
-
 
159
                timeFormatter.dateFormat = Constants.FORMAT_TIME_12
-
 
160
                
-
 
161
                let dateOn = dateFormatter.string(from: now)
-
 
162
                let timeOn = dateFormatter.string(from: now)
-
 
163
                
-
 
164
                let userNotificationDao = UserNotificationDao.sharedInstance
-
 
165
                var userNotification : UserNotificationModel  = UserNotificationModel(userUuid: appData.userUuid, title: title, body: body, viewed: 0, url: url, dateOn: dateOn, timeOn: timeOn)
-
 
166
                
-
 
167
                
-
 
168
 
-
 
169
                userNotificationDao.insert(userNotification: userNotification)
-
 
170
                
131
           appNavigation.pageActive = .goodbye
171
 
Línea 132... Línea 172...
132
 
172
            }
133
       }
173
        }