| 1 |
efrain |
1 |
//
|
|
|
2 |
// HtmlView.swift
|
|
|
3 |
// twogetskills
|
|
|
4 |
//
|
|
|
5 |
// Created by Efrain Yanez Recanatini on 4/26/22.
|
|
|
6 |
//
|
|
|
7 |
|
|
|
8 |
import Foundation
|
|
|
9 |
|
|
|
10 |
import Foundation
|
|
|
11 |
import SwiftUI
|
|
|
12 |
import PDFKit
|
|
|
13 |
import HTMLEntities
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
struct WebViewerView: View {
|
|
|
17 |
@EnvironmentObject private var appNavigation : AppNavigation
|
|
|
18 |
|
|
|
19 |
private var slideModel : SlideModel
|
|
|
20 |
private var slideTitle : String
|
|
|
21 |
private var appData = AppData.sharedInstance
|
|
|
22 |
|
|
|
23 |
init()
|
|
|
24 |
{
|
|
|
25 |
let slideDao = SlideDao.sharedInstance
|
|
|
26 |
self.slideModel = slideDao.selectByUuid(uuid: appData.slideUuidActive)
|
|
|
27 |
|
|
|
28 |
if self.slideModel.name.count > Constants.APP_BAR_TITLE_MAX_LENGTH {
|
|
|
29 |
slideTitle = String(Array(self.slideModel.name)[0...Constants.APP_BAR_TITLE_MAX_LENGTH]) + "..."
|
|
|
30 |
} else {
|
|
|
31 |
slideTitle = self.slideModel.name
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
//print("Viewer WEB: \(slideModel.description) ")
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
var body: some View {
|
|
|
38 |
VStack(spacing: 0)
|
|
|
39 |
{
|
|
|
40 |
|
|
|
41 |
HStack {
|
|
|
42 |
Button(action: {
|
|
|
43 |
let dataService = DataService()
|
|
|
44 |
dataService.completeSlide(slide: slideModel)
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
appNavigation.pageActive = .home
|
|
|
48 |
|
|
|
49 |
}, label: {
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
Image(systemName: "chevron.backward")
|
|
|
53 |
.frame(width: 32, height: 32, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
|
|
54 |
.aspectRatio(contentMode: .fit)
|
|
|
55 |
.foregroundColor(Color("color_app_bar_foreground"))
|
|
|
56 |
})
|
|
|
57 |
.padding(.leading, 16)
|
|
|
58 |
|
|
|
59 |
Text(slideTitle)
|
|
|
60 |
.font(Font.custom(Config.FONT_NAME_REGULAR, size: Config.FONT_SIZE_APP_BAR_HEAD1 ))
|
|
|
61 |
.foregroundColor(Color("color_app_bar_foreground"))
|
|
|
62 |
.padding(.leading, 4)
|
|
|
63 |
|
|
|
64 |
Spacer()
|
|
|
65 |
}
|
|
|
66 |
.background(Color("color_app_bar_background"))
|
|
|
67 |
.edgesIgnoringSafeArea(.top)
|
|
|
68 |
.frame(height: 50)
|
|
|
69 |
Divider()
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
GeometryReader { geometry in
|
|
|
73 |
|
|
|
74 |
TextHtmlView(content: slideModel.description)
|
|
|
75 |
.frame(
|
|
|
76 |
width: geometry.size.width,
|
|
|
77 |
height: geometry.size.height,
|
|
|
78 |
alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
|
|
79 |
.padding(10)
|
|
|
80 |
.border(/*@START_MENU_TOKEN@*/Color.black/*@END_MENU_TOKEN@*/, width: /*@START_MENU_TOKEN@*/1/*@END_MENU_TOKEN@*/)
|
|
|
81 |
}
|
|
|
82 |
}.background(Color("color_window_background"))
|
|
|
83 |
}
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
struct WebViewerView_Previews: PreviewProvider {
|
|
|
88 |
static var previews: some View {
|
|
|
89 |
WebViewerView()
|
|
|
90 |
}
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
|