Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions packages/rn-tester/js/examples/Alert/AlertExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import type {RNTesterModule} from '../../types/RNTesterTypes';

import RNTesterText from '../../components/RNTesterText';
import {RNTesterThemeContext} from '../../components/RNTesterTheme';
import * as React from 'react';
import {Alert, Pressable, StyleSheet, Text, View} from 'react-native';

Expand Down Expand Up @@ -243,16 +242,13 @@ const PromptOptions = () => {
style: 'cancel',
},
];
const theme = React.useContext(RNTesterThemeContext);

return (
<View>
<Text style={styles.promptValue}>
<Text style={[{color: theme.SecondaryLabelColor}, styles.bold]}>
Prompt value:
</Text>
<RNTesterText style={styles.promptValue}>
<Text style={styles.bold}>Prompt value:</Text>
{JSON.stringify(promptValue, null, 2)}
</Text>
</RNTesterText>

<Pressable
style={styles.wrapper}
Expand Down
97 changes: 40 additions & 57 deletions packages/rn-tester/js/examples/SafeAreaView/SafeAreaViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,75 +10,58 @@

'use strict';

const React = require('react');
const {
import RNTesterText from '../../components/RNTesterText';
import React from 'react';
import {
Button,
DeviceInfo,
Modal,
SafeAreaView,
StyleSheet,
Text,
View,
} = require('react-native');
} from 'react-native';

class SafeAreaViewExample extends React.Component<
{...},
{
modalVisible: boolean,
},
> {
state: {modalVisible: boolean} = {
modalVisible: false,
};
function SafeAreaViewExample(): React.Node {
const [modalVisible, setModalVisible] = React.useState<boolean>(false);

_setModalVisible = (visible: boolean) => {
this.setState({modalVisible: visible});
const toggleModal = (visible: boolean) => {
setModalVisible(visible);
};

render(): React.Node {
return (
<View>
<Modal
visible={this.state.modalVisible}
onRequestClose={() => this._setModalVisible(false)}
animationType="slide"
supportedOrientations={['portrait', 'landscape']}>
<View style={styles.modal}>
<SafeAreaView style={styles.safeArea}>
<View style={styles.safeAreaContent}>
<Button
onPress={this._setModalVisible.bind(this, false)}
title="Close"
/>
</View>
</SafeAreaView>
</View>
</Modal>
<Button
onPress={this._setModalVisible.bind(this, true)}
title="Present Modal Screen with SafeAreaView"
/>
</View>
);
}
return (
<View>
<Modal
visible={modalVisible}
onRequestClose={() => toggleModal(false)}
animationType="slide"
supportedOrientations={['portrait', 'landscape']}>
<View style={styles.modal}>
<SafeAreaView style={styles.safeArea}>
<View style={styles.safeAreaContent}>
<Button onPress={() => toggleModal(false)} title="Close" />
</View>
</SafeAreaView>
</View>
</Modal>
<Button
onPress={() => toggleModal(true)}
title="Present Modal Screen with SafeAreaView"
/>
</View>
);
}

class IsIPhoneXExample extends React.Component<{...}> {
render(): React.Node {
return (
<View>
<Text>
Is this an iPhone X:{' '}
{
// $FlowFixMe[sketchy-null-bool]
DeviceInfo.getConstants().isIPhoneX_deprecated
? 'Yeah!'
: 'Nope. (Or `isIPhoneX_deprecated` was already removed.)'
}
</Text>
</View>
);
}
function IsIPhoneXExample(): React.Node {
return (
<View>
<RNTesterText>
Is this an iPhone X:{' '}
{DeviceInfo.getConstants()?.isIPhoneX_deprecated === true
? 'Yeah!'
: 'Nope. (Or `isIPhoneX_deprecated` was already removed.)'}
</RNTesterText>
</View>
);
}

const styles = StyleSheet.create({
Expand Down
Loading