mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
1270873ed6
Summary: This Pull request adds the UI changes to the RNTester app as discussed in the MLH Fellowship. This list is not exhaustive. - The initial App screen is redesigned. - A bottom Navbar has been added. - Filter pills are added. - The list card UI is updated. - The example page UI is updated. - Recently Viewed Sections are added. It shows the last 5 recently viewed components/APIs. - Bookmarking functionality is added. - The documentation URL is added to the example page. - RNTester doesn't lose its state on a hard refresh (even on iOS). <img width="373" src="https://user-images.githubusercontent.com/22813027/90530113-20346180-e192-11ea-8ef6-789fa25b402b.png" /> <img width="373" src="https://user-images.githubusercontent.com/22813027/90530112-20346180-e192-11ea-9539-706b540fcc5f.png" /> <img width="373" src="https://user-images.githubusercontent.com/22813027/90530100-1d397100-e192-11ea-8836-b88070643233.png" /> <img width="373" src="https://user-images.githubusercontent.com/22813027/90530110-1f9bcb00-e192-11ea-936b-64ee75fa4289.png" /> Pull Request resolved: https://github.com/facebook/react-native/pull/29685 Test Plan: Imported from GitHub, without a `Test Plan:` line. {F302717939} Note: this failed **before** this diff too: {F302745716} Reviewed By: mdvacca, cpojer Differential Revision: D23240434 fbshipit-source-id: 65e2766a6a097eca0e0d0fda8dadf6871e9276c2 Co-authored-by: agarwalmanya <manya18ag@gmail.com> Co-authored-by: chirag-singhal <csinghal208@gmail.com> Co-authored-by: Ansh Godha <ag759@cornell.edu> Co-authored-by: Yash Kumar Verma <yk.verma2000@gmail.com> Co-authored-by: Sanskar Jethi <sansyrox@gmail.com> Co-authored-by: Aniketh Saha <anik220798@gmail.com> Co-authored-by: Xtremilicious <nilarjundas@outlook.com> Co-authored-by: Jani Evakallio <jani.evakallio@gmail.com>
138 lines
4.0 KiB
JavaScript
138 lines
4.0 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow strict-local
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const RNTesterBlock = require('../../components/RNTesterBlock');
|
|
const RNTesterPage = require('../../components/RNTesterPage');
|
|
const React = require('react');
|
|
|
|
const {
|
|
StyleSheet,
|
|
Text,
|
|
ToastAndroid,
|
|
TouchableWithoutFeedback,
|
|
} = require('react-native');
|
|
|
|
type Props = $ReadOnly<{||}>;
|
|
class ToastExample extends React.Component<Props> {
|
|
render(): React.Node {
|
|
return (
|
|
<RNTesterPage title="ToastAndroid">
|
|
<RNTesterBlock title="Simple toast">
|
|
<TouchableWithoutFeedback
|
|
onPress={() =>
|
|
ToastAndroid.show(
|
|
'This is a toast with short duration',
|
|
ToastAndroid.SHORT,
|
|
)
|
|
}>
|
|
<Text style={styles.text}>Click me.</Text>
|
|
</TouchableWithoutFeedback>
|
|
</RNTesterBlock>
|
|
<RNTesterBlock title="Toast with long duration">
|
|
<TouchableWithoutFeedback
|
|
onPress={() =>
|
|
ToastAndroid.show(
|
|
'This is a toast with long duration',
|
|
ToastAndroid.LONG,
|
|
)
|
|
}>
|
|
<Text style={styles.text}>Click me.</Text>
|
|
</TouchableWithoutFeedback>
|
|
</RNTesterBlock>
|
|
<RNTesterBlock title="Toast with top gravity">
|
|
<TouchableWithoutFeedback
|
|
onPress={() =>
|
|
ToastAndroid.showWithGravity(
|
|
'This is a toast with top gravity',
|
|
ToastAndroid.SHORT,
|
|
ToastAndroid.TOP,
|
|
)
|
|
}>
|
|
<Text style={styles.text}>Click me.</Text>
|
|
</TouchableWithoutFeedback>
|
|
</RNTesterBlock>
|
|
<RNTesterBlock title="Toast with center gravity">
|
|
<TouchableWithoutFeedback
|
|
onPress={() =>
|
|
ToastAndroid.showWithGravity(
|
|
'This is a toast with center gravity',
|
|
ToastAndroid.SHORT,
|
|
ToastAndroid.CENTER,
|
|
)
|
|
}>
|
|
<Text style={styles.text}>Click me.</Text>
|
|
</TouchableWithoutFeedback>
|
|
</RNTesterBlock>
|
|
<RNTesterBlock title="Toast with bottom gravity">
|
|
<TouchableWithoutFeedback
|
|
onPress={() =>
|
|
ToastAndroid.showWithGravity(
|
|
'This is a toast with bottom gravity',
|
|
ToastAndroid.SHORT,
|
|
ToastAndroid.BOTTOM,
|
|
)
|
|
}>
|
|
<Text style={styles.text}>Click me.</Text>
|
|
</TouchableWithoutFeedback>
|
|
</RNTesterBlock>
|
|
<RNTesterBlock title="Toast with x offset">
|
|
<TouchableWithoutFeedback
|
|
onPress={() =>
|
|
ToastAndroid.showWithGravityAndOffset(
|
|
'This is a toast with x offset',
|
|
ToastAndroid.SHORT,
|
|
ToastAndroid.CENTER,
|
|
50,
|
|
0,
|
|
)
|
|
}>
|
|
<Text style={styles.text}>Click me.</Text>
|
|
</TouchableWithoutFeedback>
|
|
</RNTesterBlock>
|
|
<RNTesterBlock title="Toast with y offset">
|
|
<TouchableWithoutFeedback
|
|
onPress={() =>
|
|
ToastAndroid.showWithGravityAndOffset(
|
|
'This is a toast with y offset',
|
|
ToastAndroid.SHORT,
|
|
ToastAndroid.BOTTOM,
|
|
0,
|
|
50,
|
|
)
|
|
}>
|
|
<Text style={styles.text}>Click me.</Text>
|
|
</TouchableWithoutFeedback>
|
|
</RNTesterBlock>
|
|
</RNTesterPage>
|
|
);
|
|
}
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
text: {
|
|
color: 'black',
|
|
},
|
|
});
|
|
|
|
exports.title = 'Toast Example';
|
|
exports.category = 'Android';
|
|
exports.description =
|
|
'Example that demonstrates the use of an Android Toast to provide feedback.';
|
|
exports.examples = [
|
|
{
|
|
title: 'Basic toast',
|
|
render: function(): React.Element<typeof ToastExample> {
|
|
return <ToastExample />;
|
|
},
|
|
},
|
|
];
|