Skip to content

Commit 8044284

Browse files
committed
Update examples for v1.53.0
1 parent 3fbf2fd commit 8044284

File tree

8 files changed

+234
-10
lines changed

8 files changed

+234
-10
lines changed

CESDK-Showcases.xcodeproj/project.pbxproj

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
B0575B8CFA162B68D69E51ED /* business_card.scene in Resources */ = {isa = PBXBuildFile; fileRef = 4E14B462A868AA0B8A0903B7 /* business_card.scene */; };
136136
B065040736C6A6384C909275 /* instagram_post.scene in Resources */ = {isa = PBXBuildFile; fileRef = A06B98B0CFD80A8574FF29E7 /* instagram_post.scene */; };
137137
B28AE763A74231DE41EEA845 /* 16_9.png in Resources */ = {isa = PBXBuildFile; fileRef = 93F35C0785E6E0BA4898D759 /* 16_9.png */; };
138+
B2E12A407D78AB7AEED61A31 /* CanvasMenuItemEditorSolution.swift in Sources */ = {isa = PBXBuildFile; fileRef = 002D77E0C927C8A6C3542CBC /* CanvasMenuItemEditorSolution.swift */; };
138139
B2E7742556D28E8DB88A3A5F /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB4E68AC1412CBC0B9861E49 /* Secrets.swift */; };
139140
B3516693EC558A338D214901 /* CreateSceneFromScratch.swift in Sources */ = {isa = PBXBuildFile; fileRef = A444D6F3EA290E51BE49CEE7 /* CreateSceneFromScratch.swift */; };
140141
B3D602EDBAFC73CFEED6B9C5 /* UnsplashResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = E506F9CD963DAF305853BCFB /* UnsplashResponse.swift */; };
@@ -157,6 +158,7 @@
157158
D2DD4CD7208E2253B0374D4F /* template_07_business_card.scene in Resources */ = {isa = PBXBuildFile; fileRef = BE9DBF3F7E835988A7DF0B62 /* template_07_business_card.scene */; };
158159
D468C62C26DDE36E1D4B07DC /* apparel-ui-b-3.scene in Resources */ = {isa = PBXBuildFile; fileRef = B91A41AC051C3017BB26BF57 /* apparel-ui-b-3.scene */; };
159160
D4BB01543B05839D48F77680 /* PhotoEditorSolution.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31FB9152C3C0A3C488E6583C /* PhotoEditorSolution.swift */; };
161+
D5A21CC6166EC46858D5126B /* CanvasMenuEditorSolution.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A792A212B8D5B7254C08D36 /* CanvasMenuEditorSolution.swift */; };
160162
D7F26CC6D488A82CE04AF9EF /* ShowcaseLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B377ECC1D46784B851DDF18 /* ShowcaseLink.swift */; };
161163
D8975B855DF734563CF29FC6 /* 3_4_dark.png in Resources */ = {isa = PBXBuildFile; fileRef = 2B724C8A9DAD3262FEC22A5E /* 3_4_dark.png */; };
162164
D9B2566F60CB7CEDB6D748DD /* SourceSets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65CB9B54445138CFE2054F9B /* SourceSets.swift */; };
@@ -194,11 +196,13 @@
194196
/* Begin PBXFileReference section */
195197
00096670A6812688A8B8A5AE /* StoreMetadata.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreMetadata.swift; sourceTree = "<group>"; };
196198
000B20D1152A1EE4183F2118 /* CreateSceneFromVideoURL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateSceneFromVideoURL.swift; sourceTree = "<group>"; };
199+
002D77E0C927C8A6C3542CBC /* CanvasMenuItemEditorSolution.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CanvasMenuItemEditorSolution.swift; sourceTree = "<group>"; };
197200
02B5DE7A2AB450E182FDEB89 /* milli-surf-school.scene */ = {isa = PBXFileReference; path = "milli-surf-school.scene"; sourceTree = "<group>"; };
198201
03B7BC311B92541004C5CB3D /* ShowcaseMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShowcaseMode.swift; sourceTree = "<group>"; };
199202
03CB4C9047D536384A1142CE /* full_hd.scene */ = {isa = PBXFileReference; path = full_hd.scene; sourceTree = "<group>"; };
200203
0519513C0DD4FB9B072205C9 /* 9_16.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 9_16.png; sourceTree = "<group>"; };
201204
0A00FD0DD2BDC1EA4F51FB4A /* template_05_x_header.scene */ = {isa = PBXFileReference; path = template_05_x_header.scene; sourceTree = "<group>"; };
205+
0A792A212B8D5B7254C08D36 /* CanvasMenuEditorSolution.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CanvasMenuEditorSolution.swift; sourceTree = "<group>"; };
202206
0AB6351ECFA423D9FCBF5445 /* template_03_full_hd_slides_16_9.scene */ = {isa = PBXFileReference; path = template_03_full_hd_slides_16_9.scene; sourceTree = "<group>"; };
203207
0E46FB7CEB411B5F37AA132B /* CESDK-Showcases.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = "CESDK-Showcases.app"; sourceTree = BUILT_PRODUCTS_DIR; };
204208
0EF986170C7CBF7ACB629183 /* merry_christmas_grid.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = merry_christmas_grid.png; sourceTree = "<group>"; };
@@ -647,6 +651,7 @@
647651
D31578CF453E07A22F19A588 /* editor-guides-configuration-asset-library */,
648652
F79CDD28FEB22E0A2A1FF901 /* editor-guides-configuration-basics */,
649653
79B16912C579BFE1A4CA4AA9 /* editor-guides-configuration-callbacks */,
654+
E22264063EFBF01DBCEA2236 /* editor-guides-configuration-canvas-menu */,
650655
84F12782793E6192023D3436 /* editor-guides-configuration-color-palette */,
651656
7B3D9E5E557D3A434558FDCE /* editor-guides-configuration-dock */,
652657
08A9EA956529EFCD7B5C6079 /* editor-guides-configuration-inspector-bar */,
@@ -1066,6 +1071,15 @@
10661071
path = Main;
10671072
sourceTree = "<group>";
10681073
};
1074+
E22264063EFBF01DBCEA2236 /* editor-guides-configuration-canvas-menu */ = {
1075+
isa = PBXGroup;
1076+
children = (
1077+
0A792A212B8D5B7254C08D36 /* CanvasMenuEditorSolution.swift */,
1078+
002D77E0C927C8A6C3542CBC /* CanvasMenuItemEditorSolution.swift */,
1079+
);
1080+
path = "editor-guides-configuration-canvas-menu";
1081+
sourceTree = "<group>";
1082+
};
10691083
F419E08B896C5BECF27A7AB5 /* engine-guides-save-scene-to-blob */ = {
10701084
isa = PBXGroup;
10711085
children = (
@@ -1098,7 +1112,7 @@
10981112
path = "engine-guides-uri-resolver";
10991113
sourceTree = "<group>";
11001114
};
1101-
"TEMP_CA1F4705-ED50-4323-8E19-82A5B9553CB5" /* cesdk_swift_examples */ = {
1115+
"TEMP_DA46F843-4DD4-4E7A-809E-656F16A210C9" /* cesdk_swift_examples */ = {
11021116
isa = PBXGroup;
11031117
children = (
11041118
08A9EA956529EFCD7B5C6079 /* editor-guides-configuration-inspector-bar */,
@@ -1110,6 +1124,7 @@
11101124
825E9FA84D0D0C243364CF36 /* editor-guides-solutions-photo-editor */,
11111125
D31578CF453E07A22F19A588 /* editor-guides-configuration-asset-library */,
11121126
3DF059C0359F94281AF92251 /* camera-guides-configuration */,
1127+
E22264063EFBF01DBCEA2236 /* editor-guides-configuration-canvas-menu */,
11131128
4B3B34C307EEAEC026042112 /* editor-guides-configuration-navigation-bar */,
11141129
F79CDD28FEB22E0A2A1FF901 /* editor-guides-configuration-basics */,
11151130
79B16912C579BFE1A4CA4AA9 /* editor-guides-configuration-callbacks */,
@@ -1395,6 +1410,8 @@
13951410
A3B037403C8D1AFB7C201983 /* CameraShowcase.swift in Sources */,
13961411
FADE137520225DFACE4CDB02 /* CameraSwiftUI.swift in Sources */,
13971412
0D860064896F75195E6DE10E /* CameraUIKit.swift in Sources */,
1413+
D5A21CC6166EC46858D5126B /* CanvasMenuEditorSolution.swift in Sources */,
1414+
B2E12A407D78AB7AEED61A31 /* CanvasMenuItemEditorSolution.swift in Sources */,
13981415
169A6C5CBF9B982BC261C086 /* ColorPaletteEditorSolution.swift in Sources */,
13991416
113F3337496D753CA44469FF /* ConfiguredCameraSolution.swift in Sources */,
14001417
F400A7B7A7784B4A9749D8FC /* ContentView.swift in Sources */,
@@ -1538,7 +1555,7 @@
15381555
GCC_WARN_UNUSED_VARIABLE = YES;
15391556
GENERATE_INFOPLIST_FILE = YES;
15401557
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
1541-
MARKETING_VERSION = 1.52.0;
1558+
MARKETING_VERSION = 1.53.0;
15421559
MTL_ENABLE_DEBUG_INFO = NO;
15431560
MTL_FAST_MATH = YES;
15441561
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1628,7 +1645,7 @@
16281645
GCC_WARN_UNUSED_VARIABLE = YES;
16291646
GENERATE_INFOPLIST_FILE = YES;
16301647
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
1631-
MARKETING_VERSION = 1.52.0;
1648+
MARKETING_VERSION = 1.53.0;
16321649
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
16331650
MTL_FAST_MATH = YES;
16341651
ONLY_ACTIVE_ARCH = YES;
@@ -1703,15 +1720,15 @@
17031720
repositoryURL = "https://github.com/imgly/IMGLYUI-swift";
17041721
requirement = {
17051722
kind = exactVersion;
1706-
version = 1.52.0;
1723+
version = 1.53.0;
17071724
};
17081725
};
17091726
10597E39A033ABD8B233CD14 /* XCRemoteSwiftPackageReference "IMGLYEngine-swift" */ = {
17101727
isa = XCRemoteSwiftPackageReference;
17111728
repositoryURL = "https://github.com/imgly/IMGLYEngine-swift";
17121729
requirement = {
17131730
kind = exactVersion;
1714-
version = 1.52.0;
1731+
version = 1.53.0;
17151732
};
17161733
};
17171734
150F161C090426538C39E173 /* XCRemoteSwiftPackageReference "Kingfisher" */ = {

editor-guides-configuration-basics/BasicEditorSolution.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct BasicEditorSolution: View {
88
// highlight-userID
99
userID: "<your unique user id>",
1010
// highlight-baseURL
11-
baseURL: URL(string: "https://cdn.img.ly/packages/imgly/cesdk-engine/1.52.0/assets")!
11+
baseURL: URL(string: "https://cdn.img.ly/packages/imgly/cesdk-engine/1.53.0/assets")!
1212
)
1313

1414
var editor: some View {
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// swiftlint:disable unused_closure_parameter
2+
// swiftformat:disable unusedArguments
3+
import IMGLYDesignEditor
4+
import SwiftUI
5+
6+
struct CanvasMenuEditorSolution: View {
7+
let settings = EngineSettings(license: secrets.licenseKey,
8+
userID: "<your unique user id>")
9+
10+
var editor: some View {
11+
// highlight-editor
12+
DesignEditor(settings)
13+
// highlight-canvasMenuItems
14+
.imgly.canvasMenuItems { context in
15+
CanvasMenu.Buttons.selectGroup()
16+
CanvasMenu.Divider()
17+
CanvasMenu.Buttons.bringForward()
18+
CanvasMenu.Buttons.sendBackward()
19+
CanvasMenu.Divider()
20+
CanvasMenu.Buttons.duplicate()
21+
CanvasMenu.Buttons.delete()
22+
}
23+
// highlight-canvasMenuItems
24+
// highlight-modifyCanvasMenuItems
25+
.imgly.modifyCanvasMenuItems { context, items in
26+
// highlight-addFirst
27+
items.addFirst {
28+
CanvasMenu.Button(id: "my.package.canvasMenu.button.first") { context in
29+
print("First Button action")
30+
} label: { context in
31+
Label("First Button", systemImage: "arrow.backward.circle")
32+
}
33+
}
34+
// highlight-addFirst
35+
// highlight-addLast
36+
items.addLast {
37+
CanvasMenu.Button(id: "my.package.canvasMenu.button.last") { context in
38+
print("Last Button action")
39+
} label: { context in
40+
Label("Last Button", systemImage: "arrow.forward.circle")
41+
}
42+
}
43+
// highlight-addLast
44+
// highlight-addAfter
45+
items.addAfter(id: CanvasMenu.Buttons.ID.bringForward) {
46+
CanvasMenu.Button(id: "my.package.canvasMenu.button.afterBringForward") { context in
47+
print("After Bring Forward action")
48+
} label: { context in
49+
Label("After Bring Forward", systemImage: "arrow.forward.square")
50+
}
51+
}
52+
// highlight-addAfter
53+
// highlight-addBefore
54+
items.addBefore(id: CanvasMenu.Buttons.ID.sendBackward) {
55+
CanvasMenu.Button(id: "my.package.canvasMenu.button.beforeSendBackward") { context in
56+
print("Before Send Backward action")
57+
} label: { context in
58+
Label("Before Send Backward", systemImage: "arrow.backward.square")
59+
}
60+
}
61+
// highlight-addBefore
62+
// highlight-replace
63+
items.replace(id: CanvasMenu.Buttons.ID.duplicate) {
64+
CanvasMenu.Button(id: "my.package.canvasMenu.button.replacedDuplicate") { context in
65+
print("Replaced Duplicate action")
66+
} label: { context in
67+
Label("Replaced Duplicate", systemImage: "arrow.uturn.down.square")
68+
}
69+
}
70+
// highlight-replace
71+
// highlight-remove
72+
items.remove(id: CanvasMenu.Buttons.ID.delete)
73+
}
74+
// highlight-modifyCanvasMenuItems
75+
}
76+
77+
@State private var isPresented = false
78+
79+
var body: some View {
80+
Button("Use the Editor") {
81+
isPresented = true
82+
}
83+
.fullScreenCover(isPresented: $isPresented) {
84+
ModalEditor {
85+
editor
86+
}
87+
}
88+
}
89+
}
90+
91+
#Preview {
92+
CanvasMenuEditorSolution()
93+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// swiftlint:disable unused_closure_parameter
2+
// swiftformat:disable unusedArguments
3+
import IMGLYDesignEditor
4+
import SwiftUI
5+
6+
struct CanvasMenuItemEditorSolution: View {
7+
let settings = EngineSettings(license: secrets.licenseKey,
8+
userID: "<your unique user id>")
9+
10+
var editor: some View {
11+
DesignEditor(settings)
12+
// highlight-canvasMenuItems
13+
.imgly.canvasMenuItems { context in
14+
// highlight-predefinedButton
15+
CanvasMenu.Buttons.duplicate()
16+
17+
// highlight-customizePredefinedButton
18+
CanvasMenu.Buttons.delete(
19+
// highlight-customizePredefinedButton-action
20+
action: { context in
21+
context.eventHandler.send(.deleteSelection)
22+
},
23+
// highlight-customizePredefinedButton-action
24+
// highlight-customizePredefinedButton-label
25+
label: { context in
26+
Label { Text("Delete") } icon: { Image.imgly.delete }
27+
},
28+
// highlight-customizePredefinedButton-label
29+
// highlight-customizePredefinedButton-isEnabled
30+
isEnabled: { context in true },
31+
// highlight-customizePredefinedButton-isVisible
32+
isVisible: { context in
33+
try context.engine.block.isAllowedByScope(context.selection.block, key: "lifecycle/destroy")
34+
}
35+
// highlight-customizePredefinedButton-isVisible
36+
)
37+
// highlight-customizePredefinedButton
38+
39+
// highlight-newButton
40+
CanvasMenu.Button(
41+
// highlight-newButton-id
42+
id: "my.package.canvasMenu.button.newButton"
43+
// highlight-newButton-action
44+
) { context in
45+
print("New Button action")
46+
// highlight-newButton-action
47+
// highlight-newButton-label
48+
} label: { context in
49+
Label("New Button", systemImage: "star.circle")
50+
// highlight-newButton-label
51+
// highlight-newButton-isEnabled
52+
} isEnabled: { context in
53+
true
54+
// highlight-newButton-isEnabled
55+
// highlight-newButton-isVisible
56+
} isVisible: { context in
57+
true
58+
}
59+
// highlight-newButton-isVisible
60+
// highlight-newButton
61+
62+
// highlight-newCustomItem
63+
CustomCanvasMenuItem()
64+
}
65+
// highlight-canvasMenuItems
66+
}
67+
68+
@State private var isPresented = false
69+
70+
var body: some View {
71+
Button("Use the Editor") {
72+
isPresented = true
73+
}
74+
.fullScreenCover(isPresented: $isPresented) {
75+
ModalEditor {
76+
editor
77+
}
78+
}
79+
}
80+
}
81+
82+
// highlight-newCustomItem-conformance
83+
private struct CustomCanvasMenuItem: CanvasMenu.Item {
84+
// highlight-newCustomItem-id
85+
var id: EditorComponentID { "my.package.canvasMenu.newCustomItem" }
86+
87+
// highlight-newCustomItem-body
88+
func body(_ context: CanvasMenu.Context) throws -> some View {
89+
ZStack {
90+
RoundedRectangle(cornerRadius: 10)
91+
.fill(.conicGradient(colors: [.red, .yellow, .green, .cyan, .blue, .purple, .red], center: .center))
92+
Text("New Custom Item")
93+
.padding(4)
94+
}
95+
.onTapGesture {
96+
print("New Custom Item action")
97+
}
98+
}
99+
100+
// highlight-newCustomItem-body
101+
// highlight-newCustomItem-isVisible
102+
func isVisible(_ context: CanvasMenu.Context) throws -> Bool {
103+
true
104+
}
105+
// highlight-newCustomItem-isVisible
106+
}
107+
108+
// highlight-newCustomItem-conformance
109+
110+
#Preview {
111+
CanvasMenuItemEditorSolution()
112+
}

editor-guides-configuration-inspector-bar/InspectorBarEditorSolution.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct InspectorBarEditorSolution: View {
7676
// highlight-addBefore
7777
// highlight-replace
7878
items.replace(id: InspectorBar.Buttons.ID.formatText) {
79-
InspectorBar.Button(id: "my.package.inspectorBar.button.replacedTextLibrary") { context in
79+
InspectorBar.Button(id: "my.package.inspectorBar.button.replacedFormatText") { context in
8080
print("Replaced Format action")
8181
} label: { context in
8282
Label("Replaced Format", systemImage: "arrow.uturn.down.square")

engine-guides-exporting-blocks/ExportingBlocks.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import IMGLYEngine
99

1010
@MainActor
1111
func exportingBlocks(engine: Engine) async throws {
12-
try engine.editor.setSettingString("basePath", value: "https://cdn.img.ly/packages/imgly/cesdk-engine/1.52.0/assets")
12+
try engine.editor.setSettingString("basePath", value: "https://cdn.img.ly/packages/imgly/cesdk-engine/1.53.0/assets")
1313
try await engine.addDefaultAssetSources()
1414
let sceneUrl =
1515
URL(string: "https://cdn.img.ly/assets/demo/v1/ly.img.template/templates/cesdk_postcard_1.scene")!

engine-guides-uri-resolver/URIResolver.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import IMGLYEngine
44
@MainActor
55
func uriResolver(engine: Engine) async throws {
66
// highlight-get-absolute-base-path
7-
// This will return "https://cdn.img.ly/packages/imgly/cesdk-js/1.10.0-preview.1/assets/banana.jpg"
7+
// This will return "https://cdn.img.ly/packages/imgly/cesdk-js/1.53.0/assets/banana.jpg"
88
try engine.editor.getAbsoluteURI(relativePath: "/banana.jpg")
99
// highlight-get-absolute-base-path
1010

@@ -36,7 +36,7 @@ func uriResolver(engine: Engine) async throws {
3636
try engine.editor.setURIResolver(nil)
3737

3838
// Since we"ve removed the custom resolver, this will return
39-
// "https://cdn.img.ly/packages/imgly/cesdk-js/1.10.0-preview.1/assets/banana.jpg" like before.
39+
// "https://cdn.img.ly/packages/imgly/cesdk-js/1.53.0/assets/banana.jpg" like before.
4040
try engine.editor.getAbsoluteURI(relativePath: "/banana.jpg")
4141
// highlight-remove-resolver
4242
}

showcases-app/View/Showcases.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ struct Showcases: View {
118118
Showcase(view: DockItemEditorSolution(), title: "Configuration: Dock Item")
119119
Showcase(view: InspectorBarEditorSolution(), title: "Configuration: Inspector Bar")
120120
Showcase(view: InspectorBarItemEditorSolution(), title: "Configuration: Inspector Bar Item")
121+
Showcase(view: CanvasMenuEditorSolution(), title: "Configuration: Canvas Menu")
122+
Showcase(view: CanvasMenuItemEditorSolution(), title: "Configuration: Canvas Menu Item")
121123
}
122124
}.showcaseMode(.navigationLink)
123125
Section(title: "Documentation Camera Examples") {

0 commit comments

Comments
 (0)