Commit ec125999 authored by shigemi miura's avatar shigemi miura

チャットワーニングモード対応

チャット・通知 既読マーク
parent d074fcd0
......@@ -1307,7 +1307,7 @@
CODE_SIGN_ENTITLEMENTS = Sailassist/Sailassist.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 39;
CURRENT_PROJECT_VERSION = 40;
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 = 39;
CURRENT_PROJECT_VERSION = 40;
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 = 39;
CURRENT_PROJECT_VERSION = 40;
DEVELOPMENT_ASSET_PATHS = "\"Sailassist/Preview Content\"";
DEVELOPMENT_TEAM = D2DC7QNNJ8;
ENABLE_PREVIEWS = YES;
......
......@@ -35,6 +35,15 @@ struct NotificationView: View {
Spacer()
}
.background(ColorSet.BackgroundPrimary.color)
.onAppear {
let pushCount = pushHist.viewCnt
print(debug: "\(pushCount)")
pushHist.viewCnt = 0
}
// .onChange(of: pushHist.pushHistoryData.count) { newValue in
// let pushCount = pushHist.viewCnt
// print(debug: "\(pushCount)")
// }
}
struct TitleView: View {
......
......@@ -47,9 +47,6 @@ struct NotificationContentView: View {
.font(FontStyle.SupplementText2.font)
}
.padding(EdgeInsets(top: 17, leading: 30, bottom: 17, trailing: 30))
.onAppear {
SharingData.pushHistory.viewCnt = 0
}
}
}
......
......@@ -31,28 +31,33 @@ struct ChatView: View {
.frame(height: 20)
ForEach(message.messages, id: \.messageId) { msg in
if msg.from == Preferences.UserName {
//自分のメッセージ
MyChatContentView(message: msg)
.padding(.bottom, 24)
}else{
//他人のメッセージ
OtherChatContentView(message: msg)
if msg.message != nil {
if msg.from == Preferences.UserName {
//自分のメッセージ
MyChatContentView(message: msg)
.padding(.bottom, 24)
}else{
//他人のメッセージ
OtherChatContentView(message: msg)
.padding(.bottom, 24)
}
} else {
AlertChatMessage(message: msg)
.padding(.bottom, 24)
}
}
}
.onAppear {
if let id = message.messages.last?.messageId {
print(debug: "ChatView:onAppear")
proxy.scrollTo(id, anchor: .bottom)
message.viewCnt = 0
}
}
.onChange(of: message.messages.count) { newValue in
withAnimation {
if let id = message.messages.last?.messageId {
print(debug: "ChatView:onChange")
proxy.scrollTo(id, anchor: .bottom)
message.viewCnt = 0
}
}
}
......@@ -60,8 +65,8 @@ struct ChatView: View {
withAnimation {
guard !value.isEmpty else {return}
if let id = message.messages.last?.messageId {
print(debug: "ChatView:onReceive")
proxy.scrollTo(id, anchor: .bottom)
message.viewCnt = 0
}
}
}
......@@ -97,6 +102,35 @@ struct ChatView: View {
}
}
struct AlertChatMessage: View {
@Environment(\ .colorScheme) var colorScheme
var message : ChatMessage
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)
)
} 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)
)
}
}
}
#Preview {
ChatView()
}
......
......@@ -26,9 +26,11 @@ struct ChatMemberView: View {
.frame(width: 12, height: 12)
}
Text(user.name)
.foregroundColor(ColorSet.BodyChat.color)
.font(FontStyle.SupplementText.font)
if let name = user.name {
Text(name)
.foregroundColor(ColorSet.BodyChat.color)
.font(FontStyle.SupplementText.font)
}
}
}
.listRowBackground(ColorSet.ModalWindowFront.color)
......
......@@ -75,8 +75,10 @@ struct ChatTitleView: View {
func userName() -> String {
var usersName = ""
for user in message.users {
usersName += user.name
usersName += ","
if let name = user.name {
usersName += name
usersName += ","
}
}
return usersName
}
......
......@@ -8,10 +8,12 @@
import SwiftUI
struct ChatUrlImageView: View {
var imageUrl: String
var imageUrl = ""
init(message: ChatMessage) {
self.imageUrl = message.message
if let url = message.message {
self.imageUrl = url
}
}
var body: some View {
......@@ -43,6 +45,7 @@ struct ChatUrlImageView: View {
location: 1,
from: "はだだ",
fromId: "487420489",
mode: 0,
message: "999",
stampId: 0,
viewer: [
......
......@@ -51,6 +51,7 @@ struct ChatUrlRawImageView: View {
location: 1,
from: "はだだ",
fromId: "487420489",
mode: 0,
message: "999",
stampId: 0,
viewer: [
......
......@@ -11,50 +11,59 @@ struct MyChatContentView: View {
var message : ChatMessage
var body: some View {
HStack {
Spacer()
VStack(alignment: .trailing, spacing: 6) {
Group {
if message.message.contains("https://") { //TODO: stampIdが0
ChatUrlImageView(message: message)
} else {
Text(message.message)
.font(FontStyle.DefaultText.font)
.foregroundColor(ColorSet.BodyChat.color)
.padding(15)
.background(ColorSet.ChatBaloon.color)
.cornerRadius(10, corners: [.tl, .tr, .br])
Spacer()
VStack(alignment: .trailing, spacing: 6) {
Group {
if let msg = message.message {
if msg.contains("https://") {
ChatUrlImageView(message: message)
} else {
Text(msg)
.font(FontStyle.DefaultText.font)
.foregroundColor(ColorSet.BodyChat.color)
.padding(15)
.background(ColorSet.ChatBaloon.color)
.border(Color.red.gradient.opacity(0.6), width: (message.mode == 1 ? 6 : 0))
.clipShape(
.rect(
topLeadingRadius: 10,
bottomLeadingRadius: 0,
bottomTrailingRadius: 10,
topTrailingRadius: 10
))
}
}
}
}
HStack(spacing: 5){
//既読マーク
Text(DateTextLib.ISO86012FormatText(message.time, format: "yyyy/MM/dd HH:mm", errFormat: ""))
.padding(.trailing, 8)
let viewerCnt = viewerCnt()
Image("chat_company")
.resizable()
.scaledToFit()
.frame(width: 12, height: 12)
.padding(.trailing, 4)
Text(String(viewerCnt.0))
HStack(spacing: 5){
//既読マーク
Text(DateTextLib.ISO86012FormatText(message.time, format: "yyyy/MM/dd HH:mm", errFormat: ""))
.padding(.trailing, 8)
let viewerCnt = viewerCnt()
Image("chat_company")
.resizable()
.scaledToFit()
.frame(width: 12, height: 12)
.padding(.trailing, 4)
Image("chat_ship")
.resizable()
.scaledToFit()
.frame(width: 12, height: 12)
.padding(.trailing, 4)
Text(String(viewerCnt.1))
Text(String(viewerCnt.1))
Image("chat_ship")
.resizable()
.scaledToFit()
.frame(width: 12, height: 12)
.padding(.trailing, 4)
Text(String(viewerCnt.0))
}
.font(FontStyle.DateText.font)
.foregroundColor(ColorSet.BodyDescriptiion.color)
}
.font(FontStyle.DateText.font)
.foregroundColor(ColorSet.BodyDescriptiion.color)
}
.padding(.trailing, 20)
.padding(.trailing, 20)
}
.padding(.leading, 80)
}
func viewerCnt() -> (Int, Int) {
......@@ -80,6 +89,7 @@ struct MyChatContentView: View {
location: 1,
from: "はだだ",
fromId: "487420489",
mode: 0,
message: "999",
stampId: 0,
viewer: [
......
......@@ -12,20 +12,31 @@ struct OtherChatContentView: View {
var body: some View {
HStack {
VStack(alignment: .leading, spacing: 4) {
Text(message.from)
.font(FontStyle.EmphasisText.font)
.foregroundColor(ColorSet.Body.color)
if let from = message.from {
Text(from)
.font(FontStyle.EmphasisText.font)
.foregroundColor(ColorSet.Body.color)
}
VStack(alignment: .leading, spacing: 10) {
Group {
if message.message.contains("https://") { //TODO: stampIdが0
ChatUrlImageView(message: message)
} else {
Text(message.message)
.font(FontStyle.DefaultText.font)
.foregroundColor(ColorSet.BodyChat.color)
.padding(15)
.background(ColorSet.ChatBaloon.color)
.cornerRadius(10, corners: [.tl, .tr, .br])
if let msg = message.message {
if msg.contains("https://") {
ChatUrlImageView(message: message)
} else {
Text(msg)
.font(FontStyle.DefaultText.font)
.foregroundColor(ColorSet.BodyChat.color)
.padding(15)
.background(ColorSet.ChatBaloon.color)
.border(Color.red.gradient.opacity(0.6), width: (message.mode == 1 ? 6 : 0))
.clipShape(
.rect(
topLeadingRadius: 10,
bottomLeadingRadius: 10,
bottomTrailingRadius: 0,
topTrailingRadius: 10
))
}
}
}
......@@ -39,31 +50,6 @@ struct OtherChatContentView: View {
.padding(.leading, 20)
Spacer()
}
.padding(.trailing, 80)
}
}
struct AlertChatMessage: View {
var message : ChatMessage
var body: some View {
HStack {
Image(systemName: "exclamationmark.triangle.fill")
.foregroundColor(.red)
.frame(width: 48, height: 48)
Text(alertStr())
.font(FontStyle.DefaultText.font)
.foregroundColor(ColorSet.BodyChat.color)
.padding(15)
.background(ColorSet.ChatBaloon.color)
.cornerRadius(10, corners: [.tl, .tr, .br])
}
}
func alertStr() -> String {
var msg = message.message
msg.removeFirst()
return msg
}
}
......@@ -76,6 +62,7 @@ struct AlertChatMessage: View {
location: 1,
from: "はだだ",
fromId: "487420489",
mode: 0,
message: "999",
stampId: 0,
viewer: [
......
......@@ -15,6 +15,7 @@ struct ReqMessage : Codable {
var location: Int = 0 //1:Shore / 2:Ship
var from: String = "" //投稿者名
var fromId: String = "" //ユーザーID
var mode: Int = 0
var message: String = "" //テキスト
var stampId: Int = 0 //スタンプ番号 0:Fire〜
......
......@@ -15,6 +15,7 @@ struct ResChatMessage: Codable {
var location: Int //1:Shore、2:Ship
var from: String //投稿者名
var fromId: String //ユーザーID
var mode: Int
var message: String //テキスト
var stampId: Int //スタンプ番号
}
......@@ -19,9 +19,10 @@ struct ChatMessage: Codable {
var type: Int //0:テキスト , 1:スタンプ , 2:画像
var time: String //投稿日時
var location: Int //1:Shore , 2:Ship
var from: String //投稿者名
var from: String? //投稿者名
var fromId: String? //ユーザーID
var message: String //テキスト時:テキスト , 画像時:サムネイルのUri
var mode: Int // 0:通常 , 1:Warning中
var message: String? //テキスト時:テキスト , 画像時:サムネイルのUri
var stampId: Int //スタンプ番号 0:Fire~
var viewer: [Viewer] = [] //閲覧者情報
}
......@@ -29,12 +30,13 @@ struct ChatMessage: Codable {
struct Viewer: Codable {
var time: String //確認日時
var location: Int //1:Shore , 2:Ship
var id: String //ユーザーID
var id: String? //ユーザーID
var name: String? //ユーザー名
}
struct ChatUser: Codable {
var time: String //最終アクセス日時
var location: Int //1:Shore , 2:Ship
var id: String //ログイン時のデバイスID
var name: String //ユーザー名
var id: String? //ログイン時のデバイスID
var name: String? //ユーザー名
}
......@@ -1145,9 +1145,13 @@ class MapViewController : UIViewController {
guard let Id = jsonData?.rawValue else {return}
if SharingData.nga.editNga?.isLock == false {
if let noStr = Id as? String {
if let no = Int(noStr) {
SharingData.nga.editNga?.points.insert(coordinate, at: no)
if let editNga = SharingData.nga.editNga {
if editNga.points.count < ngaAreaPointMax {
if let noStr = Id as? String {
if let no = Int(noStr) {
SharingData.nga.editNga?.points.insert(coordinate, at: no)
}
}
}
}
}
......
......@@ -39,6 +39,7 @@ struct EcaSettingView: View {
var ecaData = edittingEca
ecaData.isEnable = true
SharingData.eca.editEcaArea(key: edittingEca.areaId, value: ecaData, type: EcaOperation.Change)
taskViewModel.viewMode = .FuelSwitching
}, label: {
Text("Register")
.font(FontStyle.DefaultText.font)
......
......@@ -55,8 +55,8 @@ struct FuelSwitchingView: View {
if let ecaArea = taskViewModel.edittingEcaArea {
var newData = ecaArea
newData.isRunning = false
newData.status = EcaState.end
ecaData.editEcaArea(key: ecaArea.areaId, value: newData, type: EcaOperation.End)
newData.status = EcaState.cancel
ecaData.editEcaArea(key: ecaArea.areaId, value: newData, type: EcaOperation.Cancel)
}
taskViewModel.edittingEcaArea = nil
}
......
......@@ -179,7 +179,7 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M
}
private func handleChatMessage(message: ResChatMessage) {
let ownMsg = ChatMessage(shipId: message.shipId, messageId: message.messageId, type: message.type, time: message.time, location: message.location, from: message.from, fromId: message.fromId, message: message.message, stampId: message.stampId, viewer: [])
let ownMsg = ChatMessage(shipId: message.shipId, messageId: message.messageId, type: message.type, time: message.time, location: message.location, from: message.from, fromId: message.fromId, mode: message.mode, message: message.message, stampId: message.stampId, viewer: [])
self.msg.messages.append(ownMsg)
}
......@@ -244,11 +244,12 @@ class SignalR: NSObject {
request.location = 2 //1:Shore , 2:Ship
request.from = Preferences.UserName //投稿者名
request.fromId = String(SharingData.my.id) //ユーザーID
if msg.mode {
request.message = "⚠️\n" + message
if SharingData.message.mode {
request.mode = 1
} else {
request.message = message
request.mode = 0
}
request.message = message
request.stampId = 0 //スタンプ番号 0:Fire~
if message != "" {
......@@ -354,18 +355,22 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
}
case "sailassist":
print(debug: "sailassist")
SharingData.pushHistory.viewCnt += 1
let getPushHistory = GetPushHistory()
getPushHistory.start()
case "bam":
print(debug: "bam")
SharingData.pushHistory.viewCnt += 1
let getPushHistory = GetPushHistory()
getPushHistory.start()
case "route":
print(debug: "route")
SharingData.pushHistory.viewCnt += 1
let getPushHistory = GetPushHistory()
getPushHistory.start()
case "emergency":
print(debug: "emergency")
SharingData.pushHistory.viewCnt += 1
let getPushHistory = GetPushHistory()
getPushHistory.start()
default:
......
......@@ -145,20 +145,49 @@ struct CustomTabBar: View {
//チャットTab上の既読マーク
if tab == Tab.chat {
if message.viewCnt != 0 {
Rectangle()
.foregroundColor(.red)
.frame(width: 12, height: 12)
.cornerRadius(60)
if message.viewCnt < 10 {
Ellipse()
.fill(Color.red)
.frame(width: 12, height: 12)
.overlay(
Text(String(message.viewCnt))
.font(FontStyle.VersionText.font)
.foregroundColor(.white)
)
} else {
Ellipse()
.fill(Color.red)
.frame(width: 12, height: 12)
.overlay(
Text("-")
.font(FontStyle.VersionText.font)
.foregroundColor(.white)
)
}
}
}
//チャットTab上の既読マーク
if tab == Tab.map {
if tab == Tab.alert {
if pushHistory.viewCnt != 0 {
Rectangle()
.foregroundColor(.red)
.frame(width: 12, height: 12)
.cornerRadius(60)
if pushHistory.viewCnt < 10 {
Ellipse()
.fill(Color.red)
.frame(width: 12, height: 12)
.overlay(
Text(String(pushHistory.viewCnt))
.font(FontStyle.VersionText.font)
.foregroundColor(.white)
)
} else {
Ellipse()
.fill(Color.red)
.frame(width: 12, height: 12)
.overlay(
Text("-")
.font(FontStyle.VersionText.font)
.foregroundColor(.white)
)
}
}
}
}
......
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