Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

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

Rev 11 Rev 17
Línea 34... Línea 34...
34
                comment =  String(comment.prefix(128))
34
                comment =  String(comment.prefix(128))
35
                AudioServicesPlayAlertSoundWithCompletion(SystemSoundID(kSystemSoundID_Vibrate)) { return }
35
                AudioServicesPlayAlertSoundWithCompletion(SystemSoundID(kSystemSoundID_Vibrate)) { return }
36
            }
36
            }
37
        }
37
        }
38
    }
38
    }
39
    
-
 
Línea 40... Línea -...
40
 
-
 
41
    
-
 
42
    
39
 
Línea 43... Línea 40...
43
    @State private var selectedType: CommentAndRatingPickerType = .introduction
40
    @State private var selectedType: CommentAndRatingPickerType = .introduction
44
    
41
    
45
    @State private var presentAlert : Bool = false
42
    @State private var presentAlert : Bool = false
Línea 46... Línea 43...
46
    @State private var titleAlert : String = ""
43
    @State private var titleAlert : String = ""
Línea 47... Línea 44...
47
    @State private var messageAlert : String = ""
44
    @State private var messageAlert : String = ""
48
    
-
 
Línea 49... Línea -...
49
    @State private var showProgressView : Bool = false
-
 
50
    
45
    
Línea 51... Línea 46...
51
    private let appDao = AppDao.sharedInstance
46
    @State private var showProgressView : Bool = false
Línea 106... Línea 101...
106
                        ScrollView {
101
                        ScrollView {
107
                            LazyVStack  {
102
                            LazyVStack  {
108
                                //ForEach(0..<self.comments.count) { index in
103
                                //ForEach(0..<self.comments.count) { index in
Línea 109... Línea 104...
109
                                
104
                                
110
                                ForEach(self.commentsViewModel.comments) { commentItem in
105
                                ForEach(self.commentsViewModel.comments) { commentItem in
-
 
106
                                    CommentAndRatingCommentListItem(comment: commentItem) {
-
 
107
                                        deleteComment(id: commentItem.id, linkDelete: commentItem.link_delete  )
-
 
108
                                        
111
                                    CommentAndRatingCommentListItem(comment: commentItem)
109
                                    }
Línea 112... Línea 110...
112
                                }
110
                                }
113
                                
111
                                
114
                            }
112
                            }
Línea 118... Línea 116...
118
                    
116
                    
Línea 119... Línea 117...
119
                   // CommentAndRatingCommentListView(comments: self.commentsViewModel.comments, showProgressView: self.$showProgressView).border(Color.blue, width: 1)
117
                   // CommentAndRatingCommentListView(comments: self.commentsViewModel.comments, showProgressView: self.$showProgressView).border(Color.blue, width: 1)
120
          
118
          
121
                default :
119
                default :
-
 
120
                    CommentAndRatingPostCommentView(
-
 
121
                        capsuleModel: self.capsuleViewModel.capsule, comment: self.$comment, rating: self.$rating) {
Línea 122... Línea 122...
122
                    CommentAndRatingPostCommentView(
122
                        sendPostComment()
Línea 123... Línea 123...
123
                        capsuleModel: self.capsuleViewModel.capsule, comment: self.$comment, rating: self.$rating)
123
                    }
124
 
124
 
125
            }
125
            }
126
            
126
            
127
            Spacer()
-
 
-
 
127
            Spacer()
128
        }
128
        }
Línea 129... Línea 129...
129
        .background(Color("color_picker_background"))
129
        .background(Color("color_picker_background"))
130
        .onAppear {
130
        .onAppear {
131
            let appData = appDao.selectOne()
131
 
Línea 145... Línea 145...
145
                title: Text(self.titleAlert),
145
                title: Text(self.titleAlert),
146
                message: Text(self.messageAlert),
146
                message: Text(self.messageAlert),
147
                dismissButton: .default(Text(Config.LANG_COMMON_OK))
147
                dismissButton: .default(Text(Config.LANG_COMMON_OK))
148
            )
148
            )
149
        }
149
        }
150
      .onReceive(NotificationCenter.default.publisher(for: Constants.NOTIFICATION_NAME_COMMAND_POST_COMMENT))
-
 
151
        { data in
-
 
152
        
-
 
153
 
-
 
154
            sendPostComment()
-
 
155
        }
-
 
156
        .onReceive(NotificationCenter.default.publisher(for: Constants.NOTIFICATION_NAME_COMMAND_DELETE_COMMENT))
-
 
157
          { data in
-
 
158
            if data.userInfo != nil {
-
 
159
                
-
 
160
                //print(data.userInfo)
-
 
161
                
-
 
162
                let id = data.userInfo?["id"]! as? String ?? ""
-
 
163
                let link_delete = data.userInfo?["link_delete"]! as? String ?? ""
-
 
164
                
-
 
165
                print("id = \(id)  link_delete = \(link_delete)")
-
 
166
                
-
 
167
                if !id.isEmpty || !link_delete.isEmpty {
-
 
168
                
-
 
169
                    deleteComment(id: id, linkDelete : link_delete)
-
 
170
                }
-
 
171
              
-
 
172
            }
-
 
173
 
-
 
174
             
-
 
175
          }
