mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
000bbe8013
Summary: Currently, with the Alert API on iOS, the only way to bold one of the buttons is by setting the style to "cancel". This has the side-effect of moving it to the left. The underlying UIKit API has a way of setting a "preferred" button, which does not have this negative side-effect, so this PR wires this up. See preferredAction on UIAlertController https://developer.apple.com/documentation/uikit/uialertcontroller/ Docs PR: https://github.com/facebook/react-native-website/pull/2839 ## Changelog [iOS] [Added] - Support setting an Alert button as "preferred", to emphasize it without needing to set it as a "cancel" button. Pull Request resolved: https://github.com/facebook/react-native/pull/32538 Test Plan: I ran the RNTesterPods app and added an example. It has a button styled with "preferred" and another with "cancel", to demonstrate that the "preferred" button takes emphasis over the "cancel" button.  Luna: * Also tested this on Catalyst {F754959632} Reviewed By: sammy-SC Differential Revision: D34357811 Pulled By: lunaleaps fbshipit-source-id: 3d860702c49cb219f950904ae0b9fabef03b5588
35 lines
889 B
JavaScript
35 lines
889 B
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 type Args = {|
|
|
title?: string,
|
|
message?: string,
|
|
buttons?: Array<Object>, // TODO(T67565166): have a better type
|
|
type?: string,
|
|
defaultValue?: string,
|
|
cancelButtonKey?: string,
|
|
destructiveButtonKey?: string,
|
|
preferredButtonKey?: string,
|
|
keyboardType?: string,
|
|
userInterfaceStyle?: string,
|
|
|};
|
|
|
|
export interface Spec extends TurboModule {
|
|
+alertWithArgs: (
|
|
args: Args,
|
|
callback: (id: number, value: string) => void,
|
|
) => void;
|
|
}
|
|
|
|
export default (TurboModuleRegistry.get<Spec>('AlertManager'): ?Spec);
|