Skip to content

Commit

Permalink
fix: fix #179 Same watermark image is behaving differently on ANDROID…
Browse files Browse the repository at this point in the history
… and IOS
  • Loading branch information
JimmyDaddy committed Dec 21, 2023
1 parent 9c673c2 commit a269510
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ package com.jimmydaddy.imagemarker.base
import com.facebook.react.bridge.ReadableMap

data class WatermarkImageOptions(val options: ReadableMap?) {
var imageOption: ImageOptions
var x: String?
var y: String?
var positionEnum: PositionEnum?
lateinit var imageOption: ImageOptions
var x: String? = null
var y: String? = null
var positionEnum: PositionEnum? = null

init {
imageOption = options?.let { ImageOptions(it) }!!
val positionOptions =
if (null != options.getMap("position")) options.getMap("position") else null
x = if (positionOptions!!.hasKey("X")) Utils.handleDynamicToString(positionOptions.getDynamic("X")) else null
y = if (positionOptions.hasKey("Y")) Utils.handleDynamicToString(positionOptions.getDynamic("Y")) else null
positionEnum =
if (null != positionOptions.getString("position")) PositionEnum.getPosition(
positionOptions.getString("position")
) else null
if (options != null) {
imageOption = options?.let { ImageOptions(it) }!!
val positionOptions =
if (null != options.getMap("position")) options.getMap("position") else null
x = if (positionOptions!!.hasKey("X")) Utils.handleDynamicToString(positionOptions.getDynamic("X")) else null
y = if (positionOptions.hasKey("Y")) Utils.handleDynamicToString(positionOptions.getDynamic("Y")) else null
positionEnum =
if (null != positionOptions.getString("position")) PositionEnum.getPosition(
positionOptions.getString("position")
) else null
}
}

constructor(watermarkImage: ImageOptions, x: String?, y: String?, position: PositionEnum?) : this(null) {
Expand Down
72 changes: 69 additions & 3 deletions example/ios/ImageMarkerExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
552FE0025890E32E99AF119A /* libPods-ImageMarkerExample-ImageMarkerExampleUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 744A2F230C283E0D140F997B /* libPods-ImageMarkerExample-ImageMarkerExampleUITests.a */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
A119E9E12B162437000C0527 /* ImageMarkerExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A119E9E02B162437000C0527 /* ImageMarkerExampleUITests.swift */; };
A119E9E32B162437000C0527 /* ImageMarkerExampleUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A119E9E22B162437000C0527 /* ImageMarkerExampleUITestsLaunchTests.swift */; };
Expand All @@ -33,9 +34,12 @@
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = ImageMarkerExample/Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ImageMarkerExample/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = ImageMarkerExample/main.m; sourceTree = "<group>"; };
26EC0163490429FD1EA48765 /* Pods-ImageMarkerExample-ImageMarkerExampleUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImageMarkerExample-ImageMarkerExampleUITests.release.xcconfig"; path = "Target Support Files/Pods-ImageMarkerExample-ImageMarkerExampleUITests/Pods-ImageMarkerExample-ImageMarkerExampleUITests.release.xcconfig"; sourceTree = "<group>"; };
3B4392A12AC88292D35C810B /* Pods-ImageMarkerExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImageMarkerExample.debug.xcconfig"; path = "Target Support Files/Pods-ImageMarkerExample/Pods-ImageMarkerExample.debug.xcconfig"; sourceTree = "<group>"; };
5709B34CF0A7D63546082F79 /* Pods-ImageMarkerExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImageMarkerExample.release.xcconfig"; path = "Target Support Files/Pods-ImageMarkerExample/Pods-ImageMarkerExample.release.xcconfig"; sourceTree = "<group>"; };
5AF9B3B6D62946E1E270EDB8 /* Pods-ImageMarkerExample-ImageMarkerExampleUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImageMarkerExample-ImageMarkerExampleUITests.debug.xcconfig"; path = "Target Support Files/Pods-ImageMarkerExample-ImageMarkerExampleUITests/Pods-ImageMarkerExample-ImageMarkerExampleUITests.debug.xcconfig"; sourceTree = "<group>"; };
5DCACB8F33CDC322A6C60F78 /* libPods-ImageMarkerExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ImageMarkerExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
744A2F230C283E0D140F997B /* libPods-ImageMarkerExample-ImageMarkerExampleUITests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ImageMarkerExample-ImageMarkerExampleUITests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = ImageMarkerExample/LaunchScreen.storyboard; sourceTree = "<group>"; };
A119E9DE2B162437000C0527 /* ImageMarkerExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ImageMarkerExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
A119E9E02B162437000C0527 /* ImageMarkerExampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageMarkerExampleUITests.swift; sourceTree = "<group>"; };
Expand All @@ -56,6 +60,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
552FE0025890E32E99AF119A /* libPods-ImageMarkerExample-ImageMarkerExampleUITests.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -80,7 +85,7 @@
children = (
ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
5DCACB8F33CDC322A6C60F78 /* libPods-ImageMarkerExample.a */,
19F6CBCC0A4E27FBF8BF4A61 /* libPods-ImageMarkerExample-ImageMarkerExampleUITests.a */,
744A2F230C283E0D140F997B /* libPods-ImageMarkerExample-ImageMarkerExampleUITests.a */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -130,8 +135,8 @@
children = (
3B4392A12AC88292D35C810B /* Pods-ImageMarkerExample.debug.xcconfig */,
5709B34CF0A7D63546082F79 /* Pods-ImageMarkerExample.release.xcconfig */,
5B7EB9410499542E8C5724F5 /* Pods-ImageMarkerExample-ImageMarkerExampleUITests.debug.xcconfig */,
89C6BE57DB24E9ADA2F236DE /* Pods-ImageMarkerExample-ImageMarkerExampleUITests.release.xcconfig */,
5AF9B3B6D62946E1E270EDB8 /* Pods-ImageMarkerExample-ImageMarkerExampleUITests.debug.xcconfig */,
26EC0163490429FD1EA48765 /* Pods-ImageMarkerExample-ImageMarkerExampleUITests.release.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
Expand Down Expand Up @@ -165,9 +170,12 @@
isa = PBXNativeTarget;
buildConfigurationList = A119E9E62B162437000C0527 /* Build configuration list for PBXNativeTarget "ImageMarkerExampleUITests" */;
buildPhases = (
EBC9A7F715DF26D017D78006 /* [CP] Check Pods Manifest.lock */,
A119E9DA2B162437000C0527 /* Sources */,
A119E9DB2B162437000C0527 /* Frameworks */,
A119E9DC2B162437000C0527 /* Resources */,
ACF99CEFF8F89F281A68F64E /* [CP] Embed Pods Frameworks */,
00D2AD9DAE49776B6A95E7C2 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -236,6 +244,23 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
00D2AD9DAE49776B6A95E7C2 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-ImageMarkerExample-ImageMarkerExampleUITests/Pods-ImageMarkerExample-ImageMarkerExampleUITests-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-ImageMarkerExample-ImageMarkerExampleUITests/Pods-ImageMarkerExample-ImageMarkerExampleUITests-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ImageMarkerExample-ImageMarkerExampleUITests/Pods-ImageMarkerExample-ImageMarkerExampleUITests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -269,6 +294,23 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ImageMarkerExample/Pods-ImageMarkerExample-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
ACF99CEFF8F89F281A68F64E /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-ImageMarkerExample-ImageMarkerExampleUITests/Pods-ImageMarkerExample-ImageMarkerExampleUITests-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-ImageMarkerExample-ImageMarkerExampleUITests/Pods-ImageMarkerExample-ImageMarkerExampleUITests-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ImageMarkerExample-ImageMarkerExampleUITests/Pods-ImageMarkerExample-ImageMarkerExampleUITests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
C38B50BA6285516D6DCD4F65 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -308,6 +350,28 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ImageMarkerExample/Pods-ImageMarkerExample-resources.sh\"\n";
showEnvVarsInLog = 0;
};
EBC9A7F715DF26D017D78006 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-ImageMarkerExample-ImageMarkerExampleUITests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
FD10A7F022414F080027D42C /* Start Packager */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -550,6 +614,7 @@
};
A119E9E72B162437000C0527 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5AF9B3B6D62946E1E270EDB8 /* Pods-ImageMarkerExample-ImageMarkerExampleUITests.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -582,6 +647,7 @@
};
A119E9E82B162437000C0527 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 26EC0163490429FD1EA48765 /* Pods-ImageMarkerExample-ImageMarkerExampleUITests.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
Expand Down
14 changes: 7 additions & 7 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ PODS:
- React-jsinspector (0.71.11)
- React-logger (0.71.11):
- glog
- react-native-blob-util (0.19.2):
- react-native-blob-util (0.19.6):
- React-Core
- react-native-image-marker (1.1.8):
- react-native-image-marker (1.1.10):
- React-Core
- react-native-image-picker (5.6.1):
- react-native-image-picker (5.7.0):
- React-Core
- React-perflogger (0.71.11)
- React-RCTActionSheet (0.71.11):
Expand Down Expand Up @@ -616,9 +616,9 @@ SPEC CHECKSUMS:
React-jsiexecutor: 18b5b33c5f2687a784a61bc8176611b73524ae77
React-jsinspector: b6ed4cb3ffa27a041cd440300503dc512b761450
React-logger: 186dd536128ae5924bc38ed70932c00aa740cd5b
react-native-blob-util: c74e4ce87c76d244761c68623df78bf0d1638271
react-native-image-marker: c30f34263f1868b8bdac7ad770be6fb6c6ce9f86
react-native-image-picker: 5fcac5a5ffcb3737837f0617d43fd767249290de
react-native-blob-util: d8fa1a7f726867907a8e43163fdd8b441d4489ea
react-native-image-marker: 4414050c15944297bc24b3a37a1070d951fb57a2
react-native-image-picker: 3269f75c251cdcd61ab51b911dd30d6fff8c6169
React-perflogger: e706562ab7eb8eb590aa83a224d26fa13963d7f2
React-RCTActionSheet: 57d4bd98122f557479a3359ad5dad8e109e20c5a
React-RCTAnimation: ccf3ef00101ea74bda73a045d79a658b36728a60
Expand All @@ -636,6 +636,6 @@ SPEC CHECKSUMS:
Yoga: f7decafdc5e8c125e6fa0da38a687e35238420fa
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 20401a73c6b88dc06e028faa4ab5ae1c07ac8fa7
PODFILE CHECKSUM: 4420d5a35a7e9d1bc71140c63c7e29db0be4fdf7

COCOAPODS: 1.12.1
Loading

0 comments on commit a269510

Please sign in to comment.