Commit 4dd65f76 authored by shigemi miura's avatar shigemi miura

マニュアル対応

parent 2ccbdddd
......@@ -10,25 +10,30 @@ import PDFKit
struct MenuManualECDISView: View {
@State var isAlert: Bool = false
@State var isLoadingView: Bool = false
@Binding var path : [MenuPath]
var body: some View {
VStack{
MenuTitleView(path: $path, title: MenuPath.ManualECDIS.title)
if !isLoadingView {
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualECDISBasic.fileIdntifer}).first{
ManualDownloadButton(manualType: .ManualECDISBasic, downloadUrl: manual.path,version: Preferences.ECDISBasicManualVer, newVersion: manual.name, isAlert: $isAlert){
ManualDownloadButton(manualType: .ManualECDISBasic, downloadUrl: manual.path,version: Preferences.ECDISBasicManualVer, newVersion: manual.name, isAlert: $isAlert, isLoadingView: $isLoadingView){
path.append(.ManualECDISBasic)
Preferences.ECDISBasicManualVer = manual.name
}
}
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualECDISFunction.fileIdntifer}).first{
ManualDownloadButton(manualType: .ManualECDISFunction, downloadUrl: manual.path,version: Preferences.ECDISFunctionManualVer, newVersion: manual.name, isAlert: $isAlert){
ManualDownloadButton(manualType: .ManualECDISFunction, downloadUrl: manual.path,version: Preferences.ECDISFunctionManualVer, newVersion: manual.name, isAlert: $isAlert, isLoadingView: $isLoadingView){
path.append(.ManualECDISFunction)
Preferences.ECDISFunctionManualVer = manual.name
}
}
} else {
Text("Loading...").padding()
ProgressView()
}
Spacer()
}
.background(ColorSet.BackgroundPrimary.color)
......
......@@ -10,25 +10,30 @@ import PDFKit
struct MenuManualRADARView: View {
@State var isAlert: Bool = false
@State var isLoadingView: Bool = false
@Binding var path : [MenuPath]
var body: some View {
VStack{
MenuTitleView(path: $path, title: MenuPath.ManualRADAR.title)
if !isLoadingView {
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualRADARBasic.fileIdntifer}).first{
ManualDownloadButton(manualType: .ManualRADARBasic, downloadUrl: manual.path,version: Preferences.RADARBasicManualVer, newVersion: manual.name, isAlert: $isAlert){
ManualDownloadButton(manualType: .ManualRADARBasic, downloadUrl: manual.path,version: Preferences.RADARBasicManualVer, newVersion: manual.name, isAlert: $isAlert, isLoadingView: $isLoadingView){
path.append(.ManualRADARBasic)
Preferences.RADARBasicManualVer = manual.name
}
}
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualRADARFunction.fileIdntifer}).first{
ManualDownloadButton(manualType: .ManualRADARFunction, downloadUrl: manual.path,version: Preferences.RADARFunctionManualVer, newVersion: manual.name, isAlert: $isAlert){
ManualDownloadButton(manualType: .ManualRADARFunction, downloadUrl: manual.path,version: Preferences.RADARFunctionManualVer, newVersion: manual.name, isAlert: $isAlert, isLoadingView: $isLoadingView){
path.append(.ManualRADARFunction)
Preferences.RADARFunctionManualVer = manual.name
}
}
} else {
Text("Loading...").padding()
ProgressView()
}
Spacer()
}
......
......@@ -10,11 +10,13 @@ import PDFKit
struct MenuManualView: View {
@State var isAlert: Bool = false
@State var isLoadingView: Bool = false
@Binding var path : [MenuPath]
var body: some View {
VStack{
MenuTitleView(path: $path, title: MenuPath.Manual.title)
if !isLoadingView {
Button{
path.append(.ManualECDIS)
}label: {
......@@ -28,32 +30,36 @@ struct MenuManualView: View {
}
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualAIS.fileIdntifer}).first{
ManualDownloadButton(manualType: .ManualAIS, downloadUrl: manual.path,version: Preferences.AISManualVer, newVersion: manual.name, isAlert: $isAlert){
ManualDownloadButton(manualType: .ManualAIS, downloadUrl: manual.path,version: Preferences.AISManualVer, newVersion: manual.name, isAlert: $isAlert, isLoadingView: $isLoadingView){
path.append(.ManualAIS)
Preferences.AISManualVer = manual.name
}
}
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualInmalsatC.fileIdntifer}).first{
ManualDownloadButton(manualType: .ManualInmalsatC, downloadUrl: manual.path,version: Preferences.InmalsatCManualVer, newVersion: manual.name, isAlert: $isAlert){
ManualDownloadButton(manualType: .ManualInmalsatC, downloadUrl: manual.path,version: Preferences.InmalsatCManualVer, newVersion: manual.name, isAlert: $isAlert, isLoadingView: $isLoadingView){
path.append(.ManualInmalsatC)
Preferences.InmalsatCManualVer = manual.name
}
}
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualInternationalVHF.fileIdntifer}).first{
ManualDownloadButton(manualType: .ManualInternationalVHF, downloadUrl: manual.path,version: Preferences.InternationalVHFManualVer, newVersion: manual.name, isAlert: $isAlert){
ManualDownloadButton(manualType: .ManualInternationalVHF, downloadUrl: manual.path,version: Preferences.InternationalVHFManualVer, newVersion: manual.name, isAlert: $isAlert, isLoadingView: $isLoadingView){
path.append(.ManualInternationalVHF)
Preferences.InternationalVHFManualVer = manual.name
}
}
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualVDR.fileIdntifer}).first{
ManualDownloadButton(manualType: .ManualVDR, downloadUrl: manual.path,version: Preferences.VDRManualVer, newVersion: manual.name, isAlert: $isAlert){
ManualDownloadButton(manualType: .ManualVDR, downloadUrl: manual.path,version: Preferences.VDRManualVer, newVersion: manual.name, isAlert: $isAlert, isLoadingView: $isLoadingView){
path.append(.ManualVDR)
Preferences.VDRManualVer = manual.name
}
}
} else {
Text("Loading...").padding()
ProgressView()
}
Spacer()
}
......@@ -78,6 +84,7 @@ struct ManualDownloadButton: View {
var newVersion: String
@Binding var isAlert: Bool
@Binding var isLoadingView: Bool
var complition: () -> Void
......@@ -87,11 +94,13 @@ struct ManualDownloadButton: View {
complition()
}else{
Task {
isLoadingView = true
if await PDFDownloadManager.main.downloadFile(urlString: downloadUrl, manualType.fileSavePath!){
complition()
}else{
isAlert = true
}
isLoadingView = false
}
}
}label: {
......
......@@ -57,7 +57,6 @@ struct SailassistApp: App {
})
.environmentObject(locationViewModel)
}
}
}
......@@ -72,7 +71,11 @@ struct SailassistApp: App {
print(debug: String(data: resultData, encoding: .utf8))
let serverSession = ServerSession()
let resjson = serverSession.fromJSON(resultData: resultData, resltType: [ResGetManualUrl].self)
if let res = resjson {
if var res = resjson {
for index in res.indices {
let convert = res[index].path.replacingOccurrences(of: " ", with: "%20")
res[index].path = convert
}
SharingData.my.manualUrls = res
}
case .failure(let errorCode):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment