-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve DSL experience when working with UIScrollView and other compl…
…ex views (#7) * transform 'ibSetView' to method which extends UIView to increase readibility * Various in WIP * add IBScrollView * Update files header * update addSubviews to be Self typed * Delete IBScrollView and exhence involvesOwnerView to support UILayoutGuide * comment callAsFunction to help Swift type resolver resolve superviews * comment ibsubview without superview to help swift type resolver to resolve superviews * add explicit Void expression block to try improve superview typing in ibAttributes * Revert code added to improve ibAttributes superview type resolver. Problem is present when using expressions within ibAttributes which use implicit assignation
- Loading branch information
Showing
16 changed files
with
211 additions
and
50 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
Sources/UIViewKit/AutoresizingStrategy/InferredAttributesOwnerStrategy.swift
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,6 +1,6 @@ | ||
// | ||
// InferredAttributesOwnerStrategy.swift | ||
// | ||
// UIViewKit | ||
// | ||
// Created by Blazej SLEBODA on 29/09/2023. | ||
// | ||
|
2 changes: 1 addition & 1 deletion
2
Sources/UIViewKit/AutoresizingStrategy/InferredConstraintsStrategy.swift
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,6 +1,6 @@ | ||
// | ||
// InferredConstraintsStrategy.swift | ||
// | ||
// UIViewKit | ||
// | ||
// Created by Blazej SLEBODA on 29/09/2023. | ||
// | ||
|
2 changes: 1 addition & 1 deletion
2
Sources/UIViewKit/AutoresizingStrategy/UIViewDSLEngineConstraintsProtocol.swift
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,6 +1,6 @@ | ||
// | ||
// UIViewDSL+Attributes.swift | ||
// | ||
// UIViewKit | ||
// | ||
// Created by Blazej SLEBODA on 29/09/2023. | ||
// | ||
|
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,6 +1,6 @@ | ||
// | ||
// UIViewDSL+Constraints.swift | ||
// | ||
// UIViewKit | ||
// | ||
// Created by Blazej SLEBODA on 29/09/2023. | ||
// | ||
|
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,6 +1,6 @@ | ||
// | ||
// UIViewDSL+IBOutlet.swift | ||
// | ||
// UIViewKit | ||
// | ||
// Created by Blazej SLEBODA on 29/09/2023. | ||
// | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// | ||
// UIViewDSL+SwiftUIStyleStacks.swift | ||
// | ||
// UIViewKit | ||
// | ||
// Created by Blazej SLEBODA on 29/09/2023. | ||
// | ||
|
This file was deleted.
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// IBView.swift | ||
// UIViewKit | ||
// | ||
// Created by Blazej SLEBODA on 19/10/2023. | ||
// | ||
|
||
import UIKit | ||
|
||
open class IBView: UIView { | ||
|
||
override public init(frame: CGRect) { | ||
super.init(frame: frame) | ||
createView(frame: frame) | ||
} | ||
|
||
required public init?(coder: NSCoder) { | ||
fatalError() | ||
} | ||
|
||
open func createView(frame: CGRect) { } | ||
} | ||
|
||
extension UILabel { | ||
|
||
public convenience init(_ text: String) { | ||
self.init(frame: .zero) | ||
self.text = text | ||
} | ||
} |
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,38 @@ | ||
// | ||
// IBAttributesTests.swift | ||
// UIViewKit | ||
// | ||
// Created by Blazej SLEBODA on 26/10/2023. | ||
// | ||
|
||
import XCTest | ||
@testable import UIViewKit | ||
|
||
|
||
@MainActor | ||
class IBAttributesTests: XCTestCase { | ||
|
||
func testLabelText() throws { | ||
_ = UIView() { | ||
ViewWithLabel().ibAttributes { | ||
print($0) | ||
$0.font = .italicSystemFont(ofSize: 20) | ||
Optional<String>.none | ||
} | ||
} | ||
} | ||
} | ||
|
||
fileprivate class ViewWithLabel: IBView { | ||
|
||
var font: UIFont! | ||
|
||
override func createView(frame: CGRect) { | ||
super.createView(frame: frame) | ||
self { | ||
UILabel().ibAttributes { | ||
$0.font = font | ||
} | ||
} | ||
} | ||
} |
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