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 ExerciseRoutine: Codable { | |
let id: String | |
let templateId: String | |
let name: String | |
} | |
struct ExerciseTemplate: Codable { | |
let id: String | |
let name: 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
struct TemplatesRequest: PidgeonRequest { | |
let relativeUrl: String = "/templates" | |
let httpMethod: PidgeonHTTPMethod = .get | |
} | |
struct UploadRequest: PidgeonRequest { | |
let relativeUrl: String = "/exerciseRoutines" | |
let httpMethod: PidgeonHTTPMethod = .post | |
let routine: ExerciseRoutine |
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 | |
struct HideNavBehavior: ViewControllerLifecycleBehavior { | |
func handle(event: LifecycleEvent) { | |
switch event.eventType { | |
case .willAppear: | |
event.viewController.navigationController?.setNavigationBarHidden(true, animated: false) | |
case .willDisappear: | |
event.viewController.navigationController?.setNavigationBarHidden(false, animated: false) | |
default: |
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
class BufferingStackView: UIStackView { | |
private var viewBuffer: ViewBuffer = ViewBuffer() | |
func prepare<T: UIView>(viewCount: Int, config: @escaping (_ index: Int, _ view: T) -> Void) { | |
let currentViewCount = self.arrangedSubviews.count | |
let neededViewCount = viewCount | |
let diff = neededViewCount - currentViewCount | |
let absDiff = abs(diff) | |
let shouldDelete = diff < 0 | |
if shouldDelete { | |
(0..<absDiff).forEach({ _ 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
public class TransformingVariable<Element> : ObserverType, ObservableConvertibleType { | |
public typealias E = Element | |
public typealias TransformationBlock = (_ input: E) -> E | |
private let backingVariable: Variable<E> | |
private let transformation: TransformationBlock | |
public init(initialValue: E, transformation: @escaping TransformationBlock) { | |
self.backingVariable = Variable(initialValue) | |
self.transformation = transformation |