React Native TouchableHighlight onFocus onBlur - reactjs

I am creating a menu for an Android TV, the Menu expands when it get focus, but when moving from one menu item to the other I get a flicker because I can't find a way to make the menu focus independent from the menu item focus.
I've tried to use a Touchable around the Flat list but then i cant move focus to the items.
import { FlatList, StyleSheet, Text, TouchableHighlight, View } from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import { MaterialIcons } from '#expo/vector-icons';
import React from 'react';
interface MenuListOption {
name: string;
icon: string;
}
interface MenuItemProps {
setMenuFocus: (v: boolean) => void;
item: MenuListOption;
menuFocus: boolean;
}
export const homeLists: MenuListOption[] = [
{
name: 'HOME',
icon: 'home-filled',
},
{
name: 'MOVIES',
icon: 'local-movies',
},
{
name: 'TV SHOWS',
icon: 'movie',
},
];
const MenuItem = ({ setMenuFocus, item, menuFocus }: MenuItemProps): JSX.Element => {
const [focus, setFocus] = React.useState(false);
const onFocus = React.useCallback(() => {
setFocus(true);
setMenuFocus(true);
}, [setMenuFocus]);
const onBlur = React.useCallback(() => {
setFocus(false);
setMenuFocus(false);
}, [setMenuFocus]);
return (
<TouchableHighlight onFocus={onFocus} onBlur={onBlur} style={[styles.item, focus ? styles.itemFocused : null]}>
<View style={styles.itemWrapper}>
<MaterialIcons name={item.icon} size={50} color="red" />
{menuFocus && <Text style={styles.text}>{item.name}</Text>}
</View>
</TouchableHighlight>
);
};
const Menu = (): JSX.Element => {
const [focus, setFocus] = React.useState(false);
const colorsArray = focus ? ['gray', 'gray', 'transparent'] : ['gray', 'gray'];
const renderItem = ({ item }: { item: MenuListOption }) => (
<MenuItem setMenuFocus={setFocus} item={item} menuFocus={focus} />
);
return (
<View style={[styles.wrapper, focus ? styles.wrapperFocused : null]}>
<LinearGradient colors={colorsArray} start={{ x: 0, y: 0.9 }} end={{ x: 1, y: 0.9 }}>
<View style={focus ? styles.logoFocus : styles.logo}>
{focus && <MaterialIcons style={{ paddingRight: 20 }} name={'tv'} size={40} color={'white'} />}
<Text style={[styles.title, focus && styles.textFocus]}>MyApp</Text>
</View>
<FlatList
contentContainerStyle={{ justifyContent: 'center', flex: 1 }}
style={styles.list}
data={homeLists}
renderItem={renderItem}
keyExtractor={(item) => String(item.name)}
/>
</LinearGradient>
</View>
);
};
const styles = StyleSheet.create({
wrapper: {
height: '100%',
position: 'absolute',
top: 0,
zIndex: 1,
left: -200,
transform: [{ translateX: 200 }],
},
title: {
fontSize: 15,
lineHeight: 38,
fontWeight: '400',
textAlign: 'left',
},
wrapperFocused: {
width: 900,
},
logo: {
justifyContent: 'center',
flexDirection: 'row',
marginTop: 20,
},
list: {
flexGrow: 0,
height: '100%',
padding: 10,
},
logoFocus: {
justifyContent: 'flex-start',
flexDirection: 'row',
marginTop: 60,
marginLeft: 20,
},
textFocus: {
fontSize: 35,
},
item: {
maxWidth: 250,
marginBottom: 40,
alignSelf: 'stretch',
left: 0,
padding: 10,
},
itemFocused: {
borderBottomColor: 'yellow',
borderBottomWidth: 5,
},
itemWrapper: {
maxWidth: 250,
flexDirection: 'row',
},
text: {
color: 'white',
fontSize: 28,
lineHeight: 41,
fontWeight: '600',
marginLeft: 50,
marginTop: 5,
},
});
export default Menu;
Here is an animation of the problem:
menu

Related

Cannot select an item from autocomplete when there is button or text input behind the item

