Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Sailassist
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
CpjJwWHV
Sailassist
Commits
6062359d
Commit
6062359d
authored
Aug 25, 2024
by
shigemi miura
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
チャット・ワーニングモード変更時のエラー処理変更
parent
61d961f1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
46 deletions
+93
-46
project.pbxproj
Seilassist/Sailassist.xcodeproj/project.pbxproj
+3
-3
ChatView.swift
Seilassist/Sailassist/Chat/ChatView.swift
+34
-20
ChatInputView.swift
Seilassist/Sailassist/Chat/View/ChatInputView.swift
+11
-6
SailassistApp.swift
Seilassist/Sailassist/SailassistApp.swift
+5
-10
SharingData.swift
Seilassist/Sailassist/SharingData/SharingData.swift
+1
-1
MainTabView.swift
Seilassist/Sailassist/Tab/MainTabView.swift
+39
-6
No files found.
Seilassist/Sailassist.xcodeproj/project.pbxproj
View file @
6062359d
...
@@ -1307,7 +1307,7 @@
...
@@ -1307,7 +1307,7 @@
CODE_SIGN_ENTITLEMENTS
=
Sailassist/Sailassist.entitlements
;
CODE_SIGN_ENTITLEMENTS
=
Sailassist/Sailassist.entitlements
;
CODE_SIGN_IDENTITY
=
"Apple Development"
;
CODE_SIGN_IDENTITY
=
"Apple Development"
;
CODE_SIGN_STYLE
=
Automatic
;
CODE_SIGN_STYLE
=
Automatic
;
CURRENT_PROJECT_VERSION
=
4
6
;
CURRENT_PROJECT_VERSION
=
4
7
;
DEVELOPMENT_ASSET_PATHS
=
"\"Sailassist/Preview Content\""
;
DEVELOPMENT_ASSET_PATHS
=
"\"Sailassist/Preview Content\""
;
DEVELOPMENT_TEAM
=
D2DC7QNNJ8
;
DEVELOPMENT_TEAM
=
D2DC7QNNJ8
;
ENABLE_PREVIEWS
=
YES
;
ENABLE_PREVIEWS
=
YES
;
...
@@ -1353,7 +1353,7 @@
...
@@ -1353,7 +1353,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME
=
AccentColor
;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME
=
AccentColor
;
CODE_SIGN_ENTITLEMENTS
=
Sailassist/Sailassist.entitlements
;
CODE_SIGN_ENTITLEMENTS
=
Sailassist/Sailassist.entitlements
;
CODE_SIGN_STYLE
=
Automatic
;
CODE_SIGN_STYLE
=
Automatic
;
CURRENT_PROJECT_VERSION
=
4
6
;
CURRENT_PROJECT_VERSION
=
4
7
;
DEVELOPMENT_ASSET_PATHS
=
"\"Sailassist/Preview Content\""
;
DEVELOPMENT_ASSET_PATHS
=
"\"Sailassist/Preview Content\""
;
DEVELOPMENT_TEAM
=
D2DC7QNNJ8
;
DEVELOPMENT_TEAM
=
D2DC7QNNJ8
;
ENABLE_PREVIEWS
=
YES
;
ENABLE_PREVIEWS
=
YES
;
...
@@ -1536,7 +1536,7 @@
...
@@ -1536,7 +1536,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME
=
AccentColor
;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME
=
AccentColor
;
CODE_SIGN_ENTITLEMENTS
=
Sailassist/Sailassist.entitlements
;
CODE_SIGN_ENTITLEMENTS
=
Sailassist/Sailassist.entitlements
;
CODE_SIGN_STYLE
=
Automatic
;
CODE_SIGN_STYLE
=
Automatic
;
CURRENT_PROJECT_VERSION
=
4
6
;
CURRENT_PROJECT_VERSION
=
4
7
;
DEVELOPMENT_ASSET_PATHS
=
"\"Sailassist/Preview Content\""
;
DEVELOPMENT_ASSET_PATHS
=
"\"Sailassist/Preview Content\""
;
DEVELOPMENT_TEAM
=
D2DC7QNNJ8
;
DEVELOPMENT_TEAM
=
D2DC7QNNJ8
;
ENABLE_PREVIEWS
=
YES
;
ENABLE_PREVIEWS
=
YES
;
...
...
Seilassist/Sailassist/Chat/ChatView.swift
View file @
6062359d
...
@@ -58,13 +58,23 @@ struct ChatView: View {
...
@@ -58,13 +58,23 @@ struct ChatView: View {
if
let
id
=
message
.
messages
.
last
?
.
messageId
{
if
let
id
=
message
.
messages
.
last
?
.
messageId
{
proxy
.
scrollTo
(
id
,
anchor
:
.
bottom
)
proxy
.
scrollTo
(
id
,
anchor
:
.
bottom
)
let
getMessage
=
GetMessage
()
//Warrningモードは既読は返さない
getMessage
.
readNotification
()
if
message
.
messages
.
last
?
.
message
!=
nil
{
let
getMessage
=
GetMessage
()
getMessage
.
readNotification
()
}
message
.
viewCnt
=
0
message
.
viewCnt
=
0
}
}
}
}
}
}
.
onChange
(
of
:
message
.
mode
)
{
newValue
in
withAnimation
{
if
let
id
=
message
.
messages
.
last
?
.
messageId
{
proxy
.
scrollTo
(
id
,
anchor
:
.
bottom
)
}
}
}
.
onReceive
(
message
.
$
messages
)
{
(
value
)
in
.
onReceive
(
message
.
$
messages
)
{
(
value
)
in
withAnimation
{
withAnimation
{
guard
!
value
.
isEmpty
else
{
return
}
guard
!
value
.
isEmpty
else
{
return
}
...
@@ -112,25 +122,29 @@ struct AlertChatMessage: View {
...
@@ -112,25 +122,29 @@ struct AlertChatMessage: View {
var
body
:
some
View
{
var
body
:
some
View
{
if
message
.
mode
==
1
{
if
message
.
mode
==
1
{
Rectangle
()
HStack
()
{
.
fill
(
colorScheme
==
.
light
?
.
black
:
.
white
)
Rectangle
()
.
frame
(
width
:
300
,
height
:
1
)
.
fill
(
colorScheme
==
.
light
?
.
black
:
.
white
)
.
overlay
(
.
frame
(
width
:
20
,
height
:
1
)
Text
(
" Warrning mode start "
+
DateTextLib
.
ISO86012FormatText
(
message
.
time
,
format
:
"yyyy/MM/dd HH:mm "
,
errFormat
:
""
))
Text
(
"Warrning mode start "
+
DateTextLib
.
ISO86012FormatText
(
message
.
time
,
format
:
"yyyy/MM/dd HH:mm"
,
errFormat
:
""
))
.
font
(
FontStyle
.
DateText
.
font
)
.
font
(
FontStyle
.
DateText
.
font
)
.
foregroundColor
(
ColorSet
.
BodyDescriptiion
.
color
)
.
foregroundColor
(
ColorSet
.
BodyDescriptiion
.
color
)
.
background
(
ColorSet
.
BackgroundPrimary
.
color
)
Rectangle
()
)
.
fill
(
colorScheme
==
.
light
?
.
black
:
.
white
)
.
frame
(
width
:
20
,
height
:
1
)
}
}
else
{
}
else
{
Rectangle
()
HStack
()
{
.
fill
(
colorScheme
==
.
light
?
.
black
:
.
white
)
Rectangle
()
.
frame
(
width
:
300
,
height
:
1
)
.
fill
(
colorScheme
==
.
light
?
.
black
:
.
white
)
.
overlay
(
.
frame
(
width
:
20
,
height
:
1
)
Text
(
" Warrning mode end "
+
DateTextLib
.
ISO86012FormatText
(
message
.
time
,
format
:
"yyyy/MM/dd HH:mm "
,
errFormat
:
""
))
Text
(
"Warrning mode end "
+
DateTextLib
.
ISO86012FormatText
(
message
.
time
,
format
:
"yyyy/MM/dd HH:mm"
,
errFormat
:
""
))
.
font
(
FontStyle
.
DateText
.
font
)
.
font
(
FontStyle
.
DateText
.
font
)
.
foregroundColor
(
ColorSet
.
BodyDescriptiion
.
color
)
.
foregroundColor
(
ColorSet
.
BodyDescriptiion
.
color
)
.
background
(
ColorSet
.
BackgroundPrimary
.
color
)
Rectangle
()
)
.
fill
(
colorScheme
==
.
light
?
.
black
:
.
white
)
.
frame
(
width
:
20
,
height
:
1
)
}
}
}
}
}
}
}
...
...
Seilassist/Sailassist/Chat/View/ChatInputView.swift
View file @
6062359d
...
@@ -23,6 +23,7 @@ struct ChatInputView: View {
...
@@ -23,6 +23,7 @@ struct ChatInputView: View {
@State
var
isActionSheet
=
false
@State
var
isActionSheet
=
false
@State
var
isImagePicker
=
false
@State
var
isImagePicker
=
false
@FocusState
var
isKeyboard
:
Bool
@FocusState
var
isKeyboard
:
Bool
@State
var
isSignalrRestert
=
false
@Binding
var
isFocus
:
Bool
@Binding
var
isFocus
:
Bool
var
body
:
some
View
{
var
body
:
some
View
{
...
@@ -96,9 +97,11 @@ struct ChatInputView: View {
...
@@ -96,9 +97,11 @@ struct ChatInputView: View {
.
resizable
()
.
resizable
()
.
frame
(
width
:
24
,
height
:
24
)
.
frame
(
width
:
24
,
height
:
24
)
.
padding
(
10
)
.
padding
(
10
)
.
opacity
(
inputText
.
isEmpty
?
0.5
:
1.0
)
}
}
.
padding
(
.
vertical
,
6
)
.
padding
(
.
vertical
,
6
)
.
padding
(
.
trailing
,
11
)
.
padding
(
.
trailing
,
11
)
.
disabled
(
inputText
.
isEmpty
)
}
}
.
background
(
ColorSet
.
BackgroundSecondary
.
color
)
.
background
(
ColorSet
.
BackgroundSecondary
.
color
)
.
fullScreenCover
(
isPresented
:
.
constant
(
isImagePicker
),
onDismiss
:
{
.
fullScreenCover
(
isPresented
:
.
constant
(
isImagePicker
),
onDismiss
:
{
...
@@ -136,7 +139,13 @@ struct ChatInputView: View {
...
@@ -136,7 +139,13 @@ struct ChatInputView: View {
}
}
.
frame
(
maxHeight
:
55
)
.
frame
(
maxHeight
:
55
)
.
alert
(
"Error"
,
isPresented
:
$
isChatAlert
)
{
.
alert
(
"Error"
,
isPresented
:
$
isChatAlert
)
{
Button
(
"OK"
)
{}
Button
(
"OK"
)
{
if
self
.
isSignalrRestert
{
let
signalRService
=
SignalR
()
signalRService
.
startConnection
()
self
.
isSignalrRestert
=
false
}
}
}
message
:
{
}
message
:
{
Text
(
"The message could not be sent."
)
Text
(
"The message could not be sent."
)
}
}
...
@@ -187,7 +196,6 @@ struct ChatInputView: View {
...
@@ -187,7 +196,6 @@ struct ChatInputView: View {
if
let
e
=
error
{
if
let
e
=
error
{
print
(
debug
:
"chat error
\(
e
)
"
)
print
(
debug
:
"chat error
\(
e
)
"
)
// msg.messages.removeLast() //最後に追加したメッセージを削除
isChatAlert
=
true
isChatAlert
=
true
}
else
{
}
else
{
isKeyboard
=
false
isKeyboard
=
false
...
@@ -204,10 +212,7 @@ struct ChatInputView: View {
...
@@ -204,10 +212,7 @@ struct ChatInputView: View {
signalRService
.
stopConnection
()
signalRService
.
stopConnection
()
Thread
.
sleep
(
forTimeInterval
:
1.0
)
Thread
.
sleep
(
forTimeInterval
:
1.0
)
signalRService
.
startConnection
()
self
.
isSignalrRestert
=
true
Thread
.
sleep
(
forTimeInterval
:
2.0
)
// signalRService.chatMessage(message: inputText, completion: responseChatMessage)
}
}
}
}
}
}
...
...
Seilassist/Sailassist/SailassistApp.swift
View file @
6062359d
...
@@ -205,8 +205,8 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M
...
@@ -205,8 +205,8 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M
self
.
msg
.
mode
=
false
self
.
msg
.
mode
=
false
}
}
let
message
=
GetMessage
(
)
let
ownMsg
=
ChatMessage
(
shipId
:
message
.
shipId
,
messageId
:
UUID
()
.
uuidString
,
type
:
3
,
time
:
DateTextLib
.
Date2ISO8601Text
(
Date
()),
location
:
message
.
location
,
from
:
nil
,
fromId
:
nil
,
mode
:
message
.
mode
,
message
:
nil
,
stampId
:
0
,
viewer
:
[]
)
message
.
start
(
)
self
.
msg
.
messages
.
append
(
ownMsg
)
}
}
//アプリ終了時
//アプリ終了時
...
@@ -273,10 +273,11 @@ class SignalR: NSObject {
...
@@ -273,10 +273,11 @@ class SignalR: NSObject {
}
}
func
chatMode
(
mode
:
Bool
,
completion
:
@escaping
(
_
error
:
Error
?)
->
Void
)
{
func
chatMode
(
mode
:
Bool
,
completion
:
@escaping
(
_
error
:
Error
?)
->
Void
)
{
print
(
debug
:
"chatMode
\(
mode
)
"
)
var
request
=
ReqChatModeMessage
(
shipId
:
Preferences
.
shipId
)
var
request
=
ReqChatModeMessage
(
shipId
:
Preferences
.
shipId
)
request
.
location
=
2
//1:Shore , 2:Ship
request
.
location
=
2
//1:Shore , 2:Ship
request
.
fromeId
=
String
(
SharingData
.
my
.
id
)
//ユーザーID
request
.
fromeId
=
String
(
SharingData
.
my
.
id
)
//ユーザーID
if
mode
==
true
{
if
mode
==
true
{
request
.
mode
=
1
request
.
mode
=
1
}
else
{
}
else
{
request
.
mode
=
0
request
.
mode
=
0
...
@@ -344,16 +345,10 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
...
@@ -344,16 +345,10 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
return
return
}
}
let
subtitle
=
arrAlert
[
"subtitle"
]
as?
String
??
""
//送信先名称
let
subtitle
=
arrAlert
[
"subtitle"
]
as?
String
??
""
//送信先名称
let
strTitle
=
arrAlert
[
"title"
]
as?
String
??
""
//船名
//
let strTitle = arrAlert["title"] as? String ?? "" //船名
// let strBody = arrAlert["body"] as? String ?? "" //送信内容
// let strBody = arrAlert["body"] as? String ?? "" //送信内容
// print(debug: "called \(subtitle) \(strTitle) \(strBody)")
// print(debug: "called \(subtitle) \(strTitle) \(strBody)")
if
strTitle
==
"Chat Warning"
{
if
SharingData
.
message
.
mode
{
return
}
}
//送信先名称が同一の場合は通知を出さない
//送信先名称が同一の場合は通知を出さない
if
subtitle
==
Preferences
.
UserName
{
if
subtitle
==
Preferences
.
UserName
{
return
return
...
...
Seilassist/Sailassist/SharingData/SharingData.swift
View file @
6062359d
...
@@ -362,7 +362,7 @@ class SharingData{
...
@@ -362,7 +362,7 @@ class SharingData{
@Published
var
messages
:
[
ChatMessage
]
=
[]
@Published
var
messages
:
[
ChatMessage
]
=
[]
@Published
var
users
:
[
ChatUser
]
=
[]
@Published
var
users
:
[
ChatUser
]
=
[]
@Published
var
viewCnt
:
Int
=
0
//未読数
@Published
var
viewCnt
:
Int
=
0
//未読数
@Published
var
sendInf
:
Bool
=
false
@Published
var
sendInf
:
Bool
=
false
//送信状態
func
changeMode
(){
func
changeMode
(){
self
.
mode
.
toggle
()
self
.
mode
.
toggle
()
...
...
Seilassist/Sailassist/Tab/MainTabView.swift
View file @
6062359d
...
@@ -109,17 +109,19 @@ struct MainTabView: View {
...
@@ -109,17 +109,19 @@ struct MainTabView: View {
struct
CustomTabBar
:
View
{
struct
CustomTabBar
:
View
{
@EnvironmentObject
private
var
selectedTabModel
:
SelectedTabModel
@EnvironmentObject
private
var
selectedTabModel
:
SelectedTabModel
@State
private
var
isModeAlert
:
Bool
=
false
@State
var
isLocationAlert
=
false
@State
var
isLocationAlert
=
false
@Environment(\.openURL)
var
openURL
@Environment(\.openURL)
var
openURL
@ObservedObject
var
my
=
SharingData
.
my
@ObservedObject
var
my
=
SharingData
.
my
@ObservedObject
var
message
=
SharingData
.
message
@ObservedObject
var
message
=
SharingData
.
message
@ObservedObject
var
location
=
SharingData
.
location
@ObservedObject
var
location
=
SharingData
.
location
@ObservedObject
var
pushHistory
=
SharingData
.
pushHistory
@ObservedObject
var
pushHistory
=
SharingData
.
pushHistory
@State
var
isSignalrRestert
=
false
var
body
:
some
View
{
var
body
:
some
View
{
VStack
(
spacing
:
0
){
VStack
(
spacing
:
0
){
Divider
()
Divider
()
HStack
(
spacing
:
0
){
HStack
(
spacing
:
0
){
ForEach
(
Tab
.
allCases
,
id
:
\
.
rawValue
)
{
tab
in
ForEach
(
Tab
.
allCases
,
id
:
\
.
rawValue
)
{
tab
in
Button
(
action
:
{
Button
(
action
:
{
...
@@ -204,22 +206,25 @@ struct CustomTabBar: View {
...
@@ -204,22 +206,25 @@ struct CustomTabBar: View {
.
frame
(
maxWidth
:
.
infinity
,
maxHeight
:
.
infinity
)
.
frame
(
maxWidth
:
.
infinity
,
maxHeight
:
.
infinity
)
.
contentShape
(
.
rect
)
.
contentShape
(
.
rect
)
})
})
}
}
}
}
.
frame
(
height
:
50
)
.
frame
(
height
:
50
)
}
}
.
background
(
ColorSet
.
BottomNav
.
color
)
.
background
(
ColorSet
.
BottomNav
.
color
)
.
alert
(
""
,
isPresented
:
$
selectedTabModel
.
isShowChangeEmrMode
)
{
.
alert
(
""
,
isPresented
:
$
selectedTabModel
.
isShowChangeEmrMode
)
{
Button
(
"Yes"
){
Button
(
"Yes"
)
{
var
chatMode
=
SharingData
.
message
.
mode
var
chatMode
=
SharingData
.
message
.
mode
chatMode
.
toggle
()
chatMode
.
toggle
()
let
signalRService
=
SignalR
()
let
signalRService
=
SignalR
()
signalRService
.
chatMode
(
mode
:
chatMode
,
completion
:
responseChatMode
)
signalRService
.
chatMode
(
mode
:
chatMode
,
completion
:
responseChatMode
)
SharingData
.
message
.
sendInf
=
true
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
3.0
)
{
restartChatMode
()
}
}
}
Button
(
"No"
){
Button
(
"No"
)
{}
}
}
message
:
{
}
message
:
{
Text
(
"Do you change an warning mode?"
)
Text
(
"Do you change an warning mode?"
)
}
}
...
@@ -241,18 +246,46 @@ struct CustomTabBar: View {
...
@@ -241,18 +246,46 @@ struct CustomTabBar: View {
}
message
:
{
}
message
:
{
Text
(
"A new version of this app is available."
)
Text
(
"A new version of this app is available."
)
}
}
.
alert
(
"Error"
,
isPresented
:
$
isModeAlert
)
{
Button
(
"OK"
)
{
if
self
.
isSignalrRestert
{
let
signalRService
=
SignalR
()
signalRService
.
startConnection
()
isSignalrRestert
=
false
}
}
}
message
:
{
Text
(
"The mode did not change."
)
}
}
}
/**
/**
* Warninngモードレスポンス
* Warninngモードレスポンス
*/
*/
func
responseChatMode
(
error
:
Error
?)
{
func
responseChatMode
(
error
:
Error
?)
{
print
(
debug
:
"responseChatMode"
)
SharingData
.
message
.
sendInf
=
false
if
let
e
=
error
{
if
let
e
=
error
{
print
(
debug
:
"Error chat:
\(
e
)
"
)
print
(
debug
:
"Error chat:
\(
e
)
"
)
isModeAlert
=
true
}
else
{
}
else
{
SharingData
.
message
.
changeMode
()
SharingData
.
message
.
changeMode
()
}
}
}
}
/**
* モード変更レスポンスが無かった場合
*/
func
restartChatMode
()
{
if
SharingData
.
message
.
sendInf
{
let
signalRService
=
SignalR
()
signalRService
.
stopConnection
()
Thread
.
sleep
(
forTimeInterval
:
1.0
)
self
.
isSignalrRestert
=
true
}
}
}
}
#Preview {
#Preview {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment