Skip to content

Commit

Permalink
Rename to SetNeedsDisplay
Browse files Browse the repository at this point in the history
  • Loading branch information
b3ll committed Dec 23, 2020
1 parent b713933 commit b14ee84
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
import PackageDescription

let package = Package(
name: "LayoutInvalidating",
name: "SetNeedsDisplay",
products: [
.library(
name: "LayoutInvalidating",
targets: ["LayoutInvalidating"]),
name: "SetNeedsDisplay",
targets: ["SetNeedsDisplay"]),
],
dependencies: [],
targets: [
.target(
name: "LayoutInvalidating",
name: "SetNeedsDisplay",
dependencies: []),
.testTarget(
name: "LayoutInvalidatingTests",
dependencies: ["LayoutInvalidating"]),
name: "SetNeedsDisplayTests",
dependencies: ["SetNeedsDisplay"]),
]
)
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# LayoutInvalidating
# SetNeedsDisplay

![Tests](https://github.com/b3ll/LayoutInvalidating/workflows/Tests/badge.svg)
![Tests](https://github.com/b3ll/SetNeedsDisplay/workflows/Tests/badge.svg)

This package provides a property wrapper that can be used on properties for any `NSView` or `UIView` to invalidate the layout whenever the value of said property is changed.

**Note**: This code contains some private Swift API stuff that powers `@Published` so there's a strong likelyhood this will break in the future.

- [Introduction](#layoutinvalidating)
- [Introduction](#SetNeedsDisplay)
- [Usage](#usage)
- [Installation](#installation)
- [Requirements](#requirements)
Expand All @@ -23,7 +23,7 @@ Annotate your property of a type that conforms to `Equatable` like so:
class MyView: UIView {

// Anytime someCustomProperty is changed, `-setNeedsLayout` will be called.
@LayoutInvaldating var someCustomProperty: CGFloat = 0.0
@SetNeedsDisplay var someCustomProperty: CGFloat = 0.0

}
```
Expand All @@ -35,19 +35,19 @@ class MyView: UIView {
- iOS 13+, macOS 10.15+
- Swift 5.0 or higher

Currently LayoutInvalidating supports Swift Package Manager (or manually adding `LayoutInvalidating.swift` to your project).
Currently SetNeedsDisplay supports Swift Package Manager (or manually adding `SetNeedsDisplay.swift` to your project).

## Swift Package Manager

Add the following to your `Package.swift` (or add it via Xcode's GUI):

```swift
.package(url: "https://github.com/b3ll/LayoutInvalidating", from: "0.0.1")
.package(url: "https://github.com/b3ll/SetNeedsDisplay", from: "0.0.1")
```

# License

LayoutInvalidating is licensed under the [BSD 2-clause license](https://github.com/b3ll/LayoutInvalidating/blob/master/LICENSE).
SetNeedsDisplay is licensed under the [BSD 2-clause license](https://github.com/b3ll/SetNeedsDisplay/blob/master/LICENSE).

# Thanks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import UIKit

/// A property wrapper for `UIView` or `NSView` (depending on platform) that will invalidate the layout of the view when the property's value is changed to something new.
@propertyWrapper
public final class LayoutInvalidating<Value> where Value: Equatable {
public final class SetNeedsDisplay<Value> where Value: Equatable {

#if os(macOS)
public typealias ViewType = NSView
Expand All @@ -19,7 +19,7 @@ public final class LayoutInvalidating<Value> where Value: Equatable {
public static subscript<EnclosingSelf>(
_enclosingInstance observed: EnclosingSelf,
wrapped wrappedKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>,
storage storageKeyPath: ReferenceWritableKeyPath<EnclosingSelf, LayoutInvalidating>
storage storageKeyPath: ReferenceWritableKeyPath<EnclosingSelf, SetNeedsDisplay>
) -> Value where EnclosingSelf: ViewType {
get {
return observed[keyPath: storageKeyPath].stored
Expand Down
4 changes: 2 additions & 2 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import XCTest

import LayoutInvalidatingTests
import SetNeedsDisplayTests

var tests = [XCTestCaseEntry]()
tests += LayoutInvalidatingTests.allTests()
tests += SetNeedsDisplayTests.allTests()
XCTMain(tests)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import XCTest
@testable import LayoutInvalidating
@testable import SetNeedsDisplay

#if os(macOS)
import AppKit

class TestView: NSView {

@LayoutInvalidating var testPadding: CGFloat = 0.0
@SetNeedsDisplay var testPadding: CGFloat = 0.0

var layoutWasInvalidated: Bool = false

Expand All @@ -30,7 +30,7 @@ import UIKit

class TestView: UIView {

@LayoutInvalidating var testPadding: CGFloat = 0.0
@SetNeedsDisplay var testPadding: CGFloat = 0.0

var layoutWasInvalidated: Bool = false

Expand All @@ -49,7 +49,7 @@ class TestView: UIView {
}
#endif

final class LayoutInvalidatingTests: XCTestCase {
final class SetNeedsDisplayTests: XCTestCase {

func testLayoutInvalidation() {
let view = TestView(frame: .zero)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import XCTest
#if !canImport(ObjectiveC)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(LayoutInvalidatingTests.allTests),
testCase(SetNeedsDisplayTests.allTests),
]
}
#endif

0 comments on commit b14ee84

Please # to comment.