aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-05-26 19:51:01 -0400
committerIvan Chen <ivan@tagg.id>2021-05-26 19:51:01 -0400
commit50660677fca55f550f8ab56558046409aad13461 (patch)
tree9d2586a8f138604b5b8d6d00627c1bbb256e2777 /src/components
parent0c512ea9bc2ad75b1ae356fa7166044510750581 (diff)
Finish tagging functionality
Diffstat (limited to 'src/components')
-rw-r--r--src/components/common/TaggUserSelectionCell.tsx37
-rw-r--r--src/components/moments/TagFriendsFoooter.tsx2
-rw-r--r--src/components/taggs/TaggDraggable.tsx2
3 files changed, 21 insertions, 20 deletions
diff --git a/src/components/common/TaggUserSelectionCell.tsx b/src/components/common/TaggUserSelectionCell.tsx
index 5424ab9b..72c98822 100644
--- a/src/components/common/TaggUserSelectionCell.tsx
+++ b/src/components/common/TaggUserSelectionCell.tsx
@@ -1,23 +1,20 @@
import React, {useEffect, useState} from 'react';
import {StyleSheet, View} from 'react-native';
-import {
- TouchableOpacity,
- TouchableWithoutFeedback,
-} from 'react-native-gesture-handler';
+import {TouchableWithoutFeedback} from 'react-native-gesture-handler';
import {ProfilePreview} from '..';
-import {ProfilePreviewType, ScreenType} from '../../types';
+import {MomentTagType, ProfilePreviewType, ScreenType} from '../../types';
import {SCREEN_WIDTH} from '../../utils';
import TaggRadioButton from './TaggRadioButton';
interface TaggUserSelectionCellProps {
item: ProfilePreviewType;
- selectedUsers: ProfilePreviewType[];
- setSelectedUsers: Function;
+ tags: MomentTagType[];
+ setTags: (tags: MomentTagType[]) => void;
}
const TaggUserSelectionCell: React.FC<TaggUserSelectionCellProps> = ({
item,
- selectedUsers,
- setSelectedUsers,
+ tags,
+ setTags,
}) => {
const [pressed, setPressed] = useState<boolean>(false);
@@ -26,9 +23,7 @@ const TaggUserSelectionCell: React.FC<TaggUserSelectionCellProps> = ({
*/
useEffect(() => {
const updatePressed = () => {
- const userSelected = selectedUsers.findIndex(
- (selectedUser) => item.id === selectedUser.id,
- );
+ const userSelected = tags.findIndex((tag) => item.id === tag.user.id);
setPressed(userSelected !== -1);
};
updatePressed();
@@ -41,14 +36,20 @@ const TaggUserSelectionCell: React.FC<TaggUserSelectionCellProps> = ({
const handlePress = () => {
// Add to selected list of users
if (pressed === false) {
- setSelectedUsers([...selectedUsers, item]);
+ setTags([
+ ...tags,
+ {
+ id: '',
+ x: 50,
+ y: 50,
+ z: 1,
+ user: item,
+ },
+ ]);
}
// Remove item from selected list of users
else {
- const filteredSelection = selectedUsers.filter(
- (user) => user.id !== item.id,
- );
- setSelectedUsers(filteredSelection);
+ setTags(tags.filter((tag) => tag.user.id !== item.id));
}
};
return (
@@ -60,7 +61,7 @@ const TaggUserSelectionCell: React.FC<TaggUserSelectionCellProps> = ({
screenType={ScreenType.Profile}
/>
</View>
- <TaggRadioButton pressed={pressed} onPress={handlePress} />
+ <TaggRadioButton pressed={pressed} onPress={() => null} />
</TouchableWithoutFeedback>
);
};
diff --git a/src/components/moments/TagFriendsFoooter.tsx b/src/components/moments/TagFriendsFoooter.tsx
index 352ee49a..365d709d 100644
--- a/src/components/moments/TagFriendsFoooter.tsx
+++ b/src/components/moments/TagFriendsFoooter.tsx
@@ -41,7 +41,7 @@ const TagFriendsFooter: React.FC<TagFriendsFooterProps> = ({tags, setTags}) => {
<Text style={styles.tagMoreLabel}>{'Tagg More'}</Text>
</TouchableOpacity>
),
- [],
+ [tags],
);
const TaggedUser = (user: ProfilePreviewType) => (
diff --git a/src/components/taggs/TaggDraggable.tsx b/src/components/taggs/TaggDraggable.tsx
index 86915bb4..8e330d0b 100644
--- a/src/components/taggs/TaggDraggable.tsx
+++ b/src/components/taggs/TaggDraggable.tsx
@@ -40,7 +40,7 @@ const TaggDraggable: React.FC<TaggDraggableProps> = (
return (
<TouchableWithoutFeedback>
- <View ref={draggableRef} style={{borderWidth: 1}}>
+ <View ref={draggableRef}>
<TouchableOpacity
style={styles.container}
disabled={editingView}