forked from mirrors/linphone-iphone
Missed calls counter added to bottom navigation bar
This commit is contained in:
parent
61c2c048bb
commit
56e93a77a7
5 changed files with 145 additions and 40 deletions
|
|
@ -18,6 +18,7 @@
|
|||
D706BA822ADD72D100278F45 /* DeviceRotationViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = D706BA812ADD72D100278F45 /* DeviceRotationViewModifier.swift */; };
|
||||
D70A26EE2B7CF60B006CC8FC /* ConversationsListBottomSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = D70A26ED2B7CF60B006CC8FC /* ConversationsListBottomSheet.swift */; };
|
||||
D70A26F02B7D02E6006CC8FC /* ConversationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D70A26EF2B7D02E6006CC8FC /* ConversationViewModel.swift */; };
|
||||
D70A26F22B7F5D95006CC8FC /* ConversationFragment.swift in Sources */ = {isa = PBXBuildFile; fileRef = D70A26F12B7F5D95006CC8FC /* ConversationFragment.swift */; };
|
||||
D70C93DE2AC2D0F60063CA3B /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = D70C93DD2AC2D0F60063CA3B /* Localizable.xcstrings */; };
|
||||
D717071E2AC5922E0037746F /* ColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D717071D2AC5922E0037746F /* ColorExtension.swift */; };
|
||||
D71707202AC5989C0037746F /* TextExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D717071F2AC5989C0037746F /* TextExtension.swift */; };
|
||||
|
|
@ -118,6 +119,7 @@
|
|||
D706BA812ADD72D100278F45 /* DeviceRotationViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceRotationViewModifier.swift; sourceTree = "<group>"; };
|
||||
D70A26ED2B7CF60B006CC8FC /* ConversationsListBottomSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationsListBottomSheet.swift; sourceTree = "<group>"; };
|
||||
D70A26EF2B7D02E6006CC8FC /* ConversationViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationViewModel.swift; sourceTree = "<group>"; };
|
||||
D70A26F12B7F5D95006CC8FC /* ConversationFragment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationFragment.swift; sourceTree = "<group>"; };
|
||||
D70C93DD2AC2D0F60063CA3B /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
|
||||
D717071D2AC5922E0037746F /* ColorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorExtension.swift; sourceTree = "<group>"; };
|
||||
D717071F2AC5989C0037746F /* TextExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextExtension.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -559,6 +561,7 @@
|
|||
D7CEE03A2B7A234200FD79B7 /* ConversationsFragment.swift */,
|
||||
D7CEE03C2B7A23B200FD79B7 /* ConversationsListFragment.swift */,
|
||||
D70A26ED2B7CF60B006CC8FC /* ConversationsListBottomSheet.swift */,
|
||||
D70A26F12B7F5D95006CC8FC /* ConversationFragment.swift */,
|
||||
);
|
||||
path = Fragments;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -735,6 +738,7 @@
|
|||
D706BA822ADD72D100278F45 /* DeviceRotationViewModifier.swift in Sources */,
|
||||
D732A9132B04C7A300DB42BA /* HistoryListFragment.swift in Sources */,
|
||||
D719ABC92ABC6FD700B41C10 /* CoreContext.swift in Sources */,
|
||||
D70A26F22B7F5D95006CC8FC /* ConversationFragment.swift in Sources */,
|
||||
66C491FD2B24D36500CEA16D /* AudioRouteUtils.swift in Sources */,
|
||||
D7EAACCF2AD6ED8000AA6A8A /* PermissionsFragment.swift in Sources */,
|
||||
D777DBB32AE12C5900565A99 /* ContactsManager.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -244,9 +244,6 @@
|
|||
},
|
||||
"Contacts" : {
|
||||
|
||||
},
|
||||
"Content" : {
|
||||
|
||||
},
|
||||
"Continue" : {
|
||||
|
||||
|
|
@ -588,9 +585,6 @@
|
|||
},
|
||||
"This contact will be deleted definitively." : {
|
||||
|
||||
},
|
||||
"Title" : {
|
||||
|
||||
},
|
||||
"TLS" : {
|
||||
|
||||
|
|
|
|||
|
|
@ -108,25 +108,51 @@ struct ContentView: View {
|
|||
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
self.index = 1
|
||||
contactViewModel.indexDisplayedFriend = nil
|
||||
}, label: {
|
||||
VStack {
|
||||
Image("phone")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(self.index == 1 ? Color.orangeMain500 : Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
if self.index == 1 {
|
||||
Text("Calls")
|
||||
.default_text_style_700(styleSize: 10)
|
||||
} else {
|
||||
Text("Calls")
|
||||
ZStack {
|
||||
if historyListViewModel.missedCallsCount > 0 {
|
||||
VStack {
|
||||
HStack {
|
||||
Text(
|
||||
historyListViewModel.missedCallsCount < 99
|
||||
? String(historyListViewModel.missedCallsCount)
|
||||
: "99+"
|
||||
)
|
||||
.foregroundStyle(.white)
|
||||
.default_text_style(styleSize: 10)
|
||||
.lineLimit(1)
|
||||
}
|
||||
.frame(width: 18, height: 18)
|
||||
.background(Color.redDanger500)
|
||||
.cornerRadius(50)
|
||||
}
|
||||
.padding(.bottom, 30)
|
||||
.padding(.leading, 30)
|
||||
}
|
||||
})
|
||||
|
||||
Button(action: {
|
||||
self.index = 1
|
||||
contactViewModel.indexDisplayedFriend = nil
|
||||
if historyListViewModel.missedCallsCount > 0 {
|
||||
historyListViewModel.resetMissedCallsCount()
|
||||
}
|
||||
}, label: {
|
||||
VStack {
|
||||
Image("phone")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(self.index == 1 ? Color.orangeMain500 : Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
if self.index == 1 {
|
||||
Text("Calls")
|
||||
.default_text_style_700(styleSize: 10)
|
||||
} else {
|
||||
Text("Calls")
|
||||
.default_text_style(styleSize: 10)
|
||||
}
|
||||
}
|
||||
})
|
||||
.padding(.top)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
|
|
@ -475,27 +501,52 @@ struct ContentView: View {
|
|||
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
self.index = 1
|
||||
contactViewModel.indexDisplayedFriend = nil
|
||||
}, label: {
|
||||
VStack {
|
||||
Image("phone")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(self.index == 1 ? Color.orangeMain500 : Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
if self.index == 1 {
|
||||
Text("Calls")
|
||||
.default_text_style_700(styleSize: 10)
|
||||
} else {
|
||||
Text("Calls")
|
||||
ZStack {
|
||||
if historyListViewModel.missedCallsCount > 0 {
|
||||
VStack {
|
||||
HStack {
|
||||
Text(
|
||||
historyListViewModel.missedCallsCount < 99
|
||||
? String(historyListViewModel.missedCallsCount)
|
||||
: "99+"
|
||||
)
|
||||
.foregroundStyle(.white)
|
||||
.default_text_style(styleSize: 10)
|
||||
.lineLimit(1)
|
||||
}
|
||||
.frame(width: 18, height: 18)
|
||||
.background(Color.redDanger500)
|
||||
.cornerRadius(50)
|
||||
}
|
||||
.padding(.bottom, 30)
|
||||
.padding(.leading, 30)
|
||||
}
|
||||
})
|
||||
.padding(.top)
|
||||
.frame(width: 100)
|
||||
|
||||
Button(action: {
|
||||
self.index = 1
|
||||
contactViewModel.indexDisplayedFriend = nil
|
||||
if historyListViewModel.missedCallsCount > 0 {
|
||||
historyListViewModel.resetMissedCallsCount()
|
||||
}
|
||||
}, label: {
|
||||
VStack {
|
||||
Image("phone")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(self.index == 1 ? Color.orangeMain500 : Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
if self.index == 1 {
|
||||
Text("Calls")
|
||||
.default_text_style_700(styleSize: 10)
|
||||
} else {
|
||||
Text("Calls")
|
||||
.default_text_style(styleSize: 10)
|
||||
}
|
||||
}
|
||||
})
|
||||
.padding(.top)
|
||||
.frame(width: 100)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// ConversationFragment.swift
|
||||
// Linphone
|
||||
//
|
||||
// Created by Martins Benoît on 16/02/2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ConversationFragment: View {
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ConversationFragment()
|
||||
}
|
||||
|
|
@ -30,8 +30,11 @@ class HistoryListViewModel: ObservableObject {
|
|||
var callLogsAddressToDelete = ""
|
||||
var callLogSubscription: AnyCancellable?
|
||||
|
||||
@Published var missedCallsCount: Int = 0
|
||||
|
||||
init() {
|
||||
computeCallLogsList()
|
||||
updateMissedCallsCount()
|
||||
}
|
||||
|
||||
func computeCallLogsList() {
|
||||
|
|
@ -62,6 +65,41 @@ class HistoryListViewModel: ObservableObject {
|
|||
self.callLogsTmp.append(log)
|
||||
}
|
||||
}
|
||||
|
||||
self.updateMissedCallsCount()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func resetMissedCallsCount() {
|
||||
coreContext.doOnCoreQueue { core in
|
||||
let account = core.defaultAccount
|
||||
if account != nil {
|
||||
account?.resetMissedCallsCount()
|
||||
DispatchQueue.main.async {
|
||||
self.missedCallsCount = 0
|
||||
}
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
self.missedCallsCount = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updateMissedCallsCount() {
|
||||
coreContext.doOnCoreQueue { core in
|
||||
let account = core.defaultAccount
|
||||
if account != nil {
|
||||
let count = account?.missedCallsCount != nil ? account!.missedCallsCount : core.missedCallsCount
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.missedCallsCount = count
|
||||
}
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
self.missedCallsCount = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue