-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from mansbernhardt/release-1.1
Release 1.1
- Loading branch information
Showing
17 changed files
with
681 additions
and
150 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
# 1.0 | ||
|
||
This is the first public release of the Flow library. | ||
|
||
# 1.1 | ||
|
||
- Added `DisposeBag.hold()` convenience method for holding a reference to an object. | ||
- Added `UITextField` delegates for `shouldEndEditing` and `shouldReturn`l | ||
- Added `UITextField.isEditingSignal` signal. | ||
- Added `UIView.install()` for installing gesture recognizers. | ||
- Added `UIView` signals for displaying editing menu for copy, cut and paste. | ||
- Added `orientationSignal` that will signal on orientation changes. | ||
- Added `UIRefreshControl` `animate()` and `refersh()` helpers. | ||
- Added `disableActiveEventListeners()` helper |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// | ||
// HasEventListeners.swift | ||
// Flow | ||
// | ||
// Created by Måns Bernhardt on 2015-11-27. | ||
// Copyright © 2015 iZettle. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
/// Whether the conforming class has event listeners. | ||
public protocol HasEventListeners: class { | ||
/// Boolean value indicating whether the instance currently has event listeners. | ||
var hasEventListeners: Bool { get } | ||
} | ||
|
||
/// Whether the conforming type can provide an array of all sub views/items that conform to `Enablable & HasEventListeners`. | ||
public protocol HasEnablableEventListeners { | ||
// An array of all sub views/items that conform to `Enablable & HasEventListeners` | ||
var enablableEventListeners: [Enablable & HasEventListeners] { get } | ||
} | ||
|
||
public extension HasEnablableEventListeners { | ||
/// Will find and disable all sub views/items that conform `Enablable & HasEventListeners` that currently has event listeners. | ||
/// - Returns: A `Disposable` that will upon dispose re-enable the views/items being disabled. | ||
func disableActiveEventListeners() -> Disposable { | ||
let activeListeners = enablableEventListeners.filter { $0.hasEventListeners }.filter { ($0 as Enablable).isEnabled } | ||
activeListeners.forEach { $0.isEnabled = false } | ||
return Disposer { | ||
activeListeners.filter { $0.hasEventListeners }.forEach { $0.isEnabled = true } | ||
} | ||
} | ||
} | ||
|
||
#if canImport(UIKit) | ||
|
||
import UIKit | ||
|
||
extension UIView: HasEnablableEventListeners { | ||
public var enablableEventListeners: [Enablable & HasEventListeners] { | ||
return allSubviews(ofType: (Enablable & HasEventListeners).self) | ||
} | ||
} | ||
|
||
extension UINavigationItem: HasEnablableEventListeners { | ||
public var enablableEventListeners: [Enablable & HasEventListeners] { | ||
return allItemsOrViews(ofType: (Enablable & HasEventListeners).self) | ||
} | ||
} | ||
|
||
extension UIViewController: HasEnablableEventListeners { | ||
public var enablableEventListeners: [Enablable & HasEventListeners] { | ||
return view.enablableEventListeners + navigationItem.enablableEventListeners | ||
} | ||
} | ||
|
||
private extension UINavigationItem { | ||
func allItemsOrViews<T>(ofType type: T.Type) -> [T] { | ||
var result = [T]() | ||
let items = (leftBarButtonItems ?? []) + (rightBarButtonItems ?? []) | ||
result += items.compactMap { $0 as? T } | ||
result += items.compactMap { $0.customView }.flatMap { $0.allSubviews(ofType: T.self) } | ||
return result | ||
} | ||
} | ||
|
||
internal extension UIView { | ||
var allSubviews: [UIView] { | ||
return subviews + subviews.flatMap { | ||
$0.allSubviews | ||
} | ||
} | ||
|
||
func allSubviews<T>(ofType type: T.Type) -> [T] { | ||
return allSubviews.compactMap { $0 as? T } | ||
} | ||
} | ||
|
||
#endif | ||
|
||
|
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
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
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
Oops, something went wrong.