diff --git a/assets/eva-icons/close.png b/assets/eva-icons/close.png new file mode 100644 index 0000000..e85d20a Binary files /dev/null and b/assets/eva-icons/close.png differ diff --git a/assets/eva-icons/plus.png b/assets/eva-icons/plus.png new file mode 100644 index 0000000..3a7e147 Binary files /dev/null and b/assets/eva-icons/plus.png differ diff --git a/src/App.js b/src/App.js index 6e909b7..173b96a 100644 --- a/src/App.js +++ b/src/App.js @@ -16,12 +16,14 @@ import SearchJsx from 'src/components/pages/discover/search'; import ViewHashtagJsx from 'src/components/pages/discover/view-hashtag'; import NotificationsJsx from 'src/components/pages/profile/notifications'; import UserListJsx from "src/components/pages/user-list.js"; +import SettingsJsx from "src/components/pages/profile/settings.js"; const Stack = createStackNavigator({ Feed: { screen: FeedJsx, }, Discover: { screen: DiscoverJsx }, Notifications: { screen: NotificationsJsx }, Profile: { screen: ProfileJsx, }, + Settings: { screen: SettingsJsx }, Search: { screen: SearchJsx }, ViewPost: { screen: ViewPostJsx }, ViewComments: { screen: ViewCommentsJsx }, diff --git a/src/components/pages/profile.js b/src/components/pages/profile.js index 568ca50..1a80d83 100644 --- a/src/components/pages/profile.js +++ b/src/components/pages/profile.js @@ -4,12 +4,13 @@ import { Dimensions, Image, Text, - TouchableWithoutFeedback + TouchableOpacity } from "react-native"; import * as Linking from "expo-linking"; -import { activeOrNot } from "src/interface/interactions" +import { activeOrNot } from "src/interface/interactions"; +import { withoutHTML } from "src/interface/rendering"; import GridViewJsx from "src/components/posts/grid-view"; import { @@ -86,10 +87,6 @@ const TEST_THEIR_FOLLOWERS = [ { id: 6 }, ]; -function withoutHTML(string) { - return string.replaceAll(/<[^>]*>/ig, ""); -} - function getMutuals(yours, theirs) { // Where yours and theirs are arrays of followers, as returned by the oAPI @@ -164,19 +161,24 @@ const ProfileDisplayJsx = ({navigation}) => { let profileButton; if (state.own) { profileButton = ( - + { + navigation.navigate("Settings"); + } + }> - Edit profile + Settings - + ); } else { profileButton = ( - + Follow - + ) } @@ -201,11 +203,11 @@ const ProfileDisplayJsx = ({navigation}) => { { state.own ? - + - + : { { state.profile.statuses_count } posts •  - { const context = state.own ? "People following you" @@ -228,8 +229,8 @@ const ProfileDisplayJsx = ({navigation}) => { }> { state.own ? - "View followers" - :state.mutuals.length + " mutuals" + <>View followers + : <>{state.mutuals.length + " mutuals"} } diff --git a/src/components/pages/profile/settings.js b/src/components/pages/profile/settings.js new file mode 100644 index 0000000..81b86fd --- /dev/null +++ b/src/components/pages/profile/settings.js @@ -0,0 +1,295 @@ +import React, { useState, useEffect } from "react"; + +import { + SafeAreaView, + View, + TextInput, + Text, + Image, + TouchableOpacity, + Dimensions, +} from "react-native"; + +import { withoutHTML } from "src/interface/rendering"; + +import { ScreenWithBackBarJsx } from "src/components/navigation/navigators"; + +const TEST_IMAGE = "https://cache.desktopnexus.com/thumbseg/2255/2255124-bigthumbnail.jpg"; +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 + } + ] +}; + +const SettingsJsx = (props) => { + const [state, setState] = useState({ + // Use Context to get this stuff eventually + profile: TEST_PROFILE, + newProfile: TEST_PROFILE, + }); + + useEffect(() => { console.log(state) }); + + const fields = state.newProfile.fields; + + return ( + + + + + + Change profile photo + + + + + Display name + { + setState({...state, + newProfile: {...state.newProfile, display_name: value} + }); + } + }/> + + User name + { + setState({...state, + newProfile: {...state.newProfile, username: value} + }); + } + }/> + + Bio + { + setState({...state, + newProfile: {...state.newProfile, note: value} + }); + } + }/> + { + fields.map((field, i) => + + { + let newFields; + if (fields.length == 1) { + newFields = [{ name: "", value: "" }]; + } else { + newFields = state.newProfile.fields; + newFields.splice(i, 1); + } + + setState({...state, + newProfile: {...state.newProfile, + fields: newFields, + }, + }); + } + }> + + + + Name + { + let newFields = fields; + newFields[i] = {...newFields[i], + name: text, + }; + + setState({...state, + newProfile: {...state.newProfile, + fields: newFields, + }, + }); + } + } /> + + + Value + { + let newFields = fields; + newFields[i] = {...newFields[i], + value: text, + }; + + setState({...state, + newProfile: {...state.newProfile, + fields: newFields, + }, + }); + } + } /> + + + ) + } + { + setState({...state, + newProfile: {...state.newProfile, + fields: state.newProfile.fields.concat({ name: "", value: ""}), + }, + }); + } + }> + + + + Save Profile + + + Log out + + + + ); +}; + +const SCREEN_WIDTH = Dimensions.get("window").width; +const styles = { + label: { + paddingTop: 10, + fontWeight: "bold", + color: "#888", + }, + bar: { + borderBottomWidth: 1, + borderBottomColor: "#888", + padding: 10, + }, + avatar: { + container: { + paddingTop: 10, + paddingBottom: 10, + flex: 1, + alignItems: "center", + }, + image: { + width: SCREEN_WIDTH / 5, + height: SCREEN_WIDTH / 5, + borderRadius: SCREEN_WIDTH / 10, + marginBottom: 10, + }, + change: { + fontSize: 18, + color: "#888", + }, + }, + input: { + container: { + padding: 10, + }, + }, + fields: { + container: { + flex: 1, + flexDirection: "row", + alignItems: "flex-end", + }, + cross: { + width: 30, + height: 30, + marginRight: 10, + marginBottom: 10, + }, + plus: { + width: 30, + height: 30, + marginLeft: "auto", + marginRight: "auto", + marginTop: 10, + }, + subContainer: { + flexGrow: 0.5, + }, + cell: { + width: SCREEN_WIDTH / 2.5, + }, + }, + largeButton: { + width: SCREEN_WIDTH / 1.2, + padding: 15, + marginTop: 10, + marginBottom: 5, + marginLeft: "auto", + marginRight: "auto", + borderWidth: 1, + borderColor: "#888", + borderRadius: 5, + textAlign: "center", + }, + textWarning: { + fontWeight: "bold", + textDecorationLine: "underline", + }, +}; + +export default SettingsJsx; diff --git a/src/interface/rendering.js b/src/interface/rendering.js index 6dee69e..ff2774d 100644 --- a/src/interface/rendering.js +++ b/src/interface/rendering.js @@ -1,3 +1,7 @@ +export function withoutHTML(string) { + return string.replaceAll(/<[^>]*>/ig, ""); +} + export function pluralize(n, singular, plural) { if (n < 2) { return singular;