/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict-local * @format */ 'use strict'; import type {GestureResponderEvent} from 'react-native'; import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet'; import {RNTesterThemeContext} from './RNTesterTheme'; import * as React from 'react'; import {useContext, useState} from 'react'; import {Pressable, StyleSheet, Text, View} from 'react-native'; type Props = $ReadOnly<{ testID?: ?string, label: string, onPress?: ?(event: GestureResponderEvent) => mixed, selected?: ?boolean, multiSelect?: ?boolean, disabled?: ?boolean, style?: ViewStyleProp, }>; /** * A reusable toggle button component for RNTester. Highlights when selected. */ export default function RNTOption(props: Props): React.Node { const [pressed, setPressed] = useState(false); const theme = useContext(RNTesterThemeContext); return ( setPressed(true)} onPressOut={() => setPressed(false)} testID={props.testID}> {props.label} ); } const styles = StyleSheet.create({ pressed: { backgroundColor: 'rgba(100,215,255,.3)', }, selected: { backgroundColor: 'rgba(100,215,255,.3)', borderColor: 'rgba(100,215,255,.3)', }, disabled: {borderWidth: 0}, container: { borderWidth: 1, borderRadius: 16, padding: 6, paddingHorizontal: 10, alignItems: 'center', }, });