React Native Scrollview - scroll one by one (items with different widths) - react-native

I have a horizontal ScrollView, all items have different widths
Is there a way to scroll one by one, so it would stop in the center of each item?
If the first answer to question is yes, then is there a way to know the index of item (that is centered), so I can change the index of selected dot?
https://snack.expo.dev/#drujik/horizontal-scroll-diff-widths

Example for: https://i.stack.imgur.com/thKLv.gif
I'm using FlatList and its props.
More information: https://reactnative.dev/docs/flatlist
import * as React from "react";
import { StyleSheet, Dimensions, FlatList, Text, View } from "react-native";
const data = [
{
text: "Page1",
width: 300,
},
{
text: "Page2",
width: 250,
},
{
text: "Page3",
width: 200,
},
];
const DOT_SIZE = 8;
const { width } = Dimensions.get("window");
export default function App() {
const [indexDot, setIndexDot] = React.useState(0);
const onChangeDot = (event) => {
setIndexDot(Math.ceil(event.nativeEvent.contentOffset.x / width));
};
const renderPagination = React.useMemo(() => {
return (
<View style={styles.wrapPagination}>
{data.map((_, index) => {
return (
<View
key={index}
style={[
styles.dot,
{
backgroundColor:
indexDot === index ? "#E7537A" : "rgba(0, 0, 0, 0.3)",
},
]}
/>
);
})}
</View>
);
}, [data?.length, indexDot]);
const renderItem = ({ item }) => (
<View style={styles.wrapItem}>
<View
style={{
...styles.item,
width: item.width,
}}
>
<Text>{item.text}</Text>
</View>
</View>
);
return (
<>
<FlatList
horizontal
pagingEnabled
disableIntervalMomentum
showsHorizontalScrollIndicator={false}
data={data}
renderItem={renderItem}
scrollEventThrottle={200}
onMomentumScrollEnd={onChangeDot}
/>
{renderPagination}
</>
);
}
const styles = StyleSheet.create({
wrapPagination: {
flexDirection: "row",
flex: 1,
justifyContent: "center",
alignItems: "center",
},
dot: {
height: DOT_SIZE,
width: DOT_SIZE,
borderRadius: DOT_SIZE / 2,
marginHorizontal: 3,
},
wrapItem: {
width,
padding: 20,
alignItems: "center",
justifyContent: "center",
},
item: {
alignItems: "center",
justifyContent: "center",
borderWidth: 1,
},
});

You can achieve this by react-native-snap-carousel and For dot, You can use pagination.
import Carousel, { Pagination } from 'react-native-snap-carousel';
const [active, setActive] = useState(0)
const [data, setData] = useState([])
<Carousel
keyExtractor={(_, index) => `id-${index}`}
data={data}
renderItem={renderItem}
onSnapToItem={setActive} />
<Pagination
dotsLength=length}
activeDotIndex={active}
dotStyle={{ backgroundColor: colors.blue }}
inactiveDotStyle={{ backgroundColor: colors.gray }}
inactiveDotScale={1}
inactiveDotOpacity={1} />

Related

How to make horizontal flatlist with 2 rows but the first item should be in one row(full height) and other in half?

