Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

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

Rev 38 Rev 39
Línea 98... Línea 98...
98
                        .font(.callout)
98
                        .font(.callout)
99
                    }*/
99
                    }*/
100
            }
100
            }
101
        }
101
        }
102
        .onAppear {
102
        .onAppear {
103
            
103
 
104
            if appData.signoutActionRequired {
-
 
105
                DispatchQueue.main.asyncAfter(deadline: .now() + 1)
-
 
106
                    signout()
-
 
107
                }
-
 
108
            } else {
-
 
109
                if appData.refreshContentMessageShowPending {
104
                if appData.refreshContentMessageShowPending {
110
                    let snackbar = TTGSnackbar(message: appData.refreshContentMessage, duration: .forever)
105
                    let snackbar = TTGSnackbar(message: appData.refreshContentMessage, duration: .forever)
111
                    // Action 1
106
                    // Action 1
112
                    snackbar.actionText = Config.LANG_COMMNON_UPDATE
107
                    snackbar.actionText = Config.LANG_COMMNON_UPDATE
113
                    snackbar.actionTextColor = UIColor( Color("color_snackbar_button_yes"))
108
                    snackbar.actionTextColor = UIColor( Color("color_snackbar_button_yes"))
114
                    snackbar.actionBlock = { (snackbar) in
109
                    snackbar.actionBlock = { (snackbar) in
115
                        DispatchQueue.main.asyncAfter(deadline: .now() + 1)
110
                        DispatchQueue.main.async {
116
                            snackbar.dismiss()
111
                            snackbar.dismiss()
117
                            refreshContent()
112
                            refreshContent()
118
                        }
113
                        }
119
                   }
114
                    }
120
                       
-
 
121
                   
-
 
122
                    snackbar.show()
115
                    snackbar.show()
Línea 123... Línea 116...
123
                    
116
                    
124
                    
117
                    
125
                }
118
                }
126
            }
119
 
127
        }
120
        }
128
        .onReceive(NotificationCenter.default.publisher(for: Constants.NOTIFICATION_NAME_COMMAND_REFRESH_CONTENT))
121
        .onReceive(NotificationCenter.default.publisher(for: Constants.NOTIFICATION_NAME_COMMAND_REFRESH_CONTENT))
129
        { data in
122
        { data in
Línea 161... Línea 154...
161
                        let snackbar = TTGSnackbar(message:  message, duration: .forever)
154
                        let snackbar = TTGSnackbar(message:  message, duration: .forever)
162
                        // Action 1
155
                        // Action 1
163
                        snackbar.actionText = Config.LANG_COMMNON_UPDATE
156
                        snackbar.actionText = Config.LANG_COMMNON_UPDATE
164
                        snackbar.actionTextColor = UIColor( Color("color_snackbar_button_yes"))
157
                        snackbar.actionTextColor = UIColor( Color("color_snackbar_button_yes"))
165
                        snackbar.actionBlock = { (snackbar) in
158
                        snackbar.actionBlock = { (snackbar) in
166
                            DispatchQueue.main.asyncAfter(deadline: .now() + 1)
159
                            DispatchQueue.main.async {
167
                                snackbar.dismiss()
160
                                snackbar.dismiss()
168
                                refreshContent()
161
                                refreshContent()
169
                            }
162
                            }
170
                        }
163
                        }
171
                           
164
 
172
                        snackbar.show()
165
                        snackbar.show()
173
                    }  else {
166
                    }  else {
174
                        appData.refreshContentMessage = message
167
                        appData.refreshContentMessage = message
175
                        appData.refreshContentMessageShowPending = true
168
                        appData.refreshContentMessageShowPending = true
176
                        appData.save()
169
                        appData.save()
Línea 179... Línea 172...
179
            }
172
            }
Línea 180... Línea 173...
180
 
173
 
181
        }
174
        }
182
        .onReceive(NotificationCenter.default.publisher(for: Constants.NOTIFICATION_NAME_COMMAND_EXIT))
175
        .onReceive(NotificationCenter.default.publisher(for: Constants.NOTIFICATION_NAME_COMMAND_EXIT))
183
       { data in
-
 
184
            if data.userInfo != nil {
-
 
185
                let isForeground = (Int(data.userInfo?["is_foreground"]! as? String ?? "0") ?? 0) == 1
-
 
186
            
-
 
187
            
-
 
188
                if isForeground {
-
 
189
                    signout()
-
 
190
                } else {
-
 
191
                    appData.signoutActionRequired = true
-
 
192
                    appData.save()
-
 
Línea -... Línea 176...
-
 
176
       { data in
-
 
177
            
-
 
178
            DispatchQueue.main.async {
-
 
179
                appData.userUuid = ""
-
 
180
                appData.userFirstname = ""
-
 
181
                appData.userLastname = ""
-
 
182
                appData.userEmail = ""
-
 
183
                appData.userImage = ""
-
 
184
                appData.refreshContentActionRequired = false
-
 
185
                appData.refreshContentMessage = ""
-
 
186
                appData.refreshContentMessageShowPending = false
193
                }
187
                appData.signoutActionRequired = false
-
 
188
                appData.save()
194
            
189
                
-
 
190
                appNavigation.pageActive = .goodbye
Línea 195... Línea 191...
195
 
191
            }
196
            }
192
 
Línea 224... Línea 220...
224
            userNotificationDao.insert(userNotification: userNotification)
220
            userNotificationDao.insert(userNotification: userNotification)
225
        }
221
        }
Línea 226... Línea 222...
226
        
222
        
227
        
223
        
228
    }
-
 
229
    
-
 
230
    func signout() -> Void {
-
 
231
        appData.userUuid = ""
-
 
232
        appData.userFirstname = ""
-
 
233
        appData.userLastname = ""
-
 
234
        appData.userEmail = ""
-
 
235
        appData.userImage = ""
-
 
236
        appData.refreshContentActionRequired = false
-
 
237
        appData.refreshContentMessage = ""
-
 
238
        appData.refreshContentMessageShowPending = false
-
 
239
        appData.signoutActionRequired = false
-
 
240
        appData.save()
-
 
241
        
-
 
242
        appNavigation.pageActive = .goodbye
-
 
243
    }
224
    }
244
    
225
 
245
    func refreshContent() -> Void {
226
    func refreshContent() -> Void {
246
        appData.refreshContentMessage = ""
227
        appData.refreshContentMessage = ""
247
        appData.refreshContentMessageShowPending = false
228
        appData.refreshContentMessageShowPending = false
Línea -... Línea 229...
-
 
229
        appData.refreshContentActionRequired = true
248
        appData.refreshContentActionRequired = true
230
        appData.save()
-
 
231
        
Línea -... Línea 232...
-
 
232
        withAnimation {
249
        appData.save()
233
            appNavigation.subpageActive = .topics
250
        
234
        }
Línea 251... Línea 235...
251
        appNavigation.subpageActive = .topics
235
 
252
 
236