diff --git a/android/app/src/main/java/com/rnnewarchitectureapp/components/AnswerViewer.java b/android/app/src/main/java/com/rnnewarchitectureapp/components/AnswerViewer.java new file mode 100644 index 00000000..b5025fb7 --- /dev/null +++ b/android/app/src/main/java/com/rnnewarchitectureapp/components/AnswerViewer.java @@ -0,0 +1,22 @@ +package com.rnnewarchitectureapp.components; + +import android.content.Context; +import android.util.AttributeSet; + +import androidx.annotation.Nullable; + +public class AnswerViewer extends androidx.appcompat.widget.AppCompatTextView { + + public AnswerViewer(Context context) { + super(context); + } + + public AnswerViewer(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public AnswerViewer(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + +} \ No newline at end of file diff --git a/android/app/src/main/java/com/rnnewarchitectureapp/components/AnswerViewerManager.java b/android/app/src/main/java/com/rnnewarchitectureapp/components/AnswerViewerManager.java new file mode 100644 index 00000000..1ed4a3ac --- /dev/null +++ b/android/app/src/main/java/com/rnnewarchitectureapp/components/AnswerViewerManager.java @@ -0,0 +1,68 @@ +package com.rnnewarchitectureapp.components; + +import android.graphics.Color; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.facebook.react.bridge.ReadableArray; +import com.facebook.react.module.annotations.ReactModule; +import com.facebook.react.uimanager.SimpleViewManager; +import com.facebook.react.uimanager.ThemedReactContext; +import com.facebook.react.uimanager.ViewManagerDelegate; +import com.facebook.react.uimanager.annotations.ReactProp; +import com.facebook.react.viewmanagers.AnswerViewerManagerDelegate; +import com.facebook.react.viewmanagers.AnswerViewerManagerInterface; + +@ReactModule(name = AnswerViewerManager.REACT_CLASS) +public class AnswerViewerManager extends SimpleViewManager + implements AnswerViewerManagerInterface { + + public static final String REACT_CLASS = "AnswerViewer"; + + private final ViewManagerDelegate mDelegate; + + public AnswerViewerManager() { + mDelegate = new AnswerViewerManagerDelegate<>(this); + } + + @Nullable + @Override + protected ViewManagerDelegate getDelegate() { + return mDelegate; + } + + @NonNull + @Override + public String getName() { + return REACT_CLASS; + } + + @NonNull + @Override + protected AnswerViewer createViewInstance(@NonNull ThemedReactContext reactContext) { + return new AnswerViewer(reactContext); + } + + @Override + @ReactProp(name = "color") + public void setColor(AnswerViewer view, @Nullable String value) { + view.setTextColor(Color.parseColor(value)); + } + + @Override + @ReactProp(name = "step", defaultInt = 0) + public void setStep(AnswerViewer view, int value) { + view.setText("Step: " + value); + } + + @Override + public void changeBackgroundColor(AnswerViewer view, String value) { + view.setBackgroundColor(Color.parseColor(value)); + } + + @Override + public void receiveCommand(@NonNull AnswerViewer root, String commandId, @Nullable ReadableArray args) { + mDelegate.receiveCommand(root, commandId, args); + } +} \ No newline at end of file