I cannot click the 1st and 2nd item because there is text input behind it and 3rd and 4th item because of the button behind it. 5th item is clickable. I tried using zindex but it does not work. I am using react-native-autocomplete-input library.
It works fine in iOS but not in Android
This is my code
import Autocomplete from 'react-native-autocomplete-input';
import {
GestureHandlerRootView,
TouchableOpacity as Touchable,
} from 'react-native-gesture-handler';
<View style={[styles.inputContainer, globalStyles.zIndex1]}>
<Text style={styles.inputLabel}>{getSupplierLabel()}</Text>
<Autocomplete
editable={true}
autoCorrect={false}
data={filteredParties}
onChangeText={(text: string) => {
//some code
}}
value={party}
flatListProps={{
keyboardShouldPersistTaps: 'always',
keyExtractor: (party: any) => party.id,
renderItem: ({item: {name}}: any) => (
<Touchable
style={[globalStyles.margin10, globalStyles.zIndex1]}
onPress={() => {
setFilteredParties([]);
setParty(name);
}}>
<Text textColor={color.gray}>{name}</Text>
</Touchable>
),
}}
inputContainerStyle={globalStyles.borderWidth0}
listContainerStyle={styles.autocompleteListContainerStyle}
containerStyle={styles.textInput}
/>
const styles = StyleSheet.create({
inputContainer: {
flexDirection: 'row',
alignItems: 'center',
marginTop: 10,
},
textInput: {
flex: 2,
borderWidth: 1,
borderColor: color.gray,
borderRadius: 2,
marginLeft: 5,
},
autocompleteListContainerStyle: {
left: 0,
position: 'absolute',
right: 0,
top: 41,
zIndex: 1,
},
});
Wrap your AutoComplete component with a view and give it a suitable zIndex :
import Autocomplete from 'react-native-autocomplete-input';
import {
GestureHandlerRootView,
TouchableOpacity as Touchable,
} from 'react-native-gesture-handler';
<View style={[styles.inputContainer, globalStyles.zIndex1]}>
<Text style={styles.inputLabel}>{getSupplierLabel()}</Text>
<View style={ zIndex: 2 }>
<Autocomplete
editable={true}
autoCorrect={false}
data={filteredParties}
onChangeText={(text: string) => {
//some code
}}
value={party}
flatListProps={{
keyboardShouldPersistTaps: 'always',
keyExtractor: (party: any) => party.id,
renderItem: ({item: {name}}: any) => (
<Touchable
style={[globalStyles.margin10, globalStyles.zIndex1]}
onPress={() => {
setFilteredParties([]);
setParty(name);
}}>
<Text textColor={color.gray}>{name}</Text>
</Touchable>
),
}}
inputContainerStyle={globalStyles.borderWidth0}
listContainerStyle={styles.autocompleteListContainerStyle}
containerStyle={styles.textInput}
/>
</View>
const styles = StyleSheet.create({
inputContainer: {
flexDirection: 'row',
alignItems: 'center',
marginTop: 10,
},
textInput: {
flex: 2,
borderWidth: 1,
borderColor: color.gray,
borderRadius: 2,
marginLeft: 5,
},
autocompleteListContainerStyle: {
left: 0,
position: 'absolute',
right: 0,
top: 41,
zIndex: 1,
},
});

how to detect a face with react-native-camera facedetector?

