| 1 |
//
|
|
| 2 |
// RouteComposer
|
|
| 3 |
// Array+PrivateExtension.swift
|
|
| 4 |
// https://github.com/ekazaev/route-composer
|
|
| 5 |
//
|
|
| 6 |
// Created by Eugene Kazaev in 2018-2022.
|
|
| 7 |
// Distributed under the MIT license.
|
|
| 8 |
//
|
|
| 9 |
// Become a sponsor:
|
|
| 10 |
// https://github.com/sponsors/ekazaev
|
|
| 11 |
//
|
|
| 12 |
|
|
| 13 |
import Foundation
|
|
| 14 |
import UIKit
|
|
| 15 |
|
|
| 16 |
extension Array where Element: UIViewController {
|
|
| 17 |
|
|
| 18 |
var nonDismissibleViewController: UIViewController? {
|
309x |
| 19 |
compactMap {
|
435x |
| 20 |
$0 as? RoutingInterceptable & UIViewController
|
435x |
| 21 |
}.first {
|
435x |
| 22 |
!$0.canBeDismissed
|
213x |
| 23 |
}
|
213x |
| 24 |
}
|
309x |
| 25 |
|
|
| 26 |
func uniqueElements() -> [Element] {
|
663x |
| 27 |
reduce(into: [Element]()) {
|
1180x |
| 28 |
if !$0.contains($1) {
|
1180x |
| 29 |
$0.append($1)
|
850x |
| 30 |
}
|
1180x |
| 31 |
}
|
1180x |
| 32 |
}
|
663x |
| 33 |
|
|
| 34 |
func isEqual(to array: [UIViewController]) -> Bool {
|
7x |
| 35 |
guard count == array.count else {
|
7x |
| 36 |
return false
|
5x |
| 37 |
}
|
5x |
| 38 |
return enumerated().first(where: { index, vc in
|
5x |
| 39 |
array[index] !== vc
|
5x |
| 40 |
}) == nil
|
5x |
| 41 |
}
|
7x |
| 42 |
|
|
| 43 |
}
|
|