From 44da58a569516272f5587632061247f5d08442fd Mon Sep 17 00:00:00 2001 From: natjms Date: Sun, 21 Mar 2021 10:56:45 -0300 Subject: [PATCH] Add moderation context menu to profiles --- src/components/moderate-menu.js | 51 +++++++++++++++++++++++++++++++++ src/components/pages/profile.js | 31 ++++++++++++++------ src/components/posts/post.js | 34 ++++------------------ 3 files changed, 80 insertions(+), 36 deletions(-) create mode 100644 src/components/moderate-menu.js diff --git a/src/components/moderate-menu.js b/src/components/moderate-menu.js new file mode 100644 index 0000000..21987ee --- /dev/null +++ b/src/components/moderate-menu.js @@ -0,0 +1,51 @@ +import React from "react"; +import { Dimensions, View, Image } from "react-native"; +import { + Menu, + MenuOptions, + MenuOption, + MenuTrigger, + renderers +} from "react-native-popup-menu"; + +const { SlideInMenu } = renderers; + +const SCREEN_WIDTH = Dimensions.get("window").width; + +const ModerateMenuJsx = (props) => { + const optionsStyles = { + optionWrapper: { // The wrapper around a single option + paddingLeft: SCREEN_WIDTH / 15, + paddingTop: SCREEN_WIDTH / 30, + paddingBottom: SCREEN_WIDTH / 30 + }, + optionsWrapper: { // The wrapper around all options + marginTop: SCREEN_WIDTH / 20, + marginBottom: SCREEN_WIDTH / 20, + }, + optionsContainer: { // The Animated.View + borderTopLeftRadius: 10, + borderTopRightRadius: 10 + } + }; + + return ( + + + + + + + + + + + + + + ); +} + +export { ModerateMenuJsx as default }; diff --git a/src/components/pages/profile.js b/src/components/pages/profile.js index 2d7a4ae..d9f2c28 100644 --- a/src/components/pages/profile.js +++ b/src/components/pages/profile.js @@ -17,6 +17,8 @@ import { ScreenWithFullNavigationJsx } from "src/components/navigation/navigators"; +import ModerateMenuJsx from "src/components/moderate-menu.js"; + const TEST_IMAGE = "https://cache.desktopnexus.com/thumbseg/2255/2255124-bigthumbnail.jpg"; const TEST_POSTS = [ { @@ -141,7 +143,8 @@ const ViewProfileJsx = ({navigation}) => { const ProfileDisplayJsx = ({navigation}) => { const accountName = navigation.getParam("acct", ""); let [state, setState] = useState({ - loaded: false + loaded: false, + own: false }); const notif_pack = { @@ -195,11 +198,22 @@ const ProfileDisplayJsx = ({navigation}) => { @{state.profile.username } - - - + { + state.own ? + + + + : + } { state.profile.statuses_count } posts •  @@ -270,10 +284,11 @@ const styles = { borderRadius: "100%", marginRight: screen_width / 20 }, - bell: { + profileHeaderIcon: { width: screen_width / 12, height: screen_width / 12, - + }, + profileContextContainer: { marginLeft: "auto", marginRight: screen_width / 15 }, diff --git a/src/components/posts/post.js b/src/components/posts/post.js index 9e38742..52b9b29 100644 --- a/src/components/posts/post.js +++ b/src/components/posts/post.js @@ -8,26 +8,15 @@ import { ScrollView } from "react-native"; -import { - Menu, - MenuOptions, - MenuOption, - MenuTrigger, - renderers -} from "react-native-popup-menu"; - - -import { pluralize, timeToAge } from "src/interface/rendering" +import { pluralize, timeToAge} from "src/interface/rendering" import PostActionBarJsx from "src/components/posts/post-action-bar"; +import ModerateMenuJsx from "src/components/moderate-menu.js"; + const SCREEN_WIDTH = Dimensions.get("window").width; const TEST_IMAGE = "https://cache.desktopnexus.com/thumbseg/2255/2255124-bigthumbnail.jpg"; -// Extract the SlideInMenu function from `renderers` -// This will be used in RawPostJsx -const { SlideInMenu } = renderers; - function getAutoHeight(w1, h1, w2) { /* Given the original dimensions and the new width, calculate what would @@ -90,20 +79,9 @@ export const RawPostJsx = (props) => { source = { { uri: props.data.avatar } } /> { props.data.username } - - - - - - - - - - - - + { props.data.media_attachments.length > 1 ?