Commit b4e5721a authored by shigemi miura's avatar shigemi miura

Notice未読マーク

parent 734b7525
...@@ -47,7 +47,9 @@ struct NotificationContentView: View { ...@@ -47,7 +47,9 @@ struct NotificationContentView: View {
.font(FontStyle.SupplementText2.font) .font(FontStyle.SupplementText2.font)
} }
.padding(EdgeInsets(top: 17, leading: 30, bottom: 17, trailing: 30)) .padding(EdgeInsets(top: 17, leading: 30, bottom: 17, trailing: 30))
.onAppear {
SharingData.pushHistory.viewCnt = 0
}
} }
} }
......
...@@ -43,14 +43,14 @@ struct ChatView: View { ...@@ -43,14 +43,14 @@ struct ChatView: View {
.onAppear { .onAppear {
if let id = message.messages.last?.messageId { if let id = message.messages.last?.messageId {
print(debug: "ChatView:onAppear") print(debug: "ChatView:onAppear")
proxy.scrollTo(id, anchor: .center) proxy.scrollTo(id, anchor: .bottom)
} }
} }
.onChange(of: message.messages.count) { newValue in .onChange(of: message.messages.count) { newValue in
withAnimation { withAnimation {
if let id = message.messages.last?.messageId { if let id = message.messages.last?.messageId {
print(debug: "ChatView:onChange") print(debug: "ChatView:onChange")
proxy.scrollTo(id, anchor: .center) proxy.scrollTo(id, anchor: .bottom)
} }
} }
} }
...@@ -59,7 +59,7 @@ struct ChatView: View { ...@@ -59,7 +59,7 @@ struct ChatView: View {
guard !value.isEmpty else {return} guard !value.isEmpty else {return}
if let id = message.messages.last?.messageId { if let id = message.messages.last?.messageId {
print(debug: "ChatView:onReceive") print(debug: "ChatView:onReceive")
proxy.scrollTo(id, anchor: .center) proxy.scrollTo(id, anchor: .bottom)
} }
} }
} }
......
...@@ -309,8 +309,8 @@ class ChatHubConnectionDelegate: HubConnectionDelegate { ...@@ -309,8 +309,8 @@ class ChatHubConnectionDelegate: HubConnectionDelegate {
extension AppDelegate: UNUserNotificationCenterDelegate { extension AppDelegate: UNUserNotificationCenterDelegate {
// フォアグラウンド状態で通知を受信して表示する // フォアグラウンド状態で通知を受信して表示する
func userNotificationCenter(_ center: UNUserNotificationCenter, func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification, willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo let userInfo = notification.request.content.userInfo
if !userInfo.isEmpty { if !userInfo.isEmpty {
guard let arrAPS = userInfo["aps"] as? [String: Any] else { guard let arrAPS = userInfo["aps"] as? [String: Any] else {
...@@ -331,6 +331,9 @@ extension AppDelegate: UNUserNotificationCenterDelegate { ...@@ -331,6 +331,9 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
print(debug: "called \(subtitle) \(strTitle) \(strBody)") print(debug: "called \(subtitle) \(strTitle) \(strBody)")
let message = GetMessage()
message.start()
//送信先名称が同一の場合は通知を出さない //送信先名称が同一の場合は通知を出さない
if subtitle == Preferences.UserName { if subtitle == Preferences.UserName {
return return
...@@ -360,8 +363,8 @@ extension AppDelegate: UNUserNotificationCenterDelegate { ...@@ -360,8 +363,8 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
// バックグラウンド状態で通知を受信して表示する // バックグラウンド状態で通知を受信して表示する
func userNotificationCenter(_ center: UNUserNotificationCenter, func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse, didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) { withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo let userInfo = response.notification.request.content.userInfo
print(debug: userInfo) print(debug: userInfo)
if !userInfo.isEmpty { if !userInfo.isEmpty {
...@@ -382,22 +385,27 @@ extension AppDelegate: UNUserNotificationCenterDelegate { ...@@ -382,22 +385,27 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
let strBody = arrAlert["body"] as? String ?? "" //送信先名称 let strBody = arrAlert["body"] as? String ?? "" //送信先名称
print(debug: "called \(subtitle) \(strTitle) \(strBody)") print(debug: "called \(subtitle) \(strTitle) \(strBody)")
// let message = GetMessage()
// message.start() let message = GetMessage()
message.start()
case "sailassist": case "sailassist":
print(debug: "sailassist") print(debug: "sailassist")
SharingData.pushHistory.viewCnt += 1
let getPushHistory = GetPushHistory() let getPushHistory = GetPushHistory()
getPushHistory.start() getPushHistory.start()
case "bam": case "bam":
print(debug: "bam") print(debug: "bam")
SharingData.pushHistory.viewCnt += 1
let getPushHistory = GetPushHistory() let getPushHistory = GetPushHistory()
getPushHistory.start() getPushHistory.start()
case "route": case "route":
print(debug: "route") print(debug: "route")
SharingData.pushHistory.viewCnt += 1
let getPushHistory = GetPushHistory() let getPushHistory = GetPushHistory()
getPushHistory.start() getPushHistory.start()
case "emergency": case "emergency":
print(debug: "emergency") print(debug: "emergency")
SharingData.pushHistory.viewCnt += 1
let getPushHistory = GetPushHistory() let getPushHistory = GetPushHistory()
getPushHistory.start() getPushHistory.start()
default: default:
......
...@@ -370,6 +370,7 @@ class SharingData{ ...@@ -370,6 +370,7 @@ class SharingData{
class PushHistory: ObservableObject{ class PushHistory: ObservableObject{
@Published var pushHistoryData: Dictionary<Int, ResPushHistory> = [:] @Published var pushHistoryData: Dictionary<Int, ResPushHistory> = [:]
@Published var focusPushHistory: Int? = nil @Published var focusPushHistory: Int? = nil
@Published var viewCnt: Int = 0 //未読数
func setPushHistory(key: Int, value: ResPushHistory) { func setPushHistory(key: Int, value: ResPushHistory) {
pushHistoryData.updateValue(value, forKey: key) pushHistoryData.updateValue(value, forKey: key)
......
...@@ -105,6 +105,7 @@ struct CustomTabBar: View { ...@@ -105,6 +105,7 @@ struct CustomTabBar: View {
@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
var body: some View { var body: some View {
VStack(spacing: 0){ VStack(spacing: 0){
...@@ -141,6 +142,16 @@ struct CustomTabBar: View { ...@@ -141,6 +142,16 @@ struct CustomTabBar: View {
.cornerRadius(60) .cornerRadius(60)
} }
} }
//チャットTab上の既読マーク
if tab == Tab.task {
if pushHistory.viewCnt != 0 {
Rectangle()
.foregroundColor(.red)
.frame(width: 12, height: 12)
.cornerRadius(60)
}
}
} }
Text(tab.title) Text(tab.title)
......
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