I've a flatlist of photos but want to show like below image.
I want to show first item like above image as big box and other images as other half box as seen as in above image.
<FlatList
data={photos}
numColumns={Math.ceil(photos.length/2)}
keyExtractor={(item) => item.id}
renderItem={({item, index}) => {
return (
<Image
source={item.image}
style={{
margin: 5,
width: index === 0 ? 100 : 50,
height: index === 0 ? 100 : 50,
borderRadius: 10
}}
/>
)
}}
/>
i hope this helps. since in horizontal numOfColums isnt supported, you need to modify your data and add conditions in renderItem.
This code is exactly what #andrew developed . all credits to him
Do let me know in case of any doubts
:
import React, {Component} from 'react';
import { View, StyleSheet, Text, FlatList } from 'react-native';
export default class Screen1 extends React.Component {
state = {
data: [
{ text: 'one' },
{ item1: { text: 'two' }, item2: { text: 'three' } },
{ item1: { text: 'four' }, item2: { text: 'five' } },
{ item1: { text: 'six' }},
]
}
renderItem = ({item, index}) => {
if (index === 0) {
return (
<View style={styles.bigSquare}>
<Text>{item.text}</Text>
</View>
)
} else {
return (
<View>
<View style={styles.smallSquare}>
<Text>{item.item1.text}</Text>
</View>
{item.item2 && <View style={[styles.smallSquare, {backgroundColor: 'red'}]}>
<Text>{item.item2.text}</Text>
</View>}
</View>
)
}
}
keyExtractor = (item, index) => `${index}`;
render() {
return (
<View style={styles.container}>
<FlatList
horizontal={true}
data={this.state.data}
renderItem={this.renderItem}
keyExtractor={this.keyExtractor}
/>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
bigSquare: {
height: 220,
width: 220,
margin: 10,
backgroundColor: 'yellow',
justifyContent: 'center',
alignItems: 'center'
},
smallSquare: {
height: 100,
width: 100,
margin: 10,
backgroundColor: 'green',
justifyContent: 'center',
alignItems: 'center'
}
});
PFA link for the same Snack expo

React Native FlatList with columns does not allow horizontal scrolling on Android, but it does on iOS

I'm working on a minesweeper game with React Native. On iOS, I am able to scroll horizontally and vertically. But on Android, I can only scroll vertically.
I've tried modifying the layout and justification of content of the different views, but nothing seems to work.
Here is a shortened version of the code:
const Board = (
{game}: {game: Game}
) => {
//...
return (
<SafeAreaView
style={styles.main}
>
<FlatList
style={styles.flatList}
contentContainerStyle={styles.contentContainer}
data={game.board.grid.flat()}
numColumns={game.size} // n x n grid, so n columns
columnWrapperStyle={{ flexWrap: "nowrap" }}
renderItem={({ item: square }) => {
return (
<TouchableOpacity style={Styles.square}>
{/* ... */}
</TouchableOpacity>
);
}}
/>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
main: {
flex: 1,
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
backgroundColor: "black"
},
flatList: {
},
contentContainer: {
flexGrow: 1,
justifyContent: "center"
},
square: {
width: 35,
height: 35,
justifyContent: "center",
alignItems: "center",
margin: 1
}
});
What could I be missing?
You can add a ScrollView with property horizontal to wrap the FlatList. The code should be like this:
import React from 'react';
import { View, FlatList, ScrollView, StyleSheet } from 'react-native';
/**
* This function creates an array based on the `quantity` value
*/
const placeholderData = (quantity = 16) => (
Array.from(Array(quantity).keys()).map((item) => ({ id: item }))
)
const NUMBER_OF_COLUMNS = 60
const NUMBER_OF_ROWS = 60
const NUMBER_OF_ELEMENTS = NUMBER_OF_COLUMNS * NUMBER_OF_ROWS
export default function App() {
const renderItem = () => (
<View style={styles.square} />
)
return (
<ScrollView
style={styles.container}
horizontal
showsHorizontalScrollIndicator={false}
>
<FlatList
data={placeholderData(NUMBER_OF_ELEMENTS)}
keyExtractor={({id}) => id.toString()}
renderItem={renderItem}
numColumns={NUMBER_OF_COLUMNS}
showsVerticalScrollIndicator={false}
/>
</ScrollView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
square: {
width: 20,
height: 20,
backgroundColor: '#696969',
margin: 1,
},
});
If you prefer, I create a snack on Expo for you to see the complete example running. Just scan the QR Code from your smartphone using the Expo Go App.

how to implement the image rotary using flatlist in react native?

I'm trying to accomplish the vertical carousel as shown in the below gif. I'm struck by the second screen, where when the user scrolls the data from bottom to top or vice versa both the content and image change, how to achieve this? looking forward to your help?enter image description here
I have included a snack example which is mostly similar to what you want. You can use reanimated, Flatlist achieve the animation:
Snack Link
Code:
import * as React from 'react';
import { Text, View, StyleSheet, FlatList, Dimensions } from 'react-native';
import Constants from 'expo-constants';
import Animated, {
useSharedValue,
useAnimatedScrollHandler,
useAnimatedStyle,
interpolate,
Extrapolate,
} from 'react-native-reanimated';
const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
const { width, height } = Dimensions.get('window');
const bottomHeight = height - 150 - 30 - Constants.statusBarHeight;
const data = [
{
title: 'data1',
image:
'https://assets.website-files.com/5f204aba8e0f187e7fb85a87/5f210a533185e7434d9efcab_hero%20img.jpg',
},
{
title: 'data2',
image:
'https://www.whoa.in/201604-Whoa/10-alone-broken-image-mobile-wallpaper-hd-image.jpg',
},
{
title: 'data3',
image:
'https://images.pexels.com/photos/674010/pexels-photo-674010.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500',
},
{
title: 'data4',
image:
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTntlma5HASL0HAM-KiC01A-JX4MxKousAA6A&usqp=CAU',
},
];
const ImageContent = ({ image, scrollValue, index }) => {
const animatedStyle = useAnimatedStyle(() => {
const inputRange = [index * bottomHeight, (index + 1) * bottomHeight];
const translateY = interpolate(
scrollValue.value,
inputRange,
[0, -150],
Extrapolate.CLAMP
);
return {
transform: [{ translateY }],
};
});
return (
<Animated.Image
source={{ uri: image }}
style={[styles.image, { zIndex: data.length - index }, animatedStyle]}
resizeMode="cover"
/>
);
};
const TopPart = React.memo(({ scrollValue }) => {
return (
<View style={styles.topPartContainer}>
{data.map(({ image }, index) => (
<ImageContent {...{ scrollValue, image, index }} />
))}
</View>
);
});
const Item = ({ item, index }) => {
return (
<View
style={[
styles.item,
]}>
<Text style={{ color: 'red' }}>{item.title}</Text>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: Constants.statusBarHeight,
backgroundColor: '#ecf0f1',
},
topPartContainer: {
width: 150,
height: 150,
borderRadius: 75,
alignSelf: 'center',
overflow: 'hidden',
},
image: {
...StyleSheet.absoluteFillObject,
backgroundColor: '#fff',
borderRadius: 75,
},
item: {
width,
backgroundColor: '#fff',
justifyContent: 'center',
alignItems: 'center',
height: bottomHeight,
},
});
function App() {
const scrollValue = useSharedValue(0);
const handler = useAnimatedScrollHandler((event) => {
scrollValue.value = event.contentOffset.y;
});
return (
<View style={styles.container}>
<TopPart {...{ scrollValue }} />
<View style={{ flex: 1, paddingTop: 30, height: bottomHeight }}>
<AnimatedFlatList
contentContainerStyle={{ height: data.length * bottomHeight }}
showsVerticalScrollIndicator={false}
onScroll={handler}
scrollEventThrottle={16}
data={data}
pagingEnabled
keyExtractor={(item) => item.title}
renderItem={({ item, index }) => <Item {...{ item, index }} />}
/>
</View>
</View>
);
}

