Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

Rev 1 | Rev 11 | 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 PDFKit
Línea 10... Línea 11...
10
import PDFKit
11
import NavigationStack
11
 
-
 
12
 
-
 
Línea 13... Línea 12...
13
struct PdfViewerView: View {
12
 
-
 
13
 
14
    @Environment(\.presentationMode)
14
struct PdfViewerView: View {
Línea -... Línea 15...
-
 
15
    
-
 
16
    @State private var backToGallery : Bool = false
-
 
17
    
-
 
18
    @State private var isCompleted : Bool = false
15
       var presentationMode: Binding
19
    
16
    
-
 
17
    //@State private var backToGallery : Bool = false
-
 
Línea 18... Línea 20...
18
    @State private var isCompleted : Bool = false
20
    
19
    
21
    private var slideModel : SlideModel
-
 
22
    private var slideTitle : String
-
 
23
    
-
 
24
    private var url : URL?
-
 
25
    
-
 
26
 
-
 
27
    
20
    private var url : URL?
28
    init(slideUuid : String)
-
 
29
    {
21
 
30
        let slideDao = SlideDao.sharedInstance
22
    private var slideName : String;
31
        self.slideModel = slideDao.selectByUuid(uuid: slideUuid)
23
    
32
 
24
 
33
        if self.slideModel.name.count > Constants.APP_BAR_TITLE_MAX_LENGTH {
-
 
34
            slideTitle = String(Array(self.slideModel.name)[0...Constants.APP_BAR_TITLE_MAX_LENGTH]) + "..."
25
    
35
        } else {
Línea 26... Línea 36...
26
    init(url : String, slideName : String)
36
            slideTitle = self.slideModel.name
Línea 27... Línea 37...
27
    {
37
        }
-
 
38
        
-
 
39
        
-
 
40
        print("Viewer PDF: \(slideModel.file) ")
-
 
41
        
-
 
42
        self.url = URL(string: slideModel.file)
-
 
43
 
-
 
44
 
-
 
45
 
28
        self.url = URL(string: url)
46
    }
-
 
47
    
29
            
48
    var body: some View {
-
 
49
        VStack(spacing: 0) {
-
 
50
            PopView(
-
 
51
                destination: .root,
-
 
52
                isActive: self.$backToGallery,
-
 
53
                label: {
-
 
54
                    Text("")
-
 
55
                    
-
 
56
                }
-
 
57
            ).frame( height: 0)
-
 
58
            
-
 
59
            HStack {
-
 
60
                Button(action: {
-
 
61
                    let dataService = DataService()
-
 
62
                    if self.isCompleted {
-
 
63
                    
-
 
64
                       
-
 
65
                        dataService.completeSlide(slide: slideModel)
-
 
66
                    } else {
-
 
67
                        dataService.incompleteSlide(slide: slideModel)
-
 
68
                    }
-
 
69
                    
-
 
70
 
-
 
71
 
-
 
72
                    self.backToGallery.toggle()
-
 
73
                    
-
 
74
                    
-
 
75
               
-
 
76
                }, label: {
-
 
77
 
-
 
78
                    
-
 
79
                    Image(systemName: "chevron.backward")
-
 
80
                    .frame(width: 32, height: 32, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
-
 
81
                    .aspectRatio(contentMode: .fit)
-
 
82
                    .foregroundColor(Color("color_app_bar_foreground"))
-
 
83
                })
-
 
84
                .padding(.leading, 16)
-
 
85
                
-
 
86
                Text(self.slideTitle)
-
 
87
                .font(Font.custom(Config.FONT_NAME_REGULAR, size: Config.FONT_SIZE_APP_BAR_HEAD1 ))
-
 
88
                .foregroundColor(Color("color_app_bar_foreground"))
30
   
89
                    .padding(.leading, 4)
-
 
90
                
31
        self.slideName = slideName
91
                Spacer()
32
       
92
            }
33
       
93
            .background(Color("color_app_bar_background"))
34
 
-
 
35
 
-
 
36
    }
-
 
37
    
-
 
38
    var body: some View {
-
 
39
        GeometryReader { geometry in
-
 
40
            VStack {
-
 
41
                PDFKitRepresentedView(url!).frame(
-
 
42
                    width: geometry.size.width,
-
 
43
                    height: geometry.size.height,
-
 
44
                    alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
-
 
45
            }
-
 
46
            .background(Color("color_window_background"))
-
 
47
            .navigationBarBackButtonHidden(true)
-
 
48
            .navigationBarTitleDisplayMode(.inline)
-
 
49
            .navigationTitle(slideName)
-
 
50
            .toolbar {
94
            .edgesIgnoringSafeArea(.top)
51
                ToolbarItem(placement: .navigationBarLeading) {
-
 
52
                    Button(action: {
-
 
53
                      
-
 
Línea 54... Línea -...
54
                        self.presentationMode.wrappedValue.dismiss()
-
 
55
                        
95
            .frame(height: 50)
-
 
96
            Divider()
Línea 56... Línea 97...
56
                        
97
 
57
                    }) {
98
            GeometryReader { geometry in
58
                        HStack {
-
 
59
                            Image(systemName: "chevron.backward")
-
 
60
                                .aspectRatio(contentMode: .fit)
-
 
61
                                .foregroundColor(Color("color_app_bar_foreground"))
-
 
62
                                .background(Color("color_app_bar_background"))
99
            
Línea 63... Línea 100...
63
                        }
100
            PDFKitRepresentedView(url!)
64
                    }
101
                .frame(
65
                
102
                    width: geometry.size.width,
66
                }
-
 
67
            }
-
 
68
           
103
                    height: geometry.size.height,
69
        }
104
                    alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)