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 ProgressView: UIView, NibLoadable { | |
// MARK: Properties | |
var animationDuration = 0.3 | |
fileprivate(set) var isAnimating = false | |
// MARK: - Overrides | |
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
// MARK: - ErrorAnimatable | |
extension ErrorView: ErrorAnimatable { | |
func playAnimation() { | |
self.isAnimating = true | |
} | |
func stopAnimation() { | |
self.isAnimating = false | |
} |
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
// MARK: - ErrorDisplayable | |
extension ErrorView: ErrorDisplayable { | |
static func show<T: ErrorView>( | |
fromViewController viewController: UIViewController, | |
animated: Bool = true, | |
completion: ((Bool) -> Swift.Void)? = nil) -> T { | |
guard let subview = loadFromNib() as? T else { | |
fatalError("The subview is expected to be of type \(T.self)") |
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 ErrorView: UIView, NibLoadable { | |
// MARK: Properties | |
weak var delegate: ErrorViewDelegate? | |
var animationDuration = 0.3 | |
fileprivate(set) var isAnimating = false | |
// MARK: - Overrides | |
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
protocol ErrorAnimatable { | |
func playAnimation() | |
func stopAnimation() | |
} |
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
protocol ErrorViewDelegate: class { | |
func errorView(_ errorView: ErrorView, didRetry sender: UIButton) | |
} |
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
protocol ErrorDisplayable { | |
static func show<T: ErrorView>( | |
fromViewController viewController: UIViewController, | |
animated: Bool, | |
completion: ((Bool) -> Swift.Void)?) -> T | |
static func show<T: ErrorView>( | |
fromView view: UIView, | |
insets: UIEdgeInsets, animated: Bool, | |
completion: ((Bool) -> Swift.Void)?) -> T |
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
// Type of screen and its error view to display | |
enum ErrorScreen { | |
case home | |
case details | |
var errorView: ErrorView.Type? { | |
switch self { | |
default: | |
return ErrorViewRetry.self | |
} |
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
/// Specify the error display context when hasData is true : use the error message, or use data oriented priority | |
/// | |
/// - dataOriented: For this type, the error message will show that data inconsistency is possible | |
/// - errorOriented: The error message always use the Error type localized message if available, default message if needed | |
enum ErrorContext { | |
case dataOriented | |
case errorOriented | |
} |
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
/// Errors prompting protocol at its core | |
protocol FailableCore { | |
/// Show an error | |
func showError(_ error: Swift.Error?) | |
} | |
/// Failable protocol to display error | |
protocol Failable: FailableCore { | |
var errorScreenType: ErrorScreen? {get} |