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
07a61c4c
Commit
07a61c4c
authored
Nov 20, 2023
by
sugita mamoru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
チャットをSharingDataを参照して表示するようにした
parent
4780c488
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
156 additions
and
28 deletions
+156
-28
Contents.json
...assist/Assets.xcassets/Map/ownShip.imageset/Contents.json
+21
-0
swStartBack@2x.png
...t/Assets.xcassets/Map/ownShip.imageset/swStartBack@2x.png
+0
-0
ChatView.swift
Seilassist/Sailassist/Chat/ChatView.swift
+18
-5
MyChatContentView.swift
Seilassist/Sailassist/Chat/View/MyChatContentView.swift
+25
-4
OtherChatContentView.swift
Seilassist/Sailassist/Chat/View/OtherChatContentView.swift
+25
-4
ResGetMessages.swift
Seilassist/Sailassist/Json/ResGetMessages.swift
+5
-5
DateTextLib.swift
Seilassist/Sailassist/Lib/DateTextLib.swift
+4
-0
MapRepresentable.swift
Seilassist/Sailassist/Map/MapRepresentable.swift
+5
-6
EcaSettingView.swift
Seilassist/Sailassist/Map/Task/View/EcaSettingView.swift
+1
-1
PDFDownloadManager.swift
Seilassist/Sailassist/ServerSession/PDFDownloadManager.swift
+0
-1
SharingData.swift
Seilassist/Sailassist/SharingData/SharingData.swift
+52
-2
No files found.
Seilassist/Sailassist/Assets.xcassets/Map/ownShip.imageset/Contents.json
0 → 100644
View file @
07a61c4c
{
"images"
:
[
{
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"swStartBack@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
Seilassist/Sailassist/Assets.xcassets/Map/ownShip.imageset/swStartBack@2x.png
0 → 100644
View file @
07a61c4c
18.6 KB
Seilassist/Sailassist/Chat/ChatView.swift
View file @
07a61c4c
...
...
@@ -8,11 +8,11 @@
import
SwiftUI
struct
ChatView
:
View
{
@
State
var
isEmargency
:
Bool
=
fals
e
@
ObservedObject
var
message
=
SharingData
.
messag
e
@State
var
isShowMember
:
Bool
=
false
var
body
:
some
View
{
ZStack
{
if
isEmargency
{
if
message
.
mode
==
1
{
LinearGradient
(
gradient
:
Gradient
(
colors
:
[
.
chatEmargencyColor1
,
.
chatEmargencyColor2
]),
startPoint
:
.
top
,
endPoint
:
.
bottom
)
.
ignoresSafeArea
()
}
...
...
@@ -23,15 +23,28 @@ struct ChatView: View {
ScrollView
(
.
vertical
)
{
Spacer
()
.
frame
(
height
:
20
)
OtherChatContentView
()
MyChatContentView
()
ForEach
(
message
.
messages
,
id
:
\
.
messageId
)
{
msg
in
if
msg
.
fromId
!=
String
(
SharingData
.
my
.
id
){
//自分のメッセージ
MyChatContentView
(
message
:
msg
)
.
padding
(
.
bottom
,
24
)
}
else
{
//他人のメッセージ
OtherChatContentView
(
message
:
msg
)
.
padding
(
.
bottom
,
24
)
}
}
}
HStack
{
Spacer
()
VStack
{
Button
{
isEmargency
.
toggle
()
if
message
.
mode
==
0
{
message
.
mode
=
1
}
else
{
message
.
mode
=
0
}
}
label
:
{
Image
(
systemName
:
"exclamationmark.triangle.fill"
)
.
foregroundColor
(
.
white
)
...
...
Seilassist/Sailassist/Chat/View/MyChatContentView.swift
View file @
07a61c4c
...
...
@@ -8,11 +8,12 @@
import
SwiftUI
struct
MyChatContentView
:
View
{
var
message
:
ChatMessage
var
body
:
some
View
{
HStack
{
Spacer
()
VStack
(
alignment
:
.
trailing
,
spacing
:
6
)
{
Text
(
"テキストメッセージテキストメッセージテキストメッセージテキストメッセージテキストメッセージテキストメッセージ"
)
Text
(
message
.
message
)
.
font
(
FontStyle
.
DefaultText
.
font
)
.
foregroundColor
(
ColorSet
.
BodyChat
.
color
)
.
padding
(
15
)
...
...
@@ -20,7 +21,7 @@ struct MyChatContentView: View {
.
cornerRadius
(
10
,
corners
:
[
.
tl
,
.
tr
,
.
bl
])
HStack
(
spacing
:
0
){
Text
(
"yyyy/MM/dd hh:mm"
)
Text
(
DateTextLib
.
ISO86012FormatText
(
message
.
time
,
format
:
"yyyy/MM/dd hh:mm"
,
errFormat
:
""
)
)
.
padding
(
.
trailing
,
8
)
Image
(
systemName
:
"eye.fill"
)
...
...
@@ -29,7 +30,7 @@ struct MyChatContentView: View {
.
frame
(
width
:
17
,
height
:
17
)
.
padding
(
.
trailing
,
4
)
Text
(
"1"
)
Text
(
String
(
message
.
viewer
.
count
)
)
}
.
font
(
FontStyle
.
DateText
.
font
)
.
foregroundColor
(
ColorSet
.
BodyDescriptiion
.
color
)
...
...
@@ -41,5 +42,25 @@ struct MyChatContentView: View {
}
#Preview {
MyChatContentView
()
MyChatContentView
(
message
:
ChatMessage
(
shipId
:
10000003
,
messageId
:
"92c2dfb5-f5ed-4943-98a3-9848d7f9a962"
,
type
:
0
,
time
:
"2023-10-06T01:51:01.872Z"
,
location
:
1
,
from
:
"はだだ"
,
fromId
:
"487420489"
,
message
:
"999"
,
stampId
:
0
,
viewer
:
[
Viewer
(
time
:
"2023-10-06T01:51:12.973Z"
,
location
:
1
,
id
:
""
),
Viewer
(
time
:
"2023-10-06T01:51:12.973Z"
,
location
:
2
,
id
:
""
)
]
))
}
Seilassist/Sailassist/Chat/View/OtherChatContentView.swift
View file @
07a61c4c
...
...
@@ -8,14 +8,15 @@
import
SwiftUI
struct
OtherChatContentView
:
View
{
var
message
:
ChatMessage
var
body
:
some
View
{
HStack
{
VStack
(
alignment
:
.
leading
,
spacing
:
4
)
{
Text
(
"Taro"
)
Text
(
message
.
from
)
.
font
(
FontStyle
.
EmphasisText
.
font
)
.
foregroundColor
(
ColorSet
.
Body
.
color
)
VStack
(
alignment
:
.
leading
,
spacing
:
10
)
{
Text
(
"テキストメッセージテキストメッセージテキストメッセージテキストメッセージテキストメッセージテキストメッセージ"
)
Text
(
message
.
message
)
.
font
(
FontStyle
.
DefaultText
.
font
)
.
foregroundColor
(
ColorSet
.
BodyChat
.
color
)
.
padding
(
15
)
...
...
@@ -23,7 +24,7 @@ struct OtherChatContentView: View {
.
cornerRadius
(
10
,
corners
:
[
.
tl
,
.
tr
,
.
br
])
HStack
(
alignment
:
.
top
){
Text
(
"yyyy/MM/dd hh:mm"
)
Text
(
DateTextLib
.
ISO86012FormatText
(
message
.
time
,
format
:
"yyyy/MM/dd hh:mm"
,
errFormat
:
""
)
)
.
font
(
FontStyle
.
DateText
.
font
)
.
foregroundColor
(
ColorSet
.
ChatDate
.
color
)
}
...
...
@@ -37,5 +38,25 @@ struct OtherChatContentView: View {
}
#Preview {
OtherChatContentView
()
OtherChatContentView
(
message
:
ChatMessage
(
shipId
:
10000003
,
messageId
:
"92c2dfb5-f5ed-4943-98a3-9848d7f9a962"
,
type
:
0
,
time
:
"2023-10-06T01:51:01.872Z"
,
location
:
1
,
from
:
"はだだ"
,
fromId
:
"487420489"
,
message
:
"999"
,
stampId
:
0
,
viewer
:
[
Viewer
(
time
:
"2023-10-06T01:51:12.973Z"
,
location
:
1
,
id
:
""
),
Viewer
(
time
:
"2023-10-06T01:51:12.973Z"
,
location
:
2
,
id
:
""
)
]
))
}
Seilassist/Sailassist/Json/ResGetMessages.swift
View file @
07a61c4c
...
...
@@ -9,10 +9,10 @@ import Foundation
struct
ResGetMessages
:
Codable
{
var
mode
:
Int
// 0:通常 , 1:Warning中
var
messages
:
[
m
essage
]?
var
messages
:
[
ChatM
essage
]?
}
struct
m
essage
:
Codable
{
struct
ChatM
essage
:
Codable
{
var
shipId
:
UInt
var
messageId
:
String
//各メッセージ固有ID
var
type
:
Int
//0:テキスト , 1:スタンプ , 2:画像
...
...
@@ -22,11 +22,11 @@ struct message: Codable {
var
fromId
:
String
//ユーザーID
var
message
:
String
//テキスト時:テキスト , 画像時:サムネイルのUri
var
stampId
:
Int
//スタンプ番号 0:Fire~
var
viewer
:
[
view
]
//閲覧者情報
var
viewer
:
[
Viewer
]
//閲覧者情報
}
struct
view
:
Codable
{
struct
Viewer
:
Codable
{
var
time
:
String
//確認日時
var
location
:
Int
//1:Shore , 2:Ship
var
id
:
Int
//ユーザーID
var
id
:
String
//ユーザーID
}
Seilassist/Sailassist/Lib/DateTextLib.swift
View file @
07a61c4c
...
...
@@ -68,12 +68,14 @@ class DateTextLib: NSObject {
// サーバとの通信に使う
static
func
Date2ISO8601Text
(
_
date
:
Date
)
->
String
{
let
formatter
=
ISO8601DateFormatter
()
formatter
.
formatOptions
.
insert
(
.
withFractionalSeconds
)
let
dateString
=
formatter
.
string
(
from
:
date
)
return
dateString
}
/// ISO8601文字列をDate型に変換
static
func
ISO8601Text2Date
(
_
dateString
:
String
?
)
->
Date
?
{
let
formatter
=
ISO8601DateFormatter
()
formatter
.
formatOptions
.
insert
(
.
withFractionalSeconds
)
let
setDate
=
formatter
.
date
(
from
:
dateString
??
""
)
return
setDate
}
...
...
@@ -81,6 +83,7 @@ class DateTextLib: NSObject {
/// unixTime(整数値,秒)を最終的にISO8601文字列にする
static
func
UnixTime2ISO8601Text
(
_
unixTime
:
Int64
)
->
String
{
let
formatter
=
ISO8601DateFormatter
()
formatter
.
formatOptions
.
insert
(
.
withFractionalSeconds
)
let
timeInterval
=
TimeInterval
(
integerLiteral
:
unixTime
)
let
unixDate
=
Date
(
timeIntervalSince1970
:
timeInterval
)
let
unixStr
=
formatter
.
string
(
from
:
unixDate
)
...
...
@@ -90,6 +93,7 @@ class DateTextLib: NSObject {
/// ISO8601文字列をunixint(整数値,秒)に変換
static
func
ISO8601Text2UnixTime
(
_
unixStr
:
String
?
)
->
Int64
{
let
formatter
=
ISO8601DateFormatter
()
formatter
.
formatOptions
.
insert
(
.
withFractionalSeconds
)
var
unixTime
:
Int64
=
0
if
let
setDate
=
formatter
.
date
(
from
:
unixStr
??
""
)
{
let
unixinterval
:
Double
=
setDate
.
timeIntervalSince1970
...
...
Seilassist/Sailassist/Map/MapRepresentable.swift
View file @
07a61c4c
...
...
@@ -12,6 +12,7 @@ import UIKit
struct
MapRepresentable
:
UIViewControllerRepresentable
{
@ObservedObject
var
ecaData
=
SharingData
.
eca
@ObservedObject
var
my
=
SharingData
.
my
@State
var
mapVC
=
MapViewController
()
func
makeUIViewController
(
context
:
Context
)
->
some
UIViewController
{
...
...
@@ -24,8 +25,8 @@ struct MapRepresentable: UIViewControllerRepresentable{
mapVC
.
updateEcaLine
(
line
:
ecaArea
.
points
)
}
if
let
mylocation
=
SharingData
.
my
.
location
{
mapVC
.
updateOwnShip
(
location
:
mylocation
,
bearing
:
SharingData
.
my
.
heading
)
if
let
mylocation
=
my
.
location
{
mapVC
.
updateOwnShip
(
location
:
mylocation
,
bearing
:
my
.
heading
)
if
let
ecaArea
=
ecaArea
{
mapVC
.
updateEcaSwitchingLine
(
center
:
mylocation
,
notice
:
ecaArea
.
swNotice
,
start
:
ecaArea
.
swStart
,
finish
:
ecaArea
.
swFinish
)
...
...
@@ -64,7 +65,7 @@ class MapViewController : UIViewController{
func
addImage
(){
do
{
if
let
image
=
UIImage
(
named
:
"
account
"
){
if
let
image
=
UIImage
(
named
:
"
ownShip
"
){
try
mapView
.
mapboxMap
.
style
.
addImage
(
image
,
id
:
IconImage
.
OwnShip
.
rawValue
)
}
if
let
image
=
UIImage
(
named
:
"swNoticeBack"
){
...
...
@@ -84,9 +85,7 @@ class MapViewController : UIViewController{
addImage
()
let
point
=
Point
(
LocationCoordinate2D
(
latitude
:
0
,
longitude
:
0
))
var
feature
=
Feature
(
geometry
:
point
)
// feature.properties = [PropertyKey.IconImage.rawValue: .string(IconImage.OwnShip.rawValue)]
ownShipSymbol
.
source
.
data
=
.
feature
(
feature
)
ownShipSymbol
.
source
.
data
=
.
feature
(
Feature
(
geometry
:
point
))
var
ownShipSymbolLayer
=
SymbolLayer
(
id
:
ownShipSymbol
.
layerId
)
ownShipSymbolLayer
.
source
=
ownShipSymbol
.
sourceId
ownShipSymbolLayer
.
iconImage
=
.
expression
(
Exp
(
.
get
)
{
...
...
Seilassist/Sailassist/Map/Task/View/EcaSettingView.swift
View file @
07a61c4c
...
...
@@ -46,7 +46,7 @@ struct EcaSettingView: View {
fileprivate
struct
SliderView
:
View
{
init
(
param
:
Binding
<
Float
>
,
title
:
String
,
min
:
Float
=
1
,
max
:
Float
=
10
)
{
var
thumb
=
UIImage
(
systemName
:
"circle.fill"
)
let
thumb
=
UIImage
(
systemName
:
"circle.fill"
)
UISlider
.
appearance
()
.
setThumbImage
(
thumb
,
for
:
.
normal
)
UISlider
.
appearance
()
.
maximumTrackTintColor
=
UIColor
(
ColorSet
.
Slidebar
.
color
)
self
.
_param
=
param
...
...
Seilassist/Sailassist/ServerSession/PDFDownloadManager.swift
View file @
07a61c4c
...
...
@@ -11,7 +11,6 @@ class PDFDownloadManager{
static
let
main
=
PDFDownloadManager
()
func
downloadFile
(
urlString
:
String
,
fileName
:
String
)
->
URL
?{
let
semaphore
=
DispatchSemaphore
(
value
:
0
)
guard
let
url
=
URL
(
string
:
urlString
)
else
{
return
nil
}
guard
let
resDocPath
=
FileManager
.
default
.
urls
(
for
:
.
documentDirectory
,
in
:
.
userDomainMask
)
.
last
else
{
return
nil
}
var
filePath
:
URL
?
=
resDocPath
.
appendingPathComponent
(
fileName
)
...
...
Seilassist/Sailassist/SharingData/SharingData.swift
View file @
07a61c4c
...
...
@@ -11,7 +11,7 @@ class SharingData{
static
var
my
=
My
()
class
My
:
ObservableObject
{
@Published
var
location
:
CLLocationCoordinate2D
?
=
nil
@Published
var
location
:
CLLocationCoordinate2D
?
=
.
init
(
latitude
:
0
,
longitude
:
0
)
@Published
var
gps
:
CLLocationCoordinate2D
?
=
nil
@Published
var
server
:
CLLocationCoordinate2D
?
=
nil
@Published
var
speed
:
Double
=
0.0
...
...
@@ -24,6 +24,10 @@ class SharingData{
@Published
var
shipName
:
String
=
""
@Published
var
imo
:
Int
=
0
@Published
var
mmsi
:
Int
=
0
func
setLocation
(
_
location
:
CLLocationCoordinate2D
?){
self
.
location
=
location
}
func
reset
()
{
location
=
nil
...
...
@@ -44,7 +48,53 @@ class SharingData{
static
var
message
=
Message
()
class
Message
:
ObservableObject
{
@Published
var
mode
:
Int
=
0
// 0:通常 , 1:Warning中
@Published
var
messages
:
[
message
]
=
[]
@Published
var
messages
:
[
ChatMessage
]
=
[
ChatMessage
(
shipId
:
10000003
,
messageId
:
"92c2dfb5-f5ed-4943-98a3-9848d7f9a962"
,
type
:
0
,
time
:
"2023-10-06T01:51:01.872Z"
,
location
:
1
,
from
:
"はだだ"
,
fromId
:
"487420489"
,
message
:
"999"
,
stampId
:
0
,
viewer
:
[
Viewer
(
time
:
"2023-10-06T01:51:12.973Z"
,
location
:
1
,
id
:
""
),
Viewer
(
time
:
"2023-10-06T01:51:12.973Z"
,
location
:
2
,
id
:
""
)
]
),
ChatMessage
(
shipId
:
10000001
,
messageId
:
"92c2dfb5-f5ed-4943-98a3-a848d7f9a962"
,
type
:
0
,
time
:
"2023-10-06T01:51:01.872Z"
,
location
:
1
,
from
:
"はだだ"
,
fromId
:
"487420489"
,
message
:
"999"
,
stampId
:
0
,
viewer
:
[
Viewer
(
time
:
"2023-10-06T01:51:12.973Z"
,
location
:
1
,
id
:
""
),
Viewer
(
time
:
"2023-10-06T01:51:12.973Z"
,
location
:
2
,
id
:
""
)
]
),
]
}
/**
...
...
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