|
@@ -17,6 +17,7 @@ import { API_HOST } from 'src/constants';
|
|
import { AvatarWithInitials } from 'src/components';
|
|
import { AvatarWithInitials } from 'src/components';
|
|
import * as ImagePicker from 'expo-image-picker';
|
|
import * as ImagePicker from 'expo-image-picker';
|
|
import * as yup from 'yup';
|
|
import * as yup from 'yup';
|
|
|
|
+import Checkbox from 'expo-checkbox';
|
|
|
|
|
|
import { FlashList } from '@shopify/flash-list';
|
|
import { FlashList } from '@shopify/flash-list';
|
|
import { useSheetRouter } from 'react-native-actions-sheet';
|
|
import { useSheetRouter } from 'react-native-actions-sheet';
|
|
@@ -51,7 +52,12 @@ const RouteAddGroup = () => {
|
|
setGroupName,
|
|
setGroupName,
|
|
description,
|
|
description,
|
|
setDescription,
|
|
setDescription,
|
|
- clearStore
|
|
|
|
|
|
+ canEdit,
|
|
|
|
+ canSend,
|
|
|
|
+ canAdd,
|
|
|
|
+ setCanEdit,
|
|
|
|
+ setCanSend,
|
|
|
|
+ setCanAdd
|
|
} = useGroupChatStore();
|
|
} = useGroupChatStore();
|
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
|
|
|
|
@@ -109,7 +115,10 @@ const RouteAddGroup = () => {
|
|
name: values.name,
|
|
name: values.name,
|
|
description: values.description,
|
|
description: values.description,
|
|
users: selectedUsers.map((user) => +user.user_id),
|
|
users: selectedUsers.map((user) => +user.user_id),
|
|
- admins: []
|
|
|
|
|
|
+ admins: [],
|
|
|
|
+ members_can_edit_settings: canEdit ? 1 : 0,
|
|
|
|
+ members_can_send_messages: canSend ? 1 : 0,
|
|
|
|
+ members_can_add_new_members: canAdd ? 1 : 0
|
|
};
|
|
};
|
|
|
|
|
|
if (image && image.uri) {
|
|
if (image && image.uri) {
|
|
@@ -246,38 +255,76 @@ const RouteAddGroup = () => {
|
|
formikError={props.touched.description && props.errors.description}
|
|
formikError={props.touched.description && props.errors.description}
|
|
/>
|
|
/>
|
|
|
|
|
|
- {selectedUsers.length > 0 ? (
|
|
|
|
- <View
|
|
|
|
- style={[
|
|
|
|
- styles.usersRow,
|
|
|
|
- props.errors.users ? { borderColor: Colors.RED, borderWidth: 1 } : {}
|
|
|
|
- ]}
|
|
|
|
- >
|
|
|
|
- <FlashList
|
|
|
|
- viewabilityConfig={{
|
|
|
|
- waitForInteraction: true,
|
|
|
|
- itemVisiblePercentThreshold: 50,
|
|
|
|
- minimumViewTime: 1000
|
|
|
|
- }}
|
|
|
|
- scrollEnabled={false}
|
|
|
|
- data={selectedUsers}
|
|
|
|
- renderItem={renderUserItem}
|
|
|
|
- keyExtractor={(item) => item.user_id.toString()}
|
|
|
|
- estimatedItemSize={100}
|
|
|
|
- extraData={selectedUsers}
|
|
|
|
- showsVerticalScrollIndicator={false}
|
|
|
|
- contentContainerStyle={styles.selectedUsersList}
|
|
|
|
- numColumns={4}
|
|
|
|
- />
|
|
|
|
|
|
+ <View>
|
|
|
|
+ <Text style={styles.title}>Members can</Text>
|
|
|
|
+
|
|
|
|
+ <View style={styles.optionsContainer}>
|
|
|
|
+ <TouchableOpacity style={styles.option} onPress={() => setCanEdit(!canEdit)}>
|
|
|
|
+ <Text style={styles.optionText}>Edit group settings</Text>
|
|
|
|
+ <Checkbox
|
|
|
|
+ style={{ backgroundColor: Colors.WHITE, borderRadius: 4 }}
|
|
|
|
+ color={Colors.DARK_BLUE}
|
|
|
|
+ value={canEdit}
|
|
|
|
+ onValueChange={setCanEdit}
|
|
|
|
+ />
|
|
|
|
+ </TouchableOpacity>
|
|
|
|
+
|
|
|
|
+ <TouchableOpacity style={styles.option} onPress={() => setCanSend(!canSend)}>
|
|
|
|
+ <Text style={styles.optionText}>Send messages</Text>
|
|
|
|
+ <Checkbox
|
|
|
|
+ style={{ backgroundColor: Colors.WHITE, borderRadius: 4 }}
|
|
|
|
+ color={Colors.DARK_BLUE}
|
|
|
|
+ value={canSend}
|
|
|
|
+ onValueChange={setCanSend}
|
|
|
|
+ />
|
|
|
|
+ </TouchableOpacity>
|
|
|
|
+
|
|
|
|
+ <TouchableOpacity style={styles.option} onPress={() => setCanAdd(!canAdd)}>
|
|
|
|
+ <Text style={styles.optionText}>Add new members</Text>
|
|
|
|
+ <Checkbox
|
|
|
|
+ style={{ backgroundColor: Colors.WHITE, borderRadius: 4 }}
|
|
|
|
+ color={Colors.DARK_BLUE}
|
|
|
|
+ value={canAdd}
|
|
|
|
+ onValueChange={setCanAdd}
|
|
|
|
+ />
|
|
|
|
+ </TouchableOpacity>
|
|
</View>
|
|
</View>
|
|
- ) : null}
|
|
|
|
- {props.errors.users && (
|
|
|
|
- <Text
|
|
|
|
- style={[styles.textError, selectedUsers.length > 0 ? { marginTop: -32 } : {}]}
|
|
|
|
- >
|
|
|
|
- select at least 2 members
|
|
|
|
- </Text>
|
|
|
|
- )}
|
|
|
|
|
|
+ </View>
|
|
|
|
+ <View>
|
|
|
|
+ <Text style={styles.title}>Members: {selectedUsers.length}</Text>
|
|
|
|
+ {selectedUsers.length > 0 ? (
|
|
|
|
+ <View
|
|
|
|
+ style={[
|
|
|
|
+ styles.usersRow,
|
|
|
|
+ props.errors.users ? { borderColor: Colors.RED, borderWidth: 1 } : {}
|
|
|
|
+ ]}
|
|
|
|
+ >
|
|
|
|
+ <FlashList
|
|
|
|
+ viewabilityConfig={{
|
|
|
|
+ waitForInteraction: true,
|
|
|
|
+ itemVisiblePercentThreshold: 50,
|
|
|
|
+ minimumViewTime: 1000
|
|
|
|
+ }}
|
|
|
|
+ scrollEnabled={false}
|
|
|
|
+ data={selectedUsers}
|
|
|
|
+ renderItem={renderUserItem}
|
|
|
|
+ keyExtractor={(item) => item.user_id.toString()}
|
|
|
|
+ estimatedItemSize={100}
|
|
|
|
+ extraData={selectedUsers}
|
|
|
|
+ showsVerticalScrollIndicator={false}
|
|
|
|
+ contentContainerStyle={styles.selectedUsersList}
|
|
|
|
+ numColumns={4}
|
|
|
|
+ />
|
|
|
|
+ </View>
|
|
|
|
+ ) : null}
|
|
|
|
+ {props.errors.users && (
|
|
|
|
+ <Text
|
|
|
|
+ style={[styles.textError, selectedUsers.length > 0 ? { marginTop: -18 } : {}]}
|
|
|
|
+ >
|
|
|
|
+ select at least 2 members
|
|
|
|
+ </Text>
|
|
|
|
+ )}
|
|
|
|
+ </View>
|
|
</ScrollView>
|
|
</ScrollView>
|
|
</View>
|
|
</View>
|
|
);
|
|
);
|
|
@@ -405,6 +452,30 @@ const styles = StyleSheet.create({
|
|
fontSize: getFontSize(12),
|
|
fontSize: getFontSize(12),
|
|
fontFamily: 'redhat-600',
|
|
fontFamily: 'redhat-600',
|
|
marginTop: 5
|
|
marginTop: 5
|
|
|
|
+ },
|
|
|
|
+ optionsContainer: {
|
|
|
|
+ paddingHorizontal: 8,
|
|
|
|
+ borderRadius: 8,
|
|
|
|
+ backgroundColor: Colors.FILL_LIGHT
|
|
|
|
+ },
|
|
|
|
+ option: {
|
|
|
|
+ flexDirection: 'row',
|
|
|
|
+ alignItems: 'center',
|
|
|
|
+ justifyContent: 'space-between',
|
|
|
|
+ paddingVertical: 10,
|
|
|
|
+ borderBottomWidth: 1,
|
|
|
|
+ borderBlockColor: Colors.WHITE
|
|
|
|
+ },
|
|
|
|
+ optionText: {
|
|
|
|
+ fontSize: getFontSize(12),
|
|
|
|
+ fontWeight: '600',
|
|
|
|
+ color: Colors.DARK_BLUE
|
|
|
|
+ },
|
|
|
|
+ title: {
|
|
|
|
+ color: Colors.DARK_BLUE,
|
|
|
|
+ fontSize: getFontSize(14),
|
|
|
|
+ fontFamily: 'redhat-700',
|
|
|
|
+ marginBottom: 5
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|