Skip to content

Commit 1cabfb4

Browse files
committed
Initial commit
0 parents  commit 1cabfb4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2208
-0
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

.gitignore

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
# OSX
3+
#
4+
.DS_Store
5+
6+
# node.js
7+
#
8+
node_modules/
9+
npm-debug.log
10+
yarn-error.log
11+
12+
13+
# Xcode
14+
#
15+
build/
16+
*.pbxuser
17+
!default.pbxuser
18+
*.mode1v3
19+
!default.mode1v3
20+
*.mode2v3
21+
!default.mode2v3
22+
*.perspectivev3
23+
!default.perspectivev3
24+
xcuserdata
25+
*.xccheckout
26+
*.moved-aside
27+
DerivedData
28+
*.hmap
29+
*.ipa
30+
*.xcuserstate
31+
project.xcworkspace
32+
33+
34+
# Android/IntelliJ
35+
#
36+
build/
37+
.idea
38+
.gradle
39+
local.properties
40+
*.iml
41+
42+
# BUCK
43+
buck-out/
44+
\.buckd/
45+
*.keystore
46+

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# react-native-visual-clone
2+
3+
Create visual clones of your views and animate them cheaply ✂️📋💫
4+
5+
6+
## [0.1.0] - 2019-05-29
7+
8+
### Added
9+
10+
- Initial release

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Hein Rutjes
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# react-native-visual-clone
3+
4+
Create visual clones of your views and animate them cheaply ✂️📋💫
5+
6+
## WIP, go away

android/.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>android</name>
4+
<comment>Project android created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>

android/build.gradle

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
def safeExtGet(prop, fallback) {
2+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
3+
}
4+
5+
buildscript {
6+
repositories {
7+
jcenter()
8+
}
9+
10+
dependencies {
11+
classpath 'com.android.tools.build:gradle:1.3.1'
12+
}
13+
}
14+
15+
apply plugin: 'com.android.library'
16+
17+
android {
18+
compileSdkVersion safeExtGet('compileSdkVersion', 23)
19+
buildToolsVersion safeExtGet('buildToolsVersion', '23.0.1')
20+
21+
defaultConfig {
22+
minSdkVersion safeExtGet('minSdkVersion', 16)
23+
targetSdkVersion safeExtGet('targetSdkVersion', 22)
24+
versionCode 1
25+
versionName '1.0'
26+
}
27+
lintOptions {
28+
abortOnError false
29+
}
30+
}
31+
32+
repositories {
33+
mavenCentral()
34+
}
35+
36+
dependencies {
37+
implementation 'com.facebook.react:react-native:+'
38+
}

android/src/main/AndroidManifest.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.ijzerenhein.visualclone">
4+
5+
</manifest>
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.ijzerenhein.visualclone;
2+
3+
public class RNVisualCloneContentType {
4+
public static final int CHILDREN = 0;
5+
public static final int SNAPSHOT = 1;
6+
// public static final int RAWIMAGE = 2; Not supported on Android
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.ijzerenhein.visualclone;
2+
3+
import java.util.Map;
4+
5+
import android.view.View;
6+
import android.graphics.RectF;
7+
8+
public class RNVisualCloneData extends Object {
9+
private String mSharedId;
10+
private View mView;
11+
private RectF mLayout;
12+
private int mOptions;
13+
private int mRefCount;
14+
15+
public RNVisualCloneData(String sharedId, View view, RectF layout, int options) {
16+
mSharedId = sharedId;
17+
mLayout = layout;
18+
mView = view;
19+
mOptions = options;
20+
mRefCount = 1;
21+
}
22+
23+
public String getSharedId() {
24+
return mSharedId;
25+
}
26+
27+
public View getView() {
28+
return mView;
29+
}
30+
31+
public RectF getLayout() {
32+
return mLayout;
33+
}
34+
35+
public int getOptions() {
36+
return mOptions;
37+
}
38+
39+
public int getRefCount() {
40+
return mRefCount;
41+
}
42+
43+
public void setRefCount(int refCount) {
44+
mRefCount = refCount;
45+
}
46+
47+
public String getKey() {
48+
return keyForSharedId(mSharedId, mOptions);
49+
}
50+
51+
public static String keyForSharedId(String sharedId, int options) {
52+
String type;
53+
if ((options & RNVisualCloneOption.SCENE) != 0) {
54+
type = ((options & RNVisualCloneOption.TARGET) != 0) ? "TargetScene" : "SourceScene";
55+
} else {
56+
type = ((options & RNVisualCloneOption.TARGET) != 0) ? "TargetComponent" : "SourceComponent";
57+
}
58+
return type + ":" + sharedId;
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.ijzerenhein.visualclone;
2+
3+
import java.util.Map;
4+
import java.util.HashMap;
5+
6+
public class RNVisualCloneDataManager extends Object {
7+
private Map<String, RNVisualCloneData> mItems = new HashMap<String, RNVisualCloneData>();
8+
9+
public RNVisualCloneData acquire(String key) {
10+
synchronized (mItems) {
11+
RNVisualCloneData item = mItems.get(key);
12+
if (item != null) {
13+
item.setRefCount(item.getRefCount() + 1);
14+
}
15+
return item;
16+
}
17+
}
18+
19+
public int release(RNVisualCloneData item) {
20+
synchronized (mItems) {
21+
item.setRefCount(item.getRefCount() - 1);
22+
if (item.getRefCount() == 0) {
23+
mItems.remove(item.getKey());
24+
}
25+
return item.getRefCount();
26+
}
27+
}
28+
29+
public void put(RNVisualCloneData item) {
30+
synchronized (mItems) {
31+
mItems.put(item.getKey(), item);
32+
}
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.ijzerenhein.visualclone;
2+
3+
import com.facebook.react.uimanager.annotations.ReactProp;
4+
import com.facebook.react.uimanager.ThemedReactContext;
5+
import com.facebook.react.views.view.ReactViewManager;
6+
import com.facebook.react.views.view.ReactViewGroup;
7+
8+
public class RNVisualCloneManager extends ReactViewManager {
9+
10+
private RNVisualCloneDataManager mCloneDataManager;
11+
12+
public static final String REACT_CLASS = "RNVisualClone";
13+
14+
RNVisualCloneManager(RNVisualCloneDataManager cloneDataManager) {
15+
super();
16+
mCloneDataManager = cloneDataManager;
17+
}
18+
19+
@Override
20+
public String getName() {
21+
return REACT_CLASS;
22+
}
23+
24+
@Override
25+
public ReactViewGroup createViewInstance(ThemedReactContext context) {
26+
return new RNVisualCloneView(context, mCloneDataManager);
27+
}
28+
29+
@Override
30+
public void onDropViewInstance(ReactViewGroup view) {
31+
super.onDropViewInstance(view);
32+
((RNVisualCloneView) view).releaseData();
33+
}
34+
35+
@ReactProp(name = "id")
36+
public void setId(final RNVisualCloneView view, final String id) {
37+
view.setId(id);
38+
}
39+
40+
@ReactProp(name = "options")
41+
public void setOptions(final RNVisualCloneView view, final int options) {
42+
view.setOptions(options);
43+
}
44+
45+
@ReactProp(name = "contentType")
46+
public void setContentType(final RNVisualCloneView view, final int contentType) {
47+
view.setContentType(contentType);
48+
}
49+
50+
@ReactProp(name = "blurRadius", defaultFloat = 0.0f)
51+
public void setBlurRadius(final RNVisualCloneView view, final float blurRadius) {
52+
view.setBlurRadius(blurRadius);
53+
}
54+
}

0 commit comments

Comments
 (0)