init
Some checks failed
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
2025-09-02 14:49:16 +08:00
commit 38ba663466
2885 changed files with 391107 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
import React, { Component } from 'react';
import { WithTranslation } from 'react-i18next';
import { GestureResponderEvent, Image, ImageStyle, TouchableOpacity, ViewStyle } from 'react-native';
import { translate } from '../../base/i18n/functions';
import Button from '../../base/ui/components/native/Button';
import { BUTTON_TYPES } from '../../base/ui/constants.native';
import styles from './styles';
// eslint-disable-next-line
const GOOGLE_BRAND_IMAGE = require('../../../../images/btn_google_signin_dark_normal.png');
/**
* The Google Brand image for Sign In.
*
* NOTE: iOS doesn't handle the react-native-google-signin button component
* well due to our CocoaPods build process (the lib is not intended to be used
* this way), hence the custom button implementation.
*/
interface IProps extends WithTranslation {
/**
* The callback to invoke when the button is clicked.
*/
onClick: (e?: React.MouseEvent<HTMLButtonElement> | GestureResponderEvent) => void;
/**
* True if the user is signed in, so it needs to render a different label
* and maybe different style (for the future).
*/
signedIn?: boolean;
/**
* The text to display within {@code GoogleSignInButton}.
*/
text?: string;
}
/**
* A React Component showing a button to sign in with Google.
*
* @augments Component
*/
class GoogleSignInButton extends Component<IProps> {
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
override render() {
const { onClick, signedIn } = this.props;
if (signedIn) {
return (
<Button
accessibilityLabel = 'liveStreaming.signOut'
labelKey = 'liveStreaming.signOut'
onClick = { onClick }
style = { styles.signOutButton }
type = { BUTTON_TYPES.SECONDARY } />
);
}
return (
<TouchableOpacity
onPress = { onClick }
style = { styles.signInButton as ViewStyle } >
<Image
resizeMode = { 'contain' }
source = { GOOGLE_BRAND_IMAGE }
style = { styles.signInImage as ImageStyle } />
</TouchableOpacity>
);
}
}
export default translate(GoogleSignInButton);

View File

@@ -0,0 +1,61 @@
import React, { Component } from 'react';
import { WithTranslation } from 'react-i18next';
import { translate } from '../../base/i18n/functions';
interface IProps extends WithTranslation {
/**
* The callback to invoke when the button is clicked.
*/
onClick: (e?: React.MouseEvent) => void;
/**
* True if the user is signed in, so it needs to render a different label
* and maybe different style (for the future).
*/
signedIn?: boolean;
/**
* The text to display within {@code GoogleSignInButton}.
*/
text?: string;
}
/**
* A React Component showing a button to sign in with Google.
*
* @augments Component
*/
class GoogleSignInButton extends Component<IProps> {
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
override render() {
const { t } = this.props;
return (
<div
className = 'google-sign-in'
onClick = { this.props.onClick }>
<img
alt = { t('welcomepage.logo.googleLogo') }
className = 'google-logo'
src = 'images/googleLogo.svg' />
<div className = 'google-cta'>
{
t(this.props.signedIn
? 'liveStreaming.signOut'
: 'liveStreaming.signIn')
}
</div>
</div>
);
}
}
export default translate(GoogleSignInButton);

View File

@@ -0,0 +1,39 @@
import { createStyleSheet } from '../../base/styles/functions.any';
/**
* For styling explanations, see:
* https://developers.google.com/identity/branding-guidelines.
*/
const BUTTON_HEIGHT = 40;
/**
* The styles of the React {@code Components} of google-api.
*/
export default createStyleSheet({
/**
* Image of the sign in button (Google branded).
*/
signInImage: {
flex: 1
},
/**
* An image-based button for sign in.
*/
signInButton: {
alignItems: 'center',
height: BUTTON_HEIGHT,
justifyContent: 'center'
},
/**
* A text-based button for sign out (no sign out button guidance for
* Google).
*/
signOutButton: {
alignSelf: 'center',
maxWidth: 120,
width: 'auto'
}
});