Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made settings tab and added leave group #50

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 100 additions & 17 deletions app/(tabs)/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,114 @@
import { StyleSheet } from 'react-native';

import EditScreenInfo from '../../components/EditScreenInfo';
import { Pressable, StyleSheet } from 'react-native';
import Modal from "react-native-modal";
import { Text, View } from '../../components/Themed';
import { FontAwesome5 } from '@expo/vector-icons';
import { useState } from 'react';

export default function SettingsScreen() {
const [isModalVisible, setIsModalVisible] = useState(false);

const handleModal = () => setIsModalVisible(() => !isModalVisible);

const leaveGroup = () => {
//Remove from GUN group here
}

const renderButton = (text: 'Yes' | 'No') => {
return (
<Pressable style={[styles.button, { backgroundColor: text === 'Yes' ? '#5CBCA9' : '#E35F52' }]} onPress={() => {
if (text === 'Yes')
{
leaveGroup()
}
handleModal()
}}>
<Text style={styles.buttonText}>{text}</Text>
</Pressable>
);
};

return (
<View style={styles.container}>
<Text style={styles.title}>Settings</Text>
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
<EditScreenInfo path="app/(tabs)/settings.tsx" />
<View>
<View>
<Pressable style={styles.listButton}>
<Text style={styles.accountSettingsText}>Account Settings</Text>
</Pressable>
<Pressable style={styles.listButton} onPress={handleModal}>
<Text style={styles.leaveGroupText}>Leave Group</Text>
<FontAwesome5
name="sign-out-alt"
size={20}
color={'red'}
/>
</Pressable>
</View>
<Modal
animationIn='zoomIn'
animationOut='zoomOut'
isVisible={isModalVisible}
onBackdropPress={handleModal}>
<View style={styles.modalContainer}>
<View style={styles.modalContent}>
<Text style={styles.modalTitleText}>Leave Group</Text>
<Text style={styles.modalContentText}>Are you sure you want to leave the group?</Text>
<View style={styles.buttonContainer}>
{renderButton('Yes')}
{renderButton('No')}
</View>
</View>
</View>
</Modal>
</View>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
listButton: {
padding: 12,
justifyContent: 'space-between',
alignContent: 'center',
flexDirection: 'row',
borderBottomWidth: 1,
borderBottomColor: 'gray'
},
title: {
fontSize: 20,
leaveGroupText: {
fontSize: 16,
fontWeight: 'bold',
color: 'red'
},
separator: {
marginVertical: 30,
height: 1,
width: '80%',
accountSettingsText: {
fontSize: 16,
},
modalContainer: {
justifyContent: 'center',
backgroundColor: 'rgba(0, 0, 0, 0.5)',
},
modalContent: {
padding: 20,
borderRadius: 10,
},
modalTitleText: {
fontSize: 30,
},
modalContentText: {
fontSize: 16,
},
buttonContainer: {
flexDirection: 'row',
justifyContent: 'space-evenly',
padding: 10,
},
button: {
alignItems: 'center',
justifyContent: 'center',
paddingVertical: 12,
paddingHorizontal: 24,
borderRadius: 4,
elevation: 3,
width: "40%",
},
buttonText: {
color: 'white',
fontSize: 16,
}
});