Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Expo SDK 44 #1220

Merged
merged 11 commits into from
May 12, 2022
Merged
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ enableGlobalCache: true
lockfileFilename: yarn2.lock

nodeLinker: node-modules
nmMode: hardlinks-local

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
Expand Down
3 changes: 2 additions & 1 deletion modules/chat/client-react/index.native.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { createStackNavigator, NavigationScreenConfigProps } from 'react-navigation';
import { NavigationScreenConfigProps } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';

import ClientModule from '@gqlapp/module-client-react-native';
import { translate } from '@gqlapp/i18n-client-react';
Expand Down
35 changes: 14 additions & 21 deletions modules/contact/client-react/index.native.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { createStackNavigator, NavigationScreenConfigProps } from 'react-navigation';

import ClientModule from '@gqlapp/module-client-react-native';
import { translate } from '@gqlapp/i18n-client-react';
Expand All @@ -12,26 +11,20 @@ const HeaderTitleWithI18n = translate('contact')(HeaderTitle);

export default new ClientModule({
drawerItem: [
{
Contact: {
screen: createStackNavigator({
Contact: {
screen: Contact,
navigationOptions: ({ navigation }: NavigationScreenConfigProps) => ({
headerTitle: <HeaderTitleWithI18n i18nKey="title" style="subTitle" />,
headerLeft: (
<IconButton iconName="menu" iconSize={32} iconColor="#0275d8" onPress={() => navigation.openDrawer()} />
),
headerStyle: { backgroundColor: '#fff' },
headerForceInset: {}
})
}
}),
navigationOptions: {
drawerLabel: <HeaderTitleWithI18n />
}
}
}
Drawer => (
<Drawer.Screen
name="Contact"
component={Contact}
options={({ navigation }) => ({
headerTitle: () => <HeaderTitleWithI18n i18nKey="title" style="subTitle" />,
headerLeft: () => (
<IconButton iconName="menu" iconSize={32} iconColor="#0275d8" onPress={() => navigation.openDrawer()} />
),
headerStyle: { backgroundColor: '#fff' },
drawerLabel: () => <HeaderTitleWithI18n />
})}
/>
)
],
localization: [{ ns: 'contact', resources }]
});
10 changes: 8 additions & 2 deletions modules/core/client-react-native/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { LogBox } from 'react-native';
import { ApolloProvider } from 'react-apollo';
import { createStore, combineReducers } from 'redux';
import { Provider } from 'react-redux';
Expand All @@ -17,12 +18,17 @@ interface MainProps {
}

