This file contains hidden or 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 SwiftUI | |
| struct DatePickerInputView: UIViewRepresentable { | |
| @Binding var date: Date? | |
| let placeholder: String | |
| init(date: Binding<Date?>, placeholder: String) { | |
| self._date = date | |
| self.placeholder = placeholder | |
| } |
This file contains hidden or 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 SwiftUI | |
| import UIKit | |
| final class DatePickerTextField: UITextField { | |
| @Binding var date: Date? | |
| private let datePicker = UIDatePicker() | |
| init(date: Binding<Date?>, frame: CGRect) { | |
| self._date = date | |
| super.init(frame: frame) |
This file contains hidden or 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
| final class Reviewer { | |
| let name: String | |
| var revieweesCount: Int | |
| init(name: String) { | |
| self.name = name | |
| self.revieweesCount = 0 | |
| } | |
| } |
This file contains hidden or 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
| let vc = BaseMessagesViewController<CFMessageImpl>(messagesSocket: MessagesWSManager(socket: WebSocket(url: URL(string: "randomURL")!)), parser: CFParserImpl()) | |
| let vc1 = BaseMessagesViewController<CFMessageImpl>(messagesSocket: MessagesSocketIOManager(urlString: "randomURL"), parser: CFParserImpl()) |
This file contains hidden or 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
| protocol CFParser { | |
| func parse<T: Decodable>(response: Data) -> Result<T, Error> | |
| } | |
| class CFParserImpl: CFParser { | |
| func parse<T>(response: Data) -> Result<T, Error> where T : Decodable { | |
| return .failure(MessageError.noData) | |
| } | |
| } |
This file contains hidden or 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
| protocol CFMessage: Decodable { | |
| var id: Int { get } | |
| } | |
| class CFMessageImpl: CFMessage { | |
| var id: Int | |
| } |
This file contains hidden or 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
| class BaseMessagesViewController<Message: CFMessage>: UIViewController { | |
| private var messages = [Message]() | |
| private var currentPage: Int = 1 | |
| private var limit: Int = 10 | |
| private let messagesSocket: CFMessagesSocket | |
| private let parser: CFParser | |
| init(messagesSocket: CFMessagesSocket, parser: CFParser) { | |
| self.messagesSocket = messagesSocket | |
| self.parser = parser |
This file contains hidden or 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
| protocol CFMessagesSocketDelegate: class { | |
| func didReceiveMessage(message: String) | |
| func didReceiveError(error: Error) | |
| func didReceiveData(data: Data) | |
| } |
This file contains hidden or 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 Starscream | |
| class MessagesWSManager: CFMessagesSocket { | |
| weak var delegate: CFMessagesSocketDelegate? | |
| private let socket: WebSocket | |
| init(socket: WebSocket) { | |
| self.socket = socket | |
| } | |
This file contains hidden or 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 SocketIO | |
| class MessagesSocketIOManager: CFMessagesSocket { | |
| weak var delegate: CFMessagesSocketDelegate? | |
| private let manager: SocketManager | |
| private let socket: SocketIOClient | |
| init(urlString: String) { | |
| self.manager = SocketManager(socketURL: URL(string: urlString)!, config: [.log(true), .compress]) | |
| self.socket = manager.defaultSocket |
NewerOlder