-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from pexip/feature/live-captions-filters
Add live captions and video filters
- Loading branch information
Showing
18 changed files
with
627 additions
and
275 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
Examples/SPM/SwiftUI/Shared/Assets.xcassets/background_image.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "background_image.jpg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+3.15 MB
...M/SwiftUI/Shared/Assets.xcassets/background_image.imageset/background_image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Examples/SPM/SwiftUI/Shared/Extensions/CGImage+Extensions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import SwiftUI | ||
|
||
extension CGImage { | ||
static func withName(_ name: String) -> CGImage? { | ||
#if os(iOS) | ||
return UIImage(named: "background_image")?.cgImage | ||
#else | ||
return NSImage(named: "background_image")?.cgImage( | ||
forProposedRect: nil, | ||
context: nil, | ||
hints: nil | ||
) | ||
#endif | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
Examples/SPM/SwiftUI/Shared/Screens/Chat/ChatMessageStore.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import Foundation | ||
import PexipConference | ||
import Combine | ||
|
||
final class ChatMessageStore: ObservableObject { | ||
@Published private(set) var messages = [Chat.Message]() | ||
private let chat: Chat | ||
private var cancellables = Set<AnyCancellable>() | ||
|
||
// MARK: - Init | ||
|
||
init(chat: Chat, roster: Roster, messages: [Chat.Message] = []) { | ||
self.chat = chat | ||
|
||
chat.publisher.sink(receiveValue: { [weak self] message in | ||
self?.messages.append(.init( | ||
title: message.senderName, | ||
text: message.payload, | ||
date: message.receivedAt | ||
)) | ||
}).store(in: &cancellables) | ||
|
||
roster.eventPublisher.sink(receiveValue: { [weak self] event in | ||
guard let self = self else { return } | ||
|
||
let senderName = "Chatbot" | ||
|
||
switch event { | ||
case .added(let participant): | ||
self.messages.append(.init( | ||
title: senderName, | ||
text: "\(participant.displayName) joined" | ||
)) | ||
case .deleted(let participant): | ||
self.messages.append(.init( | ||
title: senderName, | ||
text: "\(participant.displayName) left" | ||
)) | ||
case .updated, .reloaded: | ||
break | ||
} | ||
}).store(in: &cancellables) | ||
} | ||
|
||
// MARK: - Internal | ||
|
||
func addMessage(_ text: String) async throws -> Bool { | ||
guard !text.isEmpty else { | ||
return false | ||
} | ||
|
||
return try await !chat.sendMessage(text) | ||
} | ||
} | ||
|
||
// MARK: - Message | ||
|
||
extension Chat { | ||
struct Message: Hashable { | ||
static let dateFormatter: DateFormatter = { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "hh:mm" | ||
return dateFormatter | ||
}() | ||
|
||
let title: String | ||
let text: String | ||
var date = Date() | ||
|
||
var timeString: String { | ||
Self.dateFormatter.string(from: date) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.