Skip to content

Commit

Permalink
demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Usbergo committed Dec 13, 2019
1 parent e43a8a7 commit 0955bae
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 68 deletions.
16 changes: 12 additions & 4 deletions Demo/CoreRenderDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@
16216E7C2392D792009EDD08 /* Render in Frameworks */ = {isa = PBXBuildFile; productRef = 16216E7B2392D792009EDD08 /* Render */; };
16216E7E2392D792009EDD08 /* CoreRender in Frameworks */ = {isa = PBXBuildFile; productRef = 16216E7D2392D792009EDD08 /* CoreRender */; };
1622F3D223687938007C7E00 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1622F3D123687938007C7E00 /* AppDelegate.swift */; };
1622F3D623687938007C7E00 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1622F3D523687938007C7E00 /* ContentView.swift */; };
1622F3D82368793A007C7E00 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1622F3D72368793A007C7E00 /* Assets.xcassets */; };
1622F3DB2368793A007C7E00 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1622F3DA2368793A007C7E00 /* Preview Assets.xcassets */; };
1622F3DE2368793A007C7E00 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1622F3DC2368793A007C7E00 /* LaunchScreen.storyboard */; };
1622F3E623687988007C7E00 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1622F3E523687988007C7E00 /* ViewController.swift */; };
16569BF523A3902E00DB15A1 /* SwiftUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16569BF423A3902E00DB15A1 /* SwiftUIView.swift */; };
16E97B6623687C3D00CEFB67 /* DemoWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16E97B6523687C3D00CEFB67 /* DemoWidget.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
1622F3CE23687938007C7E00 /* CoreRenderDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CoreRenderDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
1622F3D123687938007C7E00 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
1622F3D523687938007C7E00 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
1622F3D72368793A007C7E00 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
1622F3DA2368793A007C7E00 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
1622F3DD2368793A007C7E00 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
1622F3DF2368793A007C7E00 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
1622F3E523687988007C7E00 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
16569BEF23A38E6400DB15A1 /* CoreRenderDemo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = CoreRenderDemo.entitlements; sourceTree = "<group>"; };
16569BF423A3902E00DB15A1 /* SwiftUIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIView.swift; sourceTree = "<group>"; };
16E97B6523687C3D00CEFB67 /* DemoWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoWidget.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -62,9 +63,10 @@
1622F3D023687938007C7E00 /* CoreRenderDemo */ = {
isa = PBXGroup;
children = (
16569BEF23A38E6400DB15A1 /* CoreRenderDemo.entitlements */,
16569BF423A3902E00DB15A1 /* SwiftUIView.swift */,
1622F3D123687938007C7E00 /* AppDelegate.swift */,
16E97B6523687C3D00CEFB67 /* DemoWidget.swift */,
1622F3D523687938007C7E00 /* ContentView.swift */,
1622F3E523687988007C7E00 /* ViewController.swift */,
1622F3D72368793A007C7E00 /* Assets.xcassets */,
1622F3DC2368793A007C7E00 /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -163,7 +165,7 @@
1622F3D223687938007C7E00 /* AppDelegate.swift in Sources */,
1622F3E623687988007C7E00 /* ViewController.swift in Sources */,
16E97B6623687C3D00CEFB67 /* DemoWidget.swift in Sources */,
1622F3D623687938007C7E00 /* ContentView.swift in Sources */,
16569BF523A3902E00DB15A1 /* SwiftUIView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -299,7 +301,9 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = CoreRenderDemo/CoreRenderDemo.entitlements;
CODE_SIGN_STYLE = Automatic;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_ASSET_PATHS = "\"CoreRenderDemo/Preview Content\"";
DEVELOPMENT_TEAM = 9Z67YL2L6Z;
ENABLE_PREVIEWS = YES;
Expand All @@ -310,6 +314,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = io.coreRender.CoreRenderDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -319,7 +324,9 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = CoreRenderDemo/CoreRenderDemo.entitlements;
CODE_SIGN_STYLE = Automatic;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_ASSET_PATHS = "\"CoreRenderDemo/Preview Content\"";
DEVELOPMENT_TEAM = 9Z67YL2L6Z;
ENABLE_PREVIEWS = YES;
Expand All @@ -330,6 +337,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = io.coreRender.CoreRenderDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"repositoryURL": "https://github.com/alexdrone/Render",
"state": {
"branch": "master",
"revision": "2969d20a67d52efe1a88ff557ca20133383cb301",
"revision": "e43a8a7c089756f400a39996c71c889ff248c4be",
"version": null
}
}
Expand Down
2 changes: 1 addition & 1 deletion Demo/CoreRenderDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
options connectionOptions: UIScene.ConnectionOptions) {

if (useSwiftUI) {
let contentView = ContentView()
let contentView = SwiftUIView()
// Use a UIHostingCoordinator as window root view coordinator.
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
Expand Down
37 changes: 0 additions & 37 deletions Demo/CoreRenderDemo/ContentView.swift

This file was deleted.

10 changes: 10 additions & 0 deletions Demo/CoreRenderDemo/CoreRenderDemo.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
27 changes: 2 additions & 25 deletions Demo/CoreRenderDemo/DemoWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ class DemoWidgetCoordinator: Coordinator {
}

override func onTouchUp(inside sender: UIView) {
if sender === view(withKey: Const.increaseButtonKey) {
self.increase()
}
self.increase()
}
}

Expand All @@ -50,12 +48,8 @@ func makeDemoWidget(context: Context, coordinator: DemoWidgetCoordinator) -> Opa
.textColor(.systemRed)
.height(Const.size)
.margin(Const.margin)
.userInteractionEnabled(true)
.onTouchUpInside { _ in
coordinator.doSomeFunkyStuff()
}
HStackNode {
ButtonNode(key: Const.increaseButtonKey, target: coordinator)
ButtonNode(reuseIdentifier: Const.increaseButtonKey, target: coordinator)
.text("TAP HERE TO INCREASE THE COUNTER")
.font(UIFont.systemFont(ofSize: 12, weight: .bold))
.background(.systemIndigo)
Expand All @@ -68,23 +62,6 @@ func makeDemoWidget(context: Context, coordinator: DemoWidgetCoordinator) -> Opa
.matchHostingViewWidth(withMargin: 0)
}

// MARK: - Manual View Manipulation Example

extension DemoWidgetCoordinator {
// Example of manual access to the underlying view hierarchy.
// Transitions can be performed in the node description as well, this is just an
// example of manual view hierarchy manipulation.
func doSomeFunkyStuff() {
let transform = isRotated
? CGAffineTransform.identity
: CGAffineTransform.init(rotationAngle: .pi)
isRotated.toggle()
UIView.animate(withDuration: 1) {
self.view(withKey: Const.increaseButtonKey)?.transform = transform
}
}
}

// MARK: - Constants

private struct Const {
Expand Down
21 changes: 21 additions & 0 deletions Demo/CoreRenderDemo/SwiftUIView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import SwiftUI
import CoreRender
import Render

struct SwiftUIView: View {
var body: some View {
VStack {
CoreRenderBridgeView { _ in
LabelNode(text: "Hi from Render")
.font(UIFont.systemFont(ofSize: 12))
.padding(12)
}
}
}
}

struct SwiftUIView_Previews: PreviewProvider {
static var previews: some View {
SwiftUIView()
}
}

0 comments on commit 0955bae

Please sign in to comment.