diff --git a/src/components/pages/profile.js b/src/components/pages/profile.js index ea5c299..adf8179 100644 --- a/src/components/pages/profile.js +++ b/src/components/pages/profile.js @@ -1,5 +1,13 @@ import React, { useState, useEffect } from "react"; -import { View, Dimensions, Image, Text, TouchableWithoutFeedback } from "react-native"; +import { + View, + Dimensions, + Image, + Text, + TouchableWithoutFeedback +} from "react-native"; + +import * as Linking from "expo-linking"; import { activeOrNot } from "src/interface/interactions" @@ -37,6 +45,54 @@ const TEST_POSTS = [ } ]; +const TEST_PROFILE = { + username: "njms", + acct: "njms", + display_name: "Nat🔆", + locked: false, + bot: false, + note: "Yeah heart emoji.", + avatar: TEST_IMAGE, + followers_count: "1 jillion", + statuses_count: 334, + fields: [ + { + name: "Blog", + value: "https://njms.ca", + verified_at: "some time" + }, + { + name: "Github", + value: "https://github.com/natjms", + verified_at: null + } + ] +}; + +function withoutHTML(string) { + return string.replaceAll(/<[^>]*>/ig, ""); +} + +const HTMLLink = ({link}) => { + let url = link.match(/https?:\/\/\w+\.\w+/); + + if (url) { + return ( + { + Linking.openURL(url[0]); + } + }> + { withoutHTML(link) } + + ); + } else { + return ( { withoutHTML(link) } ); + } +} + const ProfileJsx = ({navigation}) => { return ( { const ProfileDisplayJsx = ({navigation}) => { const accountName = navigation.getParam("acct", ""); let [state, setState] = useState({ - avatar: "", - displayName: "Somebody", - username: "somebody", - statusesCount: 0, - followersCount: 0, - followingCount: 0, - note: "Not much here...", - unread_notifications: false, - own: false, loaded: false }); @@ -80,21 +127,11 @@ const ProfileDisplayJsx = ({navigation}) => { useEffect(() => { // do something to get the profile based on given account name - if (!state.loaded) { - setState({ - avatar: TEST_IMAGE, - displayName: "Nat🔆", - username: "njms", - statusesCount: 334, - followersCount: "1 jillion", - followingCount: 7, - note: "Yeah heart emoji.", - own: true, - unread_notifs: false, - loaded: true - }); - } - }); + setState({ + profile: TEST_PROFILE, + loaded: true + }); + }, []); let profileButton; if (state.own) { @@ -117,45 +154,71 @@ const ProfileDisplayJsx = ({navigation}) => { return ( - - - - - - {state.displayName} + { state.loaded ? + <> + + + + + + {state.profile.display_name} + + + @{state.profile.username } + + + + + + + + { state.profile.statuses_count } posts •  + { state.profile.followers_count } followers •  + { state.profile.following_count } following - @{state.username} + + {state.profile.note} + + + { + state.profile.fields.map((row, i) => + + + + + ) + } +
+ { row.name } + + + + +
+ {profileButton}
- - - -
- - { state.statusesCount } posts •  - { state.followersCount } followers •  - { state.followingCount } following - - - {state.note} - - {profileButton} -
- { - navigation.navigate("ViewPost", { - id: id, - originTab: "Profile" - }); - } - } /> + { + navigation.navigate("ViewPost", { + id: id, + originTab: "Profile" + }); + } + } /> + + : + }
); }; @@ -171,7 +234,6 @@ const styles = { display: "flex", flexDirection: "row", alignItems: "center", - marginBottom: screen_width / 20 }, displayName: { @@ -199,6 +261,23 @@ const styles = { fontSize: 16, marginTop: 10, }, + + metaData: { + marginTop: 20 + }, + row: { + padding: 10 + }, + rowName: { + width: "33%", + textAlign: "center" + }, + rowValue: { width: "67%" }, + anchor: { + color: "#888", + textDecoration: "underline" + }, + button: { borderWidth: 1, borderStyle: "solid", @@ -217,4 +296,4 @@ const styles = { }; export { ViewProfileJsx, ProfileDisplayJsx }; -export default ProfileJsx; \ No newline at end of file +export default ProfileJsx;