Skip to content

Commit

Permalink
chore: support for React Native 0.71.0 (#1631)
Browse files Browse the repository at this point in the history
## Description

It seems that autolinking got complete overhaul in 0.71.0 as
`android/app/src/main/jni` directory was deleted -> thus it works
differently for sure now.

Still need to dive into it.

**FabricTestExample**

* [x] Android
* [x] iOS

**TestsExample**

* #1679

**FabricExample**

* #1680

**TODO**: Consider whether to use `com.facebook.react:react-native:+` or
`com.facebook.react:react-native` (without `+`) in
`android/build.gradle` of the library.

AFAIK the former takes highest available version from defined
repositories (should be `node_modules`?), the latter uses version
injected by React Native Gradle Plugin (but I believe it works since
React Native 0.71.0 or 0.70.0 (need to check) -- so version check might
be necessary).


Decided to leave:

```gradle
implementation 'com.facebook.react:react-native:+'
```

in library's `android/build.gradle` due to following reasons: 

* [Android's readme in RN
repo](https://github.com/facebook/react-native/blob/e108e9ebf1e6c52b6eeffeb6c41f842ad95baa0d/android/README.md)
* [Road to 0.71.0
post](reactwg/react-native-releases#41 (reply in thread))

Blocked by:

* ~facebook/react-native#35306
*
~software-mansion/react-native-reanimated#3745
*
~software-mansion/react-native-gesture-handler#2313
(decided to fix version on commit)
* ~`react-native-safe-area-context` - lacks support for RN71~ (created
patch)
* ~`@react-native-community/cli-platform-android` requires this patch:
kkafar/RNS-tester@9edaaa9.
The patch is already merged, but it is not shipped with `react-native`
yet.~

**NOTE**: Example application will handled in separate PR, as there are
problems with detox (it does not support 0.71 yet) and we run CI on that
app.

## Changes

* Updated examples 
* Updated library's build code

## Test code and steps to reproduce

Run example applications

## Checklist

- [ ] Ensured that CI passes
  • Loading branch information
kkafar authored Jan 11, 2023
1 parent f8dfd27 commit bb282b9
Show file tree
Hide file tree
Showing 138 changed files with 12,096 additions and 15,924 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ios-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
workflow_dispatch:
jobs:
test:
runs-on: macos-latest
runs-on: macos-12
timeout-minutes: 40
env:
WORKING_DIRECTORY: Example
Expand Down
3 changes: 2 additions & 1 deletion Example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ const ExampleApp = (): JSX.Element => (
<Stack.Navigator
screenOptions={{
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
}}>
}}
>
<Stack.Screen
name="Main"
options={{ title: '📱 React Native Screens Examples' }}
Expand Down
17 changes: 10 additions & 7 deletions Example/src/screens/Animations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ const NavigateScreen = ({
const Stack = createNativeStackNavigator<StackParamList>();

const App = (): JSX.Element => {
const [stackAnimation, setStackAnimation] = useState<StackAnimation>(
'default'
);
const [stackAnimation, setStackAnimation] =
useState<StackAnimation>('default');
return (
<Stack.Navigator
screenOptions={{
headerHideBackButton: true,
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
}}>
}}
>
<Stack.Screen name="Main" options={{ title: 'Animations' }}>
{({ navigation }) => (
<MainScreen
Expand All @@ -142,7 +142,8 @@ const App = (): JSX.Element => {
name="Push"
options={{
replaceAnimation: 'push',
}}>
}}
>
{({ navigation }) => (
<ReplaceScreen
navigation={navigation}
Expand All @@ -154,7 +155,8 @@ const App = (): JSX.Element => {
name="Pop"
options={{
replaceAnimation: 'pop',
}}>
}}
>
{({ navigation }) => (
<ReplaceScreen
navigation={navigation}
Expand All @@ -166,7 +168,8 @@ const App = (): JSX.Element => {
name="Modal"
options={{
stackPresentation: 'modal',
}}>
}}
>
{({ navigation }) => (
<NavigateScreen
navigation={navigation}
Expand Down
3 changes: 2 additions & 1 deletion Example/src/screens/BottomTabsAndStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ const createStack = (letter: string) => {
headerRight: () => (
<Text testID="bottom-tabs-header-right-id">{letter}</Text>
),
}}>
}}
>
<Stack.Screen name="Details" component={DetailsScreen} />
</Stack.Navigator>
);
Expand Down
14 changes: 8 additions & 6 deletions Example/src/screens/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ const ChatsScreen = ({
nativeBackButtonDismissalEnabled: true,
headerTopInsetEnabled: false,
headerHideBackButton: true,
}}>
}}
>
<NestedStack.Screen name="Privacy" component={PrivacyScreen} />
<NestedStack.Screen name="Options" component={OptionsScreen} />
</NestedStack.Navigator>
Expand Down Expand Up @@ -250,20 +251,21 @@ const Stack = createNativeStackNavigator<StackParamList>();
const NestedStack = createNativeStackNavigator<StackParamList>();

const App = (): JSX.Element => {
const [stackAnimation, setStackAnimation] = useState<StackAnimation>(
'default'
);
const [stackAnimation, setStackAnimation] =
useState<StackAnimation>('default');

return (
<ToastProvider>
<Stack.Navigator
screenOptions={{
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
nativeBackButtonDismissalEnabled: true,
}}>
}}
>
<Stack.Screen
name="Main"
options={{ title: 'Events', headerHideBackButton: true }}>
options={{ title: 'Events', headerHideBackButton: true }}
>
{({ navigation }) => (
<MainScreen
navigation={navigation}
Expand Down
6 changes: 4 additions & 2 deletions Example/src/screens/Gestures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ const DetailsScreen = ({ navigation }: DetailsScreenProps): JSX.Element => {
left: startValue,
width: endValue - startValue,
height: bottomValue - topValue,
}}>
}}
>
<Text style={styles.heading}>Swipe here!</Text>
<Text>
This view presents where you can currently swipe while using the
Expand All @@ -171,7 +172,8 @@ const App = (): JSX.Element => (
screenOptions={{
headerHideBackButton: true,
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
}}>
}}
>
<Stack.Screen
name="Main"
component={MainScreen}
Expand Down
6 changes: 4 additions & 2 deletions Example/src/screens/HeaderOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ const SettingsScreen = ({ navigation }: SettingsScreenProps): JSX.Element => {
return (
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.container}>
style={styles.container}
>
<SettingsInput
label="Header title"
value={headerTitle}
Expand Down Expand Up @@ -142,7 +143,8 @@ const App = (): JSX.Element => (
screenOptions={{
headerHideBackButton: true,
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
}}>
}}
>
<Stack.Screen
name="Main"
options={{
Expand Down
3 changes: 2 additions & 1 deletion Example/src/screens/Modals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ const App = (): JSX.Element => (
screenOptions={{
headerHideBackButton: true,
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
}}>
}}
>
<Stack.Screen
name="Main"
component={MainScreen}
Expand Down
8 changes: 4 additions & 4 deletions Example/src/screens/Orientation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ interface FirstScreenProps {
}

const FirstScreen = ({ navigation }: FirstScreenProps): JSX.Element => {
const [screenOrientation, setScreenOrientation] = useState<ScreenOrientation>(
'default'
);
const [screenOrientation, setScreenOrientation] =
useState<ScreenOrientation>('default');

useLayoutEffect(() => {
navigation.setOptions({
Expand Down Expand Up @@ -79,7 +78,8 @@ const App = (): JSX.Element => (
screenOptions={{
headerHideBackButton: true,
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
}}>
}}
>
<Stack.Screen
name="First"
component={FirstScreen}
Expand Down
24 changes: 12 additions & 12 deletions Example/src/screens/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,15 @@ const MainScreen = ({ navigation }: MainScreenProps): JSX.Element => {
const [placeholder, setPlaceholder] = useState('Search for something...');
const [barTintColor, setBarTintColor] = useState<BarTintColor>('white');
const [hintTextColor, setHintTextColor] = useState<BarTintColor>('orange');
const [headerIconColor, setHeaderIconColor] = useState<BarTintColor>(
'orange'
);
const [shouldShowHintSearchIcon, setShouldShowHintSearchIcon] = useState(
true
);
const [headerIconColor, setHeaderIconColor] =
useState<BarTintColor>('orange');
const [shouldShowHintSearchIcon, setShouldShowHintSearchIcon] =
useState(true);
const [hideWhenScrolling, setHideWhenScrolling] = useState(false);
const [obscureBackground, setObscureBackground] = useState(false);
const [hideNavigationBar, setHideNavigationBar] = useState(false);
const [autoCapitalize, setAutoCapitalize] = useState<AutoCapitalize>(
'sentences'
);
const [autoCapitalize, setAutoCapitalize] =
useState<AutoCapitalize>('sentences');
const [inputType, setInputType] = useState<InputType>('text');

useLayoutEffect(() => {
Expand Down Expand Up @@ -115,7 +112,8 @@ const MainScreen = ({ navigation }: MainScreenProps): JSX.Element => {
<ScrollView
style={styles.container}
contentInsetAdjustmentBehavior="automatic"
keyboardDismissMode="on-drag">
keyboardDismissMode="on-drag"
>
<SettingsInput
label="Placeholder"
value={placeholder}
Expand Down Expand Up @@ -223,7 +221,8 @@ const SearchScreen = ({ navigation }: SearchScreenProps) => {
return (
<ScrollView
contentInsetAdjustmentBehavior="automatic"
keyboardDismissMode="on-drag">
keyboardDismissMode="on-drag"
>
{places
.filter(
(item) => item.toLowerCase().indexOf(search.toLowerCase()) !== -1
Expand All @@ -247,7 +246,8 @@ const App = (): JSX.Element => (
screenOptions={{
headerHideBackButton: true,
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
}}>
}}
>
<Stack.Screen
name="Main"
component={MainScreen}
Expand Down
3 changes: 2 additions & 1 deletion Example/src/screens/SimpleNativeStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ const App = (): JSX.Element => (
screenOptions={{
headerHideBackButton: true,
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
}}>
}}
>
<Stack.Screen
name="Main"
component={MainScreen}
Expand Down
9 changes: 6 additions & 3 deletions Example/src/screens/StackPresentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const MainScreen = ({ navigation }: MainScreenProps): JSX.Element => {
return (
<ScrollView
style={{ ...styles.container, backgroundColor: 'thistle' }}
testID="stack-presentation-root-scroll-view">
testID="stack-presentation-root-scroll-view"
>
<Button
title="push"
onPress={() => navigation.navigate('Push')}
Expand Down Expand Up @@ -117,7 +118,8 @@ const FullScreenModalScreen = ({
<View style={{ flex: 1 }}>
<ImageBackground
style={styles.image}
source={require('../assets/trees.jpg')}>
source={require('../assets/trees.jpg')}
>
<Button
testID="stack-presentation-fullscreen-modal-go-back-button"
title="Go back"
Expand All @@ -134,7 +136,8 @@ const App = (): JSX.Element => (
screenOptions={{
headerHideBackButton: true,
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
}}>
}}
>
<Stack.Screen
name="Main"
component={MainScreen}
Expand Down
3 changes: 2 additions & 1 deletion Example/src/screens/StackReactNavigation4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class DetailsScreen extends React.Component<{
...styles.container,
backgroundColor:
colors[Math.floor(Math.random() * Math.floor(colors.length))],
}}>
}}
>
<Text style={styles.text}>Details Screen</Text>
<Button
title="Go to Details... again"
Expand Down
8 changes: 4 additions & 4 deletions Example/src/screens/StatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ interface FirstScreenProps {
const FirstScreen = ({ navigation }: FirstScreenProps): JSX.Element => {
const [statusBarStyle, setStatusBarStyle] = useState<StatusBarStyle>('auto');
const [statusBarHidden, setStatusBarHidden] = useState(false);
const [statusBarAnimation, setStatusBarAnimation] = useState<
StatusBarAnimation
>('fade');
const [statusBarAnimation, setStatusBarAnimation] =
useState<StatusBarAnimation>('fade');
const [statusBarTranslucent, setStatusBarTranslucent] = useState(true);
const [statusBarColor, setStatusBarColor] = useState('gray');

Expand Down Expand Up @@ -117,7 +116,8 @@ const App = (): JSX.Element => (
},
headerHideBackButton: true,
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
}}>
}}
>
<Stack.Screen
name="First"
component={FirstScreen}
Expand Down
6 changes: 4 additions & 2 deletions Example/src/shared/Choose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ export const Choose = (): JSX.Element => {
<View style={styles.row}>
<TouchableOpacity
style={{ ...styles.button, backgroundColor: 'dodgerblue' }}
onPress={() => navigation.goBack()}>
onPress={() => navigation.goBack()}
>
<Text style={styles.buttonText}>Blue pill</Text>
</TouchableOpacity>
<TouchableOpacity
style={{ ...styles.button, backgroundColor: 'crimson' }}
onPress={() => navigation.goBack()}>
onPress={() => navigation.goBack()}
>
<Text style={styles.buttonText}>Red pill</Text>
</TouchableOpacity>
</View>
Expand Down
3 changes: 2 additions & 1 deletion Example/src/shared/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const Dialog = (): JSX.Element => {
<Text style={styles.heading}>Hey! Sign up for our newsletter!</Text>
<TouchableOpacity
style={{ ...styles.button }}
onPress={() => navigation.goBack()}>
onPress={() => navigation.goBack()}
>
<Text style={styles.buttonText}>Please no.</Text>
</TouchableOpacity>
</View>
Expand Down
6 changes: 4 additions & 2 deletions Example/src/shared/SettingsPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export function SettingsPicker<T extends string>({
return (
<TouchableOpacity
style={{ ...styles.container, ...style }}
onPress={() => setIsOpen(!isOpen)}>
onPress={() => setIsOpen(!isOpen)}
>
<Text testID={testID} style={styles.label}>{`${label}: ${value}`}</Text>
{isOpen
? items.map((item) => (
Expand All @@ -33,7 +34,8 @@ export function SettingsPicker<T extends string>({
item === value
? { ...styles.item, fontWeight: 'bold' }
: styles.item
}>
}
>
{item}
</Text>
</TouchableOpacity>
Expand Down
3 changes: 2 additions & 1 deletion Example/src/shared/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const Toast = ({
return (
<TouchableOpacity
style={{ ...styles.container, ...style }}
onPress={() => remove(id)}>
onPress={() => remove(id)}
>
<View style={{ ...styles.alert, backgroundColor }}>
<Text style={styles.text}>
{`${index + 1}. `}
Expand Down
6 changes: 0 additions & 6 deletions FabricExample/.buckconfig

This file was deleted.

Loading

0 comments on commit bb282b9

Please sign in to comment.