/**
* 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 {RNTesterModuleExample} from '../../types/RNTesterTypes';
import RNTesterText from '../../components/RNTesterText';
import React from 'react';
import {Pressable, StyleSheet, ToastAndroid} from 'react-native';
const ToastWithShortDuration = () => {
return (
ToastAndroid.show('Copied to clipboard!', ToastAndroid.SHORT)
}>
Tap to view toast
);
};
const ToastWithLongDuration = () => {
return (
ToastAndroid.show('Sending message..', ToastAndroid.LONG)}>
Tap to view toast
);
};
const ToastWithTopGravity = () => {
return (
ToastAndroid.showWithGravity(
'Download Started..',
ToastAndroid.SHORT,
ToastAndroid.TOP,
)
}>
Tap to view toast
);
};
const ToastWithCenterGravity = () => {
return (
ToastAndroid.showWithGravity(
'A problem has been occurred while submitting your data.',
ToastAndroid.SHORT,
ToastAndroid.CENTER,
)
}>
Tap to view toast
);
};
const ToastWithBottomGravity = () => {
return (
ToastAndroid.showWithGravity(
'Please read the contents carefully.',
ToastAndroid.SHORT,
ToastAndroid.BOTTOM,
)
}>
Tap to view toast
);
};
const ToastWithXOffset = () => {
return (
ToastAndroid.showWithGravityAndOffset(
'Alex sent you a friend request',
ToastAndroid.SHORT,
ToastAndroid.TOP,
250,
0,
)
}>
Tap to view toast
);
};
const ToastWithYOffset = () => {
return (
ToastAndroid.showWithGravityAndOffset(
'There was a problem with your internet connection',
ToastAndroid.SHORT,
ToastAndroid.BOTTOM,
0,
100,
)
}>
Tap to view toast
);
};
const styles = StyleSheet.create({
text: {
color: 'blue',
},
});
exports.title = 'Toast Example';
exports.category = 'Android';
exports.description =
'Example that demonstrates the use of an Android Toast to provide feedback.';
exports.examples = [
{
title: 'Toast with Short Duration',
render(): React.Node {
return ;
},
},
{
title: 'Toast with Long Duration',
render(): React.Node {
return ;
},
},
{
title: 'Toast with Top Gravity',
render(): React.Node {
return ;
},
},
{
title: 'Toast with Center Gravity',
render(): React.Node {
return ;
},
},
{
title: 'Toast with Bottom Gravity',
render(): React.Node {
return ;
},
},
{
title: 'Toast with X Offset',
render(): React.Node {
return ;
},
},
{
title: 'Toast with Y Offset',
render(): React.Node {
return ;
},
},
] as Array;