first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
/**
* 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
* @format
*/
export * from '../../../src/private/specs_DEPRECATED/modules/NativeToastAndroid';
export {default} from '../../../src/private/specs_DEPRECATED/modules/NativeToastAndroid';

View File

@@ -0,0 +1,74 @@
/**
* 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
*/
import NativeToastAndroid from './NativeToastAndroid';
/**
* This exposes the native ToastAndroid module as a JS module. This has a function 'show'
* which takes the following parameters:
*
* 1. String message: A string with the text to toast
* 2. int duration: The duration of the toast. May be ToastAndroid.SHORT or ToastAndroid.LONG
*
* There is also a function `showWithGravity` to specify the layout gravity. May be
* ToastAndroid.TOP, ToastAndroid.BOTTOM, ToastAndroid.CENTER.
*
* The 'showWithGravityAndOffset' function adds on the ability to specify offset
* These offset values will translate to pixels.
*
* Basic usage:
* ```javascript
* ToastAndroid.show('A pikachu appeared nearby !', ToastAndroid.SHORT);
* ToastAndroid.showWithGravity('All Your Base Are Belong To Us', ToastAndroid.SHORT, ToastAndroid.CENTER);
* ToastAndroid.showWithGravityAndOffset('A wild toast appeared!', ToastAndroid.LONG, ToastAndroid.BOTTOM, 25, 50);
* ```
*/
const ToastAndroidConstants = NativeToastAndroid.getConstants();
const ToastAndroid = {
// Toast duration constants
SHORT: (ToastAndroidConstants.SHORT: number),
LONG: (ToastAndroidConstants.LONG: number),
// Toast gravity constants
TOP: (ToastAndroidConstants.TOP: number),
BOTTOM: (ToastAndroidConstants.BOTTOM: number),
CENTER: (ToastAndroidConstants.CENTER: number),
show: function (message: string, duration: number): void {
NativeToastAndroid.show(message, duration);
},
showWithGravity: function (
message: string,
duration: number,
gravity: number,
): void {
NativeToastAndroid.showWithGravity(message, duration, gravity);
},
showWithGravityAndOffset: function (
message: string,
duration: number,
gravity: number,
xOffset: number,
yOffset: number,
): void {
NativeToastAndroid.showWithGravityAndOffset(
message,
duration,
gravity,
xOffset,
yOffset,
);
},
};
export default ToastAndroid;

View File

@@ -0,0 +1,109 @@
/**
* 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.
*
* @format
*/
/**
* This exposes the native ToastAndroid module as a JS module. This has a function 'show'
* which takes the following parameters:
*
* 1. String message: A string with the text to toast
* 2. int duration: The duration of the toast. May be ToastAndroid.SHORT or ToastAndroid.LONG
*
* There is also a function `showWithGravity` to specify the layout gravity. May be
* ToastAndroid.TOP, ToastAndroid.BOTTOM, ToastAndroid.CENTER
*
* **Note**: Starting from Android API level 30 (Android R) or higher, for apps targeting
* that API level, setting toast gravity is a no-op for text toasts.
* This means that in many cases `TOP`, `BOTTOM`, `CENTER`, or offsets may not have
* any visible effect on actual toast positioning.
*
* Reference: https://developer.android.com/reference/android/widget/Toast#setGravity(int,%20int,%20int)
*/
export interface ToastAndroidStatic {
/**
* Display a toast message for a specified duration.
*
* @param message A string with the text to toast.
* @param duration The duration of the toasteither ToastAndroid.SHORT or ToastAndroid.LONG
*/
show(message: string, duration: number): void;
/**
* Display a toast message for a specified duration with a given gravity.
*
* @param message A string with the text to display in the toast.
* @param duration The duration of the toast.
* May be `ToastAndroid.SHORT` or `ToastAndroid.LONG`.
* @param gravity Positioning on the screen, e.g.,
* `ToastAndroid.TOP`, `ToastAndroid.BOTTOM`, or `ToastAndroid.CENTER`.
*
* **Note**: On Android R (API 30) or later (when targeting API 30+), this setting may
* not have any effect on text toast placement due to `setGravity` becoming a no-op.
*/
showWithGravity(message: string, duration: number, gravity: number): void;
/**
* Display a toast message for a specified duration with a given gravity and custom offsets.
*
* @param message A string with the text to display in the toast.
* @param duration The duration of the toast.
* May be `ToastAndroid.SHORT` or `ToastAndroid.LONG`.
* @param gravity Positioning on the screen, e.g.,
* `ToastAndroid.TOP`, `ToastAndroid.BOTTOM`, or `ToastAndroid.CENTER`.
* @param xOffset Horizontal offset from the given gravity.
* @param yOffset Vertical offset from the given gravity.
*
* **Note**: On Android R (API 30) or later (when targeting API 30+), setting gravity
* and offsets may not visibly affect the placement of text toasts.
*/
showWithGravityAndOffset(
message: string,
duration: number,
gravity: number,
xOffset: number,
yOffset: number,
): void;
/**
* Indicates a short duration on the screen.
*
* Value: 2000 milliseconds (2 seconds).
*/
SHORT: number;
/**
* Indicates a long duration on the screen.
*
* Value: 3500 milliseconds (3.5 seconds).
*/
LONG: number;
/**
* Indicates that the toast message should appear at the top of the screen.
*
* **Note**: On Android R or later, this may not have any visible effect.
*/
TOP: number;
/**
* Indicates that the toast message should appear at the bottom of the screen.
*
* **Note**: On Android R or later, this may not have any visible effect.
*/
BOTTOM: number;
/**
* Indicates that the toast message should appear at the center of the screen.
*
* **Note**: On Android R or later, this may not have any visible effect.
*/
CENTER: number;
}
export const ToastAndroid: ToastAndroidStatic;
export type ToastAndroid = ToastAndroidStatic;

