Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

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

Rev 1 Rev 8
Línea 6... Línea 6...
6
//
6
//
Línea 7... Línea 7...
7
 
7
 
8
import Foundation
8
import Foundation
9
import SwiftUI
9
import SwiftUI
-
 
10
import AVKit
Línea 10... Línea 11...
10
import AVKit
11
import NavigationStack
Línea -... Línea 12...
-
 
12
 
11
 
13
struct CardGalleryView: View {
12
struct CardGalleryView: View {
14
    
Línea -... Línea 15...
-
 
15
    @EnvironmentObject private var networkMonitor : NetworkMonitor
-
 
16
    @EnvironmentObject private var appNavigation : AppNavigation
-
 
17
    @ObservedObject private var viewModel = GalleryCardViewModel()
-
 
18
    
-
 
19
    @State private var goToVideoPlayer : Bool = false
-
 
20
    @State private var goToPdfViewer : Bool = false
-
 
21
    @State private var goToWebViewer : Bool = false
-
 
22
    
-
 
23
    @State private var showGlobalAlert : Bool = false
13
    
24
    @State private var titleGlobalAlert : String = ""
Línea 14... Línea 25...
14
    @EnvironmentObject private var appNavigation : AppNavigation
25
    @State private var messageGlobalAlert : String = ""
15
    @ObservedObject private var viewModel = GalleryCardViewModel()
26
    
Línea -... Línea 27...
-
 
27
    
Línea 44... Línea 56...
44
            self.buttonTitle = Config.LANG_BUTTON_LAUNCH_AUDIO_PLAYER
56
            self.buttonTitle = Config.LANG_BUTTON_LAUNCH_AUDIO_PLAYER
45
            self.buttonShow = true
57
            self.buttonShow = true
46
        } else if self.viewModel.slide.type == Constants.SLIDE_TYPE_DOCUMENT {
58
        } else if self.viewModel.slide.type == Constants.SLIDE_TYPE_DOCUMENT {
47
            self.buttonTitle = Config.LANG_BUTTON_LAUNCH_VIEW_PDF
59
            self.buttonTitle = Config.LANG_BUTTON_LAUNCH_VIEW_PDF
48
            self.buttonShow = true
60
            self.buttonShow = true
-
 
61
            
-
 
62
        } else if self.viewModel.slide.type == Constants.SLIDE_TYPE_TEXT {
-
 
63
            self.buttonTitle = Config.LANG_BUTTON_LAUNCH_VIEW_PDF
-
 
64
            self.buttonShow = true
49
        } else {
65
        } else {
50
            self.buttonShow = false
66
            self.buttonShow = false
51
        }
67
        }
Línea 52... Línea 68...
52
        
68
        
Línea 53... Línea 69...
53
    }
69
    }
54
 
-
 
55
    
70
 
56
    
71
    
57
    
72
    
