-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exclude Epoxy directory from SwiftFormat analysis (#625)
- Loading branch information
1 parent
830eeb6
commit a9403b0
Showing
9 changed files
with
1,001 additions
and
894 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,5 +1,5 @@ | ||
# Don't format | ||
--exclude .build | ||
--exclude .build,UI/UIx/SwiftUI/Epoxy | ||
|
||
# Options | ||
|
||
|
797 changes: 391 additions & 406 deletions
797
UI/UIx/SwiftUI/Epoxy/CollectionViewScrollToItemHelper.swift
Large diffs are not rendered by default.
Oops, something went wrong.
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,17 +1,57 @@ | ||
// From: https://github.com/airbnb/epoxy-ios/blob/ecee1ace58d58e3cc918a2dea28095de713b1112 | ||
|
||
// Created by eric_horacek on 12/1/20. | ||
// Copyright © 2020 Airbnb Inc. All rights reserved. | ||
|
||
// MARK: - DataIDProviding | ||
|
||
/// The capability of providing a stable data identifier with an erased type. | ||
/// | ||
/// While it has similar semantics, this type cannot inherit from `Identifiable` as this would give | ||
/// it an associated type, which would cause the `keyPath` used in its `EpoxyModelProperty` to not | ||
/// be stable across types if written as `\Self.dataID` since the `KeyPath` `Root` would be | ||
/// different for each type. | ||
/// | ||
/// - SeeAlso: `Identifiable`. | ||
public protocol DataIDProviding { | ||
/// A stable identifier that uniquely identifies this instance, with its typed erased. | ||
/// | ||
/// Defaults to `DefaultDataID.noneProvided` if no data ID is provided. | ||
var dataID: AnyHashable { get } | ||
} | ||
|
||
// MARK: - EpoxyModeled | ||
|
||
extension EpoxyModeled where Self: DataIDProviding { | ||
|
||
// MARK: Public | ||
|
||
/// A stable identifier that uniquely identifies this model, with its typed erased. | ||
public var dataID: AnyHashable { | ||
get { self[dataIDProperty] } | ||
set { self[dataIDProperty] = newValue } | ||
} | ||
|
||
/// Returns a copy of this model with the ID replaced with the provided ID. | ||
public func dataID(_ value: AnyHashable) -> Self { | ||
copy(updating: dataIDProperty, to: value) | ||
} | ||
|
||
// MARK: Private | ||
|
||
private var dataIDProperty: EpoxyModelProperty<AnyHashable> { | ||
EpoxyModelProperty( | ||
keyPath: \DataIDProviding.dataID, | ||
defaultValue: DefaultDataID.noneProvided, | ||
updateStrategy: .replace) | ||
} | ||
} | ||
|
||
// MARK: - DefaultDataID | ||
|
||
/// The default data ID when none is provided. | ||
public enum DefaultDataID: Hashable, CustomDebugStringConvertible { | ||
case noneProvided | ||
|
||
// MARK: Public | ||
case noneProvided | ||
|
||
public var debugDescription: String { | ||
"DefaultDataID.noneProvided" | ||
} | ||
public var debugDescription: String { | ||
"DefaultDataID.noneProvided" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,55 +1,45 @@ | ||
// From: https://github.com/airbnb/epoxy-ios/blob/ecee1ace58d58e3cc918a2dea28095de713b1112 | ||
|
||
// Created by eric_horacek on 10/8/21. | ||
// Copyright © 2021 Airbnb Inc. All rights reserved. | ||
|
||
import SwiftUI | ||
|
||
#if !os(macOS) | ||
|
||
// MARK: - EpoxySwiftUIUIHostingController | ||
|
||
/// A `UIHostingController` that hosts SwiftUI views within an Epoxy container, e.g. an Epoxy | ||
/// `CollectionView`. | ||
/// | ||
/// Exposed publicly to allow consumers to reason about these view controllers, e.g. to opt | ||
/// collection view cells out of automated view controller impression tracking. | ||
/// | ||
/// - SeeAlso: `EpoxySwiftUIHostingView` | ||
open class EpoxySwiftUIHostingController<Content: View>: UIHostingController<Content> { | ||
// MARK: Lifecycle | ||
|
||
/// Creates a `UIHostingController` that optionally ignores the `safeAreaInsets` when laying out | ||
/// its contained `RootView`. | ||
public convenience init(rootView: Content, ignoreSafeArea: Bool) { | ||
self.init(rootView: rootView) | ||
|
||
clearBackground() | ||
|
||
// We unfortunately need to call a private API to disable the safe area. We can also accomplish | ||
// this by dynamically subclassing this view controller's view at runtime and overriding its | ||
// `safeAreaInsets` property and returning `.zero`. An implementation of that logic is | ||
// available in this file in the `2d28b3181cca50b89618b54836f7a9b6e36ea78e` commit if this API | ||
// no longer functions in future SwiftUI versions. | ||
_disableSafeArea = ignoreSafeArea | ||
} | ||
|
||
// MARK: Open | ||
|
||
override open func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
clearBackground() | ||
} | ||
|
||
// MARK: Internal | ||
|
||
func clearBackground() { | ||
// A `UIHostingController` has a system background color by default as it's typically used in | ||
// full-screen use cases. Since we're using this view controller to place SwiftUI views within | ||
// other view controllers we default the background color to clear so we can see the views | ||
// below, e.g. to draw highlight states in a `CollectionView`. | ||
view.backgroundColor = .clear | ||
} | ||
} | ||
// MARK: - EpoxySwiftUIUIHostingController | ||
|
||
/// A `UIHostingController` that hosts SwiftUI views within an Epoxy container, e.g. an Epoxy | ||
/// `CollectionView`. | ||
/// | ||
/// Exposed publicly to allow consumers to reason about these view controllers, e.g. to opt | ||
/// collection view cells out of automated view controller impression tracking. | ||
/// | ||
/// - SeeAlso: `EpoxySwiftUIHostingView` | ||
open class EpoxySwiftUIHostingController<Content: View>: UIHostingController<Content> { | ||
|
||
// MARK: Lifecycle | ||
|
||
/// Creates a `UIHostingController` that optionally ignores the `safeAreaInsets` when laying out | ||
/// its contained `RootView`. | ||
public convenience init(rootView: Content, ignoreSafeArea: Bool) { | ||
self.init(rootView: rootView) | ||
|
||
// We unfortunately need to call a private API to disable the safe area. We can also accomplish | ||
// this by dynamically subclassing this view controller's view at runtime and overriding its | ||
// `safeAreaInsets` property and returning `.zero`. An implementation of that logic is | ||
// available in this file in the `2d28b3181cca50b89618b54836f7a9b6e36ea78e` commit if this API | ||
// no longer functions in future SwiftUI versions. | ||
_disableSafeArea = ignoreSafeArea | ||
} | ||
|
||
// MARK: Open | ||
|
||
open override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
// A `UIHostingController` has a system background color by default as it's typically used in | ||
// full-screen use cases. Since we're using this view controller to place SwiftUI views within | ||
// other view controllers we default the background color to clear so we can see the views | ||
// below, e.g. to draw highlight states in a `CollectionView`. | ||
view.backgroundColor = .clear | ||
} | ||
} | ||
#endif |
Oops, something went wrong.