Commit fabf54a9 authored by shigemi miura's avatar shigemi miura

ログイン変更

アイコン変更
parent d63ac4ca
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
</BuildableProductRunnable> </BuildableProductRunnable>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Canary"
shouldUseLaunchSchemeArgsEnv = "YES" shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = "" savedToolIdentifier = ""
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
......
...@@ -29,16 +29,17 @@ class LoginViewParam: ObservableObject{ ...@@ -29,16 +29,17 @@ class LoginViewParam: ObservableObject{
} }
struct LoginView: View { struct LoginView: View {
@ObservedObject var scannerViewModel = ScannerViewModel()
@StateObject var locationViewModel = LocationViewModel()
@Binding var isLogin: Bool @Binding var isLogin: Bool
@State var isQrRead: Bool = false @State var isQrRead: Bool = false
@State var viewMode: LoginViewMode = .SelectType @State var viewMode: LoginViewMode = .SelectType
@State var isProgressView = false @State var isProgressView = false
@State var isAlert = false @State var isAlert = false
@State var alertType: AlertType = .loginFailure @State var alertType: AlertType = .loginFailure
@ObservedObject var scannerViewModel = ScannerViewModel()
@State var loginViewParam = LoginViewParam() @State var loginViewParam = LoginViewParam()
@State var timer :Timer? @State var timer :Timer?
@StateObject var locationViewModel = LocationViewModel()
let sessionLogin = SessionLogin() let sessionLogin = SessionLogin()
var body: some View { var body: some View {
...@@ -66,9 +67,9 @@ struct LoginView: View { ...@@ -66,9 +67,9 @@ struct LoginView: View {
case .SelectType: case .SelectType:
LoginTypeSelectView(isQrRead: $scannerViewModel.isShowing, viewMode: $viewMode) LoginTypeSelectView(isQrRead: $scannerViewModel.isShowing, viewMode: $viewMode)
case .InputIdPassword: case .InputIdPassword:
InputIdPassWordView(viewMode: $viewMode, param: $loginViewParam) InputIdPassWordView(isLogin: $isLogin, viewMode: $viewMode, param: $loginViewParam, isProgressView: $isProgressView, isAlert: $isAlert, alertType: $alertType)
case .InputUserName: case .InputUserName:
InputUserNameView(isLogin: $isLogin, param: $loginViewParam, viewMode: $viewMode, isProgressView: $isProgressView, isAlert: $isAlert, alertType: $alertType) InputUserNameView(isLogin: $isLogin, param: $loginViewParam, viewMode: $viewMode)
} }
} else { } else {
Text("Login Check").padding() Text("Login Check").padding()
...@@ -122,15 +123,17 @@ struct LoginView: View { ...@@ -122,15 +123,17 @@ struct LoginView: View {
}) })
.onAppear() { .onAppear() {
LoginCheck() LoginCheck()
gpsCheck()
} }
.preferredColorScheme(.dark) .preferredColorScheme(.dark)
} }
func LoginCheckQR() -> () { func LoginCheckQR() -> () {
isProgressView = true
loginViewParam.shipId = Preferences.Id loginViewParam.shipId = Preferences.Id
loginViewParam.password = Preferences.Password loginViewParam.password = Preferences.Password
viewMode = .InputUserName
let login = ReqLogin(Id: Preferences.Id, Password: Preferences.Password)
sessionLogin.RequestLogin(login, completion: responseQrLogin)
} }
func LoginCheck() -> () { func LoginCheck() -> () {
...@@ -147,20 +150,54 @@ struct LoginView: View { ...@@ -147,20 +150,54 @@ struct LoginView: View {
} }
} }
func gpsCheck() -> () { func responseQrLogin(result: Result<Data, APIError>) {
switch locationViewModel.authorizationStatus { print(debug: "calld")
case .notDetermined: switch result {
case .success(let resultData):
let serverSession = ServerSession()
let resjson = serverSession.fromJSON(resultData: resultData, resltType: ResLogin.self)
if let res = resjson {
SharingData.my.id = res.id
SharingData.my.shipName = res.shipName
SharingData.my.imo = res.imo
SharingData.my.mmsi = res.mmsi
Preferences.shipId = res.shipId
}
Preferences.lastLoginDate_Int64 = DateTextLib.Date2UnixTime(date: Date())
viewMode = .InputUserName
// let ecaArea = EcaArea()
// ecaArea.start()
timer = Timer.scheduledTimer(withTimeInterval: 30.0, repeats: true) { _ in
print(debug: "called timer")
let eca = EcaTask()
eca.start()
let message = GetMessage()
message.start()
let route = MonitoringRoute()
route.start()
let ecaList = GetEcaList()
ecaList.start()
let pushHistory = GetPushHistory()
pushHistory.start()
}
timer?.fire()
case .failure(let errorCode):
print(debug: errorCode)
isLogin = false
isAlert = true isAlert = true
alertType = .gpsPermission alertType = .loginFailure
case .restricted: break
ErrorView(errorText: "位置情報の使用が制限されています。")
case .denied:
ErrorView(errorText: "位置情報を使用できません。")
case .authorizedAlways, .authorizedWhenInUse:
print(debug: "called")
default:
Text("Unexpected status")
} }
isProgressView = false
} }
func responseLogin(result: Result<Data, APIError>) { func responseLogin(result: Result<Data, APIError>) {
...@@ -184,7 +221,7 @@ struct LoginView: View { ...@@ -184,7 +221,7 @@ struct LoginView: View {
// let ecaArea = EcaArea() // let ecaArea = EcaArea()
// ecaArea.start() // ecaArea.start()
timer = Timer.scheduledTimer(withTimeInterval: 60.0 * 10, repeats: true) { _ in timer = Timer.scheduledTimer(withTimeInterval: 30.0, repeats: true) { _ in
print(debug: "called timer") print(debug: "called timer")
let eca = EcaTask() let eca = EcaTask()
eca.start() eca.start()
......
...@@ -9,10 +9,17 @@ import SwiftUI ...@@ -9,10 +9,17 @@ import SwiftUI
import Combine import Combine
struct InputIdPassWordView: View { struct InputIdPassWordView: View {
@Binding var isLogin: Bool
@Binding var viewMode : LoginViewMode @Binding var viewMode : LoginViewMode
@Binding var param : LoginViewParam @Binding var param : LoginViewParam
@Binding var isProgressView : Bool
@Binding var isAlert : Bool
@Binding var alertType: AlertType
@State private var isUserNmaeEmpty = false @State private var isUserNmaeEmpty = false
@State private var isIdPassWordEmpty = false @State private var isIdPassWordEmpty = false
@State var timer :Timer?
let sessionLogin = SessionLogin()
var body: some View { var body: some View {
VStack{ VStack{
...@@ -65,7 +72,10 @@ struct InputIdPassWordView: View { ...@@ -65,7 +72,10 @@ struct InputIdPassWordView: View {
if param.shipId.isEmpty || param.password.isEmpty { if param.shipId.isEmpty || param.password.isEmpty {
isIdPassWordEmpty = true isIdPassWordEmpty = true
} else { } else {
viewMode = .InputUserName isAlert = false
isProgressView = true
let login = ReqLogin(Id: param.shipId, Password: param.password)
sessionLogin.RequestLogin(login, completion: responseLogin)
} }
}, label: { }, label: {
Text("Sign In") Text("Sign In")
...@@ -77,7 +87,7 @@ struct InputIdPassWordView: View { ...@@ -77,7 +87,7 @@ struct InputIdPassWordView: View {
}) })
.alert(isPresented: $isIdPassWordEmpty, content: { .alert(isPresented: $isIdPassWordEmpty, content: {
Alert(title: Text("error"), Alert(title: Text("error"),
message: Text("Ship Id or Password is incorrect.") message: Text("Ship ID or Password is incorrect.")
) )
}) })
.padding(.top, 40) .padding(.top, 40)
...@@ -86,8 +96,58 @@ struct InputIdPassWordView: View { ...@@ -86,8 +96,58 @@ struct InputIdPassWordView: View {
.background(ColorSet.LoginBk02.color) .background(ColorSet.LoginBk02.color)
.padding(.horizontal, 30) .padding(.horizontal, 30)
} }
func responseLogin(result: Result<Data, APIError>) {
print(debug: "calld")
switch result {
case .success(let resultData):
let serverSession = ServerSession()
let resjson = serverSession.fromJSON(resultData: resultData, resltType: ResLogin.self)
if let res = resjson {
SharingData.my.id = res.id
SharingData.my.shipName = res.shipName
SharingData.my.imo = res.imo
SharingData.my.mmsi = res.mmsi
Preferences.shipId = res.shipId
}
Preferences.lastLoginDate_Int64 = DateTextLib.Date2UnixTime(date: Date())
viewMode = .InputUserName
// let ecaArea = EcaArea()
// ecaArea.start()
timer = Timer.scheduledTimer(withTimeInterval: 30.0, repeats: true) { _ in
print(debug: "called timer")
let eca = EcaTask()
eca.start()
let message = GetMessage()
message.start()
let route = MonitoringRoute()
route.start()
let ecaList = GetEcaList()
ecaList.start()
let pushHistory = GetPushHistory()
pushHistory.start()
}
timer?.fire()
case .failure(let errorCode):
print(debug: errorCode)
isLogin = false
isAlert = true
alertType = .loginFailure
break
}
isProgressView = false
}
} }
#Preview { #Preview {
InputIdPassWordView(viewMode: .constant(.InputIdPassword), param: .constant(LoginViewParam())) InputIdPassWordView(isLogin: .constant(false), viewMode: .constant(.InputIdPassword), param: .constant(LoginViewParam()), isProgressView: .constant(false), isAlert: .constant(false), alertType: .constant(.loginFailure))
} }
...@@ -12,16 +12,12 @@ struct InputUserNameView: View { ...@@ -12,16 +12,12 @@ struct InputUserNameView: View {
@Binding var isLogin: Bool @Binding var isLogin: Bool
@Binding var param: LoginViewParam @Binding var param: LoginViewParam
@Binding var viewMode : LoginViewMode @Binding var viewMode : LoginViewMode
@Binding var isProgressView : Bool
@Binding var isAlert : Bool
@Binding var alertType: AlertType
@State private var isEmptyAlert = false @State private var isEmptyAlert = false
@State var timer :Timer?
var body: some View { var body: some View {
VStack{ VStack{
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
Text(SharingData.my.company) Text(SharingData.my.shipName)
.font(FontStyle.TitleSBold.font) .font(FontStyle.TitleSBold.font)
.padding(.leading, 10) .padding(.leading, 10)
.foregroundColor(.white) .foregroundColor(.white)
...@@ -53,12 +49,8 @@ struct InputUserNameView: View { ...@@ -53,12 +49,8 @@ struct InputUserNameView: View {
if param.userName.isEmpty { if param.userName.isEmpty {
isEmptyAlert = true isEmptyAlert = true
} else { } else {
print(debug: "signin: id(\(param.shipId)), pass(\(param.password)), name(\(param.userName))")
isAlert = false
isProgressView = true
let login = ReqLogin(Id: param.shipId, Password: param.password)
sessionLogin.RequestLogin(login, completion: responseLogin)
Preferences.UserName = param.userName Preferences.UserName = param.userName
isLogin = true
} }
}, label: { }, label: {
Text("Sign In") Text("Sign In")
...@@ -78,65 +70,9 @@ struct InputUserNameView: View { ...@@ -78,65 +70,9 @@ struct InputUserNameView: View {
.padding(EdgeInsets(top: 21, leading: 20, bottom: 32, trailing: 20)) .padding(EdgeInsets(top: 21, leading: 20, bottom: 32, trailing: 20))
.background(ColorSet.LoginBk02.color) .background(ColorSet.LoginBk02.color)
.padding(.horizontal, 30) .padding(.horizontal, 30)
}
func responseLogin(result: Result<Data, APIError>) {
print(debug: "calld")
switch result {
case .success(let resultData):
let serverSession = ServerSession()
let resjson = serverSession.fromJSON(resultData: resultData, resltType: ResLogin.self)
if let res = resjson {
SharingData.my.id = res.id
SharingData.my.shipName = res.shipName
SharingData.my.imo = res.imo
SharingData.my.mmsi = res.mmsi
Preferences.shipId = res.shipId
let notification = notificationTags()
notification.addTags()
}
Preferences.Id = param.shipId
Preferences.Password = param.password
Preferences.lastLoginDate_Int64 = DateTextLib.Date2UnixTime(date: Date())
timer = Timer.scheduledTimer(withTimeInterval: 60.0, repeats: true) { _ in
print(debug: "called timer")
let eca = EcaTask()
eca.start()
let message = GetMessage()
message.start()
let route = MonitoringRoute()
route.start()
let ecaList = GetEcaList()
ecaList.start()
let pushHistory = GetPushHistory()
pushHistory.start()
}
timer?.fire()
isProgressView = false
isLogin = true
isAlert = false
case .failure(let errorCode):
print(debug: errorCode)
isProgressView = false
isLogin = false
isAlert = true
alertType = .loginFailure
break
}
} }
} }
#Preview { #Preview {
InputUserNameView(isLogin: .constant(false), param: .constant(LoginViewParam()), viewMode: .constant(.InputIdPassword), isProgressView: .constant(false), isAlert: .constant(false), alertType: .constant(.loginFailure)) InputUserNameView(isLogin: .constant(false), param: .constant(LoginViewParam()), viewMode: .constant(.InputIdPassword))
} }
...@@ -85,7 +85,7 @@ struct TaskSwitchingMenuView: View { ...@@ -85,7 +85,7 @@ struct TaskSwitchingMenuView: View {
switch ecaAlertType { switch ecaAlertType {
case .ecaDelete: case .ecaDelete:
return Alert(title: Text("delete"), return Alert(title: Text("delete"),
message: Text("eca delete"), 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 = edittingEcaArea {
...@@ -100,7 +100,7 @@ struct TaskSwitchingMenuView: View { ...@@ -100,7 +100,7 @@ struct TaskSwitchingMenuView: View {
})) }))
case .ecaRunningStop: case .ecaRunningStop:
return Alert(title: Text("stop"), return Alert(title: Text("stop"),
message: Text("eca running stop"), 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 = edittingEcaArea {
......
...@@ -50,8 +50,10 @@ enum MenuPath: String, Hashable{ ...@@ -50,8 +50,10 @@ enum MenuPath: String, Hashable{
} }
struct MenuView: View { struct MenuView: View {
@EnvironmentObject private var sceneDelegate: SceneDelegate
@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){
...@@ -60,10 +62,10 @@ struct MenuView: View { ...@@ -60,10 +62,10 @@ struct MenuView: View {
HStack { HStack {
VStack(alignment: .leading, spacing: 10){ VStack(alignment: .leading, spacing: 10){
Text("Group") Text(SharingData.my.shipName)
.font(FontStyle.TitleL.font) .font(FontStyle.TitleL.font)
.foregroundColor(ColorSet.Body.color) .foregroundColor(ColorSet.Body.color)
Text(SharingData.my.company) Text(Preferences.UserName)
.font(FontStyle.EmphasisText.font) .font(FontStyle.EmphasisText.font)
.foregroundColor(ColorSet.BodyDescriptiion.color) .foregroundColor(ColorSet.BodyDescriptiion.color)
} }
...@@ -125,23 +127,23 @@ struct MenuView: View { ...@@ -125,23 +127,23 @@ struct MenuView: View {
} }
.navigationBarHidden(true) .navigationBarHidden(true)
.background(ColorSet.BackgroundPrimary.color) .background(ColorSet.BackgroundPrimary.color)
} }
} }
.alert(isPresented: $isSignout) { .alert(isPresented: $isSignout) {
return Alert(title: Text("Sign Out"), return Alert(title: Text("Sign Out"),
message: Text("Are you sure?"), message: Text("Are you sure?"),
primaryButton: .default(Text("Yes"), action: { primaryButton: .default(Text("No")), secondaryButton: .cancel(Text("Yes"), action: {
Preferences.Id = "" Preferences.Id = ""
Preferences.Password = "" Preferences.Password = ""
Preferences.UserName = "" Preferences.UserName = ""
}), secondaryButton: .cancel(Text("No"))) isLogin = false
}))
} }
} }
} }
} }
#Preview { #Preview {
MenuView(isSignout: .constant(false)) MenuView(isSignout: .constant(false), isLogin: .constant(false))
} }
...@@ -18,10 +18,12 @@ struct MenuContentView: View { ...@@ -18,10 +18,12 @@ struct MenuContentView: View {
Spacer() Spacer()
if content.title != "Sign Out" {
Image("ink_01") Image("ink_01")
.resizable() .resizable()
.frame(width: 22, height: 22) .frame(width: 22, height: 22)
} }
}
.padding(.vertical, 17) .padding(.vertical, 17)
.padding(.horizontal, 30) .padding(.horizontal, 30)
......
...@@ -100,8 +100,8 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M ...@@ -100,8 +100,8 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M
let bamTag = "bam-" + shipId let bamTag = "bam-" + shipId
let taskAlertTag = "taskalert-" + shipId let taskAlertTag = "taskalert-" + shipId
let sailassistTag = "sailassist-" + shipId let sailassistTag = "sailassist-" + shipId
// MSNotificationHub.addTags([routeTag, bamTag, taskAlertTag, sailassistTag]) MSNotificationHub.addTags([routeTag, bamTag, taskAlertTag, sailassistTag])
MSNotificationHub.addTags([routeTag]) // MSNotificationHub.addTags([routeTag])
} }
} }
......
...@@ -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) MenuView(isSignout: $isSignout, isLogin: $isLogin)
.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