diff --git a/native/components/relationship-button.react.js b/native/components/relationship-button.react.js
--- a/native/components/relationship-button.react.js
+++ b/native/components/relationship-button.react.js
@@ -2,11 +2,13 @@
import Icon from '@expo/vector-icons/FontAwesome5.js';
import * as React from 'react';
-import { Text } from 'react-native';
+import { Text, ActivityIndicator } from 'react-native';
import Button from './button.react.js';
import { useStyles, useColors } from '../themes/colors.js';
+type ButtonSize = 'S';
+
type RelationshipButtonType =
| 'add'
| 'withdraw'
@@ -18,10 +20,12 @@
type Props = {
+type: RelationshipButtonType,
+onPress: () => mixed,
+ +isLoading: boolean,
+ +size?: ButtonSize,
};
function RelationshipButton(props: Props): React.Node {
- const { type, onPress } = props;
+ const { type, onPress, isLoading, size } = props;
const styles = useStyles(unboundStyles);
const colors = useColors();
@@ -29,6 +33,10 @@
const buttonStyle = React.useMemo(() => {
const result = [styles.buttonContainer];
+ if (size === 'S') {
+ result.push(styles.smallButtonContainer);
+ }
+
if (type === 'add' || type === 'accept' || type === 'unblock') {
result.push(styles.greenButton);
} else {
@@ -36,35 +44,72 @@
}
return result;
- }, [styles.buttonContainer, styles.greenButton, styles.redButton, type]);
+ }, [
+ size,
+ styles.buttonContainer,
+ styles.greenButton,
+ styles.redButton,
+ styles.smallButtonContainer,
+ type,
+ ]);
+
+ const buttonTextStyle = React.useMemo(() => {
+ const result = [styles.buttonText];
+
+ if (size === 'S') {
+ result.push(styles.smallButtonText);
+ }
+
+ return result;
+ }, [size, styles.buttonText, styles.smallButtonText]);
- let buttonText = 'Add Friend';
+ let buttonText = 'Add friend';
let icon = 'user-plus';
if (type === 'withdraw') {
- buttonText = 'Withdraw Friend Request';
+ buttonText = 'Withdraw friend request';
icon = 'user-minus';
} else if (type === 'accept') {
- buttonText = 'Accept';
+ buttonText = 'Accept friend request';
} else if (type === 'reject') {
- buttonText = 'Reject';
+ buttonText = 'Reject friend request';
icon = 'user-minus';
} else if (type === 'block') {
- buttonText = 'Block User';
+ buttonText = 'Block user';
icon = 'user-shield';
} else if (type === 'unblock') {
- buttonText = 'Unblock User';
+ buttonText = 'Unblock user';
icon = 'user-shield';
}
+ const buttonContent = React.useMemo(() => {
+ if (isLoading) {
+ return ;
+ }
+
+ return (
+ <>
+
+ {buttonText}
+ >
+ );
+ }, [
+ buttonText,
+ buttonTextStyle,
+ colors.floatingButtonLabel,
+ colors.whiteText,
+ icon,
+ isLoading,
+ styles.buttonIcon,
+ ]);
+
return (
-