From cba4833d46877ecb1080165c1c2f94c00fd7b778 Mon Sep 17 00:00:00 2001 From: Vlad Date: Sun, 23 Aug 2020 23:47:56 +0300 Subject: [PATCH] Code corresction --- OTPSwiftView/Sources/Helpers/Typealias.swift | 1 + .../Views/OTPSwiftView/OTPSwiftView.swift | 16 +++++++--------- README.md | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/OTPSwiftView/Sources/Helpers/Typealias.swift b/OTPSwiftView/Sources/Helpers/Typealias.swift index c324660e..4fb8cf68 100644 --- a/OTPSwiftView/Sources/Helpers/Typealias.swift +++ b/OTPSwiftView/Sources/Helpers/Typealias.swift @@ -23,5 +23,6 @@ import UIKit public typealias Spacing = [Int: CGFloat] +public typealias ValueClosure = ((T) -> Void) public typealias VoidClosure = (() -> Void) public typealias ValidationClosure = ((T) -> Bool) diff --git a/OTPSwiftView/Sources/Views/OTPSwiftView/OTPSwiftView.swift b/OTPSwiftView/Sources/Views/OTPSwiftView/OTPSwiftView.swift index 08ceeb5d..dd1000ac 100644 --- a/OTPSwiftView/Sources/Views/OTPSwiftView/OTPSwiftView.swift +++ b/OTPSwiftView/Sources/Views/OTPSwiftView/OTPSwiftView.swift @@ -32,7 +32,7 @@ open class OTPSwiftView: BaseInitializableControl { public private(set) var codeStackView = UIStackView() public private(set) var textFieldsCollection: [View] = [] - public var onTextEnter: ((String) -> Void)? + public var onTextEnter: ValueClosure? public var code: String { get { @@ -99,28 +99,24 @@ private extension OTPSwiftView { } customSpacing.forEach { [weak self] viewIndex, spacing in - guard viewIndex < stackView.arrangedSubviews.count, viewIndex >= 0 else { + guard viewIndex < stackView.arrangedSubviews.count, viewIndex >= .zero else { return } self?.set(spacing: spacing, after: stackView.arrangedSubviews[viewIndex], - at: viewIndex, for: stackView) } } - func set(spacing: CGFloat, - after view: UIView, - at index: Int, - for stackView: UIStackView) { + func set(spacing: CGFloat, after view: UIView, for stackView: UIStackView) { stackView.setCustomSpacing(spacing, after: view) } func createTextFields(numberOfFields: Int) -> [View] { var textFieldsCollection: [View] = [] - (0..