diff options
Diffstat (limited to 'src/screens')
| -rw-r--r-- | src/screens/profile/CaptionScreen.tsx | 120 | ||||
| -rw-r--r-- | src/screens/profile/DraggableNoPress.tsx | 0 |
2 files changed, 119 insertions, 1 deletions
diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index a41abba6..ec55e43a 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -1,6 +1,6 @@ import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; -import React, {Fragment, useState} from 'react'; +import React, {Fragment, useRef, useState} from 'react'; import { Alert, Image, @@ -8,6 +8,7 @@ import { KeyboardAvoidingView, Platform, StyleSheet, + // Text, TouchableWithoutFeedback, View, } from 'react-native'; @@ -41,6 +42,12 @@ interface CaptionScreenProps { route: CaptionScreenRouteProp; navigation: CaptionScreenNavigationProp; } +interface momentTag { + userID: string; + username: string; + xLocation: number; + yLocation: number; +} const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { const {title, image, screenType} = route.params; @@ -50,6 +57,38 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { const dispatch = useDispatch(); const [caption, setCaption] = useState(''); const [loading, setLoading] = useState(false); + // const [isTop, setIsTop] = useState(false); + const imageRef = useRef(null); + + // const zIndex = [0, 999]; + // state variables used to position draggables + // const [offset, setOffset] = useState([0, 0]); + // const [curStart, setCurStart] = useState([0, 0]); + // const [imageDimensions, setImageDimensions] = useState([0, 0]); + + // state var used to keep track of draggable z ordering + // const [layerOrder, setLayerOrder] = useState<string[]>([]); + + // created a state variable to keep track of every tag + // idea is that each element in the list + // const [taggList, setTaggList] = useState([ + // { + // first_name: 'Ivan', + // id: 'cee45bf8-7f3d-43c8-99bb-ec04908efe58', + // last_name: 'Chen', + // thumbnail_url: + // 'https://tagg-dev.s3.us-east-2.amazonaws.com/thumbnails/smallProfilePicture/spp-cee45bf8-7f3d-43c8-99bb-ec04908efe58-thumbnail.jpg', + // username: 'ivan.tagg', + // }, + // { + // first_name: 'Ankit', + // id: '3bcf6947-bee6-46b0-ad02-6f4d25eaeac3', + // last_name: 'Thanekar', + // thumbnail_url: + // 'https://tagg-dev.s3.us-east-2.amazonaws.com/thumbnails/smallProfilePicture/spp-3bcf6947-bee6-46b0-ad02-6f4d25eaeac3-thumbnail.jpg', + // username: 'ankit.thanekar', + // }, + // ]); const navigateToProfile = () => { //Since the logged In User is navigating to own profile, useXId is not required @@ -58,6 +97,49 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { userXId: undefined, }); }; + /** + * Helper function that we use to keep track of which element should be on top most layer + * @param index + */ + // const bringToFront = (index: number) => { + // let currUser = taggList[index].id; + // if (layerOrder.includes(currUser)) { + // layerOrder.splice(layerOrder.indexOf(currUser), 1); + // } + // layerOrder.push(currUser); + // setLayerOrder(layerOrder); + // }; + + /** + * Helper function that tells us if the current draggable is the topmost one. + * @param index + */ + // const isOnTop = (index: number) => { + // let currUser = taggList[index].id; + // return currUser === layerOrder[0]; + // }; + /** + * function that sets the initial position of each newly created tag + * @returns + */ + + /** + * need a handler to take care of creating a tagged user object, append that object to the taggList state variable. + * @returns + */ + + // useEffect(() => { + // imageRef.current.measure((fx, fy, width, height, px, py) => { + // // console.log('Component width is: ' + width); + // // console.log('Component height is: ' + height); + // // console.log('X offset to frame: ' + fx); + // // console.log('Y offset to frame: ' + fy); + // // console.log('X offset to page: ' + px); + // // console.log('Y offset to page: ' + py); + // setOffset([px, py]); + // setImageDimensions([width, height]); + // }); + // }, []); const handleShare = async () => { setLoading(true); @@ -105,7 +187,9 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { /> </View> <CaptionScreenHeader style={styles.header} {...{title: title}} /> + {/* this is the image we want to center our tags' initial location within */} <Image + ref={imageRef} style={styles.image} source={{uri: image.path}} resizeMode={'cover'} @@ -118,6 +202,40 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { onChange={setCaption} partTypes={mentionPartTypes('blue')} /> + {/* Draggables - Commented out for now */} + {/* <Draggable + // ivan + x={imageDimensions[0] / 2 - curStart[0] / 2 + offset[0]} + y={offset[1] + imageDimensions[1] / 2 - curStart[1] / 2} + z={999} + minX={offset[0]} + minY={offset[1]} + maxX={imageDimensions[0] + offset[0]} + maxY={imageDimensions[1] + offset[1]} + onDragStart={() => bringToFront(0)}> + <TaggDraggable + taggedUser={taggList[0]} + editingView={true} + deleteFromList={() => console.log('Hello world')} + setStart={setCurStart} + /> + </Draggable> + <Draggable + x={imageDimensions[0] / 2 - curStart[0] / 2 + offset[0]} + y={offset[1] + imageDimensions[1] / 2 - curStart[1] / 2} + z={0} + minX={offset[0]} + minY={offset[1]} + maxX={imageDimensions[0] + offset[0]} + maxY={imageDimensions[1] + offset[1]} + onDragStart={() => bringToFront(1)}> + <TaggDraggable + taggedUser={taggList[1]} + editingView={true} + deleteFromList={() => console.log('Hello world')} + setStart={setCurStart} + /> + </Draggable> */} </View> </KeyboardAvoidingView> </TouchableWithoutFeedback> diff --git a/src/screens/profile/DraggableNoPress.tsx b/src/screens/profile/DraggableNoPress.tsx new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/screens/profile/DraggableNoPress.tsx |
