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

マニュアル対応

parent 2ccbdddd
...@@ -10,25 +10,30 @@ import PDFKit ...@@ -10,25 +10,30 @@ import PDFKit
struct MenuManualECDISView: View { struct MenuManualECDISView: View {
@State var isAlert: Bool = false @State var isAlert: Bool = false
@State var isLoadingView: Bool = false
@Binding var path : [MenuPath] @Binding var path : [MenuPath]
var body: some View { var body: some View {
VStack{ VStack{
MenuTitleView(path: $path, title: MenuPath.ManualECDIS.title) MenuTitleView(path: $path, title: MenuPath.ManualECDIS.title)
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualECDISBasic.fileIdntifer}).first{ if !isLoadingView {
ManualDownloadButton(manualType: .ManualECDISBasic, downloadUrl: manual.path,version: Preferences.ECDISBasicManualVer, newVersion: manual.name, isAlert: $isAlert){ if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualECDISBasic.fileIdntifer}).first{
path.append(.ManualECDISBasic) ManualDownloadButton(manualType: .ManualECDISBasic, downloadUrl: manual.path,version: Preferences.ECDISBasicManualVer, newVersion: manual.name, isAlert: $isAlert, isLoadingView: $isLoadingView){
Preferences.ECDISBasicManualVer = manual.name path.append(.ManualECDISBasic)
Preferences.ECDISBasicManualVer = manual.name
}
} }
}
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualECDISFunction.fileIdntifer}).first{
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, isLoadingView: $isLoadingView){
ManualDownloadButton(manualType: .ManualECDISFunction, downloadUrl: manual.path,version: Preferences.ECDISFunctionManualVer, newVersion: manual.name, isAlert: $isAlert){ path.append(.ManualECDISFunction)
path.append(.ManualECDISFunction) Preferences.ECDISFunctionManualVer = manual.name
Preferences.ECDISFunctionManualVer = manual.name }
} }
} else {
Text("Loading...").padding()
ProgressView()
} }
Spacer() Spacer()
} }
.background(ColorSet.BackgroundPrimary.color) .background(ColorSet.BackgroundPrimary.color)
......
...@@ -10,24 +10,29 @@ import PDFKit ...@@ -10,24 +10,29 @@ import PDFKit
struct MenuManualRADARView: View { struct MenuManualRADARView: View {
@State var isAlert: Bool = false @State var isAlert: Bool = false
@State var isLoadingView: Bool = false
@Binding var path : [MenuPath] @Binding var path : [MenuPath]
var body: some View { var body: some View {
VStack{ VStack{
MenuTitleView(path: $path, title: MenuPath.ManualRADAR.title) MenuTitleView(path: $path, title: MenuPath.ManualRADAR.title)
if !isLoadingView {
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualRADARBasic.fileIdntifer}).first{ 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) path.append(.ManualRADARBasic)
Preferences.RADARBasicManualVer = manual.name Preferences.RADARBasicManualVer = manual.name
}
} }
}
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualRADARFunction.fileIdntifer}).first{
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, isLoadingView: $isLoadingView){
ManualDownloadButton(manualType: .ManualRADARFunction, downloadUrl: manual.path,version: Preferences.RADARFunctionManualVer, newVersion: manual.name, isAlert: $isAlert){ path.append(.ManualRADARFunction)
path.append(.ManualRADARFunction) Preferences.RADARFunctionManualVer = manual.name
Preferences.RADARFunctionManualVer = manual.name }
} }
} else {
Text("Loading...").padding()
ProgressView()
} }
Spacer() Spacer()
......
...@@ -10,49 +10,55 @@ import PDFKit ...@@ -10,49 +10,55 @@ import PDFKit
struct MenuManualView: View { struct MenuManualView: View {
@State var isAlert: Bool = false @State var isAlert: Bool = false
@State var isLoadingView: Bool = false
@Binding var path : [MenuPath] @Binding var path : [MenuPath]
var body: some View { var body: some View {
VStack{ VStack{
MenuTitleView(path: $path, title: MenuPath.Manual.title) MenuTitleView(path: $path, title: MenuPath.Manual.title)
Button{ if !isLoadingView {
path.append(.ManualECDIS) Button{
}label: { path.append(.ManualECDIS)
MenuContentView(content: .ManualECDIS) }label: {
} MenuContentView(content: .ManualECDIS)
Button{
path.append(.ManualRADAR)
}label: {
MenuContentView(content: .ManualRADAR)
}
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){
path.append(.ManualAIS)
Preferences.AISManualVer = manual.name
} }
}
Button{
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualInmalsatC.fileIdntifer}).first{ path.append(.ManualRADAR)
ManualDownloadButton(manualType: .ManualInmalsatC, downloadUrl: manual.path,version: Preferences.InmalsatCManualVer, newVersion: manual.name, isAlert: $isAlert){ }label: {
path.append(.ManualInmalsatC) MenuContentView(content: .ManualRADAR)
Preferences.InmalsatCManualVer = manual.name
} }
}
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualAIS.fileIdntifer}).first{
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualInternationalVHF.fileIdntifer}).first{ ManualDownloadButton(manualType: .ManualAIS, downloadUrl: manual.path,version: Preferences.AISManualVer, newVersion: manual.name, isAlert: $isAlert, isLoadingView: $isLoadingView){
ManualDownloadButton(manualType: .ManualInternationalVHF, downloadUrl: manual.path,version: Preferences.InternationalVHFManualVer, newVersion: manual.name, isAlert: $isAlert){ path.append(.ManualAIS)
path.append(.ManualInternationalVHF) Preferences.AISManualVer = manual.name
Preferences.InternationalVHFManualVer = 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, isLoadingView: $isLoadingView){
path.append(.ManualInmalsatC)
Preferences.InmalsatCManualVer = manual.name
}
} }
}
if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualVDR.fileIdntifer}).first{ if let manual = SharingData.my.manualUrls.filter({$0.identifer == MenuPath.ManualInternationalVHF.fileIdntifer}).first{
ManualDownloadButton(manualType: .ManualVDR, downloadUrl: manual.path,version: Preferences.VDRManualVer, newVersion: manual.name, isAlert: $isAlert){ ManualDownloadButton(manualType: .ManualInternationalVHF, downloadUrl: manual.path,version: Preferences.InternationalVHFManualVer, newVersion: manual.name, isAlert: $isAlert, isLoadingView: $isLoadingView){
path.append(.ManualVDR) path.append(.ManualInternationalVHF)
Preferences.VDRManualVer = manual.name 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, isLoadingView: $isLoadingView){
path.append(.ManualVDR)
Preferences.VDRManualVer = manual.name
}
}
} else {
Text("Loading...").padding()
ProgressView()
} }
Spacer() Spacer()
...@@ -78,7 +84,8 @@ struct ManualDownloadButton: View { ...@@ -78,7 +84,8 @@ struct ManualDownloadButton: View {
var newVersion: String var newVersion: String
@Binding var isAlert: Bool @Binding var isAlert: Bool
@Binding var isLoadingView: Bool
var complition: () -> Void var complition: () -> Void
var body: some View { var body: some View {
...@@ -87,11 +94,13 @@ struct ManualDownloadButton: View { ...@@ -87,11 +94,13 @@ struct ManualDownloadButton: View {
complition() complition()
}else{ }else{
Task { Task {
isLoadingView = true
if await PDFDownloadManager.main.downloadFile(urlString: downloadUrl, manualType.fileSavePath!){ if await PDFDownloadManager.main.downloadFile(urlString: downloadUrl, manualType.fileSavePath!){
complition() complition()
}else{ }else{
isAlert = true isAlert = true
} }
isLoadingView = false
} }
} }
}label: { }label: {
......
...@@ -57,7 +57,6 @@ struct SailassistApp: App { ...@@ -57,7 +57,6 @@ struct SailassistApp: App {
}) })
.environmentObject(locationViewModel) .environmentObject(locationViewModel)
} }
} }
} }
...@@ -72,7 +71,11 @@ struct SailassistApp: App { ...@@ -72,7 +71,11 @@ struct SailassistApp: App {
print(debug: String(data: resultData, encoding: .utf8)) print(debug: String(data: resultData, encoding: .utf8))
let serverSession = ServerSession() let serverSession = ServerSession()
let resjson = serverSession.fromJSON(resultData: resultData, resltType: [ResGetManualUrl].self) 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 SharingData.my.manualUrls = res
} }
case .failure(let errorCode): 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