Skip to content

Commit 79d3f5f

Browse files
authored
fix: android border styles fix (#78)
1 parent 8a3460d commit 79d3f5f

File tree

5 files changed

+33
-30
lines changed

5 files changed

+33
-30
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.reactnativea11y;
22

33
import android.view.ViewGroup;
4-
import com.facebook.react.uimanager.ViewGroupManager;
4+
import com.facebook.react.views.view.ReactViewManager;
55

6-
public abstract class RCA11yFocusWrapperManagerSpec<T extends ViewGroup> extends ViewGroupManager<T> {
6+
public abstract class RCA11yFocusWrapperManagerSpec<T extends ViewGroup> extends ReactViewManager {
77
public abstract void setCanBeFocused(T wrapper, boolean canBeFocused);
88
}

android/src/main/java/com/reactnativea11y/RCA11yFocusWrapperManager.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
import com.facebook.react.uimanager.annotations.ReactProp;
1313
import java.util.Map;
1414
import com.facebook.react.uimanager.UIManagerHelper;
15+
import com.facebook.react.views.view.ReactViewGroup;
1516
import com.reactnativea11y.events.FocusChangeEvent;
1617
import com.reactnativea11y.events.KeyPressDownEvent;
1718
import com.reactnativea11y.events.KeyPressUpEvent;
1819
import com.reactnativea11y.services.KeyboardKeyPressHandler;
1920

20-
public class RCA11yFocusWrapperManager extends com.reactnativea11y.RCA11yFocusWrapperManagerSpec<RCA11yFocusWrapper> {
21+
public class RCA11yFocusWrapperManager extends com.reactnativea11y.RCA11yFocusWrapperManagerSpec<ReactViewGroup> {
2122

2223
public static final String NAME = "RCA11yFocusWrapper";
2324
private KeyboardKeyPressHandler keyboardKeyPressHandler;
@@ -28,13 +29,14 @@ public String getName() {
2829
}
2930

3031
@Override
31-
public RCA11yFocusWrapper createViewInstance(ThemedReactContext context) {
32+
public ReactViewGroup createViewInstance(ThemedReactContext context) {
33+
3234
this.keyboardKeyPressHandler = new KeyboardKeyPressHandler();
33-
return new RCA11yFocusWrapper(context);
35+
return super.createViewInstance(context);
3436
}
3537

3638

37-
private void onKeyPressHandler(RCA11yFocusWrapper viewGroup, int keyCode, KeyEvent keyEvent, ThemedReactContext reactContext) {
39+
private void onKeyPressHandler(ReactViewGroup viewGroup, int keyCode, KeyEvent keyEvent, ThemedReactContext reactContext) {
3840
KeyboardKeyPressHandler.PressInfo pressInfo = keyboardKeyPressHandler.getEventsFromKeyPress(keyCode,keyEvent);
3941

4042
if(pressInfo.firePressDownEvent) {
@@ -50,7 +52,7 @@ private void onKeyPressHandler(RCA11yFocusWrapper viewGroup, int keyCode, KeyEve
5052
}
5153

5254
@Override
53-
protected void addEventEmitters(final ThemedReactContext reactContext, RCA11yFocusWrapper viewGroup) {
55+
protected void addEventEmitters(final ThemedReactContext reactContext, ReactViewGroup viewGroup) {
5456
viewGroup.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
5557
@Override
5658
public void onChildViewAdded(View parent, View child) {
@@ -72,8 +74,6 @@ public void onChildViewRemoved(View parent, View child) {
7274
});
7375
}
7476

75-
76-
7777
@Nullable
7878
@Override
7979
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
@@ -91,7 +91,7 @@ public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
9191

9292
@Override
9393
@ReactProp(name = "canBeFocused", defaultBoolean = true)
94-
public void setCanBeFocused(RCA11yFocusWrapper wrapper, boolean canBeFocused) {
94+
public void setCanBeFocused(ReactViewGroup wrapper, boolean canBeFocused) {
9595
wrapper.setClickable(canBeFocused);
9696
wrapper.setFocusable(canBeFocused);
9797
wrapper.setDescendantFocusability(
Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,19 @@
11
package com.reactnativea11y;
22

3-
import android.view.ViewGroup;
4-
53
import androidx.annotation.Nullable;
64

75
import com.facebook.react.uimanager.ViewManagerDelegate;
86
import com.facebook.react.viewmanagers.RCA11yFocusWrapperManagerDelegate;
97
import com.facebook.react.viewmanagers.RCA11yFocusWrapperManagerInterface;
8+
import com.facebook.react.views.view.ReactViewGroup;
9+
import com.facebook.react.views.view.ReactViewManager;
1010
import com.facebook.soloader.SoLoader;
11-
import com.facebook.react.uimanager.ViewGroupManager;
1211

1312

14-
public abstract class RCA11yFocusWrapperManagerSpec<T extends ViewGroup> extends ViewGroupManager<T> implements RCA11yFocusWrapperManagerInterface<T> {
13+
public abstract class RCA11yFocusWrapperManagerSpec<T extends ReactViewGroup> extends ReactViewManager implements RCA11yFocusWrapperManagerInterface<T> {
1514
static {
1615
if (BuildConfig.CODEGEN_MODULE_REGISTRATION != null) {
1716
SoLoader.loadLibrary(BuildConfig.CODEGEN_MODULE_REGISTRATION);
1817
}
1918
}
20-
21-
private final ViewManagerDelegate<T> mDelegate;
22-
23-
public RCA11yFocusWrapperManagerSpec() {
24-
mDelegate = new RCA11yFocusWrapperManagerDelegate(this);
25-
}
26-
27-
@Nullable
28-
@Override
29-
protected ViewManagerDelegate<T> getDelegate() {
30-
return mDelegate;
31-
}
3219
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.reactnativea11y;
22

33
import android.view.ViewGroup;
4-
import com.facebook.react.uimanager.ViewGroupManager;
4+
import com.facebook.react.views.view.ReactViewManager;
55

6-
public abstract class RCA11yFocusWrapperManagerSpec<T extends ViewGroup> extends ViewGroupManager<T> {
6+
public abstract class RCA11yFocusWrapperManagerSpec<T extends ViewGroup> extends ReactViewManager {
77
public abstract void setCanBeFocused(T wrapper, boolean canBeFocused);
88
}

examples/A11yNewArch/src/components/Button/Button.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@ type Props = {
1212
};
1313

1414
export const Button = React.forwardRef<View, Props>(
15-
({ title, onPress, style, focusStyle, canBeFocused = true, accessible = true }, ref) => {
15+
(
16+
{
17+
title,
18+
onPress,
19+
style,
20+
focusStyle,
21+
canBeFocused = true,
22+
accessible = true,
23+
},
24+
ref,
25+
) => {
1626
const fStyle = ({ focused }: { focused: boolean }) =>
1727
focused && styles.focus;
1828

@@ -49,10 +59,16 @@ const styles = StyleSheet.create({
4959
container: {
5060
padding: 10,
5161
borderColor: "#111",
62+
borderWidth: 2,
5263
borderRadius: 50,
5364
minWidth: 100,
5465
},
55-
font: { fontSize: 18, textAlign:'center', fontWeight: "bold", color: "#111" },
66+
font: {
67+
fontSize: 18,
68+
textAlign: "center",
69+
fontWeight: "bold",
70+
color: "#111",
71+
},
5672
focus: {
5773
backgroundColor: "#aaa",
5874
borderColor: "#eee",

0 commit comments

Comments
 (0)