Skip to content

Commit 7ec8b6d

Browse files
committed
Merge branch 'main' into feat/sheet
# Conflicts: # Package.resolved
2 parents 2d97d73 + b1b4ca1 commit 7ec8b6d

File tree

16 files changed

+245
-107
lines changed

16 files changed

+245
-107
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/GreetingGeneratorExample/GreetingGeneratorApp.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import SwiftCrossUI
1010
struct GreetingGeneratorApp: App {
1111
@State var name = ""
1212
@State var greetings: [String] = []
13+
@State var isGreetingSelectable = false
1314

1415
var body: some Scene {
1516
WindowGroup("Greeting Generator") {
@@ -26,9 +27,11 @@ struct GreetingGeneratorApp: App {
2627
}
2728
}
2829

30+
Toggle("Selectable Greeting", active: $isGreetingSelectable)
2931
if let latest = greetings.last {
3032
Text(latest)
3133
.padding(.top, 5)
34+
.textSelectionEnabled(isGreetingSelectable)
3235

3336
if greetings.count > 1 {
3437
Text("History:")

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/AppKitBackend/AppKitBackend.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ public final class AppKitBackend: AppBackend {
574574
) {
575575
let field = textView as! NSTextField
576576
field.attributedStringValue = Self.attributedString(for: content, in: environment)
577+
if field.isSelectable && !environment.isTextSelectionEnabled {
578+
field.abortEditing()
579+
}
580+
field.isSelectable = environment.isTextSelectionEnabled
577581
}
578582

579583
public func createButton() -> Widget {

Sources/GtkBackend/GtkBackend.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ public final class GtkBackend: AppBackend {
622622
case .trailing:
623623
Justification.right
624624
}
625-
625+
textView.selectable = environment.isTextSelectionEnabled
626626
textView.css.clear()
627627
textView.css.set(properties: Self.cssProperties(for: environment))
628628
}

Sources/SwiftCrossUI/Environment/EnvironmentValues.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ public struct EnvironmentValues {
9595
/// The style of toggle to use.
9696
public var toggleStyle: ToggleStyle
9797

98+
/// Whether the text should be selectable. Set by ``View/textSelectionEnabled(_:)``.
99+
public var isTextSelectionEnabled: Bool
100+
98101
// Backing storage for extensible subscript
99102
private var extraValues: [ObjectIdentifier: Any]
100103

@@ -208,6 +211,7 @@ public struct EnvironmentValues {
208211
toggleStyle = .button
209212
isEnabled = true
210213
scrollDismissesKeyboardMode = .automatic
214+
isTextSelectionEnabled = false
211215
}
212216

213217
/// Returns a copy of the environment with the specified property set to the

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

0 commit comments

Comments
 (0)