Línea 58... Línea 73...
58
    var body: some View {
73
    
59
 
74
    var body: some View {
Línea 60... Línea 75...
60
        GeometryReader { geometry in
75
        GeometryReader { geometry in
61
            let checkMarkX = (geometry.size.width - 50) / 2
-
 
62
            let checkMarkY = -1 * ((geometry.size.height - 50) / 2)
76
            let checkMarkX = (geometry.size.width - 50) / 2
63
            
77
            let checkMarkY = -1 * ((geometry.size.height - 50) / 2)
64
            let buttonX = (geometry.size.width - 180) / 2
-
 
65
            let buttonY = (geometry.size.height - 80) / 2
-
 
66
          
78
            
Línea 67... Línea 79...
67
            ZStack {
79
            let buttonX = (geometry.size.width - 180) / 2
Línea 68... Línea 80...
68
          
80
            let buttonY = (geometry.size.height - 80) / 2
Línea 113... Línea 125...
113
                    .cornerRadius(/*@START_MENU_TOKEN@*/3.0/*@END_MENU_TOKEN@*/)
125
                    .cornerRadius(/*@START_MENU_TOKEN@*/3.0/*@END_MENU_TOKEN@*/)
114
                    .zIndex(10000)
126
                    .zIndex(10000)
115
                }
127
                }
Línea 116... Línea 128...
116
               
128
               
-
 
129
                VStack {
-
 
130
                
-
 
131
                    if self.viewModel.slide.type == Constants.SLIDE_TYPE_VIDEO || self.viewModel.slide.type == Constants.SLIDE_TYPE_AUDIO {
-
 
132
                    PushView(
-
 
133
                        destination: VideoPlayerView(slideUuid: viewModel.slide.uuid),
-
 
134
                        isActive: self.$goToVideoPlayer,
-
 
135
                        label: {
-
 
136
                            Text("")
-
 
137
                        }).frame(height: 0)
-
 
138
                    }
-
 
139
                    
-
 
140
                    if self.viewModel.slide.type == Constants.SLIDE_TYPE_DOCUMENT {
-
 
141
              
-
 
142
                        PushView(
-
 
143
                            destination: PdfViewerView(slideUuid: viewModel.slide.uuid),
-
 
144
                            isActive: self.$goToPdfViewer,
-
 
145
                            label: {
-
 
146
                                Text("")
-
 
147
                            }).frame(height: 0)
-
 
148
                    }
-
 
149
                    
-
 
150
                    
-
 
151
                    if self.viewModel.slide.type == Constants.SLIDE_TYPE_TEXT {
-
 
152
                    
-
 
153
                        PushView(
-
 
154
                            destination: WebViewerView(slideUuid: viewModel.slide.uuid),
-
 
155
                            isActive: self.$goToWebViewer,
-
 
156
                            label: {
-
 
157
                                Text("")
-
 
158
                        }).frame(height: 0)
-
 
159
                    }
117
                VStack {
160
                    
118
                    Spacer()
161
                    Spacer()
119
                    HStack {
162
                    HStack {
120
                        if viewModel.slide.background.isEmpty && viewModel.slide.file.isEmpty {
163
                        if viewModel.slide.background.isEmpty && viewModel.slide.file.isEmpty {
121
                            Image(uiImage: UIImage(named: "logo") ?? UIImage())
164
                            Image(uiImage: UIImage(named: "logo") ?? UIImage())
Línea 150... Línea 193...
150
                            self.viewModel.fetchProgress(slideUuid: slideUuid, userUuid: appData.userUuid)
193
                            self.viewModel.fetchProgress(slideUuid: slideUuid, userUuid: appData.userUuid)
151
                        }
194
                        }
152
                    }
195
                    }
153
                }
196
                }
Línea -... Línea 197...
-
 
197
          
-
 
198
            } .alert(isPresented: $showGlobalAlert) {
-
 
199
                Alert(
-
 
200
                    title: Text(self.titleGlobalAlert),
-
 
201
                    message: Text(self.messageGlobalAlert),
-
 
202
                    dismissButton: .default(Text(Config.LANG_COMMON_OK))
154
          
203
                )
155
            }
204
            }
156
        }
205
        }
Línea 157... Línea 206...
157
    }
206
    }
158
    
207
    
Línea -... Línea 208...
-
 
208
    private func btnPlay()
-
 
209
    {
-
 
210
        
-
 
211
        if networkMonitor.status == .disconnected {
-
 
212
        
-
 
213
            self.titleGlobalAlert = Config.LANG_ERROR_NETWORK_TITLE
-
 
214
            self.messageGlobalAlert = Config.LANG_ERROR_NETWORK_MESSAGE_LONG
-
 
215
            self.showGlobalAlert  = true
Línea 159... Línea 216...
159
    private func btnPlay()
216
            return
160
    {
217
        }
161
        
218
        
162
        
219
        
Línea 163... Línea 220...
163
        if self.viewModel.slide.type == Constants.SLIDE_TYPE_VIDEO {
220
        if self.viewModel.slide.type == Constants.SLIDE_TYPE_VIDEO {
-
 
221
            AppDelegate.orientationLock = UIInterfaceOrientationMask.landscapeLeft
-
 
222
            UIDevice.current.setValue(UIInterfaceOrientation.landscapeLeft.rawValue, forKey: "orientation")
-
 
223
            UIViewController.attemptRotationToDeviceOrientation()
164
            AppDelegate.orientationLock = UIInterfaceOrientationMask.landscapeLeft
224
            
Línea 165... Línea 225...
165
            UIDevice.current.setValue(UIInterfaceOrientation.landscapeLeft.rawValue, forKey: "orientation")
225
            
-
 
226
            self.goToVideoPlayer = true
166
            UIViewController.attemptRotationToDeviceOrientation()
227
            
Línea 167... Línea 228...
167
            
228
            
-
 
229
            
168
            
230
        }  else if self.viewModel.slide.type == Constants.SLIDE_TYPE_AUDIO {
Línea 169... Línea 231...
169
            appNavigation.subpageActive = .videoplayer
231
            
Línea 170... Línea 232...
170
        }  else if self.viewModel.slide.type == Constants.SLIDE_TYPE_AUDIO {
232
            self.goToVideoPlayer = true
Línea 171... Línea -...
171
            
-
 
-
 
233
            
172
            appNavigation.subpageActive = .videoplayer
234
        }  else if self.viewModel.slide.type == Constants.SLIDE_TYPE_DOCUMENT {
173
        }  else if self.viewModel.slide.type == Constants.SLIDE_TYPE_DOCUMENT {
235