-
 
176
    }
150
    }
Línea 177... Línea 151...
177
    
151
    
178
    func reloadComments()
152
    func reloadComments()
179
    {
153
    {
Línea 180... Línea 154...
180
        self.commentsViewModel.comments.removeAll()
154
        self.commentsViewModel.comments.removeAll()
181
        
155
        
182
        if !self.capsuleViewModel.capsule.linkComments.isEmpty && networkMonitor.status == .connected {
-
 
183
            
156
        if !self.capsuleViewModel.capsule.linkComments.isEmpty && networkMonitor.status == .connected {
Línea 184... Línea 157...
184
            let appData = appDao.selectOne()
157
 
185
            let headerSecurity : HeaderSecurity = HeaderSecurity()
158
            let headerSecurity : HeaderSecurity = HeaderSecurity()
186
            
159
            
Línea 227... Línea 200...
227
                                        newComment.rating = Decimal(Double(jcomment.1["rating"].string ??  "") ?? 0)
200
                                        newComment.rating = Decimal(Double(jcomment.1["rating"].string ??  "") ?? 0)
228
                                        newComment.fullname = jcomment.1["fullname"].string ?? ""
201
                                        newComment.fullname = jcomment.1["fullname"].string ?? ""
229
                                        newComment.comment = jcomment.1["comment"].string ?? ""
202
                                        newComment.comment = jcomment.1["comment"].string ?? ""
230
                                        newComment.image = jcomment.1["image"].string ?? ""
203
                                        newComment.image = jcomment.1["image"].string ?? ""
231
                                        newComment.link_delete = jcomment.1["link_delete"].string ?? ""
204
                                        newComment.link_delete = jcomment.1["link_delete"].string ?? ""
232
                                        newComment.date = jcomment.1["date"].string ?? ""
205
                                        let sDate = jcomment.1["date"].string ?? ""
Línea -... Línea 206...
-
 
206
 
-
 
207
                                        let formatterService = DateFormatter()
-
 
208
                                        formatterService.dateFormat = Constants.FORMAT_DATETIME_SERVICE
-
 
209
                                        if let date = formatterService.date(from: sDate) {
-
 
210
                                          
-
 
211
                                            let dateFormatterUser = DateFormatter()
-
 
212
                                            dateFormatterUser.dateFormat = Constants.FORMAT_DATE_TIME_24
-
 
213
                                            newComment.date =  dateFormatterUser.string(from: date)
-
 
214
                                            
-
 
215
                                            
-
 
216
                                        }
-
 
217
                                        
-
 
218
                                      
-
 
219
                                        
233
 
220
                                        
234
                                        commentsViewModel.comments.append(newComment)
221
                                        commentsViewModel.comments.append(newComment)
235
                                    }
222
                                    }
Línea 262... Línea 249...
262
        
249
        
Línea 263... Línea 250...
263
    }
250
    }
Línea -... Línea 251...
-
 
251
    
-
 
252
    func sendPostComment() {
-
 
253
        
-
 
254
        let now = Date()
Línea 264... Línea -...
264
    
-
 
265
    func sendPostComment() {
-
 
266
        
255
        let dateFormatter = DateFormatter()
267
        
256
        dateFormatter.dateFormat = Constants.FORMAT_DATETIME_SERVICE
268
        
257
        let dateOn = dateFormatter.string(from: now)
269
        let appData = appDao.selectOne()
258
        
-
 
259
        showProgressView = true
270
        showProgressView = true
260
        let parameters = [
Línea 271... Línea 261...
271
        let parameters = [
261
            Constants.POST_COMMENT_FIELD_COMMENT: comment,
Línea 272... Línea 262...
272
            Constants.POST_COMMENT_FIELD_COMMENT: "\(comment)",
262
            Constants.POST_COMMENT_FIELD_RATING: "\(Int(rating))",
Línea 338... Línea 328...
338
                        }
328
                        }
Línea 339... Línea 329...
339
                        
329
                        
340
                        
330
                        
341
                        
331
                        
Línea 342... Línea 332...
342
                        if json?["data"]["message"] != nil  {
332
                        if json?["data"]["message"] != nil  {
Línea 369... Línea 359...
369
        
359
        
Línea 370... Línea 360...
370
        
360
        
371
    }
-
 
372
    
-
 
373
    func deleteComment(id : String, linkDelete : String) {
-
 
374
        
-
 
375
        
-
 
Línea -... Línea 361...
-
 
361
    }
Línea 376... Línea 362...
376
        
362
    
Línea 377... Línea 363...
377
        let appData = appDao.selectOne()
363
    func deleteComment(id : String, linkDelete : String) {
378
        showProgressView = true
364
 
Línea 418... Línea 404...
418
                        }
404
                        }
Línea 419... Línea 405...
419
                        
405
                        
420
                        
406
                        
421
                        
407
                        
Línea 422... Línea 408...
422
                        if json?["data"]["message"] != nil  {
408
                        if json?["data"]["message"] != nil  {
Línea 423... Línea 409...
423
                            let snackbar = TTGSnackbar(message: json?["data"]["message"].string ?? "", duration: .short)
409
                            let snackbar = TTGSnackbar(message: json?["data"]["message"].string ?? "", duration: .long)