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

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

parent 8e5c1795
......@@ -51,6 +51,8 @@
025C27FC2AFE191A00BADC49 /* MenuManualView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025C27FB2AFE191A00BADC49 /* MenuManualView.swift */; };
025C27FE2B0206D700BADC49 /* PDFDownloadManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025C27FD2B0206D700BADC49 /* PDFDownloadManager.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 */; };
02A1DE2F2AFB4AA0005BCF55 /* ChatInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02A1DE2E2AFB4AA0005BCF55 /* ChatInputView.swift */; };
02A1DE312AFB61D8005BCF55 /* MyChatContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02A1DE302AFB61D8005BCF55 /* MyChatContentView.swift */; };
......@@ -188,6 +190,8 @@
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; };
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; };
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; };
......@@ -324,6 +328,7 @@
022789122AE602D800A87787 /* ServerSession */,
0227890A2AE22DFB00A87787 /* SharingData */,
02CE4DCD2ADFB9FF002E79BC /* Info.plist */,
025F996E2B2AC2A100C9A18A /* Parts */,
02CE4DC62ADF97D8002E79BC /* Extensions */,
020B986A2ADD3E4A0029DE4C /* Lib */,
020B985C2ADCFEF90029DE4C /* Preferences */,
......@@ -510,6 +515,7 @@
022789112AE6028800A87787 /* ViewModel */ = {
isa = PBXGroup;
children = (
025F99712B2AE3AF00C9A18A /* TaskViewModel.swift */,
);
path = ViewModel;
sourceTree = "<group>";
......@@ -540,6 +546,14 @@
path = View;
sourceTree = "<group>";
};
025F996E2B2AC2A100C9A18A /* Parts */ = {
isa = PBXGroup;
children = (
025F996F2B2AC2C100C9A18A /* YesNoButtons.swift */,
);
path = Parts;
sourceTree = "<group>";
};
02A1DE2D2AFB497B005BCF55 /* View */ = {
isa = PBXGroup;
children = (
......@@ -942,6 +956,7 @@
02CD06932AE88970005F8D8F /* ServerSession.swift in Sources */,
02A1DE312AFB61D8005BCF55 /* MyChatContentView.swift in Sources */,
D58E1F522B142A3F0092D8FE /* ResEcaArea.swift in Sources */,
025F99702B2AC2C100C9A18A /* YesNoButtons.swift in Sources */,
025C27FE2B0206D700BADC49 /* PDFDownloadManager.swift in Sources */,
D59908CA2B1AC381000E13DD /* GetPushHistory.swift in Sources */,
025C27FC2AFE191A00BADC49 /* MenuManualView.swift in Sources */,
......@@ -968,6 +983,7 @@
D51AA4042B099DCD00EBBDD4 /* SignalRService.swift in Sources */,
025C27FA2AFE119D00BADC49 /* MenuTitleView.swift in Sources */,
02CE4D892ADF62E1002E79BC /* EcaSettingView.swift in Sources */,
025F99722B2AE3AF00C9A18A /* TaskViewModel.swift in Sources */,
D5258CA32B036CC500365276 /* SessionGetMessage.swift in Sources */,
D5258C992B0334BF00365276 /* SessionShipStatus.swift in Sources */,
02CE4D872ADF62A7002E79BC /* EcaListView.swift in Sources */,
......
......@@ -7,8 +7,12 @@
import SwiftUI
class LoginViewModel: ObservableObject{
@Published var isLogin: Bool = false
}
struct ContentView: View {
@State var isLogin = false//ContentView.LoginCheck()
@StateObject private var loginViewModel = LoginViewModel()
@EnvironmentObject private var sceneDelegate: SceneDelegate
let selectedTabModel = SelectedTabModel()
let signalRService = SignalRService()
......@@ -16,19 +20,23 @@ struct ContentView: View {
var body: some View {
MainTabView()
.environmentObject(selectedTabModel)
.environmentObject(loginViewModel)
.onAppear(){
if isLogin{
if loginViewModel.isLogin{
guard sceneDelegate.tabWindow == nil else{ return }
sceneDelegate.addTabBar(selectedTabModel)
selectedTabModel.activeTab = .task
}
}
.fullScreenCover(isPresented: .constant(!isLogin), onDismiss: {
guard sceneDelegate.tabWindow == nil else{ return }
.fullScreenCover(isPresented: .constant(!loginViewModel.isLogin), onDismiss: {
guard sceneDelegate.tabWindow == nil else{
sceneDelegate.tabWindow?.isHidden = false
return
}
sceneDelegate.addTabBar(selectedTabModel)
selectedTabModel.activeTab = .task
}, content: {
LoginView(isLogin: $isLogin)
LoginView(isLogin: $loginViewModel.isLogin)
})
}
}
......
......@@ -8,7 +8,7 @@
import Foundation
import CoreLocation
#if true
#if false
//ECA Coordinates China
var chinaShore:[CLLocationCoordinate2D] = [
CLLocationCoordinate2D(latitude: 39.82805556, longitude: 124.16833333),
......@@ -4313,26 +4313,26 @@ class EcaCoordinatesTable : NSObject {
}
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), //err
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), //err
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), //err
ecaData(id: 47, name: "China Xijiang Zhaoqing,Guangdong", table: chinaXijiangNanningGuangdong), //err
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: 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), //err
// 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), //err
// 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), //err
// ecaData(id: 47, name: "China Xijiang Zhaoqing,Guangdong", table: chinaXijiangNanningGuangdong), //err
// 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)
]
......
......@@ -14,4 +14,5 @@ enum LayerEnum: String{
case SwLineLabel
case WayPoints
case WakeLines
case OneTimeEca
}
......@@ -31,6 +31,13 @@ struct MapRepresentable: UIViewControllerRepresentable{
if let focusEcaName = ecaData.focusEca, let focusEca = ecaData.ecaArea[focusEcaName]{
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]{
......@@ -65,6 +72,7 @@ class MapViewController : UIViewController{
var ecaSwLineLabel = MapSource(layer: .SwLineLabel)
var wayPoints = MapSource(layer: .WayPoints)
var wakeLines = MapSource(layer: .WakeLines)
var oneTimeEca = MapSource(layer: .OneTimeEca)
override func viewDidLoad() {
super.viewDidLoad()
......@@ -134,6 +142,19 @@ 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)])
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: []))
var ecaSwitchingLineLayer = LineLayer(id: ecaSwitchingLine.layerId)
ecaSwitchingLineLayer.source = ecaSwitchingLine.sourceId
......@@ -301,6 +322,19 @@ class MapViewController : UIViewController{
try self.mapView.mapboxMap.style.updateGeoJSONSource(withId: ecaLine.sourceId, geoJSON: .feature(geoJson))
}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]){
do{
......
......@@ -8,6 +8,7 @@
import SwiftUI
struct EcaListView: View {
@ObservedObject var taskViewModel : TaskViewModel
@ObservedObject var ecaData = SharingData.eca
var body: some View {
......@@ -25,6 +26,9 @@ struct EcaListView: View {
var newData = eca
newData.isEnable.toggle()
ecaData.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Insert)
taskViewModel.viewMode = .SwitchingMenu
taskViewModel.edittingEcaArea = eca
taskViewModel.isShowSettingView = true
}, label: {
Image("icon_plus")
.resizable()
......@@ -57,6 +61,6 @@ struct EcaListView: View {
}
#Preview {
EcaListView()
EcaListView(taskViewModel: TaskViewModel())
}
......@@ -9,6 +9,7 @@ import SwiftUI
import UIKit
struct EcaSettingView: View {
// @ObservedObject var taskViewModel: TaskViewModel
@Binding var isShowSettingEca: Bool
@State var edittingEca: RegisteredEca
......
......@@ -23,9 +23,7 @@ enum TaskViewMode{
struct MapTaskView: View {
@State var viewMode: TaskViewMode = .SwitchingMenu
@State var edittingEcaArea: RegisteredEca? = nil
@State var isShowSettingView : Bool = false
@ObservedObject var taskViewModel = TaskViewModel()
@ObservedObject var eca = SharingData.eca
var body: some View {
......@@ -38,8 +36,8 @@ struct MapTaskView: View {
//タイトルエリア
HStack{
Button(action: {
viewMode = .SwitchingMenu
isShowSettingView = false
taskViewModel.viewMode = .SwitchingMenu
taskViewModel.isShowSettingView = false
if var eca = SharingData.eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first{
eca.status = .noticePass
......@@ -48,7 +46,7 @@ struct MapTaskView: View {
}
}, label: {
if viewMode != .SwitchingMenu || isShowSettingView{
if taskViewModel.viewMode != .SwitchingMenu || taskViewModel.isShowSettingView{
Image("ink_02")
}
})
......@@ -56,7 +54,7 @@ struct MapTaskView: View {
Spacer()
Text(viewMode.title)
Text(taskViewModel.viewMode.title)
.font(FontStyle.TitleL.font)
.frame(height: 20)
.padding(.vertical, 14)
......@@ -76,15 +74,15 @@ struct MapTaskView: View {
.background(ColorSet.LineColor03.color)
ScrollView(.vertical){
switch viewMode {
switch taskViewModel.viewMode {
case .SwitchingMenu:
if let edittingEcaArea = edittingEcaArea, isShowSettingView{
EcaSettingView(isShowSettingEca: $isShowSettingView, edittingEca: edittingEcaArea)
if let edittingEcaArea = taskViewModel.edittingEcaArea, taskViewModel.isShowSettingView{
EcaSettingView(isShowSettingEca: $taskViewModel.isShowSettingView, edittingEca: edittingEcaArea)
}else{
TaskSwitchingMenuView(viewMode: $viewMode, edittingEcaArea: $edittingEcaArea, isShowSettingEca: $isShowSettingView)
TaskSwitchingMenuView(taskViewModel: taskViewModel)
}
case .EcaList:
EcaListView()
EcaListView(taskViewModel: taskViewModel)
}
}
......
......@@ -13,9 +13,7 @@ enum EcaAlertType: String {
}
struct TaskSwitchingMenuView: View {
@Binding var viewMode: TaskViewMode
@Binding var edittingEcaArea: RegisteredEca?
@Binding var isShowSettingEca : Bool
@ObservedObject var taskViewModel: TaskViewModel
@ObservedObject var ecaData = SharingData.eca
@State var isEcaAlert : Bool = false
@State var ecaAlertType: EcaAlertType = .ecaDelete
......@@ -29,7 +27,7 @@ struct TaskSwitchingMenuView: View {
//ECA開始・終了ボタン
Button {
for runningEca in ecaData.ecaArea.map{ $0.1 }.filter{ $0.isRunning }{
edittingEcaArea = runningEca
taskViewModel.edittingEcaArea = runningEca
isEcaAlert = true
ecaAlertType = .ecaRunningStop
}
......@@ -62,14 +60,14 @@ struct TaskSwitchingMenuView: View {
Text(eca.name)
Button{
edittingEcaArea = eca
isShowSettingEca = true
taskViewModel.edittingEcaArea = eca
taskViewModel.isShowSettingView = true
} label: {
Text("Edit Notice Setting")
}
Button{
edittingEcaArea = eca
taskViewModel.edittingEcaArea = eca
isEcaAlert = true
ecaAlertType = .ecaDelete
} label: {
......@@ -88,7 +86,7 @@ struct TaskSwitchingMenuView: View {
message: Text("Do you delete " + eca.name),
primaryButton: .default(Text("cancel")),
secondaryButton: .cancel(Text("delete"), action: {
if let ecaArea = edittingEcaArea {
if let ecaArea = taskViewModel.edittingEcaArea {
var newData = ecaArea
newData.isEnable = false
newData.status = EcaState.register
......@@ -96,20 +94,20 @@ struct TaskSwitchingMenuView: View {
ecaData.editEcaArea(key: ecaArea.name, value: newData, type: EcaOperation.Delete)
deleteEcaArea.start(ecaId: ecaArea.id)
}
edittingEcaArea = nil
taskViewModel.edittingEcaArea = nil
}))
case .ecaRunningStop:
return Alert(title: Text("stop"),
message: Text("Do you want to stop " + eca.name),
primaryButton: .default(Text("cancel")),
secondaryButton: .cancel(Text("stop"), action: {
if let ecaArea = edittingEcaArea {
if let ecaArea = taskViewModel.edittingEcaArea {
var newData = ecaArea
newData.isRunning = false
newData.status = EcaState.cancel
ecaData.editEcaArea(key: ecaArea.name, value: newData, type: EcaOperation.Cancel)
}
edittingEcaArea = nil
taskViewModel.edittingEcaArea = nil
}))
}
}
......@@ -123,7 +121,7 @@ struct TaskSwitchingMenuView: View {
}
//AddECAボタン
Button(action: {
viewMode = .EcaList
taskViewModel.viewMode = .EcaList
}, label: {
Text("Add ECA Task")
.font(FontStyle.DefaultText.font)
......@@ -142,5 +140,5 @@ struct TaskSwitchingMenuView: View {
#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{
struct MenuView: View {
@EnvironmentObject private var sceneDelegate: SceneDelegate
@EnvironmentObject private var loginViewModel : LoginViewModel
@State var path: [MenuPath] = []
@Binding var isSignout: Bool
@Binding var isLogin: Bool
var body: some View {
NavigationStack(path: $path){
......@@ -137,7 +137,8 @@ struct MenuView: View {
Preferences.Id = ""
Preferences.Password = ""
Preferences.UserName = ""
isLogin = false
loginViewModel.isLogin = false
sceneDelegate.tabWindow?.isHidden = true
}))
}
}
......@@ -145,5 +146,6 @@ struct MenuView: View {
}
#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{
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.Password.rawValue) static var Password: String
......
......@@ -24,6 +24,7 @@ class PreferencesKey{
case AppStartUsingDate
case LastLoginDate
case TermsAgreeDate
case PrivacyPolicyAgreeDate
}
enum TypeURL: String{
......
......@@ -12,32 +12,41 @@ import WindowsAzureMessaging
@main
struct SailassistApp: App {
@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 {
WindowGroup {
if isAgree {
ContentView()
}else{
if !isTermsAgree{
VStack(spacing: 0){
WebView(isLoading: .constant(false), url: HttpRequestType.Terms.rawValue)
Button(action: {
YesNoButtons(yesTitle: "Accept", noTitle: "Cancel") {
Preferences.termsAgreeDate_Int64 = DateTextLib.Date2UnixTime(date: Date())
isAgree = true
}, label: {
Text("Accept")
.frame(maxWidth: .infinity)
.padding(.vertical, 10)
.border(ColorSet.LineColor04.color, width: 1, cornerRadius: 5)
})
.padding()
.background(ColorSet.BackgroundPrimary.color)
isTermsAgree = true
} noAction: {
exit(0)
}
}
.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 {
NotificationView()
.tag(Tab.alert)
MenuView(isSignout: $isSignout, isLogin: $isLogin)
MenuView(isSignout: $isSignout)
.tag(Tab.menu)
}
.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