From 6f7e8d99ea47cb426eb7d1b86898102e2d382ef4 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sat, 2 Jan 2021 21:49:14 +0000 Subject: [PATCH 1/7] Build the GTK renderer on Ubuntu on CI --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71f08f210..817a434fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,3 +57,29 @@ jobs: brew install gtk+3 make build + + gtk_ubuntu_18_04_build: + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v2 + - name: Build the GTK renderer on Ubuntu 18.04 + shell: bash + run: | + set -ex + sudo apt-get install libgtk+-3.0 gtk+-3.0 + + make build + + gtk_ubuntu_20_04_build: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + - name: Build the GTK renderer on Ubuntu 20.04 + shell: bash + run: | + set -ex + sudo apt-get install libgtk+-3.0 gtk+-3.0 + + make build From d4eaadba6aeaf767462c7fc78da81c2e6cc7a7fb Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sat, 2 Jan 2021 21:58:36 +0000 Subject: [PATCH 2/7] Add `--enable-test-discovery` flag to `Makefile` --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 15cd74aa4..b2137fb07 100755 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ SWIFT_C_FLAGS ?= -Xcc $(shell echo $(C_FLAGS) | sed -e "s/ / -Xcc /g") all: build build: - swift build --product TokamakGTKDemo $(SWIFT_C_FLAGS) $(SWIFT_LINKER_FLAGS) + swift build --enable-test-discovery --product TokamakGTKDemo $(SWIFT_C_FLAGS) $(SWIFT_LINKER_FLAGS) run: build .build/debug/TokamakGTKDemo From 0bfc914c220001054b82012e796ac5728eddbd2b Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 11 Jan 2021 13:59:44 +0000 Subject: [PATCH 3/7] Use OpenCombine branch w/ no Runtime dependency --- Package.resolved | 12 ++-- Package.swift | 7 +- .../MountedViews/MountedElement.swift | 10 +-- .../MountedViews/MountedScene.swift | 2 +- .../TokamakCore/Views/Selectors/Picker.swift | 2 +- Sources/TokamakDemo/ColorDemo.swift | 4 +- .../Modifiers/LayoutModifiers.swift | 2 +- .../TokamakGTK/Modifiers/WidgetModifier.swift | 64 ++++++++++--------- Sources/TokamakGTK/Widget.swift | 4 +- .../Modifiers/ModifiedContent.swift | 2 +- 10 files changed, 59 insertions(+), 50 deletions(-) diff --git a/Package.resolved b/Package.resolved index 710aa97f1..1a0dc2863 100644 --- a/Package.resolved +++ b/Package.resolved @@ -14,18 +14,18 @@ "package": "OpenCombine", "repositoryURL": "https://github.com/TokamakUI/OpenCombine.git", "state": { - "branch": null, - "revision": "bccff3e7c84bc559e1aa0aa9ca878400360d439d", - "version": "0.12.0-alpha2" + "branch": "observableobject-mirror", + "revision": "63e4acc32fb181abb9c3dcda98fc8d396524ab83", + "version": null } }, { "package": "OpenCombineJS", "repositoryURL": "https://github.com/swiftwasm/OpenCombineJS.git", "state": { - "branch": null, - "revision": "b346f955ed21ab44576e204a7554210c77f69b9b", - "version": "0.0.1" + "branch": "update-dependencies", + "revision": "558e0389cd502f019642214edcbe968584626830", + "version": null } }, { diff --git a/Package.swift b/Package.swift index 09961ed97..7ca381a69 100644 --- a/Package.swift +++ b/Package.swift @@ -50,8 +50,11 @@ let package = Package( .upToNextMinor(from: "0.9.0") ), .package(url: "https://github.com/MaxDesiatov/Runtime.git", from: "2.1.2"), - .package(url: "https://github.com/TokamakUI/OpenCombine.git", from: "0.12.0-alpha2"), - .package(url: "https://github.com/swiftwasm/OpenCombineJS.git", from: "0.0.1"), + .package( + url: "https://github.com/TokamakUI/OpenCombine.git", + .branch("observableobject-mirror") + ), + .package(url: "https://github.com/swiftwasm/OpenCombineJS.git", .branch("update-dependencies")), ], targets: [ // Targets are the basic building blocks of a package. A target can define diff --git a/Sources/TokamakCore/MountedViews/MountedElement.swift b/Sources/TokamakCore/MountedViews/MountedElement.swift index 3be326ba8..0696991f1 100644 --- a/Sources/TokamakCore/MountedViews/MountedElement.swift +++ b/Sources/TokamakCore/MountedViews/MountedElement.swift @@ -76,10 +76,10 @@ public class MountedElement { var typeConstructorName: String { switch element { case .app: fatalError(""" - `App` values aren't supposed to be reconciled, thus the type constructor name is not stored \ - for `App` elements. Please report this crash as a bug at \ - https://github.com/swiftwasm/Tokamak/issues/new - """) + `App` values aren't supposed to be reconciled, thus the type constructor name is not stored \ + for `App` elements. Please report this crash as a bug at \ + https://github.com/swiftwasm/Tokamak/issues/new + """) case let .scene(scene): return scene.typeConstructorName case let .view(view): return view.typeConstructorName } @@ -172,7 +172,7 @@ extension TypeInfo { // swiftlint:disable force_try // Extract the view from the AnyView for modification, apply Environment changes: if genericTypes.contains(where: { $0 is EnvironmentModifier.Type }), - let modifier = try! property(named: "modifier").get(from: element) as? EnvironmentModifier + let modifier = try! property(named: "modifier").get(from: element) as? EnvironmentModifier { modifier.modifyEnvironment(&modifiedEnv) } diff --git a/Sources/TokamakCore/MountedViews/MountedScene.swift b/Sources/TokamakCore/MountedViews/MountedScene.swift index bd477ebd3..b1327e3c1 100644 --- a/Sources/TokamakCore/MountedViews/MountedScene.swift +++ b/Sources/TokamakCore/MountedViews/MountedScene.swift @@ -99,7 +99,7 @@ extension _AnyScene { ) -> MountedScene { var title: String? if let titledSelf = scene as? TitledScene, - let text = titledSelf.title + let text = titledSelf.title { title = _TextProxy(text).rawText } diff --git a/Sources/TokamakCore/Views/Selectors/Picker.swift b/Sources/TokamakCore/Views/Selectors/Picker.swift index 05887b8b0..3ce52c50e 100644 --- a/Sources/TokamakCore/Views/Selectors/Picker.swift +++ b/Sources/TokamakCore/Views/Selectors/Picker.swift @@ -76,7 +76,7 @@ public struct Picker: View // update the binding. ForEach(0.. 1 { - ForEach(Array(parentView.children.enumerated()), id: \.offset) { _, view in - view + content: { + if let parentView = anyWidget as? ParentView, parentView.children.count > 1 { + ForEach(Array(parentView.children.enumerated()), id: \.offset) { _, view in + view + } + } else if let parentView = anyWidget as? ParentView, parentView.children.count == 1 { + parentView.children[0] } - } else if let parentView = anyWidget as? ParentView, parentView.children.count == 1 { - parentView.children[0] } - }) + ) } } diff --git a/Sources/TokamakGTK/Widget.swift b/Sources/TokamakGTK/Widget.swift index 988a23744..c8cb5a894 100644 --- a/Sources/TokamakGTK/Widget.swift +++ b/Sources/TokamakGTK/Widget.swift @@ -27,12 +27,12 @@ extension AnyWidget { struct WidgetView: View, AnyWidget, ParentView { let build: (UnsafeMutablePointer) -> UnsafeMutablePointer - let update: (Widget) -> Void + let update: (Widget) -> () let content: Content let expand: Bool init(build: @escaping (UnsafeMutablePointer) -> UnsafeMutablePointer, - update: @escaping (Widget) -> Void = { _ in }, + update: @escaping (Widget) -> () = { _ in }, expand: Bool = false, @ViewBuilder content: () -> Content) { diff --git a/Sources/TokamakStaticHTML/Modifiers/ModifiedContent.swift b/Sources/TokamakStaticHTML/Modifiers/ModifiedContent.swift index df6ed2752..558a6a77f 100644 --- a/Sources/TokamakStaticHTML/Modifiers/ModifiedContent.swift +++ b/Sources/TokamakStaticHTML/Modifiers/ModifiedContent.swift @@ -34,7 +34,7 @@ extension ModifiedContent: ViewDeferredToRenderer where Content: View, Modifier: public var deferredBody: AnyView { if let domModifier = modifier as? DOMViewModifier { if let adjacentModifier = content as? AnyModifiedContent, - !(adjacentModifier.anyModifier.isOrderDependent || domModifier.isOrderDependent) + !(adjacentModifier.anyModifier.isOrderDependent || domModifier.isOrderDependent) { // Flatten non-order-dependent modifiers var attr = domModifier.attributes From ae34c7a87e7430b370f30481101f170e50bdf671 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 11 Jan 2021 14:02:09 +0000 Subject: [PATCH 4/7] Run `sudo apt-get update` on Ubuntu hosts --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 817a434fc..4c868ff9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,6 +67,7 @@ jobs: shell: bash run: | set -ex + sudo apt-get update sudo apt-get install libgtk+-3.0 gtk+-3.0 make build @@ -80,6 +81,7 @@ jobs: shell: bash run: | set -ex + sudo apt-get update sudo apt-get install libgtk+-3.0 gtk+-3.0 make build From 29e28d5e750a6d88c020ab54186eb66ec92628a9 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 11 Jan 2021 14:25:18 +0000 Subject: [PATCH 5/7] Update OpenCombine dependency --- Package.resolved | 8 ++++---- Package.swift | 5 +---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Package.resolved b/Package.resolved index 1a0dc2863..a4fc5b90e 100644 --- a/Package.resolved +++ b/Package.resolved @@ -14,9 +14,9 @@ "package": "OpenCombine", "repositoryURL": "https://github.com/TokamakUI/OpenCombine.git", "state": { - "branch": "observableobject-mirror", - "revision": "63e4acc32fb181abb9c3dcda98fc8d396524ab83", - "version": null + "branch": null, + "revision": "eea5e707b571da14fce588000046b8ec4c62018b", + "version": "0.12.0-alpha3" } }, { @@ -24,7 +24,7 @@ "repositoryURL": "https://github.com/swiftwasm/OpenCombineJS.git", "state": { "branch": "update-dependencies", - "revision": "558e0389cd502f019642214edcbe968584626830", + "revision": "59476ca222f89aad7452f31db99dbf77456f9673", "version": null } }, diff --git a/Package.swift b/Package.swift index 7ca381a69..ae118c7d5 100644 --- a/Package.swift +++ b/Package.swift @@ -50,10 +50,7 @@ let package = Package( .upToNextMinor(from: "0.9.0") ), .package(url: "https://github.com/MaxDesiatov/Runtime.git", from: "2.1.2"), - .package( - url: "https://github.com/TokamakUI/OpenCombine.git", - .branch("observableobject-mirror") - ), + .package(url: "https://github.com/TokamakUI/OpenCombine.git", from: "0.12.0-alpha3"), .package(url: "https://github.com/swiftwasm/OpenCombineJS.git", .branch("update-dependencies")), ], targets: [ From 23b263c5ce29bc6f5b4446ce20f66f870d5ab392 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 11 Jan 2021 14:56:27 +0000 Subject: [PATCH 6/7] Pin OpenCombineJS dependency --- Package.resolved | 6 +++--- Package.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Package.resolved b/Package.resolved index a4fc5b90e..0749d2c75 100644 --- a/Package.resolved +++ b/Package.resolved @@ -23,9 +23,9 @@ "package": "OpenCombineJS", "repositoryURL": "https://github.com/swiftwasm/OpenCombineJS.git", "state": { - "branch": "update-dependencies", - "revision": "59476ca222f89aad7452f31db99dbf77456f9673", - "version": null + "branch": null, + "revision": "5e8636b15bcb4b8900696d95daaab941458ed2cf", + "version": "0.0.2" } }, { diff --git a/Package.swift b/Package.swift index ae118c7d5..708de32d6 100644 --- a/Package.swift +++ b/Package.swift @@ -51,7 +51,7 @@ let package = Package( ), .package(url: "https://github.com/MaxDesiatov/Runtime.git", from: "2.1.2"), .package(url: "https://github.com/TokamakUI/OpenCombine.git", from: "0.12.0-alpha3"), - .package(url: "https://github.com/swiftwasm/OpenCombineJS.git", .branch("update-dependencies")), + .package(url: "https://github.com/swiftwasm/OpenCombineJS.git", .upToNextMinor(from: "0.0.2")), ], targets: [ // Targets are the basic building blocks of a package. A target can define From 818958bd1df6974a7b4c39faf9d37d6e38ef999b Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 11 Jan 2021 15:02:52 +0000 Subject: [PATCH 7/7] Update label.yml --- .github/workflows/label.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index 1699e4084..03278f51d 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -11,7 +11,7 @@ on: jobs: check-labels: # The type of runner that the job will run on - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Match PR Label