Fabric Android: added ReactUnimplementedView impl

Summary: Similar to iOS, here we provide the basic impl of unimplemented view.

Reviewed By: mdvacca

Differential Revision: D14895706

fbshipit-source-id: 9053edfb2175b370d9070b6921794dbcafa1f37a
This commit is contained in:
Kevin Gozali
2019-04-11 14:23:13 -07:00
committed by Facebook Github Bot
parent 335c39c895
commit e3d3b2cab9
3 changed files with 99 additions and 0 deletions
@@ -0,0 +1,23 @@
load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_target", "rn_android_library")
rn_android_library(
name = "unimplementedview",
srcs = glob(["*.java"]),
is_androidx = True,
provided_deps = [
react_native_dep("third-party/android/support/v4:lib-support-v4"),
react_native_dep("third-party/android/support/v7/appcompat:appcompat"),
],
visibility = [
"PUBLIC",
],
deps = [
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_target("java/com/facebook/react/bridge:bridge"),
react_native_target("java/com/facebook/react/common:common"),
react_native_target("java/com/facebook/react/module/annotations:annotations"),
react_native_target("java/com/facebook/react/touch:touch"),
react_native_target("java/com/facebook/react/uimanager:uimanager"),
react_native_target("java/com/facebook/react/uimanager/annotations:annotations"),
],
)
@@ -0,0 +1,35 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.views.unimplementedview;
import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.widget.LinearLayout;
import androidx.appcompat.widget.AppCompatTextView;
public class ReactUnimplementedView extends LinearLayout {
private AppCompatTextView mTextView;
public ReactUnimplementedView(Context context) {
super(context);
mTextView = new AppCompatTextView(context);
mTextView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
mTextView.setGravity(Gravity.CENTER);
mTextView.setTextColor(Color.WHITE);
setBackgroundColor(0x55ff0000);
setGravity(Gravity.CENTER_HORIZONTAL);
setOrientation(LinearLayout.VERTICAL);
addView(mTextView);
}
public void setName(String name) {
mTextView.setText("'" + name + "' is not Fabric compatible yet.");
}
}
@@ -0,0 +1,41 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.views.unimplementedview;
import static com.facebook.react.views.unimplementedview.ReactUnimplementedViewManager.REACT_CLASS;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.annotations.ReactProp;
import javax.annotation.Nullable;
/**
* ViewManager for {@link ReactUnimplementedView} to represent a component that is not
* yet supported.
*/
@ReactModule(name = ReactUnimplementedViewManager.REACT_CLASS)
public class ReactUnimplementedViewManager extends ViewGroupManager<ReactUnimplementedView> {
public static final String REACT_CLASS = "UnimplementedNativeView";
@Override
protected ReactUnimplementedView createViewInstance(ThemedReactContext reactContext) {
return new ReactUnimplementedView(reactContext);
}
@Override
public String getName() {
return REACT_CLASS;
}
@ReactProp(name = "name")
public void setName(ReactUnimplementedView view, @Nullable String name) {
view.setName(name);
}
}