how to get current flat list item data in reactnative using react-native-swipe-list-view

I'm not getting how to get the current item object of a flat list
I used react-native-swipeout and react-native-swipe-list-view and in both examples I stuck.
And on google I found very big answers. Which are not pointing only the particular issue which confused me a lot.
the below is the deleted function when I used react-native-swipeout plugin
const swipeSettings = {
left: [
{
text: 'Delete',
onPress: () => {
console.log('-----delete-----');
},
type: 'delete',
},
}
All I need is to get the current item object data like below inside onpress() when i tapped the delete button .
{
id: 1,
prodName : "abcdefg",
}
That's all, I came from native script background and in that framework I never faced such issue. Because the documentation was crystal clear. But here In react native everything seems to be complicated for me.
Kindly any one help me.
<FlatList
data={data}
keyExtractor={(item) => item.id}
renderItem={({item, index}) => (
<Swipeout {...swipeSettings}>
<View style={styles.listView}>
<Text style={styles.listViewText}>{item.prodName}</Text>
</View>
</Swipeout>
)}
/>
entire page
import React, {useState} from 'react';
import {View} from 'react-native-animatable';
import {
TextInput,
TouchableOpacity,
FlatList,
} from 'react-native-gesture-handler';
import Icon from 'react-native-vector-icons/FontAwesome';
import {StyleSheet, Pressable, Text, Button} from 'react-native';
import * as Animatable from 'react-native-animatable';
import Swipeout from 'react-native-swipeout';
import ButtonPressable from '../../components/ButtonPressable';
var sqlite_wrapper = require('./sqliteWrapper');
const DATA = [
{
prodName: 'Added data will look like this',
},
];
const swipeSettings = {
style: {
marginBottom: 10,
},
autoClose: false,
backgroundColor: 'transparent',
close: false,
disabled: false,
onClose: (sectionID, rowId, direction) => {
console.log('---onclose--');
},
onOpen: (sectionID, rowId, direction) => {
console.log('---onopen--');
},
right: [
{
backgroundColor: 'dodgerblue',
color: 'white',
text: 'Edit',
onPress: () => {
console.log('-----edit-----');
},
},
],
left: [
{
backgroundColor: 'red',
color: 'white',
text: 'Delete',
onPress: () => {
console.log('-----delete-----');
sqlite_wrapper.deleteById
},
type: 'delete',
// component : (<ButtonPressable text="delete" />)
},
],
// buttonWidth: 100,
};
const AddProductList = ({route, navigation}) => {
const {navData} = route.params;
const [prodName, setProdName] = useState('');
var [data, setData] = useState(DATA);
return (
<View style={styles.container}>
<Animatable.View
animation="bounceIn"
duration={1000}
style={styles.inputFieldView}>
<TextInput
style={styles.textInput}
onChangeText={(value) => setProdName(value)}
placeholder="Add the Product"
defaultValue={prodName}
/>
<TouchableOpacity
style={styles.addView}
onPress={() => {
sqlite_wrapper
.insert({prodName: prodName}, sqlite_wrapper.collection_product)
.then((result) => {
console.log('---result---');
console.log(result);
if (result.rowsAffected) {
fetchAllData();
}
});
function fetchAllData() {
sqlite_wrapper
.readAll(sqlite_wrapper.collection_product)
.then((resultData) => {
console.log('---resultData---');
console.log(resultData);
setData(resultData);
setProdName('');
});
}
// without sql this is how to update the state having a array
// const updatedArray = [...data];
// updatedArray.push({prodName: prodName});
// setData(updatedArray);
// setProdName('');
}}>
<Icon name="plus" size={16} style={styles.add} color="white" />
</TouchableOpacity>
</Animatable.View>
<Animatable.View
animation="bounceInLeft"
duration={1500}
style={{flex: 1}}>
<FlatList
data={data}
keyExtractor={(item) => item.id}
renderItem={({item, index}) => (
<Swipeout {...swipeSettings}>
<View style={styles.listView}>
<Text style={styles.listViewText}>{item.prodName}</Text>
</View>
</Swipeout>
)}
/>
</Animatable.View>
</View>
);
};
var styles = StyleSheet.create({
container: {
flex: 1,
},
inputFieldView: {
flexDirection: 'row',
alignItems: 'center',
alignSelf: 'stretch',
margin: 10,
},
textInput: {
flex: 1,
backgroundColor: '#b2ebf2',
borderTopLeftRadius: 7,
borderBottomLeftRadius: 7,
fontSize: 16,
},
addView: {
backgroundColor: '#0f4c75',
alignSelf: 'stretch',
alignItems: 'center',
justifyContent: 'center',
borderTopEndRadius: 7,
borderBottomEndRadius: 7,
padding: 9,
},
add: {
padding: 7,
},
listView: {
padding: 20,
backgroundColor: 'green',
margin: 0,
borderRadius: 0,
},
listViewText: {
color: 'white',
},
});
export default AddProductList;
So if I get you right you have one generic swipe setting that you want to adjust to each element in the list.
Try changing the renderItem of the Flatlist like this and let me know how it worked for you:
<FlatList
data={data}
keyExtractor={(item) => item.id}
renderItem={({ item, index }) => {
let right = [...swipeSettings.right]; <---- ADDED
let left = [...swipeSettings.left]; <---- ADDED
right[0].onPress = () => console.log('edit', item.prodName); <---- ADDED
left[0].onPress = () => console.log('delete', item.prodName); <---- ADDED
<Swipeout {...swipeSettings} {...{ right, left}} > <---- CHANGED
<View style={styles.listView}>
<Text style={styles.listViewText}>{item.prodName}</Text>
</View>
</Swipeout>
}}
/>
So what I have done here is sending the generic swipe settings to each instance of Swipeout but changed their "Left" and "Right" in order to overwrite their "onPress" function and adjust it to the rendered item.
I know it is hard to understand it like this and it's probably not the best explanation but I hope it will help you somehow.
EDIT
import React, { useState } from 'react';
import { View } from 'react-native-animatable';
import {
TextInput,
TouchableOpacity,
FlatList,
} from 'react-native-gesture-handler';
import Icon from 'react-native-vector-icons/FontAwesome';
import { StyleSheet, Pressable, Text, Button } from 'react-native';
import * as Animatable from 'react-native-animatable';
import Swipeout from 'react-native-swipeout';
import ButtonPressable from '../../components/ButtonPressable';
var sqlite_wrapper = require('./sqliteWrapper');
const DATA = [
{
prodName: 'Added data will look like this',
},
];
const AddProductList = ({ route, navigation }) => {
const { navData } = route.params;
const [prodName, setProdName] = useState('');
var [data, setData] = useState(DATA);
const renderItem = ({ item, index }) => {
const swipeSettings = {
style: {
marginBottom: 10,
},
autoClose: false,
backgroundColor: 'transparent',
close: false,
disabled: false,
onClose: (sectionID, rowId, direction) => {
console.log('---onclose--');
},
onOpen: (sectionID, rowId, direction) => {
console.log('---onopen--');
},
right: [
{
backgroundColor: 'dodgerblue',
color: 'white',
text: 'Edit',
onPress: () => console.log('-----edit-----', item.prodName)
},
],
left: [
{
backgroundColor: 'red',
color: 'white',
text: 'Delete',
onPress: () => {
console.log('-----delete-----', item.prodName);
sqlite_wrapper.deleteById
},
type: 'delete',
// component : (<ButtonPressable text="delete" />)
},
],
// buttonWidth: 100,
};
return (
<Swipeout {...swipeSettings}>
<View style={styles.listView}>
<Text style={styles.listViewText}>{item.prodName}</Text>
</View>
</Swipeout>
)
}
return (
<View style={styles.container}>
<Animatable.View
animation="bounceIn"
duration={1000}
style={styles.inputFieldView}>
<TextInput
style={styles.textInput}
onChangeText={(value) => setProdName(value)}
placeholder="Add the Product"
defaultValue={prodName}
/>
<TouchableOpacity
style={styles.addView}
onPress={() => {
sqlite_wrapper
.insert({ prodName: prodName }, sqlite_wrapper.collection_product)
.then((result) => {
console.log('---result---');
console.log(result);
if (result.rowsAffected) {
fetchAllData();
}
});
function fetchAllData() {
sqlite_wrapper
.readAll(sqlite_wrapper.collection_product)
.then((resultData) => {
console.log('---resultData---');
console.log(resultData);
setData(resultData);
setProdName('');
});
}
// without sql this is how to update the state having a array
// const updatedArray = [...data];
// updatedArray.push({prodName: prodName});
// setData(updatedArray);
// setProdName('');
}}>
<Icon name="plus" size={16} style={styles.add} color="white" />
</TouchableOpacity>
</Animatable.View>
<Animatable.View
animation="bounceInLeft"
duration={1500}
style={{ flex: 1 }}>
<FlatList
data={data}
keyExtractor={(item) => item.id}
renderItem={renderItem}
/>
</Animatable.View>
</View>
);
};
var styles = StyleSheet.create({
container: {
flex: 1,
},
inputFieldView: {
flexDirection: 'row',
alignItems: 'center',
alignSelf: 'stretch',
margin: 10,
},
textInput: {
flex: 1,
backgroundColor: '#b2ebf2',
borderTopLeftRadius: 7,
borderBottomLeftRadius: 7,
fontSize: 16,
},
addView: {
backgroundColor: '#0f4c75',
alignSelf: 'stretch',
alignItems: 'center',
justifyContent: 'center',
borderTopEndRadius: 7,
borderBottomEndRadius: 7,
padding: 9,
},
add: {
padding: 7,
},
listView: {
padding: 20,
backgroundColor: 'green',
margin: 0,
borderRadius: 0,
},
listViewText: {
color: 'white',
},
});
export default AddProductList;

React Native items are not layered properly with FlatList

I'm trying to use FlatList to stack custom-made dropdown menus on top of each other in React Native. I want the first dropdown to overlap the second while the second overlaps the third. The image below shows that the opposite is working, where the third dropdown overlaps the second while the second overlaps the first.
However, if I use the map method, it seems to work just fine.
import React from "react";
import { View, StyleSheet, FlatList } from "react-native";
import Dropdown from "../components/Dropdown";
import normalize from "react-native-normalize";
export default () => {
const arr = [0, 65, 130]; // controls the margin between the dropdowns // top
const layers = [3, 2, 1]; // Z-index
return (
<View style={styles.container}>
<FlatList // With FlatList
data={arr}
renderItem={({ item, index }) => (
<View style={[styles.dropdown, { top: item, zIndex: layers[index] }]}>
<Dropdown />
</View>
)}
/>
{/* {arr.map((spacing, index) => {
// With map
return (
<View
style={[styles.dropdown, { top: spacing, zIndex: layers[index] }]}
>
<Dropdown />
</View>
);
})} */}
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
},
dropdown: {
position: "absolute",
},
cardContainer: {
top: "41%",
left: "37%",
height: normalize(134),
},
});
Dropdown code
import React, { useState, useRef } from "react";
import {
Animated,
Easing,
View,
Text,
StyleSheet,
TouchableWithoutFeedback,
} from "react-native";
import normalize from "react-native-normalize";
import DropDownIcon from "../assets/DownArrowIcon";
export default () => {
const fadeAnim = useRef(new Animated.Value(0)).current;
const [toggle, setToggle] = useState(true); // controls the dropdown animation
const [accessLevels, setAccessLevels] = useState([
"Manager",
"Viewer",
"Admin",
]);
const height = normalize(33); // Initial height of the dropdown menu
const fadeIn = () => {
// Will change fadeAnim value to .5 in
Animated.timing(fadeAnim, {
toValue: 0.5,
easing: Easing.inOut(Easing.exp),
duration: 325,
}).start();
};
const fadeOut = () => {
// Will change fadeAnim value to 0
Animated.timing(fadeAnim, {
toValue: 0,
easing: Easing.inOut(Easing.exp),
duration: 250,
}).start();
};
const handleAnimation = () => {
setToggle((prev) => !prev);
toggle ? fadeIn() : fadeOut();
};
const handleSwap = (item) => {
// swap the selected item with the first item of the dropdown menu
let index = accessLevels.indexOf(item);
setAccessLevels((prevData) => {
let data = [...prevData];
let temp = data[0];
data[0] = item;
data[index] = temp;
return data; // We could order this in alphabetical order!
});
};
return (
<Animated.View
style={[
styles.dropdown,
{
height: fadeAnim.interpolate({
inputRange: [0, 1],
outputRange: [height, normalize(125)],
}),
},
]}
>
<TouchableWithoutFeedback onPress={handleAnimation}>
{/*First dropdown item*/}
<View
style={{
flexDirection: "row",
justifyContent: "space-evenly",
alignItems: "center",
height: normalize(34),
// color is based on the type of access level for the first dropdown item
backgroundColor:
accessLevels[0] === "Manager"
? "#019385"
: accessLevels[0] === "Viewer"
? "#376EC5"
: "#DECB52",
}}
>
<Text style={styles.dropdownText}>{accessLevels[0]}</Text>
<Animated.View // animation for the dropdown icon
style={{
transform: [
{
rotateX: fadeAnim.interpolate({
inputRange: [0, 1],
outputRange: ["0deg", "360deg"],
}),
},
],
}}
>
<DropDownIcon />
</Animated.View>
</View>
</TouchableWithoutFeedback>
<View // bottom two dropdown items
style={{
justifyContent: "space-evenly",
alignItems: "center",
minHeight: normalize(46),
flex: 1,
}}
>
<TouchableWithoutFeedback // second dropdown item
onPress={() => {
handleAnimation();
handleSwap(accessLevels[1]);
}}
>
<View style={styles.dropdownBottomItems}>
<Text style={{ color: "white" }}>{accessLevels[1]}</Text>
</View>
</TouchableWithoutFeedback>
<TouchableWithoutFeedback // third dropdown item
onPress={() => {
handleAnimation();
handleSwap(accessLevels[2]);
}}
>
<View style={styles.dropdownBottomItems}>
<Text style={{ color: "white" }}>{accessLevels[2]}</Text>
</View>
</TouchableWithoutFeedback>
</View>
</Animated.View>
);
};
const styles = StyleSheet.create({
dropdown: {
backgroundColor: "#4E585E",
width: normalize(97),
borderRadius: 4,
overflow: "hidden",
},
dropdownText: {
color: "white",
},
dropdownBottomItems: {
width: "100%",
justifyContent: "center",
alignItems: "center",
height: normalize(24),
},
});