1import React from 'react';
2
3import { AppleAuthenticationButtonProps } from './AppleAuthentication.types';
4import ExpoAppleAuthenticationButton from './ExpoAppleAuthenticationButton';
5
6// @needsAudit
7/**
8 * This component displays the proprietary "Sign In with Apple" / "Continue with Apple" button on
9 * your screen. The App Store Guidelines require you to use this component to start the
10 * authentication process instead of a custom button. Limited customization of the button is
11 * available via the provided properties.
12 *
13 * You should only attempt to render this if [`AppleAuthentication.isAvailableAsync()`](#isavailableasync)
14 * resolves to `true`. This component will render nothing if it is not available, and you will get
15 * a warning in development mode (`__DEV__ === true`).
16 *
17 * The properties of this component extend from `View`; however, you should not attempt to set
18 * `backgroundColor` or `borderRadius` with the `style` property. This will not work and is against
19 * the App Store Guidelines. Instead, you should use the `buttonStyle` property to choose one of the
20 * predefined color styles and the `cornerRadius` property to change the border radius of the
21 * button.
22 *
23 * Make sure to attach height and width via the style props as without these styles, the button will
24 * not appear on the screen.
25 *
26 * @see [Apple
27 * Documentation](https://developer.apple.com/documentation/authenticationservices/asauthorizationappleidbutton)
28 * for more details.
29 */
30export default function AppleAuthenticationButton({
31  onPress,
32  ...restProps
33}: AppleAuthenticationButtonProps) {
34  if (!ExpoAppleAuthenticationButton) {
35    if (__DEV__) {
36      console.warn("'AppleAuthenticationButton' is not available.");
37    }
38    return null;
39  }
40  return <ExpoAppleAuthenticationButton onButtonPress={onPress} {...restProps} />;
41}
42