Skip to content

Commit d23cec3

Browse files
committed
chore(release): update RealtimeKitUI to 1.0.0
1 parent e5a6c2b commit d23cec3

File tree

186 files changed

+20687
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+20687
-24
lines changed

Package.swift

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
// swift-tools-version:5.5
22
import PackageDescription
33

4-
// BEGIN KMMBRIDGE VARIABLES BLOCK (do not edit)
5-
let remoteKotlinUrl = "https://dyte-assets.s3.ap-south-1.amazonaws.com/sdk/ios_core/DyteiOSCore-2.1.0-ad6dd60e-06a1-43ca-a4d7-4d7cf3d85ef1.xcframework.zip"
6-
let remoteKotlinChecksum = "76a818e81ff026698206a33e7817eaefcc23406d51b763a0dcea56d21766655c"
7-
let packageName = "DyteiOSCore"
8-
// END KMMBRIDGE BLOCK
9-
104
let package = Package(
11-
name: "DyteMobileCoreiOS",
12-
platforms: [.iOS(.v13)],
13-
products: [
14-
.library(name: packageName, targets: [packageName, "DyteWebRTC"]),
15-
.library(name: "DyteWebRTC", targets: ["DyteWebRTC"]),
16-
],
17-
targets: [
18-
.binaryTarget(
19-
name: "DyteWebRTC",
20-
url: "https://dyte-assets.s3.ap-south-1.amazonaws.com/sdk/ios_core/DyteWebRTC_v0.0.4.zip",
21-
checksum: "25318dfb4bd018fde6ed7fd3337d9aa1c62fc8b39ab985c60fa530eb3819e68a"
22-
),
23-
.binaryTarget(
24-
name: packageName,
25-
url: remoteKotlinUrl,
26-
checksum: remoteKotlinChecksum
27-
),
28-
]
5+
name: "RealtimeKitUI",
6+
platforms: [.iOS(.v13)],
7+
products: [
8+
.library(name: "RealtimeKitUI", targets: ["RealtimeKitUI"])
9+
],
10+
dependencies: [
11+
.package(
12+
url: "https://github.com/dyte-in/RealtimeKitCoreiOS.git",
13+
revision: "843c0ec42ed206994f05d55c45e408cff2300300")
14+
],
15+
targets: [
16+
.target(
17+
name: "RealtimeKitUI",
18+
path: "RealtimeKitUI/",
19+
dependencies: [
20+
"RealtimeKitCore",
21+
"DyteWebRTC",
22+
],
23+
resources: [
24+
.process("Resources/notification_join.mp3"),
25+
.process("Resources/notification_message.mp3"),
26+
])
27+
]
2928
)
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
//
2+
// BaseAtom.swift
3+
// RealtimeKitUI
4+
//
5+
// Created by sudhir kumar on 22/11/22.
6+
//
7+
8+
import UIKit
9+
10+
public class BaseView: UIView {
11+
12+
}
13+
14+
public class BaseStackView: UIStackView {
15+
16+
}
17+
18+
public class BaseAtomView:UIView, BaseAtom {
19+
var isConstraintAdded: Bool = false
20+
}
21+
22+
public class BaseMoluculeView:UIView, Molecule {
23+
var atoms: [BaseAtom] = [BaseAtom]()
24+
var isConstraintAdded: Bool = false
25+
}
26+
27+
public class BaseImageView: UIImageView {
28+
func setImage(image: RtkImage?, completion:((UIImage)-> Void)? = nil) {
29+
if let image = image?.image {
30+
self.image = image.withRenderingMode(image.renderingMode)
31+
completion?(self.image ?? image)
32+
}else {
33+
if let url = image?.url {
34+
let result = ImageUtil.shared.obtainImageWithPath(url: url, completionHandler: { image, url in
35+
self.image = image.withRenderingMode(image.renderingMode)
36+
completion?(self.image ?? image)
37+
})
38+
if let image = result.0 {
39+
self.image = image.withRenderingMode(image.renderingMode)
40+
completion?(self.image ?? image)
41+
}
42+
}
43+
}
44+
45+
}
46+
}
47+
48+
protocol AutoLayoutable: UIView {
49+
var isConstraintAdded:Bool {get}
50+
func createSubviews()
51+
}
52+
53+
extension AutoLayoutable {
54+
55+
func createSubviews() {
56+
57+
}
58+
}
59+
60+
protocol BaseAtom: AutoLayoutable{
61+
62+
}
63+
64+
protocol Molecule: AutoLayoutable {
65+
var atoms:[BaseAtom] {get}
66+
}
67+
68+
public protocol AdaptableUI {
69+
var portraitConstraints: [NSLayoutConstraint] {get}
70+
var landscapeConstraints: [NSLayoutConstraint] {get}
71+
func applyConstraintAsPerOrientation(isLandscape:Bool, onPortait:()->Void, onLandscape:()->Void)
72+
}
73+
74+
public extension AdaptableUI {
75+
func setOrientationContraintAsDeactive() {
76+
setPortraitContraintAsDeactive()
77+
setLandscapeContraintAsDeactive()
78+
}
79+
80+
func setPortraitContraintAsDeactive() {
81+
portraitConstraints.forEach { $0.isActive = false}
82+
}
83+
func setLandscapeContraintAsDeactive() {
84+
landscapeConstraints.forEach { $0.isActive = false}
85+
}
86+
87+
func applyConstraintAsPerOrientation() {
88+
applyConstraintAsPerOrientation(isLandscape: UIScreen.isLandscape())
89+
}
90+
91+
func applyOnlyConstraintAsPerOrientation() {
92+
applyOnlyConstraintAsPerOrientation(isLandscape: UIScreen.isLandscape())
93+
}
94+
95+
private func applyOnlyConstraintAsPerOrientation(isLandscape: Bool, onPortait:()->Void = {}, onLandscape:()->Void = {}) {
96+
if isLandscape {
97+
landscapeConstraints.forEach { $0.isActive = true }
98+
onLandscape()
99+
} else {
100+
portraitConstraints.forEach { $0.isActive = true }
101+
onPortait()
102+
}
103+
}
104+
105+
func applyConstraintAsPerOrientation(isLandscape: Bool) {
106+
applyConstraintAsPerOrientation(isLandscape: isLandscape, onPortait: {}, onLandscape: {})
107+
}
108+
109+
func applyConstraintAsPerOrientation(isLandscape: Bool, onPortait:()->Void = {}, onLandscape:()->Void = {}) {
110+
setOrientationContraintAsDeactive()
111+
applyOnlyConstraintAsPerOrientation(isLandscape: isLandscape, onPortait: onPortait, onLandscape: onLandscape)
112+
}
113+
114+
func applyConstraintAsPerOrientation(onPortait:()->Void = {}, onLandscape:()->Void = {}) {
115+
applyConstraintAsPerOrientation(isLandscape: UIScreen.isLandscape(), onPortait: onPortait, onLandscape: onLandscape)
116+
}
117+
118+
func isLandscape(size: CGSize) -> Bool {
119+
return size.width > size.height
120+
}
121+
}
122+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// Constants.swift
3+
// iosApp
4+
//
5+
// Created by Shaunak Jagtap on 10/08/22.
6+
// Copyright © 2022 orgName. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
struct Constants {
12+
static let sdkVersion = "0.7.4"
13+
static let errorLoadingImage = "Error Loading Image!"
14+
static let errorTitle = "Error!"
15+
static let recordingError = "Something is wrong with recording, don't worry already, we're on it!"
16+
}
17+
18+
class Shared {
19+
static let data = Shared()
20+
private var chatReadCount: Int = 0
21+
private var viewedPollCount: Int = 0
22+
var delegate: RealtimeKitUILifeCycle?
23+
var notification: RtkNotificationConfig!
24+
var privateChatReadLookup = [String:Bool]()
25+
26+
func getUnreadChatCount(totalMessage: Int) -> Int {
27+
let unreadCount = totalMessage - chatReadCount
28+
if unreadCount < 0 {
29+
return 0
30+
}
31+
return unreadCount
32+
}
33+
34+
func setChatReadCount(totalMessage: Int) {
35+
chatReadCount = totalMessage
36+
}
37+
38+
func getUnviewPollCount(totalPolls: Int) -> Int {
39+
let unreadCount = totalPolls - viewedPollCount
40+
if unreadCount < 0 {
41+
return 0
42+
}
43+
return unreadCount
44+
}
45+
46+
func setPollViewCount(totalPolls: Int) {
47+
viewedPollCount = totalPolls
48+
}
49+
50+
func getTotalUnreadCountPollsAndChat(totalMessage: Int, totalsPolls: Int) -> Int {
51+
return getUnviewPollCount(totalPolls: totalsPolls) + getUnreadChatCount(totalMessage: totalMessage)
52+
}
53+
54+
func initialise() {
55+
chatReadCount = 0
56+
viewedPollCount = 0
57+
}
58+
59+
func clean() {
60+
initialise()
61+
}
62+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
//
2+
// ImageProvider.swift
3+
// RealtimeKitUI
4+
//
5+
// Created by sudhir kumar on 30/11/22.
6+
//
7+
8+
import UIKit
9+
10+
public class ImageProvider {
11+
// for any image located in bundle where this class has built
12+
public static func image(named: String) -> UIImage? {
13+
return UIImage(named: named, in: Bundle.resources, with: nil)
14+
}
15+
}
16+
17+
public class FileDownloader {
18+
static func downloadFile(from url: URL, to destinationURL: URL, completion: @escaping (Bool, Error?) -> Void) {
19+
let session = URLSession(configuration: .default)
20+
21+
let downloadTask = session.downloadTask(with: url) { (location, response, error) in
22+
guard let location = location else {
23+
completion(false, error)
24+
return
25+
}
26+
27+
do {
28+
try FileManager.default.moveItem(at: location, to: destinationURL)
29+
completion(true, nil)
30+
} catch {
31+
completion(false, error)
32+
}
33+
}
34+
35+
downloadTask.resume()
36+
}
37+
38+
}
39+
40+
final class ImageUtil {
41+
42+
var session = URLSession(configuration: .default)
43+
var cache: NSCache<NSString, UIImage>!
44+
static let shared = ImageUtil()
45+
private init(){
46+
session = URLSession.shared
47+
self.cache = NSCache()
48+
}
49+
func obtainImageWithPath(url: URL, completionHandler: @escaping (UIImage, URL) -> Void)-> (UIImage?,URLSessionTask?) {
50+
return self.obtainImageWithPath(imagePath: url.absoluteString, completionHandler: completionHandler)
51+
}
52+
53+
func obtainImageWithPath(imagePath: String, completionHandler: @escaping(UIImage, URL) -> Void) -> (UIImage?,URLSessionTask?){
54+
if let image = self.cache.object(forKey: imagePath as NSString) {
55+
return (image , nil)
56+
} else {
57+
guard let placeholder = ImageProvider.image(named: "icon_image") else { return (nil, nil) }
58+
if let url = URL(string: imagePath) {
59+
let task = session.dataTask(with: URLRequest(url: url)) { data, response, error in
60+
if let data = data , error == nil, let url = response?.url {
61+
if let img = UIImage(data: data) {
62+
self.cache.setObject(img, forKey: url.absoluteString as NSString)
63+
DispatchQueue.main.async {
64+
completionHandler(img, url)
65+
}
66+
}
67+
}
68+
}
69+
task.resume()
70+
71+
return (placeholder, task)
72+
}
73+
74+
print(Constants.errorLoadingImage)
75+
return (nil , nil)
76+
}
77+
}
78+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//
2+
// KeyboardObserver.swift
3+
// RealtimeKitUI
4+
//
5+
// Created by sudhir kumar on 22/11/22.
6+
//
7+
8+
import UIKit
9+
10+
internal class KeyboardObserver {
11+
12+
private var onShowHandler: ((_ keyboardFrame: CGRect) -> Void)?
13+
private var onHideHandler: (() -> Void)?
14+
15+
init(onShow: @escaping (_ keyboardFrame: CGRect) -> Void, onHide: @escaping () -> Void) {
16+
onShowHandler = onShow
17+
onHideHandler = onHide
18+
startObserving()
19+
}
20+
21+
22+
private func startObserving() {
23+
NotificationCenter.default.addObserver(self,
24+
selector: #selector(handleKeyboardWillShow(notification:)),
25+
name: UIResponder.keyboardWillShowNotification,
26+
object: nil)
27+
28+
NotificationCenter.default.addObserver(self,
29+
selector: #selector(handleKeyboardWillHide(notification:)),
30+
name: UIResponder.keyboardWillHideNotification,
31+
object: nil)
32+
}
33+
34+
35+
@objc private func handleKeyboardWillShow(notification: Notification) {
36+
guard let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
37+
onShowHandler?(keyboardFrame)
38+
}
39+
40+
41+
@objc private func handleKeyboardWillHide(notification: Notification) {
42+
onHideHandler?()
43+
}
44+
45+
46+
func stopObserving() {
47+
NotificationCenter.default.removeObserver(self)
48+
onShowHandler = nil
49+
onHideHandler = nil
50+
}
51+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ``RealtimeKitUI``
2+
3+
<!--@START_MENU_TOKEN@-->Summary<!--@END_MENU_TOKEN@-->
4+
5+
## Overview
6+
7+
<!--@START_MENU_TOKEN@-->Text<!--@END_MENU_TOKEN@-->
8+
9+
## Topics
10+
11+
### <!--@START_MENU_TOKEN@-->Group<!--@END_MENU_TOKEN@-->
12+
13+
- <!--@START_MENU_TOKEN@-->``Symbol``<!--@END_MENU_TOKEN@-->

0 commit comments

Comments
 (0)