Skip to content

Commit

Permalink
Release 3.0.914-pluto.beta.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayv-cometchat committed Jun 2, 2023
1 parent 15dad11 commit cb6a83b
Show file tree
Hide file tree
Showing 66 changed files with 1,320 additions and 624 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>CometChatUIKit.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
3 changes: 1 addition & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ let package = Package(

dependencies: [
.package(name: "CometChatPro",
url: "https://github.com/cometchat-pro/ios-chat-sdk.git",
.exact("3.0.912")
url: "https://github.com/cometchat-pro/ios-chat-sdk.git", .exact("3.0.914")
),
],
targets: [
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a href="https://cocoapods.org/pods/CometChatPro"><img src="https://img.shields.io/badge/platform-iOS-orange.svg" /></a>
<a href=""><img src="https://img.shields.io/badge/language-Objective--C%20%7C%20Swift-orange.svg" /></a>
<a href=""> <img src="https://img.shields.io/badge/Contributors-4-yellowgreen" /></a>
<a href=" "> <img src="https://img.shields.io/badge/Version-3.0.900-red" /></a>
<a href=" "> <img src="https://img.shields.io/badge/Version-3.0.914-red" /></a>
<a href=""> <img src="https://img.shields.io/github/stars/cometchat-pro/ios-chat-sdk?style=social" /></a>

</p>
Expand Down Expand Up @@ -56,7 +56,7 @@ To install iOS Chat UIKit, you need to first register on CometChat Dashboard. [
* Add CometChatProUIKit into your Package Repository as below:
* https://github.com/cometchat-pro/ios-swift-chat-ui-kit.git

* To add the package, select Version Rules, enter Up to Exact Version, [3.0.912-pluto.beta.2.0](https://github.com/cometchat-pro/ios-swift-chat-ui-kit/tree/pluto), and click Next
* To add the package, select Version Rules, enter Up to Exact Version, [3.0.914-pluto.beta.2.1](https://github.com/cometchat-pro/ios-swift-chat-ui-kit/tree/pluto), and click Next

___

Expand Down
7 changes: 6 additions & 1 deletion Sources/Components/Add Members/CometChatAddMembers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ open class CometChatAddMembers: CometChatUsers {
onBack()
} else {
if self.navigationController != nil {
self.navigationController?.popViewController(animated: true)
if self.navigationController?.viewControllers.first == self {
self.dismiss(animated: true, completion: nil)
} else {
self.navigationController?.popViewController(animated: true)
}

}else{
self.dismiss(animated: true, completion: nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ open class CometChatBannedMembers: CometChatListBase {
onBack()
} else {
if self.navigationController != nil {
self.navigationController?.popViewController(animated: true)
if self.navigationController?.viewControllers.first == self {
self.dismiss(animated: true, completion: nil)
} else {
self.navigationController?.popViewController(animated: true)
}

}else{
self.dismiss(animated: true, completion: nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class CallBubbleConfiguration {

private(set) var icon: UIImage?
private(set) var style: CallBubbleStyle?
private(set) var onClick: (() -> Void)?

@discardableResult
public func set(style: CallBubbleStyle) -> Self {
Expand All @@ -24,4 +25,9 @@ public class CallBubbleConfiguration {
return self
}

@discardableResult
public func setOnClick(onClick: @escaping (() -> Void)) -> Self {
self.onClick = onClick
return self
}
}
73 changes: 73 additions & 0 deletions Sources/Components/Calls/Call Button/CallButtonConfiguration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// File.swift
//
//
// Created by Pushpsen Airekar on 19/04/23.
//

import Foundation
import UIKit
import CometChatPro

public final class CallButtonConfiguration {

private(set) var voiceCallIcon: UIImage?
private(set) var videoCallIcon: UIImage?
private(set) var hideVoiceCall: Bool?
private(set) var hideVideoCall: Bool?
private(set) var callButtonsStyle: ButtonStyle?
private(set) var onVoiceCallClick: ((_ user: User?, _ group: Group?) -> Void)?
private(set) var onVideoCallClick: ((_ user: User?, _ group: Group?) -> Void)?
private(set) var onError: ((_ error: CometChatException?) -> Void)?

public init() {}

@discardableResult
public func set(voiceCallIcon: UIImage?) -> Self {
self.voiceCallIcon = voiceCallIcon
return self
}

@discardableResult
public func set(videoCallIcon: UIImage?) -> Self {
self.videoCallIcon = videoCallIcon
return self
}

@discardableResult
public func hide(voiceCall: Bool?) -> Self {
self.hideVoiceCall = voiceCall
return self
}

@discardableResult
public func hide(videoCall: Bool?) -> Self {
self.hideVideoCall = videoCall
return self
}

@discardableResult
public func set(callButtonsStyle: ButtonStyle?) -> Self {
self.callButtonsStyle = callButtonsStyle
return self
}

@discardableResult
public func setOnVoiceCallClick(onVoiceCallClick: @escaping ((_ user: User?, _ group: Group?) -> Void)) -> Self {
self.onVoiceCallClick = onVoiceCallClick
return self
}

@discardableResult
public func setOnVideoCallClick(onVideoCallClick: @escaping ((_ user: User?, _ group: Group?) -> Void)) -> Self {
self.onVideoCallClick = onVideoCallClick
return self
}

@discardableResult
public func setOnError(onError: @escaping ((_ error: CometChatException?) -> Void)) -> Self {
self.onError = onError
return self
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// File.swift
// CometChatCallButton.swift
//
//
// Created by Pushpsen Airekar on 14/03/23.
Expand All @@ -9,7 +9,7 @@ import Foundation
import UIKit
import CometChatPro

public class CometChatCallButton: UIStackView {
public class CometChatCallButtons: UIStackView {

private(set) var user: User?
private(set) var group: Group?
Expand All @@ -22,10 +22,12 @@ public class CometChatCallButton: UIStackView {
private(set) var hideVideoCall : Bool = false
private(set) var isFromCallDetail: Bool = false
private(set) var callButtonsStyle : ButtonStyle?
private(set) var onVoiceCallClick : (() -> Void)?
private(set) var onVideoCallClick : (() -> Void)?
private(set) var voiceCallButton : CometChatButton?
private(set) var videoCallButton : CometChatButton?
private(set) var outgoingCallConfiguration : OutgoingCallConfiguration?
private(set) var onVoiceCallClick: ((_ user: User?, _ group: Group?) -> Void)?
private(set) var onVideoCallClick: ((_ user: User?, _ group: Group?) -> Void)?
private(set) var onError: ((_ error: CometChatException?) -> Void)?

public init(width: CGFloat, height: CGFloat) {
super.init(frame: CGRect(x: 0, y: 0, width: width, height: height))
Expand Down Expand Up @@ -114,24 +116,37 @@ public class CometChatCallButton: UIStackView {
return self
}


@discardableResult
public func hide(callButtonsStyle: ButtonStyle) -> Self {
public func set(callButtonsStyle: ButtonStyle) -> Self {
self.callButtonsStyle = callButtonsStyle
return self
}

@discardableResult
public func setOnVoiceCallClick(_ onVoiceCallClick: @escaping () -> Void) -> Self {
public func set(outgoingCallConfiguration: OutgoingCallConfiguration?) -> Self {
self.outgoingCallConfiguration = outgoingCallConfiguration
return self
}

@discardableResult
public func setOnVoiceCallClick(onVoiceCallClick: @escaping ((_ user: User?, _ group: Group?) -> Void)) -> Self {
self.onVoiceCallClick = onVoiceCallClick
return self
}

@discardableResult
public func setOnVideoCallClick(_ onVideoCallClick: @escaping () -> Void) -> Self {
public func setOnVideoCallClick(onVideoCallClick: @escaping ((_ user: User?, _ group: Group?) -> Void)) -> Self {
self.onVideoCallClick = onVideoCallClick
return self
}

@discardableResult
public func setOnError(onError: @escaping ((_ error: CometChatException?) -> Void)) -> Self {
self.onError = onError
return self
}

private func setupApprearance(forUser: User) {
let style = ButtonStyle()
style.set(iconBackground: .clear)
Expand All @@ -148,7 +163,7 @@ public class CometChatCallButton: UIStackView {
voiceCallButton.set(cornerRadius: CometChatCornerStyle(cornerRadius: callButtonsStyle?.iconCornerRadius ?? 8.0))
voiceCallButton.setOnClick {
if self.onVoiceCallClick != nil {
self.onVoiceCallClick?()
self.onVoiceCallClick?(forUser, nil)
} else {
guard let user = self.user, let uid = user.uid else { return }
let call = Call(receiverId: uid, callType: .audio, receiverType: .user)
Expand All @@ -159,6 +174,7 @@ public class CometChatCallButton: UIStackView {
let outgoingCall = CometChatOutgoingCall()
outgoingCall.set(call: call)
outgoingCall.modalPresentationStyle = .fullScreen
self.setupOutgoingCallConfiguration(outgoingCall: outgoingCall)
outgoingCall.setOnCancelClick { call, controller in
CometChat.rejectCall(sessionID: call?.sessionID ?? "", status: .cancelled) { call in
if let call = call {
Expand All @@ -168,14 +184,17 @@ public class CometChatCallButton: UIStackView {
controller?.dismiss(animated: true)
}
} onError: { error in
self.onError?(error)
DispatchQueue.main.async {
controller?.dismiss(animated: true)
}
}
}

self.controller?.present(outgoingCall, animated: true)
}
} onError: { error in
self.onError?(error)
DispatchQueue.main.async {
let confirmDialog = CometChatDialog()
confirmDialog.set(confirmButtonText: "OK".localize())
Expand All @@ -186,10 +205,14 @@ public class CometChatCallButton: UIStackView {
confirmDialog.open {
}
}

}
}
}
self.addArrangedSubview(voiceCallButton)

if !hideVoiceCall {
self.addArrangedSubview(voiceCallButton)
}
}

// Video Call
Expand All @@ -203,7 +226,7 @@ public class CometChatCallButton: UIStackView {
videoCallButton.set(cornerRadius: CometChatCornerStyle(cornerRadius: callButtonsStyle?.iconCornerRadius ?? 8.0))
videoCallButton.setOnClick {
if self.onVideoCallClick != nil {
self.onVideoCallClick?()
self.onVideoCallClick?(forUser, nil)
} else {
guard let user = self.user, let uid = user.uid else { return }
let call = Call(receiverId: uid, callType: .video, receiverType: .user)
Expand All @@ -214,6 +237,7 @@ public class CometChatCallButton: UIStackView {
let outgoingCall = CometChatOutgoingCall()
outgoingCall.set(call: call)
outgoingCall.modalPresentationStyle = .fullScreen
self.setupOutgoingCallConfiguration(outgoingCall: outgoingCall)
outgoingCall.setOnCancelClick { call, controller in
CometChat.rejectCall(sessionID: call?.sessionID ?? "", status: .cancelled) { call in
if let call = call {
Expand All @@ -223,6 +247,7 @@ public class CometChatCallButton: UIStackView {
controller?.dismiss(animated: true)
}
} onError: { error in
self.onError?(error)
DispatchQueue.main.async {
controller?.dismiss(animated: true)
}
Expand All @@ -231,6 +256,7 @@ public class CometChatCallButton: UIStackView {
self.controller?.present(outgoingCall, animated: true)
}
} onError: { error in
self.onError?(error)
DispatchQueue.main.async {
let confirmDialog = CometChatDialog()
confirmDialog.set(confirmButtonText: "OK".localize())
Expand All @@ -244,7 +270,10 @@ public class CometChatCallButton: UIStackView {
}
}
}
self.addArrangedSubview(videoCallButton)
if !hideVideoCall {
self.addArrangedSubview(videoCallButton)
}

}

self.spacing = 10
Expand All @@ -268,7 +297,7 @@ public class CometChatCallButton: UIStackView {
conferenceCallButton.set(cornerRadius: CometChatCornerStyle(cornerRadius: callButtonsStyle?.iconCornerRadius ?? 8.0))
conferenceCallButton.setOnClick {
if self.onVideoCallClick != nil {
self.onVideoCallClick?()
self.onVideoCallClick?(nil, forGroup)
} else {
if let sessionID = self.group?.guid {
let videoMeeting = CustomMessage(receiverUid: self.group?.guid ?? "", receiverType: .group, customData: ["sessionID":sessionID, "callType":"video"], type: "meeting")
Expand All @@ -287,9 +316,32 @@ public class CometChatCallButton: UIStackView {
}
self.addArrangedSubview(conferenceCallButton)
}

private func setupOutgoingCallConfiguration(outgoingCall: CometChatOutgoingCall) {
if let outgoingCallConfiguration = self.outgoingCallConfiguration {
if let declineButtonIcon = outgoingCallConfiguration.declineButtonIcon {
outgoingCall.set(declineButtonIcon: declineButtonIcon)
}
if let disableSoundForCalls = outgoingCallConfiguration.disableSoundForCalls {
outgoingCall.disable(soundForCalls: disableSoundForCalls)
}
if let customSoundForCalls = outgoingCallConfiguration.customSoundForCalls {
outgoingCall.set(customSoundForCalls: customSoundForCalls)
}
if let avatarStyle = outgoingCallConfiguration.avatarStyle {
outgoingCall.set(avatarStyle: avatarStyle)
}
if let buttonStyle = outgoingCallConfiguration.buttonStyle {
outgoingCall.set(buttonStyle: buttonStyle)
}
if let outgoingCallStyle = outgoingCallConfiguration.outgoingCallStyle {
outgoingCall.set(outgoingCallStyle: outgoingCallStyle)
}
}
}
}

extension CometChatCallButton: CometChatMessageEventListener {
extension CometChatCallButtons: CometChatMessageEventListener {

public func onMessageSent(message: CometChatPro.BaseMessage, status: MessageStatus) {
if let call = message as? CustomMessage, status == .success, call.type == "meeting", let customData = call.customData, let sessionID = customData["sessionID"] as? String {
Expand Down Expand Up @@ -337,7 +389,7 @@ extension CometChatCallButton: CometChatMessageEventListener {
}
}

extension CometChatCallButton: CometChatCallDelegate {
extension CometChatCallButtons: CometChatCallDelegate {

public func onIncomingCallReceived(incomingCall: CometChatPro.Call?, error: CometChatPro.CometChatException?) {
voiceCallButton?.disable(button: true)
Expand Down
Loading

0 comments on commit cb6a83b

Please sign in to comment.