@imgly/editor-react-native 1.72.3 → 1.73.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/IMGLYEditorModule.podspec +23 -0
  2. package/android/build.gradle +9 -6
  3. package/android/src/main/AndroidManifest.xml +1 -1
  4. package/android/src/main/assets/scene/apparel.scene +1 -0
  5. package/android/src/main/assets/scene/design.scene +1 -0
  6. package/android/src/main/assets/scene/postcard.scene +1 -0
  7. package/android/src/main/assets/scene/video.scene +1 -0
  8. package/android/src/main/kotlin/ly/img/editor/configuration/apparel/ApparelConfigurationBuilder.kt +113 -0
  9. package/android/src/main/kotlin/ly/img/editor/configuration/apparel/EditorActivity.kt +37 -0
  10. package/android/src/main/kotlin/ly/img/editor/configuration/apparel/callback/OnCreate.kt +190 -0
  11. package/android/src/main/kotlin/ly/img/editor/configuration/apparel/callback/OnExport.kt +82 -0
  12. package/android/src/main/kotlin/ly/img/editor/configuration/apparel/callback/OnLoaded.kt +88 -0
  13. package/android/src/main/kotlin/ly/img/editor/configuration/apparel/component/CanvasMenu.kt +45 -0
  14. package/android/src/main/kotlin/ly/img/editor/configuration/apparel/component/Dock.kt +37 -0
  15. package/android/src/main/kotlin/ly/img/editor/configuration/apparel/component/InspectorBar.kt +52 -0
  16. package/android/src/main/kotlin/ly/img/editor/configuration/apparel/component/NavigationBar.kt +45 -0
  17. package/android/src/main/kotlin/ly/img/editor/configuration/apparel/component/Overlay.kt +15 -0
  18. package/android/src/main/kotlin/ly/img/editor/configuration/design/DesignConfigurationBuilder.kt +106 -0
  19. package/android/src/main/kotlin/ly/img/editor/configuration/design/EditorActivity.kt +37 -0
  20. package/android/src/main/kotlin/ly/img/editor/configuration/design/callback/OnCreate.kt +162 -0
  21. package/android/src/main/kotlin/ly/img/editor/configuration/design/callback/OnExport.kt +82 -0
  22. package/android/src/main/kotlin/ly/img/editor/configuration/design/callback/OnLoaded.kt +10 -0
  23. package/android/src/main/kotlin/ly/img/editor/configuration/design/component/CanvasMenu.kt +45 -0
  24. package/android/src/main/kotlin/ly/img/editor/configuration/design/component/Dock.kt +35 -0
  25. package/android/src/main/kotlin/ly/img/editor/configuration/design/component/InspectorBar.kt +52 -0
  26. package/android/src/main/kotlin/ly/img/editor/configuration/design/component/NavigationBar.kt +45 -0
  27. package/android/src/main/kotlin/ly/img/editor/configuration/design/component/Overlay.kt +15 -0
  28. package/android/src/main/kotlin/ly/img/editor/configuration/photo/EditorActivity.kt +37 -0
  29. package/android/src/main/kotlin/ly/img/editor/configuration/photo/PhotoConfigurationBuilder.kt +106 -0
  30. package/android/src/main/kotlin/ly/img/editor/configuration/photo/callback/OnCreate.kt +143 -0
  31. package/android/src/main/kotlin/ly/img/editor/configuration/photo/callback/OnExport.kt +82 -0
  32. package/android/src/main/kotlin/ly/img/editor/configuration/photo/callback/OnLoaded.kt +49 -0
  33. package/android/src/main/kotlin/ly/img/editor/configuration/photo/component/CanvasMenu.kt +45 -0
  34. package/android/src/main/kotlin/ly/img/editor/configuration/photo/component/Dock.kt +43 -0
  35. package/android/src/main/kotlin/ly/img/editor/configuration/photo/component/InspectorBar.kt +52 -0
  36. package/android/src/main/kotlin/ly/img/editor/configuration/photo/component/NavigationBar.kt +45 -0
  37. package/android/src/main/kotlin/ly/img/editor/configuration/photo/component/Overlay.kt +15 -0
  38. package/android/src/main/kotlin/ly/img/editor/configuration/postcard/EditorActivity.kt +37 -0
  39. package/android/src/main/kotlin/ly/img/editor/configuration/postcard/PostcardConfigurationBuilder.kt +106 -0
  40. package/android/src/main/kotlin/ly/img/editor/configuration/postcard/callback/OnCreate.kt +149 -0
  41. package/android/src/main/kotlin/ly/img/editor/configuration/postcard/callback/OnExport.kt +82 -0
  42. package/android/src/main/kotlin/ly/img/editor/configuration/postcard/callback/OnLoaded.kt +58 -0
  43. package/android/src/main/kotlin/ly/img/editor/configuration/postcard/component/CanvasMenu.kt +45 -0
  44. package/android/src/main/kotlin/ly/img/editor/configuration/postcard/component/Dock.kt +243 -0
  45. package/android/src/main/kotlin/ly/img/editor/configuration/postcard/component/InspectorBar.kt +52 -0
  46. package/android/src/main/kotlin/ly/img/editor/configuration/postcard/component/NavigationBar.kt +76 -0
  47. package/android/src/main/kotlin/ly/img/editor/configuration/postcard/component/Overlay.kt +15 -0
  48. package/android/src/main/kotlin/ly/img/editor/configuration/postcard/ext/Engine.kt +107 -0
  49. package/android/src/main/kotlin/ly/img/editor/configuration/video/EditorActivity.kt +37 -0
  50. package/android/src/main/kotlin/ly/img/editor/configuration/video/VideoConfigurationBuilder.kt +135 -0
  51. package/android/src/main/kotlin/ly/img/editor/configuration/video/callback/OnCreate.kt +191 -0
  52. package/android/src/main/kotlin/ly/img/editor/configuration/video/callback/OnExport.kt +98 -0
  53. package/android/src/main/kotlin/ly/img/editor/configuration/video/callback/OnLoaded.kt +20 -0
  54. package/android/src/main/kotlin/ly/img/editor/configuration/video/component/BottomPanel.kt +13 -0
  55. package/android/src/main/kotlin/ly/img/editor/configuration/video/component/CanvasMenu.kt +45 -0
  56. package/android/src/main/kotlin/ly/img/editor/configuration/video/component/Dock.kt +71 -0
  57. package/android/src/main/kotlin/ly/img/editor/configuration/video/component/InspectorBar.kt +68 -0
  58. package/android/src/main/kotlin/ly/img/editor/configuration/video/component/NavigationBar.kt +57 -0
  59. package/android/src/main/kotlin/ly/img/editor/configuration/video/component/Overlay.kt +421 -0
  60. package/android/src/main/kotlin/ly/img/editor/configuration/video/iconPack/CheckCircleOutline.kt +79 -0
  61. package/android/src/main/kotlin/ly/img/editor/configuration/video/iconPack/ErrorOutline.kt +92 -0
  62. package/android/src/main/kotlin/ly/img/editor/configuration/video/iconPack/IconPack.kt +14 -0
  63. package/android/src/main/kotlin/ly/img/editor/configuration/video/model/ExportStatus.kt +39 -0
  64. package/android/src/main/kotlin/ly/img/editor/reactnative/module/activity/EditorActivity.kt +2 -0
  65. package/android/src/main/kotlin/ly/img/editor/reactnative/module/builder/EditorBuilder.kt +240 -282
  66. package/ios/Extensions/OnCreate+.swift +38 -62
  67. package/ios/IMGLYEditorModule.swift +10 -1
  68. package/ios/Model/EditorBuilder.swift +132 -225
  69. package/ios/Model/ModalEditorConfiguration.swift +40 -0
  70. package/ios/Model/Source.swift +8 -0
  71. package/ios/StarterKits/Apparel/ApparelEditorConfiguration.swift +46 -0
  72. package/ios/StarterKits/Apparel/ApparelEditorStarterKit.swift +30 -0
  73. package/ios/StarterKits/Apparel/callbacks/OnChanged+Apparel.swift +116 -0
  74. package/ios/StarterKits/Apparel/callbacks/OnCreate+Apparel.swift +197 -0
  75. package/ios/StarterKits/Apparel/callbacks/OnExport+Apparel.swift +29 -0
  76. package/ios/StarterKits/Apparel/components/CanvasMenu+Apparel.swift +22 -0
  77. package/ios/StarterKits/Apparel/components/Dock+Apparel.swift +19 -0
  78. package/ios/StarterKits/Apparel/components/InspectorBar+Apparel.swift +35 -0
  79. package/ios/StarterKits/Apparel/components/NavigationBar+Apparel.swift +26 -0
  80. package/ios/StarterKits/Design/DesignEditorConfiguration.swift +43 -0
  81. package/ios/StarterKits/Design/DesignEditorStarterKit.swift +30 -0
  82. package/ios/StarterKits/Design/callbacks/OnCreate+Design.swift +131 -0
  83. package/ios/StarterKits/Design/callbacks/OnExport+Design.swift +30 -0
  84. package/ios/StarterKits/Design/components/CanvasMenu+Design.swift +22 -0
  85. package/ios/StarterKits/Design/components/Dock+Design.swift +23 -0
  86. package/ios/StarterKits/Design/components/InspectorBar+Design.swift +35 -0
  87. package/ios/StarterKits/Design/components/NavigationBar+Design.swift +24 -0
  88. package/ios/StarterKits/Photo/PhotoEditorConfiguration.swift +48 -0
  89. package/ios/StarterKits/Photo/PhotoEditorStarterKit.swift +30 -0
  90. package/ios/StarterKits/Photo/callbacks/OnChanged+Photo.swift +25 -0
  91. package/ios/StarterKits/Photo/callbacks/OnCreate+Photo.swift +138 -0
  92. package/ios/StarterKits/Photo/callbacks/OnExport+Photo.swift +29 -0
  93. package/ios/StarterKits/Photo/callbacks/OnLoaded+Photo.swift +18 -0
  94. package/ios/StarterKits/Photo/components/CanvasMenu+Photo.swift +22 -0
  95. package/ios/StarterKits/Photo/components/Dock+Photo.swift +23 -0
  96. package/ios/StarterKits/Photo/components/InspectorBar+Photo.swift +39 -0
  97. package/ios/StarterKits/Photo/components/NavigationBar+Photo.swift +24 -0
  98. package/ios/StarterKits/Photo/examples/ExampleForceCrop.swift +30 -0
  99. package/ios/StarterKits/Postcard/PostcardEditorConfiguration.swift +45 -0
  100. package/ios/StarterKits/Postcard/PostcardEditorStarterKit.swift +30 -0
  101. package/ios/StarterKits/Postcard/callbacks/OnChanged+Postcard.swift +92 -0
  102. package/ios/StarterKits/Postcard/callbacks/OnCreate+Postcard.swift +127 -0
  103. package/ios/StarterKits/Postcard/callbacks/OnExport+Postcard.swift +29 -0
  104. package/ios/StarterKits/Postcard/components/CanvasMenu+Postcard.swift +22 -0
  105. package/ios/StarterKits/Postcard/components/Dock+Postcard.swift +34 -0
  106. package/ios/StarterKits/Postcard/components/DockButtons+Postcard.swift +129 -0
  107. package/ios/StarterKits/Postcard/components/InspectorBar+Postcard.swift +35 -0
  108. package/ios/StarterKits/Postcard/components/NavigationBar+Postcard.swift +38 -0
  109. package/ios/StarterKits/Video/VideoEditorConfiguration.swift +54 -0
  110. package/ios/StarterKits/Video/VideoEditorStarterKit.swift +30 -0
  111. package/ios/StarterKits/Video/callbacks/OnCreate+Video.swift +137 -0
  112. package/ios/StarterKits/Video/callbacks/OnExport+Video.swift +46 -0
  113. package/ios/StarterKits/Video/components/BottomPanel+Video.swift +16 -0
  114. package/ios/StarterKits/Video/components/CanvasMenu+Video.swift +22 -0
  115. package/ios/StarterKits/Video/components/Dock+Video.swift +30 -0
  116. package/ios/StarterKits/Video/components/InspectorBar+Video.swift +43 -0
  117. package/ios/StarterKits/Video/components/NavigationBar+Video.swift +32 -0
  118. package/ios/StarterKits/Video/examples/ExampleVideoDurationConstraints.swift +23 -0
  119. package/ios/StarterKits/apparel-ui-b-empty.scene +1 -0
  120. package/ios/StarterKits/design-ui-empty.scene +1 -0
  121. package/ios/StarterKits/photo-ui-empty.png +0 -0
  122. package/ios/StarterKits/postcard-empty.scene +1 -0
  123. package/ios/StarterKits/video-empty.scene +1 -0
  124. package/package.json +1 -1
  125. package/src/NativeIMGLYEditor.ts +1 -1
  126. package/ios/View/ModalEditor.swift +0 -43
