Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

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

Rev 31 Rev 44
Línea 10... Línea 10...
10
struct NotificationListView: View {
10
struct NotificationListView: View {
11
    @Environment(\.openURL) var openURL
11
    @Environment(\.openURL) var openURL
12
    @EnvironmentObject private var networkMonitor : NetworkMonitor
12
    @EnvironmentObject private var networkMonitor : NetworkMonitor
13
    @EnvironmentObject private var appNavigation : AppNavigation
13
    @EnvironmentObject private var appNavigation : AppNavigation
Línea 14... Línea 14...
14
    
14
    
15
    @ObservedObject var viewModel :NotificationListViewModel = NotificationListViewModel()
15
    @ObservedObject var viewModel :NotificationListViewModel
Línea -... Línea 16...
-
 
16
    private let appData = AppData.sharedInstance
-
 
17
    
-
 
18
    init() {
-
 
19
 
-
 
20
        let userNotificationDao = UserNotificationDao.sharedInstance
-
 
21
        
-
 
22
        userNotificationDao.removeExpired(userUuid:appData.userUuid)
-
 
23
        
Línea 16... Línea 24...
16
    private let appData = AppData.sharedInstance
24
        viewModel = NotificationListViewModel()
17
    
25
    }
18
    
26
    
19
    var body: some View {
27
    var body: some View {
Línea 53... Línea 61...
53
                    LazyVStack  {
61
                    LazyVStack  {
Línea 54... Línea 62...
54
                        
62
                        
Línea 55... Línea 63...
55
 
63
 
Línea 56... Línea 64...
56
                        
64
                        
Línea 57... Línea 65...
57
                            
65
                            
Línea -... Línea 66...
-
 
66
                        ForEach(self.viewModel.notifications) { notificationItem  in
58
                        ForEach(0..<self.viewModel.notifications.count) { index in
67
                                
Línea 59... Línea 68...
59
                                
68
                            //let notificationItem = self.viewModel.notifications[index]
60
                            let notificationItem = self.viewModel.notifications[index]
69
                            
Línea 61... Línea 70...
61
                            
70
                                NotificationListItemView(notification: notificationItem,onExecute: {
Línea 76... Línea 85...
76
                                    } else if notificationItem.command == Constants.NOTIFICATION_COMMAND_OPEN_URL &&
85
                                    } else if notificationItem.command == Constants.NOTIFICATION_COMMAND_OPEN_URL &&
77
                                        !notificationItem.url.isEmpty  &&
86
                                        !notificationItem.url.isEmpty  &&
78
                                        notificationItem.viewed == 0  {
87
                                        notificationItem.viewed == 0  {
Línea 79... Línea 88...
79
                                        
88
                                        
-
 
89
                                        openURL(URL(string: notificationItem.url)!)
80
                                        openURL(URL(string: notificationItem.url)!)
90
                                        let notificationDao = UserNotificationDao.sharedInstance
-
 
91
                                        notificationDao.markViewed(id: notificationItem.id)
81
                                        self.viewModel.markForViewedById(id: notificationItem.id)
92
                                        
Línea 82... Línea 93...
82
                                        //self.viewModel.fetchAll()
93
                                        self.viewModel.fetchAll()
Línea 83... Línea 94...
83
                                        
94
                                        
-
 
95
                                    }
-
 
96
                                    
-
 
97
                                }) {
84
                                    }
98
                                    
-
 
99
                                    DispatchQueue.main.async {
85
                                    
100
                                        let notificationDao = UserNotificationDao.sharedInstance
-
 
101
                                        notificationDao.remove(id: notificationItem.id)
86
                                }) {
102
                                        
Línea 87... Línea 103...
87
                                    self.viewModel.removeItem(id: notificationItem.id)
103
                                        self.viewModel.fetchAll()
Línea 88... Línea 104...
88
                                    //self.viewModel.fetchAll()
104
                                    }