How can I build two buttons where when i click at chat button then it will directly go to chat history and if i click at calls button it will directly go to call history?
Is there is alternative of making dynamic buttons?
import { StyleSheet, TouchableOpacity, Text, View } from 'react-native'
import React, { useState } from 'react'
import { Colors } from '../constants'
import { useNavigation } from '@react-navigation/native'
export const GroupofButtons = ({ buttons, dosom }) => {
const navigation = useNavigation();
const [clickedId, setClickedId] = useState(0);
// const doinSomething = ({item}) => {
// navigation.navigator('item');
// }
const Nav = () => {
navigation.navigate("ChatsPage");
}
const Nav1 = () => {
navigation.navigate("CallingScreen");
}
const handleClick = (id) => {
setClickedId(id)
}
return (
<View style={styles.container}>
{
buttons.map((buttonsLabel, index) => {
return (
<TouchableOpacity
onPress={() => {Nav(),Nav1() , handleClick( index)}}
key={index}
style={[
index === clickedId ? styles.buttonActive : styles.buttons,
]}>
<Text
style={index === clickedId ? styles.textActive : styles.text}>{buttonsLabel}</Text>
</TouchableOpacity>
)
})
}
</View>
)
}
const styles = StyleSheet.create({
container: {
padding: 10,
flexDirection: 'row',
},
buttons: {
height: 25,
width: 55,
marginLeft: 10,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'white',
borderRadius: 7,
borderWidth: 1,
boarderColor: Colors.primary,
},
buttonActive: {
height: 25,
width: 55,
marginLeft: 10,
alignItems: 'center',
justifyContent: 'center',
borderRadius: 7,
backgroundColor: Colors.primary,
},
textActive: {
color: 'white',
},
text: {
color: 'black',
},
})