export default class Main extends React.Component<MainProps> {
public componentDidMount() {
LogBox.ignoreLogs(['Animated: `useNativeDriver`']);
}

public render() {
const { hostname } = url.parse(__API_URL__);
const { modules } = this.props;
const manifest = JSON.parse(this.props.exp.manifestString);
const apiUrl =
this.props.exp.manifest.bundleUrl && hostname === 'localhost'
? `${protocol}//${url.parse(this.props.exp.manifest.bundleUrl).hostname}:${port}${pathname}`
manifest.bundleUrl && hostname === 'localhost'
? `${protocol}//${url.parse(manifest.bundleUrl).hostname}:${port}${pathname}`
: __API_URL__;
const store = createStore(
Object.keys(modules.reducers).length > 0
Expand Down
5 changes: 3 additions & 2 deletions modules/core/client-react-native/AwakeInDevApp.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AppLoading, registerRootComponent } from 'expo';
import { registerRootComponent } from 'expo';
import AppLoading from 'expo-app-loading';
import Constants from 'expo-constants';
import * as Font from 'expo-font';
import { activateKeepAwake, deactivateKeepAwake } from 'expo-keep-awake';
Expand Down Expand Up @@ -37,7 +38,7 @@ export default async (modules: ClientModule) => {

public render() {
if (!this.state.isReady) {
return <AppLoading startAsync={null} onError={null} onFinish={null} />;
return <AppLoading />;
}

return React.createElement(
Expand Down
35 changes: 14 additions & 21 deletions modules/counter/client-react/index.native.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { createStackNavigator } from 'react-navigation';

import { translate } from '@gqlapp/i18n-client-react';
import { HeaderTitle, IconButton } from '@gqlapp/look-client-react-native';
Expand All @@ -13,26 +12,20 @@ const HeaderTitleWithI18n = translate('counter')(HeaderTitle);

export default new ClientModule(counters, {
drawerItem: [
{
Counter: {
screen: createStackNavigator({
Counter: {
screen: Counter,
navigationOptions: ({ navigation }: any) => ({
headerTitle: <HeaderTitleWithI18n i18nKey="title" style="subTitle" />,
headerLeft: (
<IconButton iconName="menu" iconSize={32} iconColor="#0275d8" onPress={() => navigation.openDrawer()} />
),
headerStyle: { backgroundColor: '#fff' },
headerForceInset: {}
})
}
}),
navigationOptions: {
drawerLabel: <HeaderTitleWithI18n i18nKey="title" />
}
}
}
Drawer => (
<Drawer.Screen
name="Counter"
component={Counter}
options={({ navigation }) => ({
headerTitle: () => <HeaderTitleWithI18n i18nKey="title" style="subTitle" />,
headerLeft: () => (
<IconButton iconName="menu" iconSize={32} iconColor="#0275d8" onPress={() => navigation.openDrawer()} />
),
headerStyle: { backgroundColor: '#fff' },
drawerLabel: () => <HeaderTitleWithI18n i18nKey="title" />
})}
/>
)
],
localization: [{ ns: 'counter', resources }]
});
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,15 @@ const ServerCounter = () => {
});
}

const {
error,
data: { serverCounter },
loading
} = useQuery(COUNTER_QUERY);
const query = useQuery(COUNTER_QUERY);

if (error) {
throw new Error(String(error));
if (query.error) {
throw new Error(String(query.error));
}

return (
<ServerCounterView counter={serverCounter} loading={loading}>
<IncreaseButtonContainer increaseAmount={1} counter={serverCounter} />
<ServerCounterView counter={query?.data?.serverCounter} loading={query.loading}>
<IncreaseButtonContainer increaseAmount={1} counter={query?.data?.serverCounter} />
</ServerCounterView>
);
};
Expand Down
22 changes: 12 additions & 10 deletions modules/i18n/client-react/i18nModule.native.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { default as i18next } from 'i18next';
import i18next from 'i18next';
import { I18nextProvider } from 'react-i18next';

import ClientModule from '@gqlapp/module-client-react-native';
Expand All @@ -17,19 +17,21 @@ const I18nProvider = ({ i18n, children }: any) => {
);
};

const LanguagePickerScreen = (): any => null;

const langPicker =
settings.i18n.enabled && settings.i18n.langPickerRender
? new ClientModule({
drawerItem: [
{
LangPicker: {
screen: (): any => null,
navigationOptions: {
drawerLabel: <LanguagePicker key={'picker'} i18n={i18next} />
},
skip: true
}
}
Drawer => (
<Drawer.Screen
name="Language Picker"
component={LanguagePickerScreen}
options={() => ({
drawerLabel: () => <LanguagePicker key={'picker'} i18n={i18next} />
})}
/>
)
]
})
: undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { SafeAreaView, ScrollView, StyleSheet } from 'react-native';
import { DrawerItems } from 'react-navigation';
import { DrawerItems } from '@react-navigation/drawer';

const styles = StyleSheet.create({
container: {
Expand Down
19 changes: 11 additions & 8 deletions modules/module/client-react-native/ClientModule.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { NavigationRouteConfig } from 'react-navigation';
import React from 'react';

import BaseModule, { BaseModuleShape } from '@gqlapp/module-client-react';

import { merge } from 'lodash';
import { createDrawerNavigator } from '@react-navigation/drawer';

/**
* React Native feature modules interface.
*/
export interface ClientModuleShape extends BaseModuleShape {
// Item list for React Navigation drawer
drawerItem?: NavigationRouteConfig[];
// Screen list for React Navigation Drawer
drawerItem?: Array<(Drawer: ReturnType<typeof createDrawerNavigator>) => React.ReactElement<any>>;
}

interface ClientModule extends ClientModuleShape {}
Expand All @@ -29,10 +28,14 @@ class ClientModule extends BaseModule {
}

/**
* @returns item list for React Navigation drawer
* @returns screen list for React Navigation Drawer
*/
get drawerItems() {
return merge({}, ...(this.drawerItem || []));
public createDrawerItems(Drawer: ReturnType<typeof createDrawerNavigator>) {
return (this.drawerItem || [])
.map(x => x(Drawer))
.map((component: React.ReactElement<any>, idx: number, items: Array<React.ReactElement<any>>) =>
React.cloneElement(component, { key: component.key || idx + items.length })
);
}
}

Expand Down
33 changes: 13 additions & 20 deletions modules/pagination/client-react/index.native.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { createStackNavigator } from 'react-navigation';
import { translate } from '@gqlapp/i18n-client-react';
import { HeaderTitle, IconButton } from '@gqlapp/look-client-react-native';
import ClientModule from '@gqlapp/module-client-react-native';
Expand All @@ -11,25 +10,19 @@ const HeaderTitleWithI18n = translate('pagination')(HeaderTitle);

export default new ClientModule({
drawerItem: [
{
Pagination: {
screen: createStackNavigator({
Pagination: {
screen: PaginationDemo,
navigationOptions: ({ navigation }) => ({
headerTitle: <HeaderTitleWithI18n style="subTitle" />,
headerLeft: (
<IconButton iconName="menu" iconSize={32} iconColor="#0275d8" onPress={() => navigation.openDrawer()} />
),
headerForceInset: {}
})
}
}),
navigationOptions: {
drawerLabel: <HeaderTitleWithI18n />
}
}
}
Drawer => (
<Drawer.Screen
name="Pagination"
component={PaginationDemo}
options={({ navigation }) => ({
headerTitle: () => <HeaderTitleWithI18n style="subTitle" />,
headerLeft: () => (
<IconButton iconName="menu" iconSize={32} iconColor="#0275d8" onPress={() => navigation.openDrawer()} />
),
drawerLabel: () => <HeaderTitleWithI18n />
})}
/>
)
],
localization: [{ ns: 'pagination', resources }]
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { createStackNavigator } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';

import { translate } from '@gqlapp/i18n-client-react';
import { HeaderTitle, IconButton } from '@gqlapp/look-client-react-native';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import {
StyleSheet,
FlatList,
ScrollView,
Text,
View,
Keyboard,
Expand Down Expand Up @@ -95,9 +96,9 @@ class PostCommentsView extends React.PureComponent {
comment={comment}
/>
{comments.length > 0 && (
<View style={styles.list} keyboardDismissMode="on-drag">
<ScrollView horizontal style={styles.list} keyboardDismissMode="on-drag">
<FlatList data={comments} keyExtractor={this.keyExtractor} renderItem={renderItem} />
</View>
</ScrollView>
)}
</View>
);
Expand Down
14 changes: 5 additions & 9 deletions modules/post/client-react/components/PostEditView.native.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const onSubmit = (post, editPost) => values => {
Keyboard.dismiss();
};

const PostEditView = ({ loading, post, navigation, subscribeToMore, editPost, t }) => {
const PostEditView = ({ loading, post, route, subscribeToMore, editPost, t }) => {
let postObj = post;
// if new post was just added read it from router
if (!postObj && navigation.state) {
postObj = navigation.state.params.post;
if (!postObj && route.params) {
postObj = route.params.post;
}

if (loading && !postObj) {
Expand All @@ -28,11 +28,7 @@ const PostEditView = ({ loading, post, navigation, subscribeToMore, editPost, t
<ScrollView keyboardDismissMode="none" keyboardShouldPersistTaps="always">
<PostForm onSubmit={onSubmit(postObj, editPost)} post={post} />
{postObj && (
<PostComments
postId={navigation.state.params.id}
comments={postObj.comments}
subscribeToMore={subscribeToMore}
/>
<PostComments postId={route.params.id} comments={postObj.comments} subscribeToMore={subscribeToMore} />
)}
<KeyboardSpacer />
</ScrollView>
Expand All @@ -45,7 +41,7 @@ PostEditView.propTypes = {
loading: PropTypes.bool.isRequired,
post: PropTypes.object,
editPost: PropTypes.func.isRequired,
navigation: PropTypes.object.isRequired,
route: PropTypes.object.isRequired,
subscribeToMore: PropTypes.func.isRequired,
t: PropTypes.func
};
Expand Down
4 changes: 2 additions & 2 deletions modules/post/client-react/containers/PostEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export default compose(
let id = 0;
if (props.match) {
id = props.match.params.id;
} else if (props.navigation) {
id = props.navigation.state.params.id;
} else if (props.route) {
id = props.route.params.id;
}

return {
Expand Down
4 changes: 2 additions & 2 deletions modules/post/client-react/containers/PostEdit.web.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export default compose(
let id = 0;
if (props.match) {
id = props.match.params.id;
} else if (props.navigation) {
id = props.navigation.state.params.id;
} else if (props.route) {
id = props.route.params.id;
}

return {
Expand Down