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 @@
CODE_SIGN_ENTITLEMENTS
=
Sailassist/Sailassist.entitlements
;
CODE_SIGN_IDENTITY
=
"Apple Development"
;
CODE_SIGN_STYLE
=
Automatic
;
CURRENT_PROJECT_VERSION
=
4
6
;
CURRENT_PROJECT_VERSION
=
4
7
;
DEVELOPMENT_ASSET_PATHS
=
"\"Sailassist/Preview Content\""
;
DEVELOPMENT_TEAM
=
D2DC7QNNJ8
;
ENABLE_PREVIEWS
=
YES
;
...
...
@@ -1353,7 +1353,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME
=
AccentColor
;
CODE_SIGN_ENTITLEMENTS
=
Sailassist/Sailassist.entitlements
;
CODE_SIGN_STYLE
=
Automatic
;
CURRENT_PROJECT_VERSION
=
4
6
;
CURRENT_PROJECT_VERSION
=
4
7
;
DEVELOPMENT_ASSET_PATHS
=
"\"Sailassist/Preview Content\""
;
DEVELOPMENT_TEAM
=
D2DC7QNNJ8
;
ENABLE_PREVIEWS
=
YES
;
...
...
@@ -1536,7 +1536,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME
=
AccentColor
;
CODE_SIGN_ENTITLEMENTS
=
Sailassist/Sailassist.entitlements
;
CODE_SIGN_STYLE
=
Automatic
;
CURRENT_PROJECT_VERSION
=
4
6
;
CURRENT_PROJECT_VERSION
=
4
7
;
DEVELOPMENT_ASSET_PATHS
=
"\"Sailassist/Preview Content\""
;
DEVELOPMENT_TEAM
=
D2DC7QNNJ8
;
ENABLE_PREVIEWS
=
YES
;
...
...
Seilassist/Sailassist/Chat/ChatView.swift
View file @
6062359d
...
...
@@ -58,13 +58,23 @@ struct ChatView: View {
if
let
id
=
message
.
messages
.
last
?
.
messageId
{
proxy
.
scrollTo
(
id
,
anchor
:
.
bottom
)
let
getMessage
=
GetMessage
()
getMessage
.
readNotification
()
//Warrningモードは既読は返さない
if
message
.
messages
.
last
?
.
message
!=
nil
{
let
getMessage
=
GetMessage
()
getMessage
.
readNotification
()
}
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
withAnimation
{
guard
!
value
.
isEmpty
else
{
return
}
...
...
@@ -112,25 +122,29 @@ struct AlertChatMessage: View {
var
body
:
some
View
{
if
message
.
mode
==
1
{
Rectangle
()
.
fill
(
colorScheme
==
.
light
?
.
black
:
.
white
)
.
frame
(
width
:
300
,
height
:
1
)
.
overlay
(
Text
(
" Warrning mode start "
+
DateTextLib
.
ISO86012FormatText
(
message
.
time
,
format
:
"yyyy/MM/dd HH:mm "
,
errFormat
:
""
))
.
font
(
FontStyle
.
DateText
.
font
)
.
foregroundColor
(
ColorSet
.
BodyDescriptiion
.
color
)
.
background
(
ColorSet
.
BackgroundPrimary
.
color
)
)
HStack
()
{
Rectangle
()
.
fill
(
colorScheme
==
.
light
?
.
black
:
.
white
)
.
frame
(
width
:
20
,
height
:
1
)
Text
(
"Warrning mode start "
+
DateTextLib
.
ISO86012FormatText
(
message
.
time
,
format
:
"yyyy/MM/dd HH:mm"
,
errFormat
:
""
))
.
font
(
FontStyle
.
DateText
.
font
)
.
foregroundColor
(
ColorSet
.
BodyDescriptiion
.
color
)
Rectangle
()
.
fill
(
colorScheme
==
.
light
?
.
black
:
.
white
)
.
frame
(
width
:
20
,
height
:
1
)
}
}
else
{
Rectangle
()
.
fill
(
colorScheme
==
.
light
?
.
black
:
.
white
)
.
frame
(
width
:
300
,
height
:
1
)
.
overlay
(
Text
(
" Warrning mode end "
+
DateTextLib
.
ISO86012FormatText
(
message
.
time
,
format
:
"yyyy/MM/dd HH:mm "
,
errFormat
:
""
))
.
font
(
FontStyle
.
DateText
.
font
)
.
foregroundColor
(
ColorSet
.
BodyDescriptiion
.
color
)
.
background
(
ColorSet
.
BackgroundPrimary
.
color
)
)
HStack
()
{
Rectangle
()
.
fill
(
colorScheme
==
.
light
?
.
black
:
.
white
)
.
frame
(
width
:
20
,
height
:
1
)
Text
(
"Warrning mode end "
+
DateTextLib
.
ISO86012FormatText
(
message
.
time
,
format
:
"yyyy/MM/dd HH:mm"
,
errFormat
:
""
))
.
font
(
FontStyle
.
DateText
.
font
)
.
foregroundColor
(
ColorSet
.
BodyDescriptiion
.
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 {
@State
var
isActionSheet
=
false
@State
var
isImagePicker
=
false
@FocusState
var
isKeyboard
:
Bool
@State
var
isSignalrRestert
=
false
@Binding
var
isFocus
:
Bool
var
body
:
some
View
{
...
...
@@ -96,9 +97,11 @@ struct ChatInputView: View {
.
resizable
()
.
frame
(
width
:
24
,
height
:
24
)
.
padding
(
10
)
.
opacity
(
inputText
.
isEmpty
?
0.5
:
1.0
)
}
.
padding
(
.
vertical
,
6
)
.
padding
(
.
trailing
,
11
)
.
disabled
(
inputText
.
isEmpty
)
}
.
background
(
ColorSet
.
BackgroundSecondary
.
color
)
.
fullScreenCover
(
isPresented
:
.
constant
(
isImagePicker
),
onDismiss
:
{
...
...
@@ -136,7 +139,13 @@ struct ChatInputView: View {
}
.
frame
(
maxHeight
:
55
)
.
alert
(
"Error"
,
isPresented
:
$
isChatAlert
)
{
Button
(
"OK"
)
{}
Button
(
"OK"
)
{
if
self
.
isSignalrRestert
{
let
signalRService
=
SignalR
()
signalRService
.
startConnection
()
self
.
isSignalrRestert
=
false
}
}
}
message
:
{
Text
(
"The message could not be sent."
)
}
...
...
@@ -187,7 +196,6 @@ struct ChatInputView: View {
if
let
e
=
error
{
print
(
debug
:
"chat error
\(
e
)
"
)
// msg.messages.removeLast() //最後に追加したメッセージを削除
isChatAlert
=
true
}
else
{
isKeyboard
=
false
...
...
@@ -204,10 +212,7 @@ struct ChatInputView: View {
signalRService
.
stopConnection
()
Thread
.
sleep
(
forTimeInterval
:
1.0
)
signalRService
.
startConnection
()
Thread
.
sleep
(
forTimeInterval
:
2.0
)
// signalRService.chatMessage(message: inputText, completion: responseChatMessage)
self
.
isSignalrRestert
=
true
}
}
}
...
...
Seilassist/Sailassist/SailassistApp.swift
View file @
6062359d
...
...
@@ -205,8 +205,8 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M
self
.
msg
.
mode
=
false
}
let
message
=
GetMessage
(
)
message
.
start
(
)
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
:
[]
)
self
.
msg
.
messages
.
append
(
ownMsg
)
}
//アプリ終了時
...
...
@@ -273,10 +273,11 @@ class SignalR: NSObject {
}
func
chatMode
(
mode
:
Bool
,
completion
:
@escaping
(
_
error
:
Error
?)
->
Void
)
{
print
(
debug
:
"chatMode
\(
mode
)
"
)
var
request
=
ReqChatModeMessage
(
shipId
:
Preferences
.
shipId
)
request
.
location
=
2
//1:Shore , 2:Ship
request
.
fromeId
=
String
(
SharingData
.
my
.
id
)
//ユーザーID
if
mode
==
true
{
if
mode
==
true
{
request
.
mode
=
1
}
else
{
request
.
mode
=
0
...
...
@@ -344,16 +345,10 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
return
}
let
subtitle
=
arrAlert
[
"subtitle"
]
as?
String
??
""
//送信先名称
let
strTitle
=
arrAlert
[
"title"
]
as?
String
??
""
//船名
//
let strTitle = arrAlert["title"] as? String ?? "" //船名
// let strBody = arrAlert["body"] as? String ?? "" //送信内容
// print(debug: "called \(subtitle) \(strTitle) \(strBody)")
if
strTitle
==
"Chat Warning"
{
if
SharingData
.
message
.
mode
{
return
}
}
//送信先名称が同一の場合は通知を出さない
if
subtitle
==
Preferences
.
UserName
{
return
...
...
Seilassist/Sailassist/SharingData/SharingData.swift
View file @
6062359d
...
...
@@ -362,7 +362,7 @@ class SharingData{
@Published
var
messages
:
[
ChatMessage
]
=
[]
@Published
var
users
:
[
ChatUser
]
=
[]
@Published
var
viewCnt
:
Int
=
0
//未読数
@Published
var
sendInf
:
Bool
=
false
@Published
var
sendInf
:
Bool
=
false
//送信状態
func
changeMode
(){
self
.
mode
.
toggle
()
...
...
Seilassist/Sailassist/Tab/MainTabView.swift
View file @
6062359d
...
...
@@ -109,17 +109,19 @@ struct MainTabView: View {
struct
CustomTabBar
:
View
{
@EnvironmentObject
private
var
selectedTabModel
:
SelectedTabModel
@State
private
var
isModeAlert
:
Bool
=
false
@State
var
isLocationAlert
=
false
@Environment(\.openURL)
var
openURL
@ObservedObject
var
my
=
SharingData
.
my
@ObservedObject
var
message
=
SharingData
.
message
@ObservedObject
var
location
=
SharingData
.
location
@ObservedObject
var
pushHistory
=
SharingData
.
pushHistory
@State
var
isSignalrRestert
=
false
var
body
:
some
View
{
VStack
(
spacing
:
0
){
Divider
()
HStack
(
spacing
:
0
){
ForEach
(
Tab
.
allCases
,
id
:
\
.
rawValue
)
{
tab
in
Button
(
action
:
{
...
...
@@ -204,22 +206,25 @@ struct CustomTabBar: View {
.
frame
(
maxWidth
:
.
infinity
,
maxHeight
:
.
infinity
)
.
contentShape
(
.
rect
)
})
}
}
.
frame
(
height
:
50
)
}
.
background
(
ColorSet
.
BottomNav
.
color
)
.
alert
(
""
,
isPresented
:
$
selectedTabModel
.
isShowChangeEmrMode
)
{
Button
(
"Yes"
){
Button
(
"Yes"
)
{
var
chatMode
=
SharingData
.
message
.
mode
chatMode
.
toggle
()
let
signalRService
=
SignalR
()
signalRService
.
chatMode
(
mode
:
chatMode
,
completion
:
responseChatMode
)
SharingData
.
message
.
sendInf
=
true
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
3.0
)
{
restartChatMode
()
}
}
Button
(
"No"
){
}
Button
(
"No"
)
{}
}
message
:
{
Text
(
"Do you change an warning mode?"
)
}
...
...
@@ -241,18 +246,46 @@ struct CustomTabBar: View {
}
message
:
{
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モードレスポンス
*/
func
responseChatMode
(
error
:
Error
?)
{
print
(
debug
:
"responseChatMode"
)
SharingData
.
message
.
sendInf
=
false
if
let
e
=
error
{
print
(
debug
:
"Error chat:
\(
e
)
"
)
isModeAlert
=
true
}
else
{
SharingData
.
message
.
changeMode
()
}
}
/**
* モード変更レスポンスが無かった場合
*/
func
restartChatMode
()
{
if
SharingData
.
message
.
sendInf
{
let
signalRService
=
SignalR
()
signalRService
.
stopConnection
()
Thread
.
sleep
(
forTimeInterval
:
1.0
)
self
.
isSignalrRestert
=
true
}
}
}
#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