Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Examples/DemosApp/DemosApp/Login/SwiftUILogin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ struct SwiftUILogin: View {
@State private var isLoading = false

private var isButtonEnabled: Bool {
return self.email.isNotEmpty
&& self.password.isNotEmpty
return !self.email.isEmpty
&& !self.password.isEmpty
&& self.isConsented
&& (
self.selectedPage == .signUp && self.name.isNotEmpty
self.selectedPage == .signUp && !self.name.isEmpty
|| self.selectedPage == .signIn
)
}
Expand Down
6 changes: 3 additions & 3 deletions Examples/DemosApp/DemosApp/Login/UIKitLogin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ final class UIKitLogin: UIViewController {
}

private var isButtonEnabled: Bool {
return self.emailInput.text.isNotEmpty
&& self.passwordInput.text.isNotEmpty
return !self.emailInput.text.isEmpty
&& !self.passwordInput.text.isEmpty
&& self.consentCheckbox.isSelected
&& (
self.pageControl.selectedId == .signUp && self.nameInput.text.isNotEmpty
self.pageControl.selectedId == .signUp && !self.nameInput.text.isEmpty
|| self.pageControl.selectedId == .signIn
)
}
Expand Down
8 changes: 3 additions & 5 deletions Sources/ComponentsKit/Helpers/Array+Safe.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import Foundation

extension Array {
/// Returns the element at the specified index iff it is within bounds, nil otherwise.
/// Complexity: O(1).
/// Returns the element at the specified index if it is within bounds, nil otherwise.
///
/// - Parameter index: The index of the element to be returned.
/// - Returns: The value that corresponds to the index. nil if the value cannot be found.
public subscript(safe index: Index) -> Iterator.Element? {
subscript(safe index: Index) -> Iterator.Element? {
return self.isIndexValid(index) ? self[index] : nil
}

/// Checks whether the index is valid for the array.
/// Complexity: O(1).
///
/// - Parameter index: The index to be checked.
/// - Returns: true if the index is valid for the collection, false otherwise.
public func isIndexValid(_ index: Index) -> Bool {
func isIndexValid(_ index: Index) -> Bool {
return index >= self.startIndex && index < self.endIndex
}
}
2 changes: 1 addition & 1 deletion Sources/ComponentsKit/Helpers/Collection+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

extension Collection {
/// Whether the collection is not empty.
public var isNotEmpty: Bool {
var isNotEmpty: Bool {
return !self.isEmpty
}
}
8 changes: 4 additions & 4 deletions Sources/ComponentsKit/Helpers/Optional+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import Foundation

extension Optional {
/// Whether the value is nil.
public var isNil: Bool {
var isNil: Bool {
return self == nil
}

/// Whether the value is not nil.
public var isNotNil: Bool {
var isNotNil: Bool {
return self != nil
}
}

extension Optional where Wrapped: Collection {
/// Whether the value is not nil and empty.
public var isNotNilAndEmpty: Bool {
var isNotNilAndEmpty: Bool {
if let self {
return self.isNotEmpty
} else {
Expand All @@ -23,7 +23,7 @@ extension Optional where Wrapped: Collection {
}

/// Whether the value is nil or empty.
public var isNilOrEmpty: Bool {
var isNilOrEmpty: Bool {
if let self {
return self.isEmpty
} else {
Expand Down