Skip to content

Commit 5816fc0

Browse files
authored
Merge branch 'main' into feat/textSelectionEnabled
2 parents 88ea429 + 7d775a2 commit 5816fc0

File tree

8 files changed

+72
-38
lines changed

8 files changed

+72
-38
lines changed

.github/workflows/build-test-and-docs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ jobs:
8080

8181
- name: Build
8282
run: |
83-
set -uexo pipefail
83+
set -uxo pipefail
8484
device_type=${{ matrix.device-type }}
8585
set +e
8686
deviceid=$(xcrun simctl list devices $device_type available | grep -v -- -- | tail -n 1 | grep -oE '[0-9A-F\-]{36}')
8787
if [ $? -eq 0 ]; then
8888
(
89+
set -e
90+
8991
buildtarget () {
9092
# Use the same derived data path as DocC compilation so that we don't duplicate work.
9193
xcodebuild -derivedDataPath /tmp/data -skipMacroValidation -scheme "$1" -destination "id=$deviceid" build | xcbeautify --renderer github-actions
@@ -116,6 +118,7 @@ jobs:
116118
)
117119
else
118120
echo "No $device_type simulators found" >&2
121+
false
119122
fi
120123
121124
- name: Extract UIKitBackend symbol graphs

Examples/Package.resolved

Lines changed: 9 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Sources/HoverExample/HoverApp.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ struct HoverExample: App {
1313
WindowGroup("Hover Example") {
1414
#hotReloadable {
1515
VStack(spacing: 0) {
16-
ForEach([Bool](repeating: false, count: 18)) { _ in
16+
ForEach(1...18) { _ in
1717
HStack(spacing: 0) {
18-
ForEach([Bool](repeating: false, count: 30)) { _ in
18+
ForEach(1...30) { _ in
1919
CellView()
2020
}
2121
}

Package.resolved

Lines changed: 12 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ let package = Package(
100100
),
101101
.package(
102102
url: "https://github.com/stackotter/swift-windowsappsdk",
103-
branch: "ed938db0b9790b36391dc91b20cee81f2410309f"
103+
revision: "ba6f0ec377b70d8be835d253102ff665a0e47d99"
104104
),
105105
.package(
106-
url: "https://github.com/thebrowsercompany/swift-windowsfoundation",
107-
branch: "main"
106+
url: "https://github.com/stackotter/swift-windowsfoundation",
107+
revision: "4ad57d20553514bcb23724bdae9121569b19f172"
108108
),
109109
.package(
110110
url: "https://github.com/stackotter/swift-winui",
111-
branch: "927e2c46430cfb1b6c195590b9e65a30a8fd98a2"
111+
revision: "1695ee3ea2b7a249f6504c7f1759e7ec7a38eb86"
112112
),
113113
// .package(
114114
// url: "https://github.com/stackotter/TermKit",

Sources/SwiftCrossUI/Views/ForEach.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,28 @@ extension ForEach where Child == [MenuItem] {
1818
}
1919
}
2020

21+
extension ForEach where Items == [Int] {
22+
/// Creates a view that creates child views on demand based on a given ClosedRange
23+
@_disfavoredOverload
24+
public init(
25+
_ range: ClosedRange<Int>,
26+
child: @escaping (Int) -> Child
27+
) {
28+
self.elements = Array(range)
29+
self.child = child
30+
}
31+
32+
/// Creates a view that creates child views on demand based on a given Range
33+
@_disfavoredOverload
34+
public init(
35+
_ range: Range<Int>,
36+
child: @escaping (Int) -> Child
37+
) {
38+
self.elements = Array(range)
39+
self.child = child
40+
}
41+
}
42+
2143
extension ForEach: TypeSafeView, View where Child: View {
2244
typealias Children = ForEachViewChildren<Items, Child>
2345

Sources/SwiftCrossUI/Views/WebView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22

3+
@available(tvOS, unavailable)
34
public struct WebView: ElementaryView {
45
@State var currentURL: URL?
56
@Binding var url: URL

Sources/UIKitBackend/UIKitBackend+Control.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ final class TextFieldWidget: WrapperWidget<UITextField>, UITextFieldDelegate {
5959

6060
final class TextEditorWidget: WrapperWidget<UITextView>, UITextViewDelegate {
6161
var onChange: ((String) -> Void)?
62+
var isEditable: Bool = true {
63+
didSet {
64+
#if os(tvOS)
65+
if !isEditable {
66+
child.resignFirstResponder()
67+
}
68+
#else
69+
child.isEditable = isEditable
70+
#endif
71+
}
72+
}
6273

6374
init() {
6475
super.init(child: UITextView())
@@ -68,6 +79,10 @@ final class TextEditorWidget: WrapperWidget<UITextView>, UITextViewDelegate {
6879
func textViewDidChange(_: UITextView) {
6980
onChange?(child.text ?? "")
7081
}
82+
83+
func textViewShouldBeginEditing(_: UITextView) -> Bool {
84+
return isEditable
85+
}
7186
}
7287

7388
#if os(tvOS)
@@ -332,10 +347,8 @@ extension UIKitBackend {
332347
onChange: @escaping (String) -> Void
333348
) {
334349
let textEditorWidget = textEditor as! TextEditorWidget
335-
//remove on merge, replace with beberka's solution
336-
#if !os(tvOS)
337-
textEditorWidget.child.isEditable = environment.isEnabled
338-
#endif
350+
351+
textEditorWidget.isEditable = environment.isEnabled
339352
textEditorWidget.child.font = environment.resolvedFont.uiFont
340353
textEditorWidget.child.textColor = UIColor(color: environment.suggestedForegroundColor)
341354
textEditorWidget.onChange = onChange
@@ -451,7 +464,7 @@ extension UIKitBackend {
451464
}
452465
}
453466

454-
#if !os(tvOS)
467+
#if os(iOS) || os(visionOS) || targetEnvironment(macCatalyst)
455468
public func createHoverTarget(wrapping child: Widget) -> Widget {
456469
HoverableWidget(child: child)
457470
}
@@ -464,9 +477,7 @@ extension UIKitBackend {
464477
let wrapper = hoverTarget as! HoverableWidget
465478
wrapper.hoverChangesHandler = action
466479
}
467-
#endif
468480

469-
#if os(iOS) || os(visionOS) || targetEnvironment(macCatalyst)
470481
public func createSlider() -> Widget {
471482
SliderWidget()
472483
}

0 commit comments

Comments
 (0)