mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
64ebe5bbdd
Summary: This PR adds a `dismissActionSheet` method to `ActionSheetIOS` in order to allow dismissing an ActionSheet programmatically. This is especially useful in apps where a user has the ability to open an ActionSheet and then open a push notification that will redirect them to another screen which usually leads to scenarios where the presented ActionSheet has no relation with the current screen. #### TODO - [ ] Submit react-native-website PR updating ActionSheetIOS documentation. ## Changelog [iOS] [Added] - Add dismissActionSheet method to ActionSheetIOS Pull Request resolved: https://github.com/facebook/react-native/pull/33189 Test Plan: 1. Open the RNTester app and navigate to the ActionSheetIOS page 2. Test `dismissActionSheet` through the `Show Action Sheet and automatically dismiss it` example https://user-images.githubusercontent.com/11707729/155867546-c6770a49-9b09-45e3-a6b1-4f7645d67dbf.mov Reviewed By: lunaleaps Differential Revision: D34518952 Pulled By: cortinico fbshipit-source-id: 912a9b83ee078f791b42efddf5abb7e1cd09d520
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
/**
|
|
* 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
|
|
* @format
|
|
*/
|
|
|
|
import type {TurboModule} from '../TurboModule/RCTExport';
|
|
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
|
|
|
|
export interface Spec extends TurboModule {
|
|
+getConstants: () => {||};
|
|
+showActionSheetWithOptions: (
|
|
options: {|
|
|
+title?: ?string,
|
|
+message?: ?string,
|
|
+options: ?Array<string>,
|
|
+destructiveButtonIndices?: ?Array<number>,
|
|
+cancelButtonIndex?: ?number,
|
|
+anchor?: ?number,
|
|
+tintColor?: ?number,
|
|
+cancelButtonTintColor?: ?number,
|
|
+userInterfaceStyle?: ?string,
|
|
+disabledButtonIndices?: Array<number>,
|
|
|},
|
|
callback: (buttonIndex: number) => void,
|
|
) => void;
|
|
+showShareActionSheetWithOptions: (
|
|
options: {|
|
|
+message?: ?string,
|
|
+url?: ?string,
|
|
+subject?: ?string,
|
|
+anchor?: ?number,
|
|
+tintColor?: ?number,
|
|
+cancelButtonTintColor?: ?number,
|
|
+excludedActivityTypes?: ?Array<string>,
|
|
+userInterfaceStyle?: ?string,
|
|
|},
|
|
failureCallback: (error: {|
|
|
+domain: string,
|
|
+code: string,
|
|
+userInfo?: ?Object,
|
|
+message: string,
|
|
|}) => void,
|
|
successCallback: (completed: boolean, activityType: ?string) => void,
|
|
) => void;
|
|
+dismissActionSheet?: () => void;
|
|
}
|
|
|
|
export default (TurboModuleRegistry.get<Spec>('ActionSheetManager'): ?Spec);
|