Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[react-native-shared-element] Upgrade react-native-shared-element to 0.7.0 #8427

Merged
merged 2 commits into from May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@ Package-specific changes not released in any SDK will be added here just before
### 📚 3rd party library updates

- Updated `react-native-reanimated` from `1.7.0` to `1.9.0`. ([#8424](https://github.com/expo/expo/pull/8424) by [@sjchmiela](https://github.com/sjchmiela))
- Updated `react-native-shared-element` from `0.5.6` to `0.7.0`. ([#8427](https://github.com/expo/expo/pull/8427) by [@IjzerenHein](https://github.com/IjzerenHein))

### 🛠 Breaking changes

Expand Down
Expand Up @@ -10,36 +10,35 @@
import com.facebook.drawee.interfaces.DraweeController;

class RNSharedElementContent {
View view;
RectF size;
View view;
RectF size;

static RectF getSize(View view) {
if (view instanceof GenericDraweeView) {
GenericDraweeView imageView = (GenericDraweeView) view;
DraweeController controller = imageView.getController();
GenericDraweeHierarchy hierarchy = imageView.getHierarchy();
String controllerDetails = controller.toString();
if (controllerDetails.contains("fetchedImage=0,")) {
return null;
}
Drawable drawable = imageView.getDrawable();
RectF imageBounds = new RectF();
hierarchy.getActualImageBounds(imageBounds);
return imageBounds;
}
else if (view instanceof ImageView) {
ImageView imageView = (ImageView) view;
Drawable drawable = imageView.getDrawable();
if (drawable == null) return null;
int width = drawable.getIntrinsicWidth();
int height = drawable.getIntrinsicHeight();
if ((width <= 0) || (height <= 0)) {
return null;
}
return new RectF(0, 0, width, height);
}
return new RectF(0, 0, view.getWidth(), view.getHeight());
static RectF getSize(View view) {
if (view instanceof GenericDraweeView) {
GenericDraweeView imageView = (GenericDraweeView) view;
DraweeController controller = imageView.getController();
GenericDraweeHierarchy hierarchy = imageView.getHierarchy();
String controllerDetails = controller.toString();
if (controllerDetails.contains("fetchedImage=0,")) {
return null;
}
Drawable drawable = imageView.getDrawable();
RectF imageBounds = new RectF();
hierarchy.getActualImageBounds(imageBounds);
return imageBounds;
} else if (view instanceof ImageView) {
ImageView imageView = (ImageView) view;
Drawable drawable = imageView.getDrawable();
if (drawable == null) return null;
int width = drawable.getIntrinsicWidth();
int height = drawable.getIntrinsicHeight();
if ((width <= 0) || (height <= 0)) {
return null;
}
return new RectF(0, 0, width, height);
}
return new RectF(0, 0, view.getWidth(), view.getHeight());
}

/*
static public Rect getLayout(Rect layout, RectF contentSize, ScaleType scaleType, boolean reverse) {
Expand Down
Expand Up @@ -31,8 +31,14 @@ enum ViewType {
GENERIC("generic");

private final String value;
ViewType(final String newValue) { value = newValue;}
public String getValue() { return value; }

ViewType(final String newValue) {
value = newValue;
}

public String getValue() {
return value;
}
}

static private String LOG_TAG = "RNSharedElementDrawable";
Expand All @@ -58,10 +64,10 @@ float getPosition() {
}

ViewType update(
RNSharedElementContent content,
RNSharedElementStyle style,
float position
) {
RNSharedElementContent content,
RNSharedElementStyle style,
float position
) {
boolean invalidated = false;

// Update content
Expand All @@ -83,9 +89,9 @@ ViewType update(
case REACTIMAGEVIEW:
case IMAGEVIEW:
if ((mStyle.compare(style) &
(RNSharedElementStyle.PROP_BORDER
| RNSharedElementStyle.PROP_BACKGROUND_COLOR
| RNSharedElementStyle.PROP_SCALETYPE)) != 0) {
(RNSharedElementStyle.PROP_BORDER
| RNSharedElementStyle.PROP_BACKGROUND_COLOR
| RNSharedElementStyle.PROP_SCALETYPE)) != 0) {
//Log.d(LOG_TAG, "drawableChanged, viewType: " + viewType + ", changes: " + mStyle.compare(style));
invalidated = true;
} else {
Expand All @@ -94,8 +100,8 @@ ViewType update(
break;
case PLAIN:
if ((mStyle.compare(style) &
(RNSharedElementStyle.PROP_BORDER
| RNSharedElementStyle.PROP_BACKGROUND_COLOR)) != 0) {
(RNSharedElementStyle.PROP_BORDER
| RNSharedElementStyle.PROP_BACKGROUND_COLOR)) != 0) {
//Log.d(LOG_TAG, "drawableChanged, viewType: " + viewType + ", changes: " + mStyle.compare(style));
invalidated = true;
} else {
Expand Down Expand Up @@ -156,9 +162,9 @@ public void getOutline(Outline outline) {
return;
}
if ((mStyle.borderTopLeftRadius == 0) &&
(mStyle.borderTopRightRadius == 0) &&
(mStyle.borderBottomLeftRadius == 0) &&
(mStyle.borderBottomRightRadius == 0)) {
(mStyle.borderTopRightRadius == 0) &&
(mStyle.borderBottomLeftRadius == 0) &&
(mStyle.borderBottomRightRadius == 0)) {
outline.setRect(getBounds());
return;
}
Expand All @@ -170,18 +176,18 @@ public void getOutline(Outline outline) {
}
float extraRadiusForOutline = mStyle.borderWidth / 2f;
mPathForBorderRadiusOutline.addRoundRect(
new RectF(getBounds()),
new float[]{
mStyle.borderTopLeftRadius + extraRadiusForOutline,
mStyle.borderTopLeftRadius + extraRadiusForOutline,
mStyle.borderTopRightRadius + extraRadiusForOutline,
mStyle.borderTopRightRadius + extraRadiusForOutline,
mStyle.borderBottomRightRadius + extraRadiusForOutline,
mStyle.borderBottomRightRadius + extraRadiusForOutline,
mStyle.borderBottomLeftRadius + extraRadiusForOutline,
mStyle.borderBottomLeftRadius + extraRadiusForOutline
},
Path.Direction.CW
new RectF(getBounds()),
new float[]{
mStyle.borderTopLeftRadius + extraRadiusForOutline,
mStyle.borderTopLeftRadius + extraRadiusForOutline,
mStyle.borderTopRightRadius + extraRadiusForOutline,
mStyle.borderTopRightRadius + extraRadiusForOutline,
mStyle.borderBottomRightRadius + extraRadiusForOutline,
mStyle.borderBottomRightRadius + extraRadiusForOutline,
mStyle.borderBottomLeftRadius + extraRadiusForOutline,
mStyle.borderBottomLeftRadius + extraRadiusForOutline
},
Path.Direction.CW
);
outline.setConvexPath(mPathForBorderRadiusOutline);
}
Expand Down Expand Up @@ -249,10 +255,10 @@ private void drawReactImageView(Canvas canvas) {
roundingParams.setBorderWidth(style.borderWidth);
roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
roundingParams.setCornersRadii(
style.borderTopLeftRadius,
style.borderTopRightRadius,
style.borderBottomRightRadius,
style.borderBottomLeftRadius
style.borderTopLeftRadius,
style.borderTopRightRadius,
style.borderBottomRightRadius,
style.borderBottomLeftRadius
);
hierarchy.setRoundingParams(roundingParams);
hierarchy.setBackgroundImage(null);
Expand Down
Expand Up @@ -12,38 +12,38 @@

@ReactModule(name = RNSharedElementModule.MODULE_NAME)
public class RNSharedElementModule extends ReactContextBaseJavaModule {
public static final String MODULE_NAME = "RNSharedElementTransition";
static String LOG_TAG = "RNSharedElementModule";

private RNSharedElementNodeManager mNodeManager;

public RNSharedElementModule(ReactApplicationContext reactContext) {
super(reactContext);
mNodeManager = new RNSharedElementNodeManager(reactContext);
}

@Override
public String getName() {
return MODULE_NAME;
}

RNSharedElementNodeManager getNodeManager() {
return mNodeManager;
}

@ReactMethod
public void configure(final ReadableMap config, final Promise promise) {

// Store a reference to the native view manager in the node-manager.
// This is done so that we can efficiently resolve a view when the
// start- and end props are set on the Transition view.
final ReactApplicationContext context = getReactApplicationContext();
final UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
uiManager.prependUIBlock(new UIBlock() {
@Override
public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
mNodeManager.setNativeViewHierarchyManager(nativeViewHierarchyManager);
}
});
}
public static final String MODULE_NAME = "RNSharedElementTransition";
static String LOG_TAG = "RNSharedElementModule";

private RNSharedElementNodeManager mNodeManager;

public RNSharedElementModule(ReactApplicationContext reactContext) {
super(reactContext);
mNodeManager = new RNSharedElementNodeManager(reactContext);
}

@Override
public String getName() {
return MODULE_NAME;
}

RNSharedElementNodeManager getNodeManager() {
return mNodeManager;
}

@ReactMethod
public void configure(final ReadableMap config, final Promise promise) {

// Store a reference to the native view manager in the node-manager.
// This is done so that we can efficiently resolve a view when the
// start- and end props are set on the Transition view.
final ReactApplicationContext context = getReactApplicationContext();
final UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
uiManager.prependUIBlock(new UIBlock() {
@Override
public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
mNodeManager.setNativeViewHierarchyManager(nativeViewHierarchyManager);
}
});
}
}