| 1 |
efrain |
1 |
//
|
|
|
2 |
// PdfView.swift
|
|
|
3 |
// twogetskills
|
|
|
4 |
//
|
|
|
5 |
// Created by Efrain Yanez Recanatini on 4/26/22.
|
|
|
6 |
//
|
|
|
7 |
|
|
|
8 |
import Foundation
|
|
|
9 |
import SwiftUI
|
|
|
10 |
import PDFKit
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
struct PdfViewerView: View {
|
|
|
14 |
@Environment(\.presentationMode)
|
|
|
15 |
var presentationMode: Binding
|
|
|
16 |
|
|
|
17 |
//@State private var backToGallery : Bool = false
|
|
|
18 |
@State private var isCompleted : Bool = false
|
|
|
19 |
|
|
|
20 |
private var url : URL?
|
|
|
21 |
|
|
|
22 |
private var slideName : String;
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
private let colorBackgroundTopic = UIColor(hex: Config.COLOR_BACKGROUND_TOPIC)
|
|
|
26 |
|
|
|
27 |
private let colorAppTextView = UIColor(hex: Config.COLOR_APP_TEXT_VIEW_TITLE)
|
|
|
28 |
|
|
|
29 |
private let colorAppBackground = UIColor(hex: Config.COLOR_APP_BAR)
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
init(url : String, slideName : String)
|
|
|
33 |
{
|
|
|
34 |
self.url = URL(string: url)
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
self.slideName = slideName
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
var body: some View {
|
|
|
45 |
GeometryReader { geometry in
|
|
|
46 |
VStack {
|
|
|
47 |
PDFKitRepresentedView(url!).frame(
|
|
|
48 |
width: geometry.size.width,
|
|
|
49 |
height: geometry.size.height,
|
|
|
50 |
alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
|
|
51 |
}
|
|
|
52 |
.background(Color(colorBackgroundTopic ?? .gray))
|
|
|
53 |
.navigationBarBackButtonHidden(true)
|
|
|
54 |
.navigationBarTitleDisplayMode(.inline)
|
|
|
55 |
.navigationTitle(slideName)
|
|
|
56 |
.toolbar {
|
|
|
57 |
ToolbarItem(placement: .navigationBarLeading) {
|
|
|
58 |
Button(action: {
|
|
|
59 |
|
|
|
60 |
self.presentationMode.wrappedValue.dismiss()
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
}) {
|
|
|
64 |
HStack {
|
|
|
65 |
Image(systemName: "chevron.backward")
|
|
|
66 |
.aspectRatio(contentMode: .fit)
|
|
|
67 |
.foregroundColor(Color( colorAppTextView ?? .systemBlue))
|
|
|
68 |
.background(Color(colorAppBackground ?? .systemBlue))
|
|
|
69 |
}
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
struct PdfViewerView_Previews: PreviewProvider {
|
|
|
85 |
static var previews: some View {
|
|
|
86 |
PdfViewerView(
|
|
|
87 |
url : "https://cesams.com/wp-content/uploads/2021/11/Programa-Innovacion-Softskills-y-Habitos-de-Alto-Rendimiento-CESA-MS.pdf",
|
|
|
88 |
slideName: "")
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
|