Skip to content

Commit

Permalink
Use customLogoUrl prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Shreyaschorge committed Jan 18, 2024
1 parent 4a00968 commit b0e6f41
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion react-native-sign-in-with-neynar/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neynar/react-native-signin",
"version": "0.2.2",
"version": "0.2.3",
"keywords": [
"react-native",
"neynar",
Expand Down
20 changes: 17 additions & 3 deletions react-native-sign-in-with-neynar/src/NeynarSigninButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Linking,
ViewStyle,
TextStyle,
Image,
} from "react-native";
import NeynarLogo from "./components/NeynarLogo";
import WebView, { WebViewMessageEvent } from "react-native-webview";
Expand Down Expand Up @@ -91,7 +92,7 @@ export const NeynarSigninButton = ({
color,
backgroundColor,
customLogoUrl,
logoSize,
logoSize = "30",
buttonStyles: customButtonStyle,
textStyles: customTextStyle,
}: IProps) => {
Expand Down Expand Up @@ -121,7 +122,7 @@ export const NeynarSigninButton = ({
}
};

const getLogo = (logoSize: string = "30") => {
const getLogo = () => {
try {
if (Number.isNaN(parseInt(logoSize)))
throw new Error("logoSize must be a number");
Expand Down Expand Up @@ -154,6 +155,11 @@ export const NeynarSigninButton = ({
}
};

const getCustomLogo = () => {
if (!customLogoUrl) return <></>;
return <Image source={{ uri: customLogoUrl }} style={styles.customLogo} />;
};

const defaultButtonStyle: ViewStyle = {
flexDirection: "row",
alignItems: "center",
Expand Down Expand Up @@ -189,7 +195,7 @@ export const NeynarSigninButton = ({
return (
<>
<TouchableOpacity onPress={handleOnPress} style={combinedButtonStyle}>
{!text && getLogo(logoSize)}
{!text ? getLogo() : getCustomLogo()}
<Text style={combinedTextStyle}>{text || getButtonText()}</Text>
</TouchableOpacity>
{modalVisible && (
Expand Down Expand Up @@ -224,3 +230,11 @@ export const NeynarSigninButton = ({
</>
);
};

const styles = StyleSheet.create({
customLogo: {
width: 30,
height: 30,
resizeMode: "contain",
},
});

0 comments on commit b0e6f41

Please sign in to comment.