-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fabric] Create the corresponding ViewManager
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
android/app/src/main/java/com/rnnewarchitectureapp/components/AnswerViewer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
android/app/src/main/java/com/rnnewarchitectureapp/components/AnswerViewerManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AnswerViewer> | ||
implements AnswerViewerManagerInterface<AnswerViewer> { | ||
|
||
public static final String REACT_CLASS = "AnswerViewer"; | ||
|
||
private final ViewManagerDelegate<AnswerViewer> mDelegate; | ||
|
||
public AnswerViewerManager() { | ||
mDelegate = new AnswerViewerManagerDelegate<>(this); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
protected ViewManagerDelegate<AnswerViewer> 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); | ||
} | ||
} |