View File

@@ -0,0 +1,13 @@
/**
* 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
*/
import ToastAndroidFallback from './ToastAndroidFallback';
export default ToastAndroidFallback;

View File

@@ -0,0 +1,17 @@
/**
* 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
*/
// NOTE: This file supports backwards compatibility of subpath (deep) imports
// from 'react-native' with platform-specific extensions. It can be deleted
// once we remove the "./*" mapping from package.json "exports".
import ToastAndroid from './ToastAndroid';
export default ToastAndroid;

View File

@@ -0,0 +1,109 @@
/**
* 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
*/
/**
* This exposes the native ToastAndroid module as a JS module. This has a function 'show'
* which takes the following parameters:
*
* 1. String message: A string with the text to toast
* 2. int duration: The duration of the toast. May be ToastAndroid.SHORT or ToastAndroid.LONG
*
* There is also a function `showWithGravity` to specify the layout gravity. May be
* ToastAndroid.TOP, ToastAndroid.BOTTOM, ToastAndroid.CENTER
*
* **Note**: Starting from Android API level 30 (Android R) or higher, for apps targeting
* that API level, setting toast gravity is a no-op for text toasts.
* This means that in many cases `TOP`, `BOTTOM`, `CENTER`, or offsets may not have
* any visible effect on actual toast positioning.
*
* Reference: https://developer.android.com/reference/android/widget/Toast#setGravity(int,%20int,%20int)
*/
declare const ToastAndroid: {
/**
* Indicates a short duration on the screen.
*
* Value: 2000 milliseconds (2 seconds).
*/
SHORT: number,
/**
* Indicates a long duration on the screen.
*
* Value: 3500 milliseconds (3.5 seconds).
*/
LONG: number,
/**
* Indicates that the toast message should appear at the top of the screen.
*
* **Note**: On Android R or later, this may not have any visible effect.
*/
TOP: number,
/**
* Indicates that the toast message should appear at the bottom of the screen.
*
* **Note**: On Android R or later, this may not have any visible effect.
*/
BOTTOM: number,
/**
* Indicates that the toast message should appear at the center of the screen.
*
* **Note**: On Android R or later, this may not have any visible effect.
*/
CENTER: number,
/**
* Display a toast message for a specified duration.
*
* @param message A string with the text to toast.
* @param duration The duration of the toasteither ToastAndroid.SHORT or ToastAndroid.LONG
*/
show: (message: string, duration: number) => void,
/**
* Display a toast message for a specified duration with a given gravity.
*
* @param message A string with the text to display in the toast.
* @param duration The duration of the toast.
* May be `ToastAndroid.SHORT` or `ToastAndroid.LONG`.
* @param gravity Positioning on the screen, e.g.,
* `ToastAndroid.TOP`, `ToastAndroid.BOTTOM`, or `ToastAndroid.CENTER`.
*
* **Note**: On Android R (API 30) or later (when targeting API 30+), this setting may
* not have any effect on text toast placement due to `setGravity` becoming a no-op.
*/
showWithGravity: (message: string, duration: number, gravity: number) => void,
/**
* Display a toast message for a specified duration with a given gravity and custom offsets.
*
* @param message A string with the text to display in the toast.
* @param duration The duration of the toast.
* May be `ToastAndroid.SHORT` or `ToastAndroid.LONG`.
* @param gravity Positioning on the screen, e.g.,
* `ToastAndroid.TOP`, `ToastAndroid.BOTTOM`, or `ToastAndroid.CENTER`.
* @param xOffset Horizontal offset from the given gravity.
* @param yOffset Vertical offset from the given gravity.
*
* **Note**: On Android R (API 30) or later (when targeting API 30+), setting gravity
* and offsets may not visibly affect the placement of text toasts.
*/
showWithGravityAndOffset: (
message: string,
duration: number,
gravity: number,
xOffset: number,
yOffset: number,
) => void,
};
export default ToastAndroid;

View File

@@ -0,0 +1,45 @@
/**
* 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';
const ToastAndroid = {
// Dummy fallback toast duration constants
SHORT: (0: number),
LONG: (0: number),
// Dummy fallback toast gravity constants
TOP: (0: number),
BOTTOM: (0: number),
CENTER: (0: number),
show: function (message: string, duration: number): void {
console.warn('ToastAndroid is not supported on this platform.');
},
showWithGravity: function (
message: string,
duration: number,
gravity: number,
): void {
console.warn('ToastAndroid is not supported on this platform.');
},
showWithGravityAndOffset: function (
message: string,
duration: number,
gravity: number,
xOffset: number,
yOffset: number,
): void {
console.warn('ToastAndroid is not supported on this platform.');
},
};
export default ToastAndroid;