Commit f1e7b24d authored by shigemi miura's avatar shigemi miura

位置情報移動

ECA中央値情報追加
parent 08eaee57
......@@ -94,6 +94,7 @@
D545FC742B09C74300F206D0 /* AlertManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D545FC732B09C74300F206D0 /* AlertManager.swift */; };
D545FC762B09C81300F206D0 /* PushNotificationTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = D545FC752B09C81300F206D0 /* PushNotificationTypes.swift */; };
D54D174B2B35137A00A0EAA5 /* LocalWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D54D174A2B35137A00A0EAA5 /* LocalWebView.swift */; };
D54D17512B35923400A0EAA5 /* GetManualUrl.swift in Sources */ = {isa = PBXBuildFile; fileRef = D54D17502B35923400A0EAA5 /* GetManualUrl.swift */; };
D55135202B15B030007B66B1 /* SetEcaArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = D551351F2B15B030007B66B1 /* SetEcaArea.swift */; };
D55135222B15C062007B66B1 /* GetEcaList.swift in Sources */ = {isa = PBXBuildFile; fileRef = D55135212B15C062007B66B1 /* GetEcaList.swift */; };
D55135242B15C3BF007B66B1 /* DeleteEcaArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = D55135232B15C3BF007B66B1 /* DeleteEcaArea.swift */; };
......@@ -251,6 +252,7 @@
D545FC732B09C74300F206D0 /* AlertManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AlertManager.swift; path = Sailassist/VoiceManager/AlertManager.swift; sourceTree = SOURCE_ROOT; };
D545FC752B09C81300F206D0 /* PushNotificationTypes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PushNotificationTypes.swift; path = Sailassist/DataSource/PushNotificationTypes.swift; sourceTree = SOURCE_ROOT; };
D54D174A2B35137A00A0EAA5 /* LocalWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = LocalWebView.swift; path = Sailassist/Menu/View/LocalWebView.swift; sourceTree = SOURCE_ROOT; };
D54D17502B35923400A0EAA5 /* GetManualUrl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = GetManualUrl.swift; path = Sailassist/Menu/GetManualUrl.swift; sourceTree = SOURCE_ROOT; };
D551351F2B15B030007B66B1 /* SetEcaArea.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SetEcaArea.swift; path = Sailassist/ECA/SetEcaArea.swift; sourceTree = SOURCE_ROOT; };
D55135212B15C062007B66B1 /* GetEcaList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = GetEcaList.swift; path = Sailassist/ECA/GetEcaList.swift; sourceTree = SOURCE_ROOT; };
D55135232B15C3BF007B66B1 /* DeleteEcaArea.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = DeleteEcaArea.swift; path = Sailassist/ECA/DeleteEcaArea.swift; sourceTree = SOURCE_ROOT; };
......@@ -491,6 +493,7 @@
children = (
02CE4D7D2ADE4297002E79BC /* View */,
020B98662ADD15050029DE4C /* MenuView.swift */,
D54D17502B35923400A0EAA5 /* GetManualUrl.swift */,
);
path = Menu;
sourceTree = "<group>";
......@@ -1027,6 +1030,7 @@
025C27FA2AFE119D00BADC49 /* MenuTitleView.swift in Sources */,
02CE4D892ADF62E1002E79BC /* EcaSettingView.swift in Sources */,
025F99722B2AE3AF00C9A18A /* TaskViewModel.swift in Sources */,
D54D17512B35923400A0EAA5 /* GetManualUrl.swift in Sources */,
D5258CA32B036CC500365276 /* SessionGetMessage.swift in Sources */,
D5258C992B0334BF00365276 /* SessionShipStatus.swift in Sources */,
02CE4D872ADF62A7002E79BC /* EcaListView.swift in Sources */,
......@@ -1226,7 +1230,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.9;
MARKETING_VERSION = 0.9.4;
OTHER_SWIFT_FLAGS = "-D CANARY -D COCOAPODS";
PRODUCT_BUNDLE_IDENTIFIER = com.jrc.sailassist.canary;
PRODUCT_NAME = "Sail Assist";
......@@ -1269,7 +1273,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.9;
MARKETING_VERSION = 0.9.4;
OTHER_SWIFT_FLAGS = "-D COCOAPODS";
PRODUCT_BUNDLE_IDENTIFIER = com.jrc.sailassist;
PRODUCT_NAME = "Sail Assist";
......@@ -1455,7 +1459,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.9;
MARKETING_VERSION = 0.9.4;
OTHER_SWIFT_FLAGS = "-D QC -D COCOAPODS";
PRODUCT_BUNDLE_IDENTIFIER = com.jrc.sailassist.qc;
PRODUCT_NAME = "Sail Assist";
......
......@@ -4309,31 +4309,33 @@ class EcaCoordinatesTable : NSObject {
struct ecaData {
var id: Int
var name: String
var centerPosition: CLLocationCoordinate2D
var zoomLevel: CGFloat
var table: [CLLocationCoordinate2D]
}
var ecaDataTable:[ecaData] = [
ecaData(id: 1, name: "Iceland", table: iceland),
ecaData(id: 11, name: "North American Atlantic Coasts", table: northAmericanAtlanticCoasts),
ecaData(id: 12, name: "North American Hawai", table: northAmericanHawai),
ecaData(id: 13, name: "North American Pacific Coasts", table: northAmericanPacificCoasts),
ecaData(id: 21, name: "North Sea 1", table: northSea1),
ecaData(id: 22, name: "North Sea 2", table: northSea2),
ecaData(id: 31, name: "Unites States Caribbean", table: unitesStatesCaribbean),
ecaData(id: 41, name: "China Shore", table: chinaShore),
ecaData(id: 42, name: "China Hainan", table: chinaHainan),
ecaData(id: 43, name: "China Yangtzi Shuifu,Yunnan", table: chinaYangtziShuifuYunnan),
ecaData(id: 44, name: "China Yangtzi Liuhekou,Jiangsu1", table: chinaYangtziLiuhekouJiangsu1),
ecaData(id: 45, name: "China Yangtzi Liuhekou,Jiangsu2", table: chinaYangtziLiuhekouJiangsu2),
ecaData(id: 46, name: "China Xijiang Nanning,Guangxi", table: chinaXijiangNanningGuangxi),
ecaData(id: 47, name: "China Xijiang Zhaoqing,Guangdong", table: chinaXijiangNanningGuangdong),
ecaData(id: 51, name: "Korea Incheon, PyeongtaekDangjin Port", table: incheonPyeongtaekDanjinPort),
ecaData(id: 52, name: "Korea Yeosu, Gwangyang Port", table: yeosuGwangyangPort),
ecaData(id: 53, name: "Korea Busan Port", table: koreaBusanPort),
ecaData(id: 54, name: "Korea Busan Port West", table: koreaBusanPortWest),
ecaData(id: 55, name: "Korea Ulsan Port", table: koreaUlsanPort),
ecaData(id: 61, name: "Panama Canal Atlantic Entrance", table: panamaCanalAtlanticEntrance),
ecaData(id: 62, name: "Panama Canal Pacific Entrance", table: panamaCanalPacificEntrance)
ecaData(id: 1, name: "Iceland", centerPosition: CLLocationCoordinate2D(latitude: 62.56528431, longitude: -18.48170601), zoomLevel: 4.0, table: iceland),
ecaData(id: 11, name: "North American Atlantic Coasts", centerPosition: CLLocationCoordinate2D(latitude: 17.89000000, longitude: -79.69611111), zoomLevel: 1.0, table: northAmericanAtlanticCoasts),
ecaData(id: 12, name: "North American Hawai", centerPosition: CLLocationCoordinate2D(latitude: 15.85444444, longitude: -158.32055556), zoomLevel: 4.0, table: northAmericanHawai),
ecaData(id: 13, name: "North American Pacific Coasts", centerPosition: CLLocationCoordinate2D(latitude: 37.22750000, longitude: -128.67277778), zoomLevel: 1.0, table: northAmericanPacificCoasts),
ecaData(id: 21, name: "North Sea 1", centerPosition: CLLocationCoordinate2D(latitude: 54.00000000, longitude: -4.00000000), zoomLevel: 3.0, table: northSea1),
ecaData(id: 22, name: "North Sea 2", centerPosition: CLLocationCoordinate2D(latitude: 43.50000000, longitude: -4.78333333), zoomLevel: 4.0, table: northSea2),
ecaData(id: 31, name: "Unites States Caribbean", centerPosition: CLLocationCoordinate2D(latitude: 13.37083333, longitude: -64.70083333), zoomLevel: 4.0, table: unitesStatesCaribbean),
ecaData(id: 41, name: "China Shore", centerPosition: CLLocationCoordinate2D(latitude: 12.13420000, longitude: 115.21700000), zoomLevel: 2.0, table: chinaShore),
ecaData(id: 42, name: "China Hainan", centerPosition: CLLocationCoordinate2D(latitude: 16.21260000, longitude: 110.15700000), zoomLevel: 5.0, table: chinaHainan),
ecaData(id: 43, name: "China Yangtzi Shuifu,Yunnan", centerPosition: CLLocationCoordinate2D(latitude: 28.60531667, longitude: 104.40085000), zoomLevel: 11.0, table: chinaYangtziShuifuYunnan),
ecaData(id: 44, name: "China Yangtzi Liuhekou,Jiangsu1", centerPosition: CLLocationCoordinate2D(latitude: 31.52461111, longitude: 121.37808333), zoomLevel: 10.0, table: chinaYangtziLiuhekouJiangsu1),
ecaData(id: 45, name: "China Yangtzi Liuhekou,Jiangsu2", centerPosition: CLLocationCoordinate2D(latitude: 30.20172222, longitude: 121.32094444), zoomLevel: 8.0, table: chinaYangtziLiuhekouJiangsu2),
ecaData(id: 46, name: "China Xijiang Nanning,Guangxi", centerPosition: CLLocationCoordinate2D(latitude: 22.75000000, longitude: 108.31303333), zoomLevel: 11.0, table: chinaXijiangNanningGuangxi),
ecaData(id: 47, name: "China Xijiang Zhaoqing,Guangdong", centerPosition: CLLocationCoordinate2D(latitude: 23.08005000, longitude: 112.77791667), zoomLevel: 11.0, table: chinaXijiangNanningGuangdong),
ecaData(id: 51, name: "Korea Incheon, PyeongtaekDangjin Port", centerPosition: CLLocationCoordinate2D(latitude: 36.88996667, longitude: 126.05833333), zoomLevel: 7.0, table: incheonPyeongtaekDanjinPort),
ecaData(id: 52, name: "Korea Yeosu, Gwangyang Port", centerPosition: CLLocationCoordinate2D(latitude: 34.21166667, longitude: 128.00022222), zoomLevel: 8.0, table: yeosuGwangyangPort),
ecaData(id: 53, name: "Korea Busan Port", centerPosition: CLLocationCoordinate2D(latitude: 34.81029311, longitude: 128.89994528), zoomLevel: 8.0, table: koreaBusanPort),
ecaData(id: 54, name: "Korea Busan Port West", centerPosition: CLLocationCoordinate2D(latitude: 34.82819444, longitude: 128.82208333), zoomLevel: 9.0, table: koreaBusanPortWest),
ecaData(id: 55, name: "Korea Ulsan Port", centerPosition: CLLocationCoordinate2D(latitude: 34.98933675, longitude: 129.52881635), zoomLevel: 8.0, table: koreaUlsanPort),
ecaData(id: 61, name: "Panama Canal Atlantic Entrance", centerPosition: CLLocationCoordinate2D(latitude: 7.09898818, longitude: -79.99448871), zoomLevel: 6.0, table: panamaCanalAtlanticEntrance),
ecaData(id: 62, name: "Panama Canal Pacific Entrance", centerPosition: CLLocationCoordinate2D(latitude: 6.65073570, longitude: -79.42740275), zoomLevel: 6.0, table: panamaCanalPacificEntrance)
]
func setEcaData() {
......@@ -4342,6 +4344,8 @@ class EcaCoordinatesTable : NSObject {
var reg = RegisteredEca(id: data.id, ecaName: data.name)!
reg.color = "0xFF0000" //ライン色(ARGB)
reg.points = data.table
reg.centerPosition = data.centerPosition
reg.zoomLevel = data.zoomLevel
SharingData.eca.ecaArea.updateValue(reg, forKey: data.name)
}
}
......
......@@ -39,13 +39,13 @@ class EcaTask {
let serverSession = ServerSession()
let resjson = serverSession.fromJSON(resultData: resultData, resltType: ResShipStatus.self)
if let res = resjson {
SharingData.my.speed = res.speed
SharingData.my.course = res.course
SharingData.my.heading = res.heading
SharingData.my.server = CLLocationCoordinate2D(latitude: res.lat, longitude: res.lon)
SharingData.my.dataTime = res.dataTime //2023-11-02T05:25:49.4362123Z
SharingData.location.speed = res.speed
SharingData.location.course = res.course
SharingData.location.heading = res.heading
SharingData.location.server = CLLocationCoordinate2D(latitude: res.lat, longitude: res.lon)
SharingData.location.dataTime = res.dataTime //2023-11-02T05:25:49.4362123Z
SharingData.my.setLocation()
SharingData.location.setLocation()
checkEca()
}
......@@ -58,7 +58,7 @@ class EcaTask {
func checkEca() {
let runningEca = eca.ecaArea.first(where: {(key, value) in value.isRunning == true})
if var eca = runningEca?.value {
if let location = SharingData.my.location {
if let location = SharingData.location.location {
if let distance = LocationCalculation.checkPolyline(objPos: eca.points, shipPos: location) {
//起動時に状態を設定
......
......@@ -24,8 +24,14 @@ class GetEcaList {
let serverSession = ServerSession()
let resjson = serverSession.fromJSON(resultData: resultData, resltType: [ReqTaskList].self)
if let res = resjson {
for ecaList in res {
if var value = ecaData.ecaArea[ecaList.taskName] {
var ecaAreas = ecaData.ecaArea
for ares in ecaData.ecaArea {
var eca = ares.value
eca.isEnable = false
ecaAreas.updateValue(eca, forKey: eca.name)
}
for ecaList in res{
if var value = ecaAreas[ecaList.taskName]{
value.isEnable = true
value.swNotice = ecaList.noticeRange
value.swStart = ecaList.startRange
......@@ -37,8 +43,11 @@ class GetEcaList {
value.isRunning = false
value.status = EcaState.register
}
ecaData.setEcaArea(key: ecaList.taskName, value: value)
ecaAreas.updateValue(value, forKey: ecaList.taskName)
}
}
for ares in ecaAreas{
ecaData.setEcaArea(key: ares.value.name, value: ares.value)
}
}
case .failure(let errorCode):
......
......@@ -40,6 +40,8 @@ struct RegisteredEca {
var datetime: String = "" //時刻(UTC ISO8601準拠)
var color: String = "" //ライン色(ARGB)
var width: Int = 1 //ライン幅
var centerPosition: CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0)
var zoomLevel: CGFloat = 11.0
var points: [CLLocationCoordinate2D] = []
init?(id: Int, ecaName: String ) {
......
......@@ -76,8 +76,8 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
print(debug: "called locationManager")
lastSeenLocation = newLocation
let targetCoordinate : CLLocationCoordinate2D = lastSeenLocation!.coordinate
SharingData.my.gps = targetCoordinate
SharingData.my.setLocation()
SharingData.location.gps = targetCoordinate
SharingData.location.setLocation()
if Preferences.LocationType == 0 {
ecaTask.checkEca()
......
......@@ -22,7 +22,7 @@ enum Policy: String, Hashable{
}
struct AboutAppView: View {
// @State var policy: Policy = .TermsOfUse
@State var policy: Policy = .TermsOfUse
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
var body: some View {
......@@ -67,7 +67,7 @@ struct AboutAppView: View {
HStack {
NavigationLink {
LocalWebView()
LocalWebView(policy: .constant(.TermsOfUse))
} label: {
Text("Terms Of Use")
.font(FontStyle.EmphasisText.font)
......@@ -85,8 +85,7 @@ struct AboutAppView: View {
HStack {
NavigationLink {
// policy = PrivacyStatement
LocalWebView()
LocalWebView(policy: .constant(.PrivacyStatement))
} label: {
Text("Privacy Statement")
.font(FontStyle.EmphasisText.font)
......@@ -120,6 +119,7 @@ struct AboutAppView: View {
.padding(.top, 17)
VStack(spacing: 30) {
Link("https://github.com/Azure/azure-notificationhubs-ios/blob/main/LICENSE", destination: URL(string: HttpRequestType.ApachLicens.rawValue)!)
}
.padding(.top, 2)
......
......@@ -136,10 +136,13 @@ struct LoginView: View {
.fullScreenCover(isPresented: $scannerViewModel.isShowing, onDismiss: {LoginCheckQR()}, content: {
QRReadView(viewMode: .constant(.SelectType), viewModel: scannerViewModel)
})
.onAppear() {
.onAppear(perform: {
LoginCheck()
let manual = GetManualUrl()
manual.start()
selectedTabModel.isLocationAlert = locationViewModel.requestPermission()
}
})
.preferredColorScheme(.dark)
}
}
......@@ -190,8 +193,8 @@ struct LoginView: View {
Preferences.lastLoginDate_Int64 = DateTextLib.Date2UnixTime(date: Date())
viewMode = .InputUserName
// let ecaArea = EcaArea()
// ecaArea.start()
// let ecaArea = EcaArea()
// ecaArea.start()
timer = Timer.scheduledTimer(withTimeInterval: TimerInterval, repeats: true) { _ in
print(debug: "called timer")
......@@ -250,8 +253,8 @@ struct LoginView: View {
Preferences.lastLoginDate_Int64 = DateTextLib.Date2UnixTime(date: Date())
isLogin = true
// let ecaArea = EcaArea()
// ecaArea.start()
// let ecaArea = EcaArea()
// ecaArea.start()
timer = Timer.scheduledTimer(withTimeInterval: TimerInterval, repeats: true) { _ in
print(debug: "called timer")
......
......@@ -120,6 +120,9 @@ struct InputUserNameView: View {
isLogin = true
isAlert = false
let manual = GetManualUrl()
manual.start()
case .failure(let errorCode):
print(debug: errorCode)
isProgressView = false
......
......@@ -12,7 +12,7 @@ import UIKit
struct MapRepresentable: UIViewControllerRepresentable{
@ObservedObject var ecaData = SharingData.eca
@ObservedObject var my = SharingData.my
@ObservedObject var location = SharingData.location
@ObservedObject var map = SharingData.map
@ObservedObject var pushHistory = SharingData.pushHistory
......@@ -30,7 +30,7 @@ struct MapRepresentable: UIViewControllerRepresentable{
}
if let focusEcaName = ecaData.focusEca, let focusEca = ecaData.ecaArea[focusEcaName]{
mapVC.updateCamera(location: focusEca.points.first)
mapVC.updateCamera(location: focusEca.centerPosition, zoomlevel: focusEca.zoomLevel)
mapVC.updateOneTimeEca(eca: focusEca.points)
//5秒後削除
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
......@@ -45,13 +45,13 @@ struct MapRepresentable: UIViewControllerRepresentable{
if let focusPushHistoryId = pushHistory.focusPushHistory, let focusPushHistory = pushHistory.pushHistoryData[focusPushHistoryId]{
if let position = focusPushHistory.position {
if let latitude = position.lat, let longitude = position.lon {
mapVC.updateCamera(location: CLLocationCoordinate2D(latitude: latitude, longitude: longitude))
mapVC.updateCamera(location: CLLocationCoordinate2D(latitude: latitude, longitude: longitude), zoomlevel: nil)
}
}
}
if let mylocation = my.location {
mapVC.updateOwnShip(location: mylocation, bearing: my.heading)
if let mylocation = location.location {
mapVC.updateOwnShip(location: mylocation, bearing: location.heading)
if let ecaArea = ecaArea{
mapVC.updateEcaSwitchingLine(center: mylocation, notice: ecaArea.swNotice, start: ecaArea.swStart, finish: ecaArea.swFinish)
......@@ -144,7 +144,7 @@ class MapViewController : UIViewController{
try! mapView.mapboxMap.style.addSource(ecaLine.source, id: ecaLine.sourceId)
try? mapView.mapboxMap.style.addLayer(ecaLineLayer)
let oneTimeEcaLineString = LineString([LocationCoordinate2D(latitude: 0, longitude: 0)])
_ = LineString([LocationCoordinate2D(latitude: 0, longitude: 0)])
let oneTimeEcaLinefeature = Feature(geometry: ecaLineString)
oneTimeEca.source.data = .feature(oneTimeEcaLinefeature)
var oneTimeEcaLayer = LineLayer(id: oneTimeEca.layerId)
......@@ -221,12 +221,16 @@ class MapViewController : UIViewController{
}
///カメラ
func updateCamera(location: CLLocationCoordinate2D?){
func updateCamera(location: CLLocationCoordinate2D?, zoomlevel: CGFloat?){
if let level = zoomlevel {
self.mapView.camera.ease(to: CameraOptions(center: location, zoom: zoomlevel), duration: 1)
} else {
self.mapView.camera.ease(to: CameraOptions(center: location), duration: 1)
if let eca = SharingData.eca.focusEca {
}
if SharingData.eca.focusEca != nil {
SharingData.eca.focusEca = nil
}
if let push = SharingData.pushHistory.focusPushHistory {
if SharingData.pushHistory.focusPushHistory != nil {
SharingData.pushHistory.focusPushHistory = nil
}
}
......
......@@ -39,7 +39,7 @@ struct MapTaskView: View {
taskViewModel.viewMode = .SwitchingMenu
taskViewModel.isShowSettingView = false
if var eca = SharingData.eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first{
if var eca = SharingData.eca.ecaArea.map({ $0.1 }).filter({ $0.isRunning }).first{
eca.status = .noticePass
// SharingData.eca.editEcaArea(key: eca.name, value: eca)
SharingData.eca.isShowEcaAlert = true
......@@ -94,7 +94,7 @@ struct MapTaskView: View {
EcaCoordinatesTable().setEcaData()
}
.alert("", isPresented: $eca.isShowEcaAlert) {
if let ecaArea = eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first{
if let ecaArea = eca.ecaArea.map({ $0.1 }).filter({ $0.isRunning }).first{
if SharingData.my.ecaStatus == .finishPass{
Button("Yes"){
var newData = ecaArea
......@@ -116,7 +116,7 @@ struct MapTaskView: View {
}
}
} message: {
if let ecaArea = eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first{
if let ecaArea = eca.ecaArea.map({ $0.1 }).filter({ $0.isRunning }).first{
if let status = SharingData.my.ecaStatus {
switch status {
case .noticePass:
......
......@@ -26,8 +26,9 @@ struct TaskSwitchingMenuView: View {
HStack {
//ECA開始・終了ボタン
Button {
for runningEca in ecaData.ecaArea.map{ $0.1 }.filter{ $0.isRunning }{
for runningEca in ecaData.ecaArea.map({ $0.1 }).filter({ $0.isRunning }){
taskViewModel.edittingEcaArea = runningEca
taskViewModel.ecaName = runningEca.name
isEcaAlert = true
ecaAlertType = .ecaRunningStop
}
......@@ -61,6 +62,7 @@ struct TaskSwitchingMenuView: View {
Button{
taskViewModel.edittingEcaArea = eca
taskViewModel.ecaName = eca.name
taskViewModel.isShowSettingView = true
} label: {
Text("Edit Notice Setting")
......@@ -68,6 +70,7 @@ struct TaskSwitchingMenuView: View {
Button{
taskViewModel.edittingEcaArea = eca
taskViewModel.ecaName = eca.name
isEcaAlert = true
ecaAlertType = .ecaDelete
} label: {
......@@ -83,7 +86,7 @@ struct TaskSwitchingMenuView: View {
switch ecaAlertType {
case .ecaDelete:
return Alert(title: Text("Delete"),
message: Text("Do you delete " + eca.name + "?"),
message: Text("Do you delete " + taskViewModel.ecaName + "?"),
primaryButton: .default(Text("No")),
secondaryButton: .cancel(Text("Yes"), action: {
if let ecaArea = taskViewModel.edittingEcaArea {
......@@ -98,7 +101,7 @@ struct TaskSwitchingMenuView: View {
}))
case .ecaRunningStop:
return Alert(title: Text("Stop"),
message: Text("Do you want to stop " + eca.name + "?"),
message: Text("Do you want to stop " + taskViewModel.ecaName + "?"),
primaryButton: .default(Text("Cancel")),
secondaryButton: .cancel(Text("Stop"), action: {
if let ecaArea = taskViewModel.edittingEcaArea {
......
......@@ -10,5 +10,6 @@ import Foundation
class TaskViewModel: ObservableObject{
@Published var viewMode: TaskViewMode = .SwitchingMenu
@Published var edittingEcaArea: RegisteredEca? = nil
@Published var ecaName: String = ""
@Published var isShowSettingView : Bool = false
}
//
// GetManualUrl.swift
// Sailassist
//
// Created by 三浦薫巳 on 2023/12/22.
//
import Foundation
class GetManualUrl {
var sessionGetManualUrl = SessionGetManualUrl()
func start() {
print(debug: "called")
sessionGetManualUrl.getManualUrl { response in
print(debug: "called")
switch response {
case .success(let resultData):
print(debug: String(data: resultData, encoding: .utf8) as Any)
let serverSession = ServerSession()
let resjson = serverSession.fromJSON(resultData: resultData, resltType: [ResGetManualUrl].self)
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):
print(debug: errorCode)
break
}
}
}
}
......@@ -26,8 +26,6 @@ enum MenuPath: String, Hashable{
case GpsSelect
case Help
case AboutApp
case TermsOfUse
case PrivacyStatement
case ContactUs
case SignOut
......@@ -65,10 +63,6 @@ enum MenuPath: String, Hashable{
"Help"
case .AboutApp:
"About this App"
case .TermsOfUse:
"Terms Of Use"
case .PrivacyStatement:
"Privacy Statement"
case .ContactUs:
"Contact Us"
case .SignOut:
......@@ -186,14 +180,6 @@ struct MenuView: View {
}else if goto == .AboutApp{
MenuAboutAppView(path: $path)
.navigationBarHidden(true)
}else if goto == .TermsOfUse{
if let htmlPath = Bundle.main.path(forResource: "TermsView", ofType: "html") {
WebView(isLoading: .constant(false), url: htmlPath)
}
}else if goto == .PrivacyStatement{
if let htmlPath = Bundle.main.path(forResource: "PrivacyView", ofType: "html") {
WebView(isLoading: .constant(false), url: htmlPath)
}
}else{
VStack(spacing: 0) {
MenuTitleView(path: $path, title: goto.title)
......
......@@ -8,12 +8,18 @@
import SwiftUI
struct LocalWebView: View {
// @Binding var policy: Policy
@Binding var policy: Policy
var body: some View {
VStack{
if policy == .TermsOfUse {
if let htmlPath = Bundle.main.path(forResource: "TermsView", ofType: "html") {
WebView(isLoading: .constant(false), url: htmlPath)
}
} else {
if let htmlPath = Bundle.main.path(forResource: "PrivacyView", ofType: "html") {
WebView(isLoading: .constant(false), url: htmlPath)
}
}
Spacer()
}
......@@ -22,5 +28,5 @@ struct LocalWebView: View {
}
#Preview {
LocalWebView()
LocalWebView(policy: .constant(.TermsOfUse))
}
......@@ -52,19 +52,55 @@ struct MenuAboutAppView: View {
Divider()
.background(ColorSet.LineColor04.color)
Button{
path.append(.TermsOfUse)
}label: {
MenuContentView(content: .TermsOfUse)
// Button{
// path.append(.TermsOfUse)
// }label: {
// MenuContentView(content: .TermsOfUse)
// }
// .padding(.leading, 20)
//
// Button{
// path.append(.PrivacyStatement)
// }label: {
// MenuContentView(content: .PrivacyStatement)
// }
// .padding(.leading, 20)
HStack {
NavigationLink {
LocalWebView(policy: .constant(.TermsOfUse))
} label: {
Text("Terms Of Use")
.font(FontStyle.EmphasisText.font)
.foregroundColor(ColorSet.Body.color)
Spacer()
Image("ink_01")
.resizable()
.frame(width: 22, height: 22)
}
.padding(.leading, 20)
.padding(.vertical, 17)
.padding(.horizontal, 30)
}
HStack {
NavigationLink {
LocalWebView(policy: .constant(.PrivacyStatement))
} label: {
Text("Privacy Statement")
.font(FontStyle.EmphasisText.font)
.foregroundColor(ColorSet.Body.color)
Button{
path.append(.PrivacyStatement)
}label: {
MenuContentView(content: .PrivacyStatement)
Spacer()
Image("ink_01")
.resizable()
.frame(width: 22, height: 22)
}
.padding(.vertical, 17)
.padding(.horizontal, 30)
}
.padding(.leading, 20)
Spacer().frame(height: 50)
Text("Open Source Licenses")
......
......@@ -49,7 +49,7 @@ struct MenuGpsSelectView: View {
} else {
Preferences.LocationType = 1
}
SharingData.my.setLocation()
SharingData.location.setLocation()
}label:{
HStack {
Text(content.title)
......
......@@ -12,6 +12,7 @@ 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)
......
......@@ -52,37 +52,10 @@ struct SailassistApp: App {
.preferredColorScheme(.dark)
} else {
ContentView()
.onAppear(perform: {
getManualUrl()
})
.environmentObject(locationViewModel)
}
}
}
private func getManualUrl(){
let session = SessionGetManualUrl()
session.getManualUrl { response in
print(debug: "called")
switch response {
case .success(let resultData):
print(debug: String(data: resultData, encoding: .utf8))
let serverSession = ServerSession()
let resjson = serverSession.fromJSON(resultData: resultData, resltType: [ResGetManualUrl].self)
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):
print(debug: errorCode)
break
}
}
}
}
class NotificationTags: NSObject {
......@@ -94,6 +67,7 @@ class NotificationTags: NSObject {
let bamTag = "bam-" + shipId
let taskAlertTag = "taskalert-" + shipId
let sailassistTag = "sailassist-" + shipId
// let chatTag = "chat-" + shipId
MSNotificationHub.addTags([routeTag, bamTag, taskAlertTag, sailassistTag])
}
}
......@@ -134,7 +108,6 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M
return config
}
// Push通知を受信した時(サイレントプッシュ)
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
print(debug: "called \(userInfo)")
......@@ -143,42 +116,18 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M
// Complete handling the notificationposition
completionHandler(.noData)
}
let message = GetMessage()
message.start()
let route = MonitoringRoute()
route.start()
// Push通知を受信した時(サイレントプッシュ)
func notificationHub(_ notificationHub: MSNotificationHub, didReceivePushNotification notification: MSNotificationHubMessage) {
// let title = notification.title ?? ""
// let body = notification.body ?? ""
let userInfo = notification.userInfo
print(debug: "called \(String(describing: userInfo))")
if !userInfo!.isEmpty {
let ecaList = GetEcaList()
ecaList.start()
let pushHistory = GetPushHistory()
pushHistory.start()
// guard let data = userInfo["data"] as? [String: Any],
// let newTitle = data["newTitle"] as? String,
// let newBody = data["newBody"] as? String else {
// completionHandler(.noData)
// return
// }
// // ローカル通知で表示するタイトルとメッセージを変更する
// showLocalNotification(identifier: "SilentPush", title: newTitle, body: newBody)
// completionHandler(.newData)
}
func notificationHub(_ notificationHub: MSNotificationHub!, didReceivePushNotification notification: MSNotificationHubMessage!) {
let title = notification.title ?? ""
let body = notification.body ?? ""
if (UIApplication.shared.applicationState == .background) {
print("Notification received in background: title:\"\(title)\" body:\"\(body)\"")
} else {
let alertController = UIAlertController(title: title, message: body, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "OK", style: .cancel))
// self.present(alertController, animated: true)
}
}
......@@ -202,31 +151,10 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
let userInfo = notification.request.content.userInfo
print(debug: userInfo)
if !userInfo.isEmpty {
guard let senTypeStr = userInfo["sendType"] as? String else {
guard userInfo["sendType"] is String else {
completionHandler([.badge, .sound, .banner, .list])
return
}
// switch PushNotificationTypes.SendType(Int32(sendTypeStr) ?? -1){
// case .NewChatMessage:
// //foreground時、通知の内容種別がチャットなら通知を表示しない
// let semaphore = DispatchSemaphore(value: 0)
// SessionManager().prepareSession(semaphore: semaphore)
// let sessionGetWatchingApp = SessionGetWatchingApp()
// let sessionGetWatcherApp = SessionGetWatcherApp()
//
// DispatchQueue(label: "WebAppRequest").async {
// semaphore.wait()
// sessionGetWatchingApp.ErrCnt = 0
// sessionGetWatchingApp.RequestGetWatchingApp("arrivedChatPush")
//
// sessionGetWatcherApp.ErrCnt = 0
// sessionGetWatcherApp.RequestGetWatcherApp("arrivedChatPush")
// }
// completionHandler([])
// return
// default:
// break
// }
}
completionHandler([[.banner, .badge, .sound]])
}
......@@ -257,7 +185,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, ObservableObject {
windowScene = scene as? UIWindowScene
}
func addTabBar(_ selectedTabModel: SelectedTabModel){
guard let scene = windowScene else{
return
......
......@@ -50,7 +50,7 @@ class ServerSession{
session.finishTasksAndInvalidate()
do{
if let error = error{
if error != nil{
throw APIError.clientError
}
guard let indata = data, let inresponse = response as? HTTPURLResponse else {
......@@ -92,8 +92,7 @@ class ServerSession{
session.finishTasksAndInvalidate()
do{
if let error = error{
// let err = APIError.clientError
if error != nil{
throw APIError.clientError
}
guard let indata = data, let inresponse = response as? HTTPURLResponse else {
......@@ -130,8 +129,8 @@ class ServerSession{
session.finishTasksAndInvalidate()
do{
if let error = error{
let err = APIError.clientError
if error != nil{
_ = APIError.clientError
throw APIError.clientError
}
guard let indata = data, let inresponse = response as? HTTPURLResponse else {
......
......@@ -23,14 +23,6 @@ class SharingData{
static var my = My()
class My: ObservableObject {
@Published var location: CLLocationCoordinate2D? = .init(latitude: 0, longitude: 0)
@Published var gps: CLLocationCoordinate2D? = nil
@Published var server: CLLocationCoordinate2D? = nil
@Published var speed: Double = 0.0
@Published var course: Double = 0.0
@Published var heading: Double = 0.0
@Published var dataTime: String = "" //2023-11-02T05:25:49.4362123Z
@Published var id: Int = 0
@Published var shipName: String = ""
@Published var imo: Int = 0
......@@ -39,6 +31,20 @@ class SharingData{
@Published var ecaStatus: EcaState?
var manualUrls: [ResGetManualUrl] = []
}
static var location = Location()
class Location: ObservableObject {
@Published var location: CLLocationCoordinate2D? = .init(latitude: 0, longitude: 0)
@Published var gps: CLLocationCoordinate2D? = nil
@Published var server: CLLocationCoordinate2D? = nil
@Published var speed: Double = 0.0
@Published var course: Double = 0.0
@Published var heading: Double = 0.0
@Published var dataTime: String = "" //2023-11-02T05:25:49.4362123Z
func setLocation(){
if Preferences.LocationType == 0 {
self.location = self.gps
......@@ -48,13 +54,12 @@ class SharingData{
}
func reset() {
location = nil
speed = 0.0
course = 0.0
heading = 0.0
}
var manualUrls: [ResGetManualUrl] = []
location = nil
}
}
static var map = Map()
......
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