@@ -0,0 +1,37 @@
1
+ // highlight-starter-kit-activity-full
2
+ package ly.img.editor.configuration.design
3
+
4
+ import android.os.Bundle
5
+ import androidx.activity.ComponentActivity
6
+ import androidx.activity.compose.setContent
7
+ import androidx.activity.enableEdgeToEdge
8
+ import ly.img.editor.Editor
9
+ import ly.img.editor.core.configuration.EditorConfiguration
10
+ import ly.img.editor.core.configuration.remember
11
+
12
+ /**
13
+ * Encapsulated editor to be used in legacy activity navigation.
14
+ * Delete this file if you are using jetpack compose navigation.
15
+ */
16
+ class EditorActivity : ComponentActivity() {
17
+ override fun onCreate(savedInstanceState: Bundle?) {
18
+ super.onCreate(savedInstanceState)
19
+ // This is required to remove the default action bar on top.
20
+ setTheme(android.R.style.Theme_Material_Light_NoActionBar)
21
+ // This is required, so that the editor is displayed full screen on relatively older devices.
22
+ enableEdgeToEdge()
23
+ setContent {
24
+ Editor(
25
+ license = null, // pass null or empty for evaluation mode with watermark
26
+ configuration = {
27
+ EditorConfiguration.remember(::DesignConfigurationBuilder)
28
+ },
29
+ onClose = {
30
+ // Finish the activity, potentially handle errors.
31
+ finish()
32
+ },
33
+ )
34
+ }
35
+ }
36
+ }
37
+ // highlight-starter-kit-activity-full
@@ -0,0 +1,162 @@
1
+ package ly.img.editor.configuration.design.callback
2
+
3
+ import androidx.core.net.toUri
4
+ import kotlinx.coroutines.coroutineScope
5
+ import kotlinx.coroutines.launch
6
+ import ly.img.editor.configuration.design.DesignConfigurationBuilder
7
+ import ly.img.editor.core.library.data.AssetSourceType
8
+ import ly.img.editor.core.library.data.SystemGalleryAssetSource
9
+ import ly.img.editor.core.library.data.SystemGalleryPermission
10
+ import ly.img.editor.core.library.data.TextAssetSource
11
+ import ly.img.editor.core.library.data.TypefaceProvider
12
+ import ly.img.engine.DefaultAssetSource
13
+ import ly.img.engine.DemoAssetSource
14
+ import ly.img.engine.DesignBlockType
15
+ import ly.img.engine.populateAssetSource
16
+
17
+ /**
18
+ * The callback that is invoked when the editor is created.
19
+ */
20
+ suspend fun DesignConfigurationBuilder.onCreate(
21
+ preCreateScene: suspend DesignConfigurationBuilder.() -> Unit = {
22
+ onPreCreateScene()
23
+ },
24
+ createScene: suspend DesignConfigurationBuilder.() -> Unit = {
25
+ onCreateScene()
26
+ },
27
+ loadAssetSources: suspend DesignConfigurationBuilder.() -> Unit = {
28
+ onLoadAssetSources()
29
+ },
30
+ postCreateScene: suspend DesignConfigurationBuilder.() -> Unit = {
31
+ onPostCreateScene()
32
+ },
33
+ finally: suspend DesignConfigurationBuilder.() -> Unit = {
34
+ onCreateFinally()
35
+ },
36
+ ) {
37
+ try {
38
+ preCreateScene()
39
+ createScene()
40
+ loadAssetSources()
41
+ postCreateScene()
42
+ } finally {
43
+ finally()
44
+ }
45
+ }
46
+
47
+ /**
48
+ * The callback that is invoked before the scene is created.
49
+ */
50
+ fun DesignConfigurationBuilder.onPreCreateScene() {
51
+ showLoading = true
52
+ // Enable horizontal sliding between pages
53
+ editorContext.engine.editor.setSettingBoolean(
54
+ keypath = "features/pageCarouselEnabled",
55
+ value = true,
56
+ )
57
+ }
58
+
59
+ /**
60
+ * The callback that is responsible for creating the scene.
61
+ */
62
+ // highlight-starter-kit-on-create-scene
63
+ suspend fun DesignConfigurationBuilder.onCreateScene() {
64
+ getOrLoadScene(sceneUri = "file:///android_asset/scene/design.scene".toUri())
65
+ }
66
+ // highlight-starter-kit-on-create-scene
67
+
68
+ /**
69
+ * The callback that loads all the required assets sources.
70
+ */
71
+ // highlight-starter-kit-on-load-asset-sources
72
+ suspend fun DesignConfigurationBuilder.onLoadAssetSources() {
73
+ // Load asset sources in parallel from content.json files
74
+ coroutineScope {
75
+ listOf(
76
+ DefaultAssetSource.STICKER.key,
77
+ DefaultAssetSource.VECTOR_PATH.key,
78
+ DefaultAssetSource.FILTER_LUT.key,
79
+ DefaultAssetSource.FILTER_DUO_TONE.key,
80
+ DefaultAssetSource.CROP_PRESETS.key,
81
+ DefaultAssetSource.PAGE_PRESETS.key,
82
+ DefaultAssetSource.EFFECT.key,
83
+ DefaultAssetSource.BLUR.key,
84
+ DefaultAssetSource.TYPEFACE.key,
85
+ DemoAssetSource.IMAGE.key,
86
+ DemoAssetSource.TEXT_COMPONENTS.key,
87
+ ).forEach { assetSource ->
88
+ launch {
89
+ val baseUri = editorContext.baseUri
90
+ editorContext.engine.populateAssetSource(
91
+ id = assetSource,
92
+ jsonUri = "$baseUri/$assetSource/content.json".toUri(),
93
+ replaceBaseUri = baseUri,
94
+ )
95
+ }
96
+ }
97
+ }
98
+
99
+ // Load local asset sources
100
+ editorContext.engine.asset.addLocalSource(
101
+ sourceId = DemoAssetSource.IMAGE_UPLOAD.key,
102
+ supportedMimeTypes = listOf(
103
+ "image/jpeg",
104
+ "image/png",
105
+ "image/heic",
106
+ "image/heif",
107
+ "image/svg+xml",
108
+ "image/gif",
109
+ "image/bmp",
110
+ ),
111
+ )
112
+
113
+ // Register gallery asset sources
114
+ listOf(
115
+ AssetSourceType.GalleryAllVisuals,
116
+ AssetSourceType.GalleryImage,
117
+ AssetSourceType.GalleryVideo,
118
+ ).forEach { type ->
119
+ editorContext.engine.asset.addSource(
120
+ source = SystemGalleryAssetSource(
121
+ context = editorContext.engine.applicationContext,
122
+ type = type,
123
+ ),
124
+ )
125
+ }
126
+ SystemGalleryPermission.setMode(systemGalleryConfiguration)
127
+
128
+ // Register text asset source
129
+ TypefaceProvider().provideTypeface(
130
+ engine = editorContext.engine,
131
+ name = "Roboto",
132
+ )?.let {
133
+ val textAssetSource = TextAssetSource(engine = editorContext.engine, typeface = it)
134
+ editorContext.engine.asset.addSource(textAssetSource)
135
+ }
136
+ }
137
+ // highlight-starter-kit-on-load-asset-sources
138
+
139
+ /**
140
+ * The callback that is invoked right after [onCreateScene], after the scene is created.
141
+ */
142
+ fun DesignConfigurationBuilder.onPostCreateScene() {
143
+ editorContext.engine.block
144
+ .findByType(DesignBlockType.Stack)
145
+ .firstOrNull()
146
+ ?.let {
147
+ // Display all pages in a horizontal stack.
148
+ editorContext.engine.block.setEnum(
149
+ block = it,
150
+ property = "stack/axis",
151
+ value = "Horizontal",
152
+ )
153
+ }
154
+ }
155
+
156
+ /**
157
+ * The callback that is invoked as the last step of [onCreate].
158
+ * It always runs, no matter success or failure on previous steps.
159
+ */
160
+ fun DesignConfigurationBuilder.onCreateFinally() {
161
+ showLoading = false
162
+ }
@@ -0,0 +1,82 @@
1
+ package ly.img.editor.configuration.design.callback
2
+
3
+ import kotlinx.coroutines.CancellationException
4
+ import ly.img.editor.configuration.design.DesignConfigurationBuilder
5
+ import ly.img.engine.MimeType
6
+ import java.nio.ByteBuffer
7
+
8
+ /**
9
+ * The callback that is invoked when the export button is clicked.
10
+ */
11
+ suspend fun DesignConfigurationBuilder.onExport(
12
+ preExport: suspend DesignConfigurationBuilder.() -> Unit = {
13
+ onPreExport()
14
+ },
15
+ exportByteBuffer: suspend DesignConfigurationBuilder.() -> ByteBuffer = {
16
+ onExportByteBuffer()
17
+ },
18
+ postExport: suspend DesignConfigurationBuilder.(ByteBuffer) -> Unit = {
19
+ onPostExport(it)
20
+ },
21
+ error: suspend DesignConfigurationBuilder.(Exception) -> Unit = {
22
+ onExportError(it)
23
+ },
24
+ finally: suspend DesignConfigurationBuilder.() -> Unit = {
25
+ onExportFinally()
26
+ },
27
+ ) {
28
+ try {
29
+ preExport()
30
+ val result = exportByteBuffer()
31
+ postExport(result)
32
+ } catch (exception: Exception) {
33
+ error(exception)
34
+ } finally {
35
+ finally()
36
+ }
37
+ }
38
+
39
+ /**
40
+ * The callback that is invoked before the export is started.
41
+ */
42
+ fun DesignConfigurationBuilder.onPreExport() {
43
+ showLoading = true
44
+ }
45
+
46
+ /**
47
+ * The callback that exports the content of the editor into [ByteBuffer].
48
+ */
49
+ // highlight-starter-kit-on-export-byte-buffer
50
+ suspend fun DesignConfigurationBuilder.onExportByteBuffer(): ByteBuffer = export(
51
+ block = requireNotNull(editorContext.engine.scene.get()),
52
+ mimeType = MimeType.PDF,
53
+ )
54
+ // highlight-starter-kit-on-export-byte-buffer
55
+
56
+ /**
57
+ * The callback that is invoked after [onExportByteBuffer] and handles its output.
58
+ */
59
+ // highlight-starter-kit-on-post-export
60
+ suspend fun DesignConfigurationBuilder.onPostExport(byteBuffer: ByteBuffer) {
61
+ val file = writeToFile(byteBuffer = byteBuffer, mimeType = MimeType.PDF)
62
+ shareFile(file = file, mimeType = MimeType.PDF)
63
+ }
64
+ // highlight-starter-kit-on-post-export
65
+
66
+ /**
67
+ * The callback that is invoked in case any of the export functions throw an exception.
68
+ */
69
+ fun DesignConfigurationBuilder.onExportError(error: Exception) {
70
+ if (error is CancellationException) {
71
+ throw error
72
+ }
73
+ this.error = error
74
+ }
75
+
76
+ /**
77
+ * The callback that is invoked as the last step of [onExportByteBuffer].
78
+ * It always runs, no matter success or failure on previous steps.
79
+ */
80
+ fun DesignConfigurationBuilder.onExportFinally() {
81
+ showLoading = false
82
+ }
@@ -0,0 +1,10 @@
1
+ package ly.img.editor.configuration.design.callback
2
+
3
+ import ly.img.editor.configuration.design.DesignConfigurationBuilder
4
+
5
+ /**
6
+ * The callback that is invoked when the editor is loaded and ready to be used.
7
+ */
8
+ suspend fun DesignConfigurationBuilder.onLoaded() {
9
+ observeEditorEditMode()
10
+ }
@@ -0,0 +1,45 @@
1
+ @file:Suppress("UnusedReceiverParameter")
2
+
3
+ package ly.img.editor.configuration.design.component
4
+
5
+ import androidx.compose.runtime.Composable
6
+ import ly.img.editor.configuration.design.DesignConfigurationBuilder
7
+ import ly.img.editor.core.component.CanvasMenu
8
+ import ly.img.editor.core.component.EditorComponentId
9
+ import ly.img.editor.core.component.remember
10
+ import ly.img.editor.core.component.rememberBringForward
11
+ import ly.img.editor.core.component.rememberDelete
12
+ import ly.img.editor.core.component.rememberDuplicate
13
+ import ly.img.editor.core.component.rememberSelectGroup
14
+ import ly.img.editor.core.component.rememberSendBackward
15
+
16
+ /**
17
+ * The configuration of the component that is displayed as horizontal list of items next to
18
+ * the selected design block.
19
+ */
20
+ @Composable
21
+ fun DesignConfigurationBuilder.rememberCanvasMenu() = CanvasMenu.remember {
22
+ listBuilder = {
23
+ CanvasMenu.ListBuilder.remember {
24
+ add { CanvasMenu.Button.rememberSelectGroup() }
25
+ if (editorContext.isSelectionInGroup) {
26
+ add {
27
+ CanvasMenu.Divider.remember {
28
+ id = { EditorComponentId("ly.img.component.canvasMenu.divider1") }
29
+ }
30
+ }
31
+ }
32
+ add { CanvasMenu.Button.rememberBringForward() }
33
+ add { CanvasMenu.Button.rememberSendBackward() }
34
+ if (editorContext.canSelectionMove) {
35
+ add {
36
+ CanvasMenu.Divider.remember {
37
+ id = { EditorComponentId("ly.img.component.canvasMenu.divider2") }
38
+ }
39
+ }
40
+ }
41
+ add { CanvasMenu.Button.rememberDuplicate() }
42
+ add { CanvasMenu.Button.rememberDelete() }
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,35 @@
1
+ @file:Suppress("UnusedReceiverParameter")
2
+
3
+ package ly.img.editor.configuration.design.component
4
+
5
+ import androidx.compose.runtime.Composable
6
+ import ly.img.editor.configuration.design.DesignConfigurationBuilder
7
+ import ly.img.editor.core.component.Dock
8
+ import ly.img.editor.core.component.remember
9
+ import ly.img.editor.core.component.rememberElementsLibrary
10
+ import ly.img.editor.core.component.rememberImagesLibrary
11
+ import ly.img.editor.core.component.rememberResizeAll
12
+ import ly.img.editor.core.component.rememberShapesLibrary
13
+ import ly.img.editor.core.component.rememberStickersLibrary
14
+ import ly.img.editor.core.component.rememberSystemCamera
15
+ import ly.img.editor.core.component.rememberSystemGallery
16
+ import ly.img.editor.core.component.rememberTextLibrary
17
+
18
+ /**
19
+ * The configuration of the component that is displayed as horizontal list of items at the bottom of the editor.
20
+ */
21
+ @Composable
22
+ fun DesignConfigurationBuilder.rememberDock() = Dock.remember {
23
+ listBuilder = {
24
+ Dock.ListBuilder.remember {
25
+ add { Dock.Button.rememberElementsLibrary() }
26
+ add { Dock.Button.rememberSystemGallery() }
27
+ add { Dock.Button.rememberSystemCamera() }
28
+ add { Dock.Button.rememberImagesLibrary() }
29
+ add { Dock.Button.rememberTextLibrary() }
30
+ add { Dock.Button.rememberShapesLibrary() }
31
+ add { Dock.Button.rememberStickersLibrary() }
32
+ add { Dock.Button.rememberResizeAll() }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,52 @@
1
+ @file:Suppress("UnusedReceiverParameter")
2
+
3
+ package ly.img.editor.configuration.design.component
4
+
5
+ import androidx.compose.runtime.Composable
6
+ import ly.img.editor.configuration.design.DesignConfigurationBuilder
7
+ import ly.img.editor.core.component.InspectorBar
8
+ import ly.img.editor.core.component.remember
9
+ import ly.img.editor.core.component.rememberAdjustments
10
+ import ly.img.editor.core.component.rememberBlur
11
+ import ly.img.editor.core.component.rememberCrop
12
+ import ly.img.editor.core.component.rememberDelete
13
+ import ly.img.editor.core.component.rememberDuplicate
14
+ import ly.img.editor.core.component.rememberEditText
15
+ import ly.img.editor.core.component.rememberEffect
16
+ import ly.img.editor.core.component.rememberEnterGroup
17
+ import ly.img.editor.core.component.rememberFillStroke
18
+ import ly.img.editor.core.component.rememberFilter
19
+ import ly.img.editor.core.component.rememberFormatText
20
+ import ly.img.editor.core.component.rememberLayer
21
+ import ly.img.editor.core.component.rememberReplace
22
+ import ly.img.editor.core.component.rememberSelectGroup
23
+ import ly.img.editor.core.component.rememberShape
24
+ import ly.img.editor.core.component.rememberTextBackground
25
+
26
+ /**
27
+ * The configuration of the component that is displayed as horizontal list of items at the
28
+ * bottom of the editor when a design block is selected.
29
+ */
30
+ @Composable
31
+ fun DesignConfigurationBuilder.rememberInspectorBar() = InspectorBar.remember {
32
+ listBuilder = {
33
+ InspectorBar.ListBuilder.remember {
34
+ add { InspectorBar.Button.rememberReplace() } // Image, Sticker, Audio
35
+ add { InspectorBar.Button.rememberEditText() } // Text
36
+ add { InspectorBar.Button.rememberFormatText() } // Text
37
+ add { InspectorBar.Button.rememberFillStroke() } // Page, Image, Shape, Text
38
+ add { InspectorBar.Button.rememberTextBackground() } // Text
39
+ add { InspectorBar.Button.rememberCrop() } // Image
40
+ add { InspectorBar.Button.rememberAdjustments() } // Image
41
+ add { InspectorBar.Button.rememberFilter() } // Image
42
+ add { InspectorBar.Button.rememberEffect() } // Image
43
+ add { InspectorBar.Button.rememberBlur() } // Image
44
+ add { InspectorBar.Button.rememberShape() } // Image, Shape
45
+ add { InspectorBar.Button.rememberSelectGroup() } // Image, Sticker, Shape, Text
46
+ add { InspectorBar.Button.rememberEnterGroup() } // Group
47
+ add { InspectorBar.Button.rememberLayer() } // Image, Sticker, Shape, Text
48
+ add { InspectorBar.Button.rememberDuplicate() } // Image, Sticker, Shape, Text
49
+ add { InspectorBar.Button.rememberDelete() } // Image, Sticker, Shape, Text
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,45 @@
1
+ @file:Suppress("UnusedReceiverParameter")
2
+
3
+ package ly.img.editor.configuration.design.component
4
+
5
+ import androidx.compose.runtime.Composable
6
+ import androidx.compose.runtime.remember
7
+ import androidx.compose.ui.Alignment
8
+ import ly.img.editor.configuration.design.DesignConfigurationBuilder
9
+ import ly.img.editor.core.component.EditorTrigger
10
+ import ly.img.editor.core.component.NavigationBar
11
+ import ly.img.editor.core.component.remember
12
+ import ly.img.editor.core.component.rememberCloseEditor
13
+ import ly.img.editor.core.component.rememberExport
14
+ import ly.img.editor.core.component.rememberRedo
15
+ import ly.img.editor.core.component.rememberTogglePagesMode
16
+ import ly.img.editor.core.component.rememberUndo
17
+
18
+ /**
19
+ * The configuration of the component that is displayed as horizontal list of items at the top of the editor.
20
+ */
21
+ @Composable
22
+ fun DesignConfigurationBuilder.rememberNavigationBar() = NavigationBar.remember {
23
+ scope = {
24
+ val historyTrigger by EditorTrigger.remember {
25
+ editorContext.engine.editor.onHistoryUpdated()
26
+ }
27
+ // Update NavigationBar whenever the editor history changes
28
+ remember(this, historyTrigger) {
29
+ NavigationBar.Scope(parentScope = this)
30
+ }
31
+ }
32
+ listBuilder = {
33
+ NavigationBar.ListBuilder.remember {
34
+ aligned(alignment = Alignment.Start) {
35
+ add { NavigationBar.Button.rememberCloseEditor() }
36
+ }
37
+ aligned(alignment = Alignment.End) {
38
+ add { NavigationBar.Button.rememberUndo() }
39
+ add { NavigationBar.Button.rememberRedo() }
40
+ add { NavigationBar.Button.rememberTogglePagesMode() }
41
+ add { NavigationBar.Button.rememberExport() }
42
+ }
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,15 @@
1
+ package ly.img.editor.configuration.design.component
2
+
3
+ import androidx.compose.runtime.Composable
4
+ import ly.img.editor.configuration.design.DesignConfigurationBuilder
5
+ import ly.img.editor.core.component.EditorComponent
6
+ import ly.img.editor.core.component.remember
7
+
8
+ /**
9
+ * The configuration of the component that is displayed over the editor. It is useful if you want to display a popup dialog or anything in the
10
+ * overlay.
11
+ */
12
+ @Composable
13
+ fun DesignConfigurationBuilder.rememberOverlay() = EditorComponent.remember {
14
+ decoration = { Overlay() }
15
+ }
@@ -0,0 +1,37 @@
1
+ // highlight-starter-kit-activity-full
2
+ package ly.img.editor.configuration.photo
3
+
4
+ import android.os.Bundle
5
+ import androidx.activity.ComponentActivity
6
+ import androidx.activity.compose.setContent
7
+ import androidx.activity.enableEdgeToEdge
8
+ import ly.img.editor.Editor
9
+ import ly.img.editor.core.configuration.EditorConfiguration
10
+ import ly.img.editor.core.configuration.remember
11
+
12
+ /**
13
+ * Encapsulated editor to be used in legacy activity navigation.
14
+ * Delete this file if you are using jetpack compose navigation.
15
+ */
16
+ class EditorActivity : ComponentActivity() {
17
+ override fun onCreate(savedInstanceState: Bundle?) {
18
+ super.onCreate(savedInstanceState)
19
+ // This is required to remove the default action bar on top.
20
+ setTheme(android.R.style.Theme_Material_Light_NoActionBar)
21
+ // This is required, so that the editor is displayed full screen on relatively older devices.
22
+ enableEdgeToEdge()
23
+ setContent {
24
+ Editor(
25
+ license = null, // pass null or empty for evaluation mode with watermark
26
+ configuration = {
27
+ EditorConfiguration.remember(::PhotoConfigurationBuilder)
28
+ },
29
+ onClose = {
30
+ // Finish the activity, potentially handle errors.
31
+ finish()
32
+ },
33
+ )
34
+ }
35
+ }
36
+ }
37
+ // highlight-starter-kit-activity-full
@@ -0,0 +1,106 @@
1
+ package ly.img.editor.configuration.photo
2
+
3
+ import androidx.compose.runtime.Stable
4
+ import ly.img.editor.BasicConfigurationBuilder
5
+ import ly.img.editor.configuration.photo.callback.onCreate
6
+ import ly.img.editor.configuration.photo.callback.onExport
7
+ import ly.img.editor.configuration.photo.callback.onLoaded
8
+ import ly.img.editor.configuration.photo.component.rememberCanvasMenu
9
+ import ly.img.editor.configuration.photo.component.rememberDock
10
+ import ly.img.editor.configuration.photo.component.rememberInspectorBar
11
+ import ly.img.editor.configuration.photo.component.rememberNavigationBar
12
+ import ly.img.editor.configuration.photo.component.rememberOverlay
13
+ import ly.img.editor.core.EditorScope
14
+ import ly.img.editor.core.ScopedProperty
15
+ import ly.img.editor.core.component.EditorComponent
16
+ import ly.img.editor.core.event.EditorEvent
17
+
18
+ /**
19
+ * Configuration builder class for photo editor starter kit.
20
+ */
21
+ @Stable
22
+ class PhotoConfigurationBuilder : BasicConfigurationBuilder() {
23
+ /**
24
+ * The callback that is invoked when the editor is created.
25
+ * Check parent class declaration for more details.
26
+ */
27
+ override var onCreate: (suspend EditorScope.() -> Unit)? = {
28
+ onCreate()
29
+ }
30
+
31
+ /**
32
+ * The callback that is invoked when the editor is loaded and ready to be used.
33
+ * Check parent class declaration for more details.
34
+ */
35
+ override var onLoaded: (suspend EditorScope.() -> Unit)? = {
36
+ onLoaded()
37
+ }
38
+
39
+ /**
40
+ * The callback that is invoked when the export button is clicked.
41
+ * Check parent class declaration for more details.
42
+ */
43
+ override var onExport: (suspend EditorScope.() -> Unit)? = {
44
+ onExport()
45
+ }
46
+
47
+ /**
48
+ * The callback that is invoked after [EditorEvent.OnClose] event is triggered or when the system back button is clicked
49
+ * and editor cannot handle the event internally.
50
+ * Check parent class declaration for more details.
51
+ */
52
+ override var onClose: (suspend EditorScope.() -> Unit)? = {
53
+ showConfirmationOrCloseEditor()
54
+ }
55
+
56
+ /**
57
+ * The callback that is invoked after the editor captures an error.
58
+ * Check parent class declaration for more details.
59
+ */
60
+ override var onError: (suspend EditorScope.(Throwable) -> Unit)? = {
61
+ error = it
62
+ }
63
+
64
+ /**
65
+ * The configuration of the component that is displayed as horizontal list of items at the bottom of the editor.
66
+ * Check parent class declaration for more details.
67
+ */
68
+ override var dock: ScopedProperty<EditorScope, EditorComponent<*>>? = {
69
+ rememberDock()
70
+ }
71
+
72
+ /**
73
+ * The configuration of the component that is displayed as horizontal list of items at the top of the editor.
74
+ * Check parent class declaration for more details.
75
+ */
76
+ override var navigationBar: ScopedProperty<EditorScope, EditorComponent<*>>? = {
77
+ rememberNavigationBar()
78
+ }
79
+
80
+ /**
81
+ * The configuration of the component that is displayed as horizontal list of items at the
82
+ * bottom of the editor when a design block is selected.
83
+ * Check parent class declaration for more details.
84
+ */
85
+ override var inspectorBar: ScopedProperty<EditorScope, EditorComponent<*>>? = {
86
+ rememberInspectorBar()
87
+ }
88
+
89
+ /**
90
+ * The configuration of the component that is displayed as horizontal list of items next to
91
+ * the selected design block.
92
+ * Check parent class declaration for more details.
93
+ */
94
+ override var canvasMenu: ScopedProperty<EditorScope, EditorComponent<*>>? = {
95
+ rememberCanvasMenu()
96
+ }
97
+
98
+ /**
99
+ * The configuration of the component that is displayed over the editor. It is useful if you want to display a popup dialog or anything in the
100
+ * overlay.
101
+ * Check parent class declaration for more details.
102
+ */
103
+ override var overlay: ScopedProperty<EditorScope, EditorComponent<*>>? = {
104
+ rememberOverlay()
105
+ }
106
+ }