Skip to content

Commit 20fe4e4

Browse files
authored
chore: include apps directory in format-js script (#4082)
## Description `apps` directory wasn't included in `format-js` script. Closes software-mansion/react-native-screens-labs#785 ## Changes - update `package.json` - applies formatting to `apps` directory ## Before & after - visual documentation N/A ## Test plan N/A ## Checklist - [ ] Included code example that can be used to test this change. - [ ] For visual changes, included screenshots / GIFs / recordings documenting the change. - [ ] For API changes, updated relevant public types. - [ ] Ensured that CI passes
1 parent 88572ae commit 20fe4e4

95 files changed

Lines changed: 1801 additions & 938 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/src/screens/BarButtonItems.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,9 @@ export default function BarButtonItemsExample() {
490490
type: 'action',
491491
icon: {
492492
type: 'templateSource',
493-
templateSource:
494-
require('@assets/search_black.png'),
493+
templateSource: require('@assets/search_black.png'),
495494
},
496-
onPress: () =>
497-
Alert.alert('Sub Image Action pressed'),
495+
onPress: () => Alert.alert('Sub Image Action pressed'),
498496
},
499497
],
500498
},

apps/src/screens/PreventRemove.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import React from 'react';
2-
import { View, StyleSheet, TextInput, Platform, Alert, ScrollView, Text } from 'react-native';
2+
import {
3+
View,
4+
StyleSheet,
5+
TextInput,
6+
Platform,
7+
Alert,
8+
ScrollView,
9+
Text,
10+
} from 'react-native';
311
import { usePreventRemove } from '@react-navigation/native';
412
import {
513
createNativeStackNavigator,
@@ -45,7 +53,7 @@ const PreventRemoveScreen = ({
4553
'Discard changes?',
4654
'You have unsaved changes. Discard them and leave the screen?',
4755
[
48-
{ text: "Don't leave", style: 'cancel', onPress: () => { } },
56+
{ text: "Don't leave", style: 'cancel', onPress: () => {} },
4957
{
5058
text: 'Discard',
5159
style: 'destructive',
@@ -59,8 +67,7 @@ const PreventRemoveScreen = ({
5967
<View style={{ ...styles.container, backgroundColor: 'thistle' }}>
6068
<ScrollView
6169
contentContainerStyle={styles.contentContainer}
62-
keyboardDismissMode="interactive"
63-
>
70+
keyboardDismissMode="interactive">
6471
<TextInput
6572
autoFocus
6673
value={text}

apps/src/screens/StackPresentation.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ const FullScreenModalScreen = ({
160160
navigation,
161161
}: FullScreenModalProps): React.JSX.Element => (
162162
<View style={{ flex: 1 }}>
163-
<ImageBackground
164-
style={styles.image}
165-
source={require('@assets/trees.jpg')}>
163+
<ImageBackground style={styles.image} source={require('@assets/trees.jpg')}>
166164
<Button
167165
testID="stack-presentation-fullscreen-modal-go-back-button"
168166
title="Go back"

apps/src/screens/SwipeBackAnimation.tsx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ interface ScreenBProps {
2929
}
3030

3131
const ScreenB = ({ navigation }: ScreenBProps): React.JSX.Element => {
32-
const [gestureType, setGestureType] = React.useState<NonNullable<NativeStackNavigationOptions['gestureType']>>('twoDimensionalSwipe');
32+
const [gestureType, setGestureType] = React.useState<
33+
NonNullable<NativeStackNavigationOptions['gestureType']>
34+
>('twoDimensionalSwipe');
3335

3436
React.useEffect(() => {
3537
navigation.setOptions({
@@ -39,25 +41,28 @@ const ScreenB = ({ navigation }: ScreenBProps): React.JSX.Element => {
3941

4042
return (
4143
<View style={{ ...styles.container, backgroundColor: 'thistle' }}>
42-
<SettingsPicker<NonNullable<NativeStackNavigationOptions['gestureType']>>
43-
label="Stack animation"
44-
value={gestureType}
45-
onValueChange={setGestureType}
46-
items={[
47-
"swipeRight",
48-
"swipeLeft",
49-
"swipeUp",
50-
"swipeDown",
51-
"verticalSwipe",
52-
"horizontalSwipe",
53-
"twoDimensionalSwipe",
54-
]}
55-
/>
56-
<Button title="Go ScreenC" onPress={() => navigation.navigate('ScreenC')} />
44+
<SettingsPicker<NonNullable<NativeStackNavigationOptions['gestureType']>>
45+
label="Stack animation"
46+
value={gestureType}
47+
onValueChange={setGestureType}
48+
items={[
49+
'swipeRight',
50+
'swipeLeft',
51+
'swipeUp',
52+
'swipeDown',
53+
'verticalSwipe',
54+
'horizontalSwipe',
55+
'twoDimensionalSwipe',
56+
]}
57+
/>
58+
<Button
59+
title="Go ScreenC"
60+
onPress={() => navigation.navigate('ScreenC')}
61+
/>
5762
<Button title="Go back" onPress={() => navigation.goBack()} />
5863
</View>
5964
);
60-
}
65+
};
6166

6267
interface ScreenCProps {
6368
navigation: NativeStackNavigationProp<StackParamList, 'ScreenC'>;
@@ -78,10 +83,7 @@ const App = (): React.JSX.Element => (
7883
animation: 'none',
7984
}}>
8085
<Stack.Screen name="ScreenA" component={MainScreen} />
81-
<Stack.Screen
82-
name="ScreenB"
83-
component={ScreenB}
84-
/>
86+
<Stack.Screen name="ScreenB" component={ScreenB} />
8587
<Stack.Screen name="ScreenC" component={ScreenC} />
8688
</Stack.Navigator>
8789
);

apps/src/shared/Rectangle.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ import React from 'react';
22
import { ColorValue, View, ViewProps, ViewStyle } from 'react-native';
33

44
export interface RectangleProps extends ViewProps {
5-
color?: ColorValue,
6-
width?: ViewStyle['width'],
7-
height?: ViewStyle['height'],
5+
color?: ColorValue;
6+
width?: ViewStyle['width'];
7+
height?: ViewStyle['height'];
88
}
99

1010
export function Rectangle(props: RectangleProps) {
1111
const { color, width, height, style, ...remainingProps } = props;
12-
return <View style={[{ backgroundColor: color, width, height }, style]} {...remainingProps} />;
12+
return (
13+
<View
14+
style={[{ backgroundColor: color, width, height }, style]}
15+
{...remainingProps}
16+
/>
17+
);
1318
}
14-

apps/src/shared/Spacer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { View } from 'react-native';
33

44
interface Props {
55
children?: ReactNode;
6-
space?: number
6+
space?: number;
77
}
88

99
export const Spacer = ({ children, space }: Props): React.JSX.Element => (

apps/src/shared/gamma/containers/shared/id-generator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ export function generateID(): number {
55
GLOBAL_ID += 1;
66
return nextID;
77
}
8-

apps/src/shared/gamma/containers/stack/StackContainer.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ export function StackContainer({ routeConfigs }: StackContainerProps) {
6565
return (
6666
<Stack.Host ref={hostRef}>
6767
{stackNavState.stack.map(
68-
({ options: { headerConfig, ...options }, activityMode, routeKey, name }) => {
68+
({
69+
options: { headerConfig, ...options },
70+
activityMode,
71+
routeKey,
72+
name,
73+
}) => {
6974
const stackNavigationContext: StackNavigationContextPayload = {
7075
routeKey,
7176
routeOptions: { ...options },

apps/src/shared/gamma/containers/stack/reducer.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ function navigationActionPushHandler(
8080
const stack = state.stack;
8181
const renderedRouteIndex = stack.findIndex(
8282
route =>
83-
route.name === action.routeName && route.activityMode === 'detached' && !route.isMarkedForDismissal,
83+
route.name === action.routeName &&
84+
route.activityMode === 'detached' &&
85+
!route.isMarkedForDismissal,
8486
);
8587

8688
if (renderedRouteIndex !== NOT_FOUND_INDEX) {
@@ -161,10 +163,14 @@ function navigationActionPopHandler(
161163
}
162164

163165
// Pop operation on not-top screen is forbidden and might crash.
164-
const topAttachedRouteIndex = state.stack.findLastIndex(r => r.activityMode === 'attached');
166+
const topAttachedRouteIndex = state.stack.findLastIndex(
167+
r => r.activityMode === 'attached',
168+
);
165169

166170
if (topAttachedRouteIndex > routeIndex) {
167-
console.warn(`[Stack] Can not perform pop action on route: ${action.routeKey} - not a top screen`);
171+
console.warn(
172+
`[Stack] Can not perform pop action on route: ${action.routeKey} - not a top screen`,
173+
);
168174
return state;
169175
}
170176

apps/src/shared/gamma/containers/tabs/TabsContainer.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ import { useComponentsByName } from '../shared/use-components-by-name';
2626
export function TabsContainer(props: TabsContainerProps) {
2727
RNSLog.info('TabsContainer render');
2828

29-
const {
30-
routeConfigs,
31-
defaultRouteName,
32-
onTabSelected,
33-
...restProps
34-
} = props;
29+
const { routeConfigs, defaultRouteName, onTabSelected, ...restProps } = props;
3530

3631
useSanitizeRouteConfigs(routeConfigs);
3732

@@ -137,7 +132,9 @@ function useSanitizeRouteConfigs(routeConfigs: TabRouteConfig[]) {
137132
}
138133
}
139134

140-
function useTabsNavigationMethods(dispatch: React.Dispatch<TabsNavigationAction>): TabsNavigationMethods {
135+
function useTabsNavigationMethods(
136+
dispatch: React.Dispatch<TabsNavigationAction>,
137+
): TabsNavigationMethods {
141138
const setRouteOptions = React.useCallback(
142139
(routeKey: string, options: Partial<TabRouteOptions>) => {
143140
dispatch({ type: 'set-options', routeKey, options });
@@ -148,14 +145,20 @@ function useTabsNavigationMethods(dispatch: React.Dispatch<TabsNavigationAction>
148145
const selectTab: SelectTabMethod = React.useCallback(
149146
(routeKey: string, forceAction?: boolean) => {
150147
const shouldForceAction = forceAction ?? false;
151-
dispatch({ type: 'tab-select', routeKey, forceAction: shouldForceAction });
148+
dispatch({
149+
type: 'tab-select',
150+
routeKey,
151+
forceAction: shouldForceAction,
152+
});
152153
},
153154
[dispatch],
154155
);
155156

156-
157-
return React.useMemo(() => ({
158-
setRouteOptions,
159-
selectTab
160-
}), [setRouteOptions, selectTab]);
157+
return React.useMemo(
158+
() => ({
159+
setRouteOptions,
160+
selectTab,
161+
}),
162+
[setRouteOptions, selectTab],
163+
);
161164
}

0 commit comments

Comments
 (0)