Commit 46236c97 authored by sugita mamoru's avatar sugita mamoru

フォーカス時のEca表示、サインアウト、画面遷移変更

parent 8e5c1795
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
025C27FC2AFE191A00BADC49 /* MenuManualView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025C27FB2AFE191A00BADC49 /* MenuManualView.swift */; }; 025C27FC2AFE191A00BADC49 /* MenuManualView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025C27FB2AFE191A00BADC49 /* MenuManualView.swift */; };
025C27FE2B0206D700BADC49 /* PDFDownloadManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025C27FD2B0206D700BADC49 /* PDFDownloadManager.swift */; }; 025C27FE2B0206D700BADC49 /* PDFDownloadManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025C27FD2B0206D700BADC49 /* PDFDownloadManager.swift */; };
025C28002B034A1900BADC49 /* PDFViewer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025C27FF2B034A1900BADC49 /* PDFViewer.swift */; }; 025C28002B034A1900BADC49 /* PDFViewer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025C27FF2B034A1900BADC49 /* PDFViewer.swift */; };
025F99702B2AC2C100C9A18A /* YesNoButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025F996F2B2AC2C100C9A18A /* YesNoButtons.swift */; };
025F99722B2AE3AF00C9A18A /* TaskViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025F99712B2AE3AF00C9A18A /* TaskViewModel.swift */; };
027EF9F22B0D804C0079B825 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 027EF9F12B0D804C0079B825 /* WebView.swift */; }; 027EF9F22B0D804C0079B825 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 027EF9F12B0D804C0079B825 /* WebView.swift */; };
02A1DE2F2AFB4AA0005BCF55 /* ChatInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02A1DE2E2AFB4AA0005BCF55 /* ChatInputView.swift */; }; 02A1DE2F2AFB4AA0005BCF55 /* ChatInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02A1DE2E2AFB4AA0005BCF55 /* ChatInputView.swift */; };
02A1DE312AFB61D8005BCF55 /* MyChatContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02A1DE302AFB61D8005BCF55 /* MyChatContentView.swift */; }; 02A1DE312AFB61D8005BCF55 /* MyChatContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02A1DE302AFB61D8005BCF55 /* MyChatContentView.swift */; };
...@@ -188,6 +190,8 @@ ...@@ -188,6 +190,8 @@
025C27FB2AFE191A00BADC49 /* MenuManualView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MenuManualView.swift; path = Sailassist/Menu/View/MenuManualView.swift; sourceTree = SOURCE_ROOT; }; 025C27FB2AFE191A00BADC49 /* MenuManualView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MenuManualView.swift; path = Sailassist/Menu/View/MenuManualView.swift; sourceTree = SOURCE_ROOT; };
025C27FD2B0206D700BADC49 /* PDFDownloadManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PDFDownloadManager.swift; path = Sailassist/ServerSession/PDFDownloadManager.swift; sourceTree = SOURCE_ROOT; }; 025C27FD2B0206D700BADC49 /* PDFDownloadManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PDFDownloadManager.swift; path = Sailassist/ServerSession/PDFDownloadManager.swift; sourceTree = SOURCE_ROOT; };
025C27FF2B034A1900BADC49 /* PDFViewer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PDFViewer.swift; path = Sailassist/Menu/View/PDFViewer.swift; sourceTree = SOURCE_ROOT; }; 025C27FF2B034A1900BADC49 /* PDFViewer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PDFViewer.swift; path = Sailassist/Menu/View/PDFViewer.swift; sourceTree = SOURCE_ROOT; };
025F996F2B2AC2C100C9A18A /* YesNoButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = YesNoButtons.swift; path = Sailassist/Parts/YesNoButtons.swift; sourceTree = SOURCE_ROOT; };
025F99712B2AE3AF00C9A18A /* TaskViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = TaskViewModel.swift; path = Sailassist/Map/Task/ViewModel/TaskViewModel.swift; sourceTree = SOURCE_ROOT; };
027EF9F12B0D804C0079B825 /* WebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WebView.swift; path = Sailassist/WebView.swift; sourceTree = SOURCE_ROOT; }; 027EF9F12B0D804C0079B825 /* WebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WebView.swift; path = Sailassist/WebView.swift; sourceTree = SOURCE_ROOT; };
02A1DE2E2AFB4AA0005BCF55 /* ChatInputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ChatInputView.swift; path = Sailassist/Chat/View/ChatInputView.swift; sourceTree = SOURCE_ROOT; }; 02A1DE2E2AFB4AA0005BCF55 /* ChatInputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ChatInputView.swift; path = Sailassist/Chat/View/ChatInputView.swift; sourceTree = SOURCE_ROOT; };
02A1DE302AFB61D8005BCF55 /* MyChatContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MyChatContentView.swift; path = Sailassist/Chat/View/MyChatContentView.swift; sourceTree = SOURCE_ROOT; }; 02A1DE302AFB61D8005BCF55 /* MyChatContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MyChatContentView.swift; path = Sailassist/Chat/View/MyChatContentView.swift; sourceTree = SOURCE_ROOT; };
...@@ -324,6 +328,7 @@ ...@@ -324,6 +328,7 @@
022789122AE602D800A87787 /* ServerSession */, 022789122AE602D800A87787 /* ServerSession */,
0227890A2AE22DFB00A87787 /* SharingData */, 0227890A2AE22DFB00A87787 /* SharingData */,
02CE4DCD2ADFB9FF002E79BC /* Info.plist */, 02CE4DCD2ADFB9FF002E79BC /* Info.plist */,
025F996E2B2AC2A100C9A18A /* Parts */,
02CE4DC62ADF97D8002E79BC /* Extensions */, 02CE4DC62ADF97D8002E79BC /* Extensions */,
020B986A2ADD3E4A0029DE4C /* Lib */, 020B986A2ADD3E4A0029DE4C /* Lib */,
020B985C2ADCFEF90029DE4C /* Preferences */, 020B985C2ADCFEF90029DE4C /* Preferences */,
...@@ -510,6 +515,7 @@ ...@@ -510,6 +515,7 @@
022789112AE6028800A87787 /* ViewModel */ = { 022789112AE6028800A87787 /* ViewModel */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
025F99712B2AE3AF00C9A18A /* TaskViewModel.swift */,
); );
path = ViewModel; path = ViewModel;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -540,6 +546,14 @@ ...@@ -540,6 +546,14 @@
path = View; path = View;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
025F996E2B2AC2A100C9A18A /* Parts */ = {
isa = PBXGroup;
children = (
025F996F2B2AC2C100C9A18A /* YesNoButtons.swift */,
);
path = Parts;
sourceTree = "<group>";
};
02A1DE2D2AFB497B005BCF55 /* View */ = { 02A1DE2D2AFB497B005BCF55 /* View */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -942,6 +956,7 @@ ...@@ -942,6 +956,7 @@
02CD06932AE88970005F8D8F /* ServerSession.swift in Sources */, 02CD06932AE88970005F8D8F /* ServerSession.swift in Sources */,
02A1DE312AFB61D8005BCF55 /* MyChatContentView.swift in Sources */, 02A1DE312AFB61D8005BCF55 /* MyChatContentView.swift in Sources */,
D58E1F522B142A3F0092D8FE /* ResEcaArea.swift in Sources */, D58E1F522B142A3F0092D8FE /* ResEcaArea.swift in Sources */,
025F99702B2AC2C100C9A18A /* YesNoButtons.swift in Sources */,
025C27FE2B0206D700BADC49 /* PDFDownloadManager.swift in Sources */, 025C27FE2B0206D700BADC49 /* PDFDownloadManager.swift in Sources */,
D59908CA2B1AC381000E13DD /* GetPushHistory.swift in Sources */, D59908CA2B1AC381000E13DD /* GetPushHistory.swift in Sources */,
025C27FC2AFE191A00BADC49 /* MenuManualView.swift in Sources */, 025C27FC2AFE191A00BADC49 /* MenuManualView.swift in Sources */,
...@@ -968,6 +983,7 @@ ...@@ -968,6 +983,7 @@
D51AA4042B099DCD00EBBDD4 /* SignalRService.swift in Sources */, D51AA4042B099DCD00EBBDD4 /* SignalRService.swift in Sources */,
025C27FA2AFE119D00BADC49 /* MenuTitleView.swift in Sources */, 025C27FA2AFE119D00BADC49 /* MenuTitleView.swift in Sources */,
02CE4D892ADF62E1002E79BC /* EcaSettingView.swift in Sources */, 02CE4D892ADF62E1002E79BC /* EcaSettingView.swift in Sources */,
025F99722B2AE3AF00C9A18A /* TaskViewModel.swift in Sources */,
D5258CA32B036CC500365276 /* SessionGetMessage.swift in Sources */, D5258CA32B036CC500365276 /* SessionGetMessage.swift in Sources */,
D5258C992B0334BF00365276 /* SessionShipStatus.swift in Sources */, D5258C992B0334BF00365276 /* SessionShipStatus.swift in Sources */,
02CE4D872ADF62A7002E79BC /* EcaListView.swift in Sources */, 02CE4D872ADF62A7002E79BC /* EcaListView.swift in Sources */,
......
...@@ -7,8 +7,12 @@ ...@@ -7,8 +7,12 @@
import SwiftUI import SwiftUI
class LoginViewModel: ObservableObject{
@Published var isLogin: Bool = false
}
struct ContentView: View { struct ContentView: View {
@State var isLogin = false//ContentView.LoginCheck() @StateObject private var loginViewModel = LoginViewModel()
@EnvironmentObject private var sceneDelegate: SceneDelegate @EnvironmentObject private var sceneDelegate: SceneDelegate
let selectedTabModel = SelectedTabModel() let selectedTabModel = SelectedTabModel()
let signalRService = SignalRService() let signalRService = SignalRService()
...@@ -16,19 +20,23 @@ struct ContentView: View { ...@@ -16,19 +20,23 @@ struct ContentView: View {
var body: some View { var body: some View {
MainTabView() MainTabView()
.environmentObject(selectedTabModel) .environmentObject(selectedTabModel)
.environmentObject(loginViewModel)
.onAppear(){ .onAppear(){
if isLogin{ if loginViewModel.isLogin{
guard sceneDelegate.tabWindow == nil else{ return } guard sceneDelegate.tabWindow == nil else{ return }
sceneDelegate.addTabBar(selectedTabModel) sceneDelegate.addTabBar(selectedTabModel)
selectedTabModel.activeTab = .task selectedTabModel.activeTab = .task
} }
} }
.fullScreenCover(isPresented: .constant(!isLogin), onDismiss: { .fullScreenCover(isPresented: .constant(!loginViewModel.isLogin), onDismiss: {
guard sceneDelegate.tabWindow == nil else{ return } guard sceneDelegate.tabWindow == nil else{
sceneDelegate.tabWindow?.isHidden = false
return
}
sceneDelegate.addTabBar(selectedTabModel) sceneDelegate.addTabBar(selectedTabModel)
selectedTabModel.activeTab = .task selectedTabModel.activeTab = .task
}, content: { }, content: {
LoginView(isLogin: $isLogin) LoginView(isLogin: $loginViewModel.isLogin)
}) })
} }
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import Foundation import Foundation
import CoreLocation import CoreLocation
#if true #if false
//ECA Coordinates China //ECA Coordinates China
var chinaShore:[CLLocationCoordinate2D] = [ var chinaShore:[CLLocationCoordinate2D] = [
CLLocationCoordinate2D(latitude: 39.82805556, longitude: 124.16833333), CLLocationCoordinate2D(latitude: 39.82805556, longitude: 124.16833333),
...@@ -4313,26 +4313,26 @@ class EcaCoordinatesTable : NSObject { ...@@ -4313,26 +4313,26 @@ class EcaCoordinatesTable : NSObject {
} }
var ecaDataTable:[ecaData] = [ var ecaDataTable:[ecaData] = [
ecaData(id: 1, name: "Iceland", table: iceland), // ecaData(id: 1, name: "Iceland", table: iceland),
ecaData(id: 11, name: "North American Atlantic Coasts", table: northAmericanAtlanticCoasts), // ecaData(id: 11, name: "North American Atlantic Coasts", table: northAmericanAtlanticCoasts),
ecaData(id: 12, name: "North American Hawai", table: northAmericanHawai), // ecaData(id: 12, name: "North American Hawai", table: northAmericanHawai),
ecaData(id: 13, name: "North American Pacific Coasts", table: northAmericanPacificCoasts), // ecaData(id: 13, name: "North American Pacific Coasts", table: northAmericanPacificCoasts),
ecaData(id: 21, name: "North Sea 1", table: northSea1), //err // ecaData(id: 21, name: "North Sea 1", table: northSea1), //err
ecaData(id: 22, name: "North Sea 2", table: northSea2), // ecaData(id: 22, name: "North Sea 2", table: northSea2),
ecaData(id: 31, name: "Unites States Caribbean", table: unitesStatesCaribbean), // ecaData(id: 31, name: "Unites States Caribbean", table: unitesStatesCaribbean),
ecaData(id: 41, name: "China Shore", table: chinaShore), // ecaData(id: 41, name: "China Shore", table: chinaShore),
ecaData(id: 42, name: "China Hainan", table: chinaHainan), // ecaData(id: 42, name: "China Hainan", table: chinaHainan),
ecaData(id: 43, name: "China Yangtzi Shuifu,Yunnan", table: chinaYangtziShuifuYunnan), //err // ecaData(id: 43, name: "China Yangtzi Shuifu,Yunnan", table: chinaYangtziShuifuYunnan), //err
ecaData(id: 44, name: "China Yangtzi Liuhekou,Jiangsu1", table: chinaYangtziLiuhekouJiangsu1), // ecaData(id: 44, name: "China Yangtzi Liuhekou,Jiangsu1", table: chinaYangtziLiuhekouJiangsu1),
ecaData(id: 45, name: "China Yangtzi Liuhekou,Jiangsu2", table: chinaYangtziLiuhekouJiangsu2), // ecaData(id: 45, name: "China Yangtzi Liuhekou,Jiangsu2", table: chinaYangtziLiuhekouJiangsu2),
ecaData(id: 46, name: "China Xijiang Nanning,Guangxi", table: chinaXijiangNanningGuangxi), //err // ecaData(id: 46, name: "China Xijiang Nanning,Guangxi", table: chinaXijiangNanningGuangxi), //err
ecaData(id: 47, name: "China Xijiang Zhaoqing,Guangdong", table: chinaXijiangNanningGuangdong), //err // ecaData(id: 47, name: "China Xijiang Zhaoqing,Guangdong", table: chinaXijiangNanningGuangdong), //err
ecaData(id: 51, name: "Korea Incheon, PyeongtaekDangjin Port", table: incheonPyeongtaekDanjinPort), // ecaData(id: 51, name: "Korea Incheon, PyeongtaekDangjin Port", table: incheonPyeongtaekDanjinPort),
ecaData(id: 52, name: "Korea Yeosu, Gwangyang Port", table: yeosuGwangyangPort), // ecaData(id: 52, name: "Korea Yeosu, Gwangyang Port", table: yeosuGwangyangPort),
ecaData(id: 53, name: "Korea Busan Port", table: koreaBusanPort), // ecaData(id: 53, name: "Korea Busan Port", table: koreaBusanPort),
ecaData(id: 54, name: "Korea Busan Port West", table: koreaBusanPortWest), // ecaData(id: 54, name: "Korea Busan Port West", table: koreaBusanPortWest),
ecaData(id: 55, name: "Korea Ulsan Port", table: koreaUlsanPort), // ecaData(id: 55, name: "Korea Ulsan Port", table: koreaUlsanPort),
ecaData(id: 61, name: "Panama Canal Atlantic Entrance", table: panamaCanalAtlanticEntrance), // ecaData(id: 61, name: "Panama Canal Atlantic Entrance", table: panamaCanalAtlanticEntrance),
ecaData(id: 62, name: "Panama Canal Pacific Entrance", table: panamaCanalPacificEntrance) ecaData(id: 62, name: "Panama Canal Pacific Entrance", table: panamaCanalPacificEntrance)
] ]
......
...@@ -14,4 +14,5 @@ enum LayerEnum: String{ ...@@ -14,4 +14,5 @@ enum LayerEnum: String{
case SwLineLabel case SwLineLabel
case WayPoints case WayPoints
case WakeLines case WakeLines
case OneTimeEca
} }
...@@ -31,6 +31,13 @@ struct MapRepresentable: UIViewControllerRepresentable{ ...@@ -31,6 +31,13 @@ struct MapRepresentable: UIViewControllerRepresentable{
if let focusEcaName = ecaData.focusEca, let focusEca = ecaData.ecaArea[focusEcaName]{ if let focusEcaName = ecaData.focusEca, let focusEca = ecaData.ecaArea[focusEcaName]{
mapVC.updateCamera(location: focusEca.points.first) mapVC.updateCamera(location: focusEca.points.first)
mapVC.updateOneTimeEca(eca: focusEca.points)
//5秒後削除
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
do{
mapVC.updateOneTimeEca(eca: nil)
}catch{}
}
} }
if let focusPushHistoryId = pushHistory.focusPushHistory, let focusPushHistory = pushHistory.pushHistoryData[focusPushHistoryId]{ if let focusPushHistoryId = pushHistory.focusPushHistory, let focusPushHistory = pushHistory.pushHistoryData[focusPushHistoryId]{
...@@ -65,6 +72,7 @@ class MapViewController : UIViewController{ ...@@ -65,6 +72,7 @@ class MapViewController : UIViewController{
var ecaSwLineLabel = MapSource(layer: .SwLineLabel) var ecaSwLineLabel = MapSource(layer: .SwLineLabel)
var wayPoints = MapSource(layer: .WayPoints) var wayPoints = MapSource(layer: .WayPoints)
var wakeLines = MapSource(layer: .WakeLines) var wakeLines = MapSource(layer: .WakeLines)
var oneTimeEca = MapSource(layer: .OneTimeEca)
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
...@@ -134,6 +142,19 @@ class MapViewController : UIViewController{ ...@@ -134,6 +142,19 @@ class MapViewController : UIViewController{
try! mapView.mapboxMap.style.addSource(ecaLine.source, id: ecaLine.sourceId) try! mapView.mapboxMap.style.addSource(ecaLine.source, id: ecaLine.sourceId)
try? mapView.mapboxMap.style.addLayer(ecaLineLayer) try? mapView.mapboxMap.style.addLayer(ecaLineLayer)
let oneTimeEcaLineString = LineString([LocationCoordinate2D(latitude: 0, longitude: 0)])
let oneTimeEcaLinefeature = Feature(geometry: ecaLineString)
oneTimeEca.source.data = .feature(oneTimeEcaLinefeature)
var oneTimeEcaLayer = LineLayer(id: oneTimeEca.layerId)
oneTimeEcaLayer.source = oneTimeEca.sourceId
oneTimeEcaLayer.lineColor = .expression(Exp(.get) {
PropertyKey.Color.rawValue
})
oneTimeEcaLayer.lineDasharray = .constant([2,1])
try! mapView.mapboxMap.style.addSource(oneTimeEca.source, id: oneTimeEca.sourceId)
try? mapView.mapboxMap.style.addLayer(oneTimeEcaLayer)
ecaSwitchingLine.source.data = .featureCollection(FeatureCollection(features: [])) ecaSwitchingLine.source.data = .featureCollection(FeatureCollection(features: []))
var ecaSwitchingLineLayer = LineLayer(id: ecaSwitchingLine.layerId) var ecaSwitchingLineLayer = LineLayer(id: ecaSwitchingLine.layerId)
ecaSwitchingLineLayer.source = ecaSwitchingLine.sourceId ecaSwitchingLineLayer.source = ecaSwitchingLine.sourceId
...@@ -301,6 +322,19 @@ class MapViewController : UIViewController{ ...@@ -301,6 +322,19 @@ class MapViewController : UIViewController{
try self.mapView.mapboxMap.style.updateGeoJSONSource(withId: ecaLine.sourceId, geoJSON: .feature(geoJson)) try self.mapView.mapboxMap.style.updateGeoJSONSource(withId: ecaLine.sourceId, geoJSON: .feature(geoJson))
}catch{} }catch{}
} }
///一時的に見たいEcaを表示
func updateOneTimeEca(eca: [CLLocationCoordinate2D]?){
do{
let eca = eca ?? []
var geoJson = Feature(geometry: LineString(eca))
geoJson.properties = [PropertyKey.Color.rawValue: .string(Color.black.description)]
try self.mapView.mapboxMap.style.updateGeoJSONSource(withId: oneTimeEca.sourceId, geoJSON: .feature(geoJson))
}catch{
}
}
func updateWakeLines(legLine: [CLLocationCoordinate2D], portLine: [CLLocationCoordinate2D], starboardLine: [CLLocationCoordinate2D]){ func updateWakeLines(legLine: [CLLocationCoordinate2D], portLine: [CLLocationCoordinate2D], starboardLine: [CLLocationCoordinate2D]){
do{ do{
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import SwiftUI import SwiftUI
struct EcaListView: View { struct EcaListView: View {
@ObservedObject var taskViewModel : TaskViewModel
@ObservedObject var ecaData = SharingData.eca @ObservedObject var ecaData = SharingData.eca
var body: some View { var body: some View {
...@@ -25,6 +26,9 @@ struct EcaListView: View { ...@@ -25,6 +26,9 @@ struct EcaListView: View {
var newData = eca var newData = eca
newData.isEnable.toggle() newData.isEnable.toggle()
ecaData.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Insert) ecaData.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Insert)
taskViewModel.viewMode = .SwitchingMenu
taskViewModel.edittingEcaArea = eca
taskViewModel.isShowSettingView = true
}, label: { }, label: {
Image("icon_plus") Image("icon_plus")
.resizable() .resizable()
...@@ -57,6 +61,6 @@ struct EcaListView: View { ...@@ -57,6 +61,6 @@ struct EcaListView: View {
} }
#Preview { #Preview {
EcaListView() EcaListView(taskViewModel: TaskViewModel())
} }
...@@ -9,6 +9,7 @@ import SwiftUI ...@@ -9,6 +9,7 @@ import SwiftUI
import UIKit import UIKit
struct EcaSettingView: View { struct EcaSettingView: View {
// @ObservedObject var taskViewModel: TaskViewModel
@Binding var isShowSettingEca: Bool @Binding var isShowSettingEca: Bool
@State var edittingEca: RegisteredEca @State var edittingEca: RegisteredEca
......
...@@ -23,9 +23,7 @@ enum TaskViewMode{ ...@@ -23,9 +23,7 @@ enum TaskViewMode{
struct MapTaskView: View { struct MapTaskView: View {
@State var viewMode: TaskViewMode = .SwitchingMenu @ObservedObject var taskViewModel = TaskViewModel()
@State var edittingEcaArea: RegisteredEca? = nil
@State var isShowSettingView : Bool = false
@ObservedObject var eca = SharingData.eca @ObservedObject var eca = SharingData.eca
var body: some View { var body: some View {
...@@ -38,8 +36,8 @@ struct MapTaskView: View { ...@@ -38,8 +36,8 @@ struct MapTaskView: View {
//タイトルエリア //タイトルエリア
HStack{ HStack{
Button(action: { Button(action: {
viewMode = .SwitchingMenu taskViewModel.viewMode = .SwitchingMenu
isShowSettingView = false 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 eca.status = .noticePass
...@@ -48,7 +46,7 @@ struct MapTaskView: View { ...@@ -48,7 +46,7 @@ struct MapTaskView: View {
} }
}, label: { }, label: {
if viewMode != .SwitchingMenu || isShowSettingView{ if taskViewModel.viewMode != .SwitchingMenu || taskViewModel.isShowSettingView{
Image("ink_02") Image("ink_02")
} }
}) })
...@@ -56,7 +54,7 @@ struct MapTaskView: View { ...@@ -56,7 +54,7 @@ struct MapTaskView: View {
Spacer() Spacer()
Text(viewMode.title) Text(taskViewModel.viewMode.title)
.font(FontStyle.TitleL.font) .font(FontStyle.TitleL.font)
.frame(height: 20) .frame(height: 20)
.padding(.vertical, 14) .padding(.vertical, 14)
...@@ -76,15 +74,15 @@ struct MapTaskView: View { ...@@ -76,15 +74,15 @@ struct MapTaskView: View {
.background(ColorSet.LineColor03.color) .background(ColorSet.LineColor03.color)
ScrollView(.vertical){ ScrollView(.vertical){
switch viewMode { switch taskViewModel.viewMode {
case .SwitchingMenu: case .SwitchingMenu:
if let edittingEcaArea = edittingEcaArea, isShowSettingView{ if let edittingEcaArea = taskViewModel.edittingEcaArea, taskViewModel.isShowSettingView{
EcaSettingView(isShowSettingEca: $isShowSettingView, edittingEca: edittingEcaArea) EcaSettingView(isShowSettingEca: $taskViewModel.isShowSettingView, edittingEca: edittingEcaArea)
}else{ }else{
TaskSwitchingMenuView(viewMode: $viewMode, edittingEcaArea: $edittingEcaArea, isShowSettingEca: $isShowSettingView) TaskSwitchingMenuView(taskViewModel: taskViewModel)
} }
case .EcaList: case .EcaList:
EcaListView() EcaListView(taskViewModel: taskViewModel)
} }
} }
......
...@@ -13,9 +13,7 @@ enum EcaAlertType: String { ...@@ -13,9 +13,7 @@ enum EcaAlertType: String {
} }
struct TaskSwitchingMenuView: View { struct TaskSwitchingMenuView: View {
@Binding var viewMode: TaskViewMode @ObservedObject var taskViewModel: TaskViewModel
@Binding var edittingEcaArea: RegisteredEca?
@Binding var isShowSettingEca : Bool
@ObservedObject var ecaData = SharingData.eca @ObservedObject var ecaData = SharingData.eca
@State var isEcaAlert : Bool = false @State var isEcaAlert : Bool = false
@State var ecaAlertType: EcaAlertType = .ecaDelete @State var ecaAlertType: EcaAlertType = .ecaDelete
...@@ -29,7 +27,7 @@ struct TaskSwitchingMenuView: View { ...@@ -29,7 +27,7 @@ struct TaskSwitchingMenuView: View {
//ECA開始・終了ボタン //ECA開始・終了ボタン
Button { Button {
for runningEca in ecaData.ecaArea.map{ $0.1 }.filter{ $0.isRunning }{ for runningEca in ecaData.ecaArea.map{ $0.1 }.filter{ $0.isRunning }{
edittingEcaArea = runningEca taskViewModel.edittingEcaArea = runningEca
isEcaAlert = true isEcaAlert = true
ecaAlertType = .ecaRunningStop ecaAlertType = .ecaRunningStop
} }
...@@ -62,14 +60,14 @@ struct TaskSwitchingMenuView: View { ...@@ -62,14 +60,14 @@ struct TaskSwitchingMenuView: View {
Text(eca.name) Text(eca.name)
Button{ Button{
edittingEcaArea = eca taskViewModel.edittingEcaArea = eca
isShowSettingEca = true taskViewModel.isShowSettingView = true
} label: { } label: {
Text("Edit Notice Setting") Text("Edit Notice Setting")
} }
Button{ Button{
edittingEcaArea = eca taskViewModel.edittingEcaArea = eca
isEcaAlert = true isEcaAlert = true
ecaAlertType = .ecaDelete ecaAlertType = .ecaDelete
} label: { } label: {
...@@ -88,7 +86,7 @@ struct TaskSwitchingMenuView: View { ...@@ -88,7 +86,7 @@ struct TaskSwitchingMenuView: View {
message: Text("Do you delete " + eca.name), message: Text("Do you delete " + eca.name),
primaryButton: .default(Text("cancel")), primaryButton: .default(Text("cancel")),
secondaryButton: .cancel(Text("delete"), action: { secondaryButton: .cancel(Text("delete"), action: {
if let ecaArea = edittingEcaArea { if let ecaArea = taskViewModel.edittingEcaArea {
var newData = ecaArea var newData = ecaArea
newData.isEnable = false newData.isEnable = false
newData.status = EcaState.register newData.status = EcaState.register
...@@ -96,20 +94,20 @@ struct TaskSwitchingMenuView: View { ...@@ -96,20 +94,20 @@ struct TaskSwitchingMenuView: View {
ecaData.editEcaArea(key: ecaArea.name, value: newData, type: EcaOperation.Delete) ecaData.editEcaArea(key: ecaArea.name, value: newData, type: EcaOperation.Delete)
deleteEcaArea.start(ecaId: ecaArea.id) deleteEcaArea.start(ecaId: ecaArea.id)
} }
edittingEcaArea = nil taskViewModel.edittingEcaArea = nil
})) }))
case .ecaRunningStop: case .ecaRunningStop:
return Alert(title: Text("stop"), return Alert(title: Text("stop"),
message: Text("Do you want to stop " + eca.name), message: Text("Do you want to stop " + eca.name),
primaryButton: .default(Text("cancel")), primaryButton: .default(Text("cancel")),
secondaryButton: .cancel(Text("stop"), action: { secondaryButton: .cancel(Text("stop"), action: {
if let ecaArea = edittingEcaArea { if let ecaArea = taskViewModel.edittingEcaArea {
var newData = ecaArea var newData = ecaArea
newData.isRunning = false newData.isRunning = false
newData.status = EcaState.cancel newData.status = EcaState.cancel
ecaData.editEcaArea(key: ecaArea.name, value: newData, type: EcaOperation.Cancel) ecaData.editEcaArea(key: ecaArea.name, value: newData, type: EcaOperation.Cancel)
} }
edittingEcaArea = nil taskViewModel.edittingEcaArea = nil
})) }))
} }
} }
...@@ -123,7 +121,7 @@ struct TaskSwitchingMenuView: View { ...@@ -123,7 +121,7 @@ struct TaskSwitchingMenuView: View {
} }
//AddECAボタン //AddECAボタン
Button(action: { Button(action: {
viewMode = .EcaList taskViewModel.viewMode = .EcaList
}, label: { }, label: {
Text("Add ECA Task") Text("Add ECA Task")
.font(FontStyle.DefaultText.font) .font(FontStyle.DefaultText.font)
...@@ -142,5 +140,5 @@ struct TaskSwitchingMenuView: View { ...@@ -142,5 +140,5 @@ struct TaskSwitchingMenuView: View {
#Preview { #Preview {
TaskSwitchingMenuView(viewMode: .constant(.SwitchingMenu), edittingEcaArea: .constant(nil), isShowSettingEca: .constant(false)) TaskSwitchingMenuView(taskViewModel: TaskViewModel())
} }
//
// TaskViewModel.swift
// Sailassist
//
// Created by Mamoru Sugita on 2023/12/14.
//
import Foundation
class TaskViewModel: ObservableObject{
@Published var viewMode: TaskViewMode = .SwitchingMenu
@Published var edittingEcaArea: RegisteredEca? = nil
@Published var isShowSettingView : Bool = false
}
...@@ -51,9 +51,9 @@ enum MenuPath: String, Hashable{ ...@@ -51,9 +51,9 @@ enum MenuPath: String, Hashable{
struct MenuView: View { struct MenuView: View {
@EnvironmentObject private var sceneDelegate: SceneDelegate @EnvironmentObject private var sceneDelegate: SceneDelegate
@EnvironmentObject private var loginViewModel : LoginViewModel
@State var path: [MenuPath] = [] @State var path: [MenuPath] = []
@Binding var isSignout: Bool @Binding var isSignout: Bool
@Binding var isLogin: Bool
var body: some View { var body: some View {
NavigationStack(path: $path){ NavigationStack(path: $path){
...@@ -137,7 +137,8 @@ struct MenuView: View { ...@@ -137,7 +137,8 @@ struct MenuView: View {
Preferences.Id = "" Preferences.Id = ""
Preferences.Password = "" Preferences.Password = ""
Preferences.UserName = "" Preferences.UserName = ""
isLogin = false loginViewModel.isLogin = false
sceneDelegate.tabWindow?.isHidden = true
})) }))
} }
} }
...@@ -145,5 +146,6 @@ struct MenuView: View { ...@@ -145,5 +146,6 @@ struct MenuView: View {
} }
#Preview { #Preview {
MenuView(isSignout: .constant(false), isLogin: .constant(false)) MenuView(isSignout: .constant(false))
.environmentObject(LoginViewModel())
} }
//
// YesNoButtons.swift
// Sailassist
//
// Created by Mamoru Sugita on 2023/12/14.
//
import SwiftUI
struct YesNoButtons: View {
var yesTitle: String
var noTitle: String
var yesAction: () -> Void
var noAction: () -> Void
var body: some View {
HStack(spacing: 5){
Button(action: yesAction, label: {
Text(yesTitle)
.frame(maxWidth: .infinity)
.padding(.vertical, 10)
.border(ColorSet.LineColor04.color, width: 1, cornerRadius: 5)
})
Button(action: noAction, label: {
Text(noTitle)
.frame(maxWidth: .infinity)
.padding(.vertical, 10)
.border(ColorSet.LineColor04.color, width: 1, cornerRadius: 5)
})
}
.padding()
.background(ColorSet.BackgroundPrimary.color)
}
}
#Preview {
YesNoButtons(yesTitle: "Yes", noTitle: "No"){
} noAction: {
}
}
...@@ -35,6 +35,19 @@ class Preferences{ ...@@ -35,6 +35,19 @@ class Preferences{
termsAgreeDate = DateTextLib.UnixTime2Date(newValue ?? 0) termsAgreeDate = DateTextLib.UnixTime2Date(newValue ?? 0)
} }
} }
@AppStorage(PreferencesKey.TypeInt.PrivacyPolicyAgreeDate.rawValue) static var privacyPolicyAgreeDate: Date?
static var privacyPolicyAgreeDate_Int64 : Int64?{
get{
if let date = privacyPolicyAgreeDate{
DateTextLib.Date2UnixTime(date: date)
}else{
nil
}
}
set{
privacyPolicyAgreeDate = DateTextLib.UnixTime2Date(newValue ?? 0)
}
}
@AppStorage(wrappedValue:"", PreferencesKey.TypeString.Id.rawValue) static var Id: String @AppStorage(wrappedValue:"", PreferencesKey.TypeString.Id.rawValue) static var Id: String
@AppStorage(wrappedValue:"", PreferencesKey.TypeString.Password.rawValue) static var Password: String @AppStorage(wrappedValue:"", PreferencesKey.TypeString.Password.rawValue) static var Password: String
......
...@@ -24,6 +24,7 @@ class PreferencesKey{ ...@@ -24,6 +24,7 @@ class PreferencesKey{
case AppStartUsingDate case AppStartUsingDate
case LastLoginDate case LastLoginDate
case TermsAgreeDate case TermsAgreeDate
case PrivacyPolicyAgreeDate
} }
enum TypeURL: String{ enum TypeURL: String{
......
...@@ -12,32 +12,41 @@ import WindowsAzureMessaging ...@@ -12,32 +12,41 @@ import WindowsAzureMessaging
@main @main
struct SailassistApp: App { struct SailassistApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate @UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
@State var isAgree = Preferences.termsAgreeDate != nil @State private var isTermsAgree = Preferences.termsAgreeDate != nil
@State private var isPrivAgree = Preferences.privacyPolicyAgreeDate != nil
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
if isAgree { if !isTermsAgree{
ContentView()
}else{
VStack(spacing: 0){ VStack(spacing: 0){
WebView(isLoading: .constant(false), url: HttpRequestType.Terms.rawValue) WebView(isLoading: .constant(false), url: HttpRequestType.Terms.rawValue)
Button(action: { YesNoButtons(yesTitle: "Accept", noTitle: "Cancel") {
Preferences.termsAgreeDate_Int64 = DateTextLib.Date2UnixTime(date: Date()) Preferences.termsAgreeDate_Int64 = DateTextLib.Date2UnixTime(date: Date())
isAgree = true isTermsAgree = true
}, label: { } noAction: {
Text("Accept") exit(0)
.frame(maxWidth: .infinity) }
.padding(.vertical, 10)
.border(ColorSet.LineColor04.color, width: 1, cornerRadius: 5)
})
.padding()
.background(ColorSet.BackgroundPrimary.color)
} }
.preferredColorScheme(.dark) .preferredColorScheme(.dark)
}else if !isPrivAgree{
VStack(spacing: 0){
WebView(isLoading: .constant(false), url: HttpRequestType.Terms.rawValue)
YesNoButtons(yesTitle: "Accept", noTitle: "Cancel") {
Preferences.privacyPolicyAgreeDate_Int64 = DateTextLib.Date2UnixTime(date: Date())
isPrivAgree = true
} noAction: {
exit(0)
}
}
.preferredColorScheme(.dark)
} else {
ContentView()
} }
} }
} }
} }
......
...@@ -46,7 +46,7 @@ struct MainTabView: View { ...@@ -46,7 +46,7 @@ struct MainTabView: View {
NotificationView() NotificationView()
.tag(Tab.alert) .tag(Tab.alert)
MenuView(isSignout: $isSignout, isLogin: $isLogin) MenuView(isSignout: $isSignout)
.tag(Tab.menu) .tag(Tab.menu)
} }
.hideNativeTabBar() .hideNativeTabBar()
......
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