I am trying to detect face with react-native-camera, I want to know how can we detect an individual's face, there is no proper documentation about the mlkit.
await FaceDetector.detectFacesAsync(data.uri) this statement is just returning face object like this face[0] = { bounds: { origin: { x: 739, y: 987 }, size: { x: 806, y: 789 } }, faceID: 0, rollAngle: 10.533509254455566, yawAngle: 0.7682874798774719 }.
This is just object's position, I cannot figure out how to recognize individual's face characteristics like eys, nose with the FaceDetector and suppose I will save person A's face data then how I will match the data with A's face later with react-native-camera ?
ML Kit does not support Face Recognition. Also, React Native is not officially supported (yet), but you could check out https://rnfirebase.io/ml-vision/face-detection#process which outlines how you can get a 133-point contour of the face. However, this is not meant for facial recognition, but rather for overlays (e.g. masks, filters).
import SplashScreen from 'react-native-splash-screen'
import React, { useEffect, createRef,useState } from 'react';
import { SafeAreaView, View, Image, StyleSheet, Text, Modal, TouchableOpacity } from 'react-native';
import { RNCamera } from 'react-native-camera';
const Test = (props) => {
useEffect(() => {
SplashScreen.hide();
});
const [faces, setFace] = useState([]);
const [faceavl, setFaceavl] = useState(false);
const [takeTimeFaceAvl, setTakeTimeFaceAvl] = useState(false);
const [searchWaiting, setsearchWaiting] = useState(null)
const [modalVisible, setModalVisible] = useState(false);
const [image, setImage] = useState(null);
const mycamera = createRef()
const PendingView = () => (
<View
style={{
flex: 1,
backgroundColor: 'lightgreen',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Text>Waiting</Text>
</View>
);
const renderFaces = () => (
<View style={{
position: 'absolute',
bottom: 0,
right: 0,
left: 0,
top: 0,
}} pointerEvents="none">
{faces.map(renderFace)}
</View>
);
const renderFace = ({ bounds, faceID, rollAngle, yawAngle }) => (
<View
key={faceID}
transform={[
{ perspective: 600 },
{ rotateZ: `${rollAngle.toFixed(0)}deg` },
{ rotateY: `${yawAngle.toFixed(0)}deg` },
]}
style={[
{
padding: 10,
borderWidth: 1,
borderRadius: 2,
position: 'absolute',
borderColor: '#000',
justifyContent: 'center',
},
{
...bounds.size,
left: bounds.origin.x,
top: bounds.origin.y,
},
]}
>
</View>
);
return (
<>
<SafeAreaView style={styles.container}>
<RNCamera
ref={mycamera}
style={styles.preview}
type={RNCamera.Constants.Type.front}
flashMode={RNCamera.Constants.FlashMode.on}
androidCameraPermissionOptions={{
title: 'Permission to use camera',
message: 'We need your permission to use your camera',
buttonPositive: 'Ok',
buttonNegative: 'Cancel',
}}
androidRecordAudioPermissionOptions={{
title: 'Permission to use audio recording',
message: 'We need your permission to use your audio',
buttonPositive: 'Ok',
buttonNegative: 'Cancel',
}}
onFacesDetected={(data) => {
setFace(data.faces)
setFaceavl(true);
clearTimeout(searchWaiting)
const avc = setTimeout(() => {
console.log()
setFaceavl(false);
setFace([])
}, 500)
setsearchWaiting(avc)
}}
onFaceDetectionError={(error) => {
console.log('face--detact-->', error)
}}
>
{({ camera, status, recordAudioPermissionStatus }) => {
if (status !== 'READY') return <PendingView />;
return (
<View style={{ flex: 0, flexDirection: 'row', justifyContent: 'center' }}>
<TouchableOpacity onPress={async () => {
const options = { quality: 0.5, base64: true };
const data = await camera.takePictureAsync(options)
if (faceavl) {
setTakeTimeFaceAvl(true)
} else {
setTakeTimeFaceAvl(false)
}
console.log(data.uri)
setImage(data)
setModalVisible(!modalVisible)
}} style={styles.capture}>
<Text style={{ fontSize: 14 }}> SNAP </Text>
</TouchableOpacity>
</View>
);
}}
</RNCamera>
{faces ? renderFaces() : null}
</SafeAreaView>
<Modal
animationType="slide"
transparent={true}
visible={modalVisible}
onRequestClose={() => {
Alert.alert("Modal has been closed.");
setModalVisible(!modalVisible);
}}
>
<View style={styles.centeredView}>
<View style={styles.modalView}>
{takeTimeFaceAvl ? image ? <Image
style={{
width: 200,
height: 100,
}}
source={{
uri: image.uri,
}}
/> : null : <Text>Face not found</Text>}
<TouchableOpacity
style={[styles.button, styles.buttonClose]}
onPress={() => setModalVisible(!modalVisible)}
>
<Text style={styles.textStyle}>Hide Modal</Text>
</TouchableOpacity>
</View>
</View>
</Modal>
</>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column',
backgroundColor: 'black',
},
item: {
backgroundColor: '#FFF',
},
viewOne: {
flexDirection: 'row'
},
viewTwo: {
alignItems: 'flex-end', marginEnd: 9
},
title: {
fontSize: 16, // Semibold #000000
color: '#000000',
},
noOff: {
color: '#D65D35',
fontSize: 20, // Semibold
}, product: {
color: '#A6A6A6',
fontSize: 16, // Regular
}, titleView: {
flex: 1,
alignSelf: 'center',
marginStart: 14,
marginEnd: 14,
},
centeredView: {
flex: 1,
justifyContent: "center",
alignItems: "center",
marginTop: 22
},
modalView: {
margin: 20,
backgroundColor: "white",
borderRadius: 20,
padding: 10,
alignItems: "center",
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5
},
button: {
borderRadius: 20,
padding: 10,
elevation: 2
},
buttonOpen: {
backgroundColor: "#F194FF",
},
buttonClose: {
backgroundColor: "#2196F3",
},
textStyle: {
color: "white",
fontWeight: "bold",
textAlign: "center"
},
modalText: {
marginBottom: 15,
textAlign: "center"
},
preview: {
flex: 1,
justifyContent: 'flex-end',
alignItems: 'center',
},
capture: {
flex: 0,
backgroundColor: '#fff',
borderRadius: 5,
padding: 15,
paddingHorizontal: 20,
alignSelf: 'center',
margin: 20,
},
});

React-Native Handle huge multiple number of inputs in accordion with single click from parent component

I am kind of beginner in React world. In my project, i have a different number of custom accordion objects that has flatlist of text inputs. How can i handle such a input system with single button click from parent of accordion objects. I want to have one button that collect all of the current inputs and then end it on a server or any other relevant pages. (I am using functional layout with state hooks.)
Thank you for any response,
Bests
You can see the layout here !
You may see accordion.js below:
import React, { Component, useState, useEffect} from 'react';
import { View, TouchableOpacity, FlatList, StyleSheet, TextInput } from "react-native";
//import { Colors } from './Colors';
import { theme } from "../constants";
import Text from "./Text";
import Icon from "react-native-vector-icons/MaterialIcons";
import { ScrollView } from 'react-native-gesture-handler';
const Colors = {
PRIMARY: '#1abc9c',
WHITE: '#ffffff',
LIGHTGREEN: '#BABABA',
GREEN: '#0da935',
GRAY: '#f7f7f7',
LIGHTGRAY: '#C7C7C7',
DARKGRAY: '#5E5E5E',
CGRAY: '#ececec',
OFFLINE_GRAY: '#535353'
}
export default function Accordion (props) {
const [data, setData] = useState(props.data)
const [expanded, setExpanded] = useState(false)
const onClick = (index) => {
const temp = data.slice()
temp[index].value = !temp[index].value
console.log(temp)
setData(temp)
}
const toggleExpand = (section) => {
//this.setState({ expanded: !this.state.expanded )
setExpanded(prev_state => !prev_state)
props.fromparentonClick(expanded)
}
useEffect(() => {
console.log('will unmount')
}, [expanded]);
return (
<View>
<TouchableOpacity
style={styles.row}
onPress={() => toggleExpand()}
>
<Text style={[styles.title, styles.font]}>
{props.title}
</Text>
<Icon
name={
expanded
? "keyboard-arrow-up" //this is condinational ternary operator rendering :)
: "keyboard-arrow-down"
}
size={30}
color={Colors.DARKGRAY}
/>
</TouchableOpacity>
<View style={styles.parentHr} />
{ expanded && ( //this is short circuit operator
<View style={{}}>
<FlatList
data={data}
numColumns={1}
scrollEnabled={true}
renderItem={({ item, index }) => (
<View styles={styles.deneme}>
<Text style={[styles.font, styles.itemInActive]}>
{item.key}
</Text>
<TouchableOpacity
style={[
styles.childRow,
styles.button,
item.value ? styles.btnInActive : styles.btnActive
]}
onPress={() => onClick(index)}
>
<Icon
name={"check-circle"}
size={24}
color={item.value ? Colors.LIGHTGRAY : Colors.GREEN}
/>
{/* <Text style={[styles.font, styles.itemInActive]}>
{item.key}
</Text>*/}
<TextInput
style={
styles.text_input
}
blurOnSubmit
placeholder="input1"
placeholderTextColor="#60605e"
numeric
keyboardType={"numeric"}
maxLength={3}
/>
<TextInput
style={
styles.text_input
}
blurOnSubmit
placeholder="input2"
placeholderTextColor="#60605e"
numeric
keyboardType={"numeric"}
maxLength={3}
/>
<TextInput
style={
styles.text_input
}
blurOnSubmit
placeholder="input3"
placeholderTextColor="#60605e"
numeric
keyboardType={"numeric"}
maxLength={3}
/>
</TouchableOpacity>
<View style={styles.childHr} />
</View>
)}
/>
</View>
)}
</View>
);
}
const styles = StyleSheet.create({
container: {
justifyContent: 'center',
alignItems: 'center'
},
font: {
// fontFamily: Fonts.bold,
},
button: {
width: '100%',
height: 54,
alignItems: 'center',
paddingLeft: 35,
paddingRight: 35,
fontSize: 12,
},
title: {
fontSize: 14,
fontWeight: 'bold',
color: Colors.DARKGRAY,
},
itemActive: {
fontSize: 12,
color: Colors.GREEN,
},
itemInActive: {
fontSize: 12,
color: Colors.DARKGRAY,
},
btnActive: {
borderColor: Colors.GREEN,
},
btnInActive: {
borderColor: Colors.DARKGRAY,
},
row: {
flexDirection: 'row',
justifyContent: 'space-between',
height: 56,
paddingLeft: 25,
paddingRight: 18,
alignItems: 'center',
backgroundColor: Colors.CGRAY,
},
childRow: {
flexDirection: 'row',
justifyContent: 'space-around',
backgroundColor: Colors.GRAY,
},
parentHr: {
height: 1,
color: Colors.WHITE,
width: '100%'
},
childHr: {
height: 1,
backgroundColor: Colors.LIGHTGRAY,
width: '100%',
},
colorActive: {
borderColor: Colors.GREEN,
},
colorInActive: {
borderColor: Colors.DARKGRAY,
},
text_input: {
width: 80,
backgroundColor: "#dde8c9",
padding: 10,
textAlign: 'center'
},
deneme: {
flexDirection: 'column',
textAlign: 'center',
justifyContent: 'center',
}
});
You may see parent component below:
import * as WebBrowser from 'expo-web-browser';
import React, { Component,useState } from 'react';
import {
Image,
Platform,
ScrollView,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
import { Button, Block, Input,Accordion ,Header} from "../components";
import { theme } from "../constants";
//import {CATEGORIES} from "../Data/dersler";
import SwitchSelector from "react-native-switch-selector";
import { MonoText } from '../components/StyledText';
import 'core-js/es6/symbol'; import 'core-js/fn/symbol/iterator';
export default function HomeScreen (props) {
const options = [
{ label: "x", value: "1" },
{ label: "y", value: "2" }
]
const initial_state = {
courses: [
{
key: "c1",
title: "ss",
data: [
{ key: "dd", value: "false" },
{ key: "ff", value: "false" },
{ key: "gg ", value: "false" }
]
},
{
key: "c2",
title: "ss2",
data: [
{ key: "dd", value: "false" },
{ key: "ff", value: "false" },
{ key: "gg", value: "false" },
{ key: "cc", value: "false" }
]
},
],
}
const second_state = {
courses: [
{
key: "c1",
title: "dd",
data: [
{ key: "cc", value: "false" },
{ key: "dd", value: "false" },
{ key: "ff ", value: "false" }
]
},
]
}
const [exam, setExam] = useState(initial_state)
const [onlineAcc, setonlineAcc] = useState(false)
const [activeSession, setactiveSession] = useState(0)
const controlAccordions = (arg) => {
setonlineAcc(prev_state => !prev_state)
//console.log(onlineAcc)
console.log(arg)
if(arg){
setactiveSession(prev_state => prev_state -1 )
}
else {
setactiveSession(prev_state => prev_state + 1)
}
console.log(activeSession)
}
const renderAccordians = () => {
let items = [];
//console.log(`Call onPress with value: ${ this.state}`);
//console.log(exam.courses);
return exam.courses.map(ex => (<Accordion active={activeSession} fromparentonClick={controlAccordions} title={ex.title} data={ex.data} key={ex.key} /> ))
//return items;
}
return (
<View style={styles.container}>
<Header title="Anasayfa" />
<SwitchSelector
options={options}
initial={1}
buttonColor={theme.colors.gray2}
onPress={value => {
if( value== 1)
{setExam (second_state)}
else {
setExam(initial_state)
}
console.log(value)
}}
/>
<ScrollView style={styles.container}>
{renderAccordians()}
</ScrollView>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
developmentModeText: {
marginBottom: 20,
color: 'rgba(0,0,0,0.4)',
fontSize: 14,
lineHeight: 19,
textAlign: 'center',
},
contentContainer: {
paddingTop: 30,
},
welcomeContainer: {
alignItems: 'center',
marginTop: 10,
marginBottom: 20,
},
welcomeImage: {
width: 100,
height: 80,
resizeMode: 'contain',
marginTop: 3,
marginLeft: -10,
},
getStartedContainer: {
alignItems: 'center',
marginHorizontal: 50,
},
homeScreenFilename: {
marginVertical: 7,
},
codeHighlightText: {
color: 'rgba(96,100,109, 0.8)',
},
codeHighlightContainer: {
backgroundColor: 'rgba(0,0,0,0.05)',
borderRadius: 3,
paddingHorizontal: 4,
},
getStartedText: {
fontSize: 17,
color: 'rgba(96,100,109, 1)',
lineHeight: 24,
textAlign: 'center',
},
tabBarInfoContainer: {
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
...Platform.select({
ios: {
shadowColor: 'black',
shadowOffset: { width: 0, height: -3 },
shadowOpacity: 0.1,
shadowRadius: 3,
},
android: {
elevation: 20,
},
}),
alignItems: 'center',
backgroundColor: '#fbfbfb',
paddingVertical: 20,
},
tabBarInfoText: {
fontSize: 17,
color: 'rgba(96,100,109, 1)',
textAlign: 'center',
},
navigationFilename: {
marginTop: 5,
},
helpContainer: {
marginTop: 15,
alignItems: 'center',
},
helpLink: {
paddingVertical: 15,
},
helpLinkText: {
fontSize: 14,
color: '#2e78b7',
},
});
you will have to keep track of the data of the accordians in the parent class
let accordionData = [];
const addAccordionData = data => {
accordionData.push(data);
}
const renderAccordians = () => {
let items = [];
//console.log(`Call onPress with value: ${ this.state}`);
//console.log(exam.courses);
return exam
.courses.map(ex => (
<Accordion
active={activeSession}
fromparentonClick= {controlAccordions}
title={ex.title}
data={ex.data}
onAccordianDataSet={addAccordianData} // add this line <====
key={ex.key} /> ))
//return items;
}
in the accordion component do this
// in the **accordion ** component do this
const onClick = (index) => {
const temp = data.slice()
temp[index].value = !temp[index].value
console.log(temp)
setData(temp);
// add this line
props.onAccordianDataSet(temp); // now the answer will be in the parents
}
and you can have a button in the parent that calls a function like this
const submitDataToDatabase = () => {
if(accordionData.length === 0) {
alert("answer every question");
return;
}
submit data to database storage
}

Horizontal scrollview inside another horizontalscroll view in react-native

I'm designing UI in react native where I've a HorizontalScrollView inside another HorizontalScrollView. However, the child HorizontalScrollView doesn't work.
Is it possible to disable the parent HorizontalScrollView whenever a gesture is made in child HorizontalScrollView. I know this sounds tricky but I need to implement this in my UI.
note: working fine in IOS
code snippet:
import React from 'react';
import { StyleSheet, Text, View, Dimensions, SafeAreaView, TouchableHighlight, ScrollView,
TouchableOpacity, TouchableWithoutFeedback, Image, Linking, Platform } from 'react-native';
import Carousel, { Pagination } from 'react-native-snap-carousel';
import { Input, Button, Divider, Card, Overlay } from 'react-native-elements';
export default class Cart extends React.Component {
state = {
data: [
{ title: 'a', url: require("./Light-Hover34x34.png") },
{ title: 'b', url: require("./Light-Hover34x34.png") },
{ title: 'c', url: require("./Light-Hover34x34.png") },
{ title: 'd', url: require("./Light-Hover34x34.png") },
{ title: 'e', url: require("./Light-Hover34x34.png") },
],
activeSlide: 0,
room: ["one", "two", "three"]
}
_renderItem = ({ item, index }) => {
console.log("active slide", this.state.activeSlide)
const isActive = index === this.state.activeSlide;
return (
<TouchableHighlight
// onPress={() => Linking.openURL(item.url)}
style={{
backgroundColor: isActive ? '#FFD845' : null,
width: 60,
height: 60,
borderRadius: 60/2,
justifyContent: 'center',
alignItems: 'center',
}}>
<Image
source={item.url}
style={{ width: '50%', height: '40%' }}
/>
</TouchableHighlight>
);
};
render() {
return (
<View style={{alignItems: 'center', justifyContent: 'center', paddingVertical: 100}}>
<ScrollView horizontal={true}>
{
this.state.room.map((r, i) => {
return(
<View key={i}>
<TouchableWithoutFeedback>
<Card containerStyle={[styles.cardEleBig,]}>
<SafeAreaView style={{ height: 150 }}>
<Carousel
data={this.state.data}
renderItem={this._renderItem}
sliderWidth={120}
itemWidth={50}
onSnapToItem={index => this.setState({ activeSlide: index })} //for pagination
/>
</SafeAreaView>
</Card>
</TouchableWithoutFeedback>
</View>
)
})
}
</ScrollView>
</View>
);
}
}
const styles = StyleSheet.create({
cardCircleParking: {
backgroundColor: "yellow",
// marginBottom: 10,
// marginLeft: '5%',
width: 50,
height: 50,
borderRadius: 50/2,
borderColor: 'white',
},
cardEleBig: {
borderRadius: 20,
borderBottomWidth: 0,
borderColor: 'white',
width: 159,
height: Platform == "ios" ? 210 : 200,
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
marginLeft: 5,
marginRight: 5,
marginTop: 10,
marginBottom: 2
},
})
But this code is working fine with IOS
Thanks in advance

Why is extended stylesheet not rendering?

Brand new project. react-native-extended-stylesheet installed. everything working fine, and then out of nowhere it stops working. here's the full component:
import React from 'react';
import { Image, FlatList, View, Text, StyleSheet, SafeAreaView, TouchableOpacity, Dimensions } from 'react-native';
import EStyleSheet from 'react-native-extended-stylesheet';
const { height, width } = Dimensions.get('window');
const data = [
{
title: 'Johnny Appleseed',
subtitle: 'November 12, 2019',
img: require('./src/assets/img/johnny_appleseed.png'),
type: 'video'
},
{
title: 'Johnathan Doe',
subtitle: 'November 19, 2019',
img: require('./src/assets/img/johnny_appleseed.png'),
type: 'voice'
}
];
const AgendaItem = (props) => {
return (
<TouchableOpacity onPress={props.onPress}>
<View style={styles.container}>
<View style={styles.leftContainer}>
<Image
resizeMethod={'scale'}
source={
props.type === 'voice' ? (
require('./src/assets/img/voice_icon.png')
) : (
require('./src/assets/img/video_icon.png')
)
}
style={styles.icon}
/>
<View style={styles.textContainer}>
<Text style={styles.title}>{props.title}</Text>
<Text style={styles.subtitle}>{props.subtitle}</Text>
</View>
</View>
<Image source={props.img} style={styles.img} />
</View>
</TouchableOpacity>
);
};
const ProfileList = () => {
return (
<SafeAreaView>
<FlatList
data={data}
renderItem={({ item }) => (
<AgendaItem title={item.title} subtitle={item.subtitle} img={item.img} type={item.type} />
)}
keyExtractor={(item) => item.id}
/>
</SafeAreaView>
);
};
const styles = EStyleSheet.create({
$rem: width > 380 ? 18 : 16,
container: {
flexDirection: 'row',
backgroundColor: '#fff',
borderRadius: 25,
elevation: 3,
marginBottom: 5,
width: '22rem',
justifyContent: 'space-between',
marginHorizontal: '0.5rem',
paddingVertical: '.75rem',
paddingHorizontal: '1.5rem'
},
textContainer: {
justifyContent: 'space-around'
},
leftContainer: {
flexDirection: 'row',
alignItems: 'center'
},
title: {
fontWeight: 'bold',
fontSize: 20,
color: '#454A66'
},
subtitle: {
color: '#454A66',
fontSize: 12
},
img: {
height: '3rem',
width: '3rem',
borderWidth: 1,
borderColor: '#169C75',
borderRadius: 30
},
icon: {
height: '1.5rem',
width: '1.5rem'
}
});
export default ProfileList;
I was just messing with some of the properties and all of a sudden it stopped rendering any style in the styles object. ive tried closing/opening the project. ive tried rebooting system. this just seems buggy because its happened before.
any suggestions or something I missed?

Resources