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
import Foundation | |
class KxSwift<T> { | |
typealias Observer = (T) -> () | |
var observer: Observer? | |
var value: T { | |
didSet { | |
observer?(value) |
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
import UIKit | |
import Foundation | |
import SocketIO | |
let kHost = "http://192.168.1.43:3001" | |
let kConnectUser = "connectUser" | |
let kUserList = "userList" | |
let kExitUser = "exitUser" | |
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
import UIKit | |
class ChatListTableView: UITableView, UITableViewDelegate, UITableViewDataSource { | |
var onDidSelect: ((User) -> Void)? | |
private var chatViewModel: ChatViewModel = ChatViewModel() | |
var nickName: String? | |
override func awakeFromNib() { |
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
import Foundation | |
final class ChatViewModel { | |
var arrUsers: KxSwift<[User]> = KxSwift<[User]>([]) | |
func fetchParticipantList(_ name: String) { | |
SocketHelper.shared.participantList {[weak self] (result: [User]?) in | |
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
struct User: Codable { | |
var id: String? | |
var isConnected: Bool? | |
var nickname: String? | |
} |
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
import UIKit | |
class ChatDetailsTableView: UITableView, UITableViewDelegate, UITableViewDataSource { | |
private var messageViewModel: MessageViewModel = MessageViewModel() | |
var nickName: String? | |
override func awakeFromNib() { | |
super.awakeFromNib() | |
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
import Foundation | |
final class MessageViewModel { | |
var arrMessage: KxSwift<[Message]> = KxSwift<[Message]>([]) | |
func getMessagesFromServer() { | |
SocketHelper.shared.getMessage { [weak self] (message: Message?) in | |
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
import Foundation | |
struct Message: Codable { | |
var date: String? | |
var message: String? | |
var nickname: String? | |
} | |
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
import Foundation | |
import UIKit | |
extension UIApplication { | |
static func jsonString(from object:Any) -> String? { | |
guard let data = jsonData(from: object) else { | |
return nil | |
} |
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
import Foundation | |
import UIKit | |
extension UITableView { | |
static func emptyCell() -> UITableViewCell { | |
let cell = UITableViewCell() | |
cell.selectionStyle = .none | |
return cell | |
} |
OlderNewer