aboutsummaryrefslogtreecommitdiff
path: root/src/components/common/SocialIcon.tsx
diff options
context:
space:
mode:
authorJustin Shillingford <jgs272@cornell.edu>2020-08-17 11:17:31 -0400
committerGitHub <noreply@github.com>2020-08-17 11:17:31 -0400
commit2a300bd5e09e44832699a0bcd449de5a35368706 (patch)
treeb627bd55205b23e765c3646ac6cddb6fa8b6d1a1 /src/components/common/SocialIcon.tsx
parent59ea758ba64dd4e00f12b5ceb941d0ea5e273210 (diff)
[TMA-19*] Abstracted out Social Icon logic (#32)
* Basic mostly functional implementation Need to figure out why API is being called so much * Hey it works now! Without a million API calls! * Fixed bug where app would crash upon login Also updated property names to be more appropriate * Added post datetime and social icon * Updated error message * Fixed typecheck errors I don't know that these fixes are the best since I don't think they're generalizable * Formatted datetime in PostHeader * Abstracted out social icon switching logic * Basic mostly functional implementation Need to figure out why API is being called so much * Hey it works now! Without a million API calls! * Fixed bug where app would crash upon login Also updated property names to be more appropriate * Added post datetime and social icon * Updated error message * Fixed typecheck errors I don't know that these fixes are the best since I don't think they're generalizable * Abstracted out social icon switching logic
Diffstat (limited to 'src/components/common/SocialIcon.tsx')
-rw-r--r--src/components/common/SocialIcon.tsx50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/components/common/SocialIcon.tsx b/src/components/common/SocialIcon.tsx
new file mode 100644
index 00000000..5c1098af
--- /dev/null
+++ b/src/components/common/SocialIcon.tsx
@@ -0,0 +1,50 @@
+import React from 'react';
+import {Image} from 'react-native';
+
+interface SocialIconProps {
+ social: string;
+ style: object;
+}
+/**
+ * An image component that returns the <Image> of the icon for a specific social media platform.
+ */
+const SocialIcon: React.FC<SocialIconProps> = ({
+ social: social,
+ style: style,
+}) => {
+ switch (social) {
+ case 'Instagram':
+ var icon = require('../../assets/images/instagram-icon.png');
+ break;
+ case 'Facebook':
+ var icon = require('../../assets/images/facebook-icon.png');
+ break;
+ case 'Twitter':
+ var icon = require('../../assets/images/twitter-icon.png');
+ break;
+ case 'Twitch':
+ var icon = require('../../assets/images/twitch-icon.png');
+ break;
+ case 'Pinterest':
+ var icon = require('../../assets/images/pinterest-icon.png');
+ break;
+ case 'Whatsapp':
+ var icon = require('../../assets/images/whatsapp-icon.png');
+ break;
+ case 'Linkedin':
+ var icon = require('../../assets/images/linkedin-icon.png');
+ break;
+ case 'Snapchat':
+ var icon = require('../../assets/images/snapchat-icon.png');
+ break;
+ case 'Youtube':
+ var icon = require('../../assets/images/youtube-icon.png');
+ break;
+ default:
+ var icon = require('../../assets/images/logo.png');
+ break;
+ }
+ return <Image style={style} source={icon} />;
+};
+
+export default SocialIcon;