Skip to content

Commit 9d256ae

Browse files
j-piaseckiCopilot
andauthored
[Example] Use Touchable instead of RectButton (#4136)
## Description Replaces `RectButton` with `Touchable` in the common app ## Test plan Run the app --------- Co-authored-by: Copilot <copilot@github.com>
1 parent 3c4d189 commit 9d256ae

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

apps/common-app/App.tsx

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @eslint-react/no-nested-component-definitions */
2+
/* eslint-disable @eslint-react/no-nested-components */
13
import AsyncStorage from '@react-native-async-storage/async-storage';
24
import type { ParamListBase } from '@react-navigation/native';
35
import { NavigationContainer } from '@react-navigation/native';
@@ -11,8 +13,8 @@ import { useEffect, useState } from 'react';
1113
import { Dimensions, Platform, StyleSheet, Text, View } from 'react-native';
1214
import {
1315
GestureHandlerRootView,
14-
RectButton,
1516
Switch,
17+
Touchable,
1618
} from 'react-native-gesture-handler';
1719
import { useSafeAreaInsets } from 'react-native-safe-area-context';
1820

@@ -123,7 +125,7 @@ export default function App() {
123125
<MainScreenItem
124126
name={item.name}
125127
onPressItem={(name) => navigate(navigation, name)}
126-
enabled={!item.unsupportedPlatforms?.has(Platform.OS)}
128+
disabled={!!item.unsupportedPlatforms?.has(Platform.OS)}
127129
/>
128130
)}
129131
renderSectionHeader={({ section: { sectionTitle } }) => (
@@ -156,7 +158,9 @@ export default function App() {
156158
}
157159
return (
158160
<View style={styles.settings}>
159-
<RectButton
161+
<Touchable
162+
androidRipple={{}}
163+
activeUnderlayOpacity={Platform.OS !== 'android' ? 0.1 : 0}
160164
style={styles.settingsButton}
161165
onPress={() => {
162166
updateKeepSetting(!openLastExample);
@@ -175,8 +179,10 @@ export default function App() {
175179
}}
176180
/>
177181
</View>
178-
</RectButton>
179-
<RectButton
182+
</Touchable>
183+
<Touchable
184+
androidRipple={{}}
185+
activeUnderlayOpacity={Platform.OS !== 'android' ? 0.1 : 0}
180186
style={styles.settingsButton}
181187
onPress={() => {
182188
updateVersionSetting(!showLegacyVersion);
@@ -195,28 +201,34 @@ export default function App() {
195201
}}
196202
/>
197203
</View>
198-
</RectButton>
204+
</Touchable>
199205
</View>
200206
);
201207
}
202208

203209
interface MainScreenItemProps {
204210
name: string;
205211
onPressItem: (name: string) => void;
206-
enabled: boolean;
212+
disabled: boolean;
207213
}
208214

209-
function MainScreenItem({ name, onPressItem, enabled }: MainScreenItemProps) {
215+
function MainScreenItem({
216+
name,
217+
onPressItem,
218+
disabled,
219+
}: MainScreenItemProps) {
210220
return (
211-
<RectButton
212-
enabled={enabled}
213-
style={[styles.button, !enabled && styles.unavailableExample]}
221+
<Touchable
222+
disabled={disabled}
223+
style={[styles.button, disabled && styles.unavailableExample]}
224+
androidRipple={{}}
225+
activeUnderlayOpacity={Platform.OS !== 'android' ? 0.1 : 0}
214226
onPress={() => onPressItem(name)}>
215227
<Text style={styles.text}>{name}</Text>
216-
{Platform.OS !== 'macos' && enabled && (
228+
{Platform.OS !== 'macos' && !disabled && (
217229
<Icon name="chevron-small-right" size={24} color="#bbb" />
218230
)}
219-
</RectButton>
231+
</Touchable>
220232
);
221233
}
222234
}

0 commit comments

Comments
 (0)