Commit b4e5721a authored by shigemi miura's avatar shigemi miura

Notice未読マーク

parent 734b7525
......@@ -47,7 +47,9 @@ struct NotificationContentView: View {
.font(FontStyle.SupplementText2.font)
}
.padding(EdgeInsets(top: 17, leading: 30, bottom: 17, trailing: 30))
.onAppear {
SharingData.pushHistory.viewCnt = 0
}
}
}
......
......@@ -43,14 +43,14 @@ struct ChatView: View {
.onAppear {
if let id = message.messages.last?.messageId {
print(debug: "ChatView:onAppear")
proxy.scrollTo(id, anchor: .center)
proxy.scrollTo(id, anchor: .bottom)
}
}
.onChange(of: message.messages.count) { newValue in
withAnimation {
if let id = message.messages.last?.messageId {
print(debug: "ChatView:onChange")
proxy.scrollTo(id, anchor: .center)
proxy.scrollTo(id, anchor: .bottom)
}
}
}
......@@ -59,7 +59,7 @@ struct ChatView: View {
guard !value.isEmpty else {return}
if let id = message.messages.last?.messageId {
print(debug: "ChatView:onReceive")
proxy.scrollTo(id, anchor: .center)
proxy.scrollTo(id, anchor: .bottom)
}
}
}
......
......@@ -331,6 +331,9 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
print(debug: "called \(subtitle) \(strTitle) \(strBody)")
let message = GetMessage()
message.start()
//送信先名称が同一の場合は通知を出さない
if subtitle == Preferences.UserName {
return
......@@ -382,22 +385,27 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
let strBody = arrAlert["body"] as? String ?? "" //送信先名称
print(debug: "called \(subtitle) \(strTitle) \(strBody)")
// let message = GetMessage()
// message.start()
let message = GetMessage()
message.start()
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:
......
......@@ -370,6 +370,7 @@ class SharingData{
class PushHistory: ObservableObject{
@Published var pushHistoryData: Dictionary<Int, ResPushHistory> = [:]
@Published var focusPushHistory: Int? = nil
@Published var viewCnt: Int = 0 //未読数
func setPushHistory(key: Int, value: ResPushHistory) {
pushHistoryData.updateValue(value, forKey: key)
......
......@@ -105,6 +105,7 @@ struct CustomTabBar: View {
@ObservedObject var my = SharingData.my
@ObservedObject var message = SharingData.message
@ObservedObject var location = SharingData.location
@ObservedObject var pushHistory = SharingData.pushHistory
var body: some View {
VStack(spacing: 0){
......@@ -141,6 +142,16 @@ struct CustomTabBar: View {
.cornerRadius(60)
}
}
//チャットTab上の既読マーク
if tab == Tab.task {
if pushHistory.viewCnt != 0 {
Rectangle()
.foregroundColor(.red)
.frame(width: 12, height: 12)
.cornerRadius(60)
}
}
}
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