mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-19 09:01:46 +08:00
Re-license and rename UIExplorer integration test app as RNTester
Reviewed By: yungsters Differential Revision: D4950085 fbshipit-source-id: 44574b5d0ef0d2ad5dfc714309b18dc69cbad9ff
This commit is contained in:
committed by
Facebook Github Bot
parent
82c4b9f0b7
commit
4a80dceac7
96
RNTester/js/ToastAndroidExample.android.js
Normal file
96
RNTester/js/ToastAndroidExample.android.js
Normal file
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @flow
|
||||
* @providesModule ToastAndroidExample
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var {
|
||||
StyleSheet,
|
||||
Text,
|
||||
ToastAndroid,
|
||||
TouchableWithoutFeedback,
|
||||
} = ReactNative;
|
||||
|
||||
var RNTesterBlock = require('RNTesterBlock');
|
||||
var RNTesterPage = require('RNTesterPage');
|
||||
|
||||
class ToastExample extends React.Component {
|
||||
static title = 'Toast Example';
|
||||
static description = 'Example that demonstrates the use of an Android Toast to provide feedback.';
|
||||
state = {};
|
||||
|
||||
render() {
|
||||
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>
|
||||
</RNTesterPage>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
text: {
|
||||
color: 'black',
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = ToastExample;
|
||||
Reference in New Issue
Block a user