React WebkitAppRegion Warnings - css

Ok, so I'm extremely new to react, so sorry if this question is really dumb.
I've been working on a react application using electron and expo, and don't fully understand how to solve this warning which is showing in my developer console.
Warning: Failed prop type: Invalid props.style key `WebkitAppRegion` supplied to `View`.
Bad object: {
"display": "flex",
"flexDirection": "row",
"height": 20,
"backgroundColor": "#0e0e11",
"margin": 0,
"borderBottomWidth": 0.5,
"borderColor": "#060607",
"WebkitAppRegion": "drag"
}
When I originally built the design for this UI, I did so with standard html and SCSS, and now I'm attempting to change it to react as my first big project. So having done some googling, I found the information that to include my -webkit-app-region: drag all I needed to do was CammelCase and remove the "-"'s. Except it's now throwing this error, it does the function as intended but how does one solve the "invalid props style" issue?
Some shitty code for ya to critique xD
//app.tsx
import React from 'react';
import { Platform, StyleSheet, Text, View } from 'react-native';
import { SplashScreen } from 'expo';
import * as Font from 'expo-font';
import * as styles from './assets/styles/main'
SplashScreen.preventAutoHide();
setTimeout(SplashScreen.hide, 10000);
export default class App extends React.Component {
state = {
fontLoaded: false,
};
async componentDidMount() {
await Font.loadAsync(styles.fontList);
this.setState({ fontLoaded: true });
}
render() {
return (
this.state.fontLoaded ? (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'stretch', backgroundColor: styles.colors.dark1 }}>
<this.DisplayHandles />
</View>
) : null
);
}
DisplayHandles() {
if (Platform.OS === 'web' && process.versions.electron) {
return ([
<View style={[styles.electron.header, {WebkitAppRegion: 'drag'}]}>
<View style={styles.electron.titleContainer}>
<Text key='title' style={[styles.electron.title, {WebkitAppRegion: 'no-drag', 'userSelect': 'none'}]}> Smartcloud</Text>
</View>
<View style={styles.electron.controlContainer}>
<Text key='minimize' style={[styles.electron.button, {WebkitAppRegion: 'no-drag', 'userSelect': 'none'}]} onClick={handleClick}>-</Text>
<Text key='maximize' style={[styles.electron.button, {WebkitAppRegion: 'no-drag', 'userSelect': 'none'}]} onClick={handleClick}>+</Text>
<Text key='close' style={[styles.electron.button, {WebkitAppRegion: 'no-drag', 'userSelect': 'none'}]} onClick={handleClick}>x</Text>
</View>
</View>,
<View style={{ flex: 1}}>
<Content.CreateHandles />
</View>
]
)
}
return <Content.Container/>
}
}
function handleClick(e) {
e.preventDefault();
console.log('I was clicked')
}
class Content {
static CreateHandles() {
return (
<View>
<Content.Container />
</View>
)
}
static Container () {
return (
<View style={{alignItems: 'center',}}>
<Content.TestingText />
</View>
)
}
static TestingText() {
if (Platform.OS === 'web') {
if (process.versions.electron) {
return (<Text style={{fontSize: 60, color: styles.colors.light5, fontFamily: styles.rubik.medium} }> This is a Electron {process.versions.electron} + {Platform.OS} version </Text>)
}
return (<Text style={{fontSize: 60, color: styles.colors.light5, fontFamily: styles.rubik.medium}}> This is a {Platform.OS} version </Text>)
}
return <Text style={{fontSize: 20, color: styles.colors.light5, fontFamily: styles.rubik.medium}}> This is a {Platform.OS} version</Text>
}
}
// ./assets/styles/main.tsx
export const electron = StyleSheet.create({
header: {
display: 'flex',
flexDirection: 'row',
height: 20,
backgroundColor: colors.dark4,
margin: 0,
borderBottomWidth: 0.5,
borderColor: colors.dark5,
},
titleContainer: {
display: 'flex',
alignItems: 'flex-start',
flexGrow: 1,
},
controlContainer: {
display: 'flex',
justifyContent: 'flex-end',
flexDirection: 'row',
alignItems: 'center',
},
title: {
color: colors.purple,
margin: 0,
marginLeft: 10,
fontSize: 14,
fontFamily: rubik.black,
},
button: {
width: 25,
margin: 0,
marginLeft: 10,
color: colors.purple,
textAlign: 'center',
fontSize: 14,
fontFamily: rubik.black,
}
})

Related

React Native - Pressable is not clickable on Android

What I'm building:
I'm creating a card that will render with a question mark at top of it and when the user press it, the card will flip with animation and show some information.
Code:
From a code perspective it looks like this:
import { View, StyleSheet, Text, Pressable, Animated } from 'react-native';
import { FontAwesome } from '#expo/vector-icons';
import { GlobalStyles } from '../../constants/styles';
import { useTranslation } from 'react-i18next';
export default Card = ({ isSpy, guessingItem, onPress }) => {
const { t } = useTranslation();
let currentValue = 0;
const animatedValue = new Animated.Value(0);
animatedValue.addListener((v) => (currentValue = v.value));
const frontInterpolate = animatedValue.interpolate({
inputRange: [0, 180],
outputRange: ['0deg', '180deg'],
});
const backInterpolate = animatedValue.interpolate({
inputRange: [0, 180],
outputRange: ['180deg', '360deg'],
});
const frontAnimatedStyles = {
transform: [{ rotateY: frontInterpolate }],
};
const backAnimatedStyles = {
transform: [{ rotateY: backInterpolate }],
};
const flipCard = () => {
console.log(currentValue);
if (currentValue >= 90) {
Animated.spring(animatedValue, {
toValue: 0,
tension: 10,
friction: 8,
useNativeDriver: false,
}).start();
setTimeout(() => onPress(), 600);
} else {
Animated.spring(animatedValue, {
toValue: 180,
tension: 10,
friction: 8,
useNativeDriver: false,
}).start();
}
};
return (
<View style={styles.constainer}>
<Pressable onPress={flipCard} style={{ backgroundColor: 'red' }}>
<View style={GlobalStyles.styles.flexbox}>
<Animated.View style={[styles.innerContainer, frontAnimatedStyles]}>
<FontAwesome name="question" size={160} />
</Animated.View>
</View>
</Pressable>
<Pressable onPress={flipCard}>
<View style={GlobalStyles.styles.flexbox}>
<Animated.View style={[backAnimatedStyles, styles.innerContainer, styles.innerContainerBack]}>
<View style={styles.constainer}>
{!isSpy && (
<>
<FontAwesome name={guessingItem.section.icon} size={60} />
<Text style={styles.itemName}>{guessingItem.name}</Text>
</>
)}
{isSpy && (
<>
<FontAwesome name="user-secret" size={60} />
<Text style={styles.placeName}>{t('youAreSpy')}</Text>
</>
)}
</View>
</Animated.View>
</View>
</Pressable>
</View>
);
};
const styles = StyleSheet.create({
constainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
innerContainer: {
height: 300,
width: 230,
marginVertical: 50,
padding: 60,
borderWidth: 6,
borderColor: GlobalStyles.colors.primary50,
borderRadius: 20,
justifyContent: 'center',
alignItems: 'center',
backfaceVisibility: 'hidden',
},
innerContainerBack: {
position: 'absolute',
right: -115,
bottom: 0,
justifyContent: 'center',
alignItems: 'center',
},
itemName: {
marginTop: 20,
fontSize: 18,
alignItems: 'center',
color: GlobalStyles.colors.primary50,
},
pressed: {},
});
What is an issue:
On-screen below you can see a pressable element with red background.
If I click on any part of this red part, the card would flip. If I test it on Android, clicking on anything inside the white border would not trigger a flip. Only clicking outside of that white border but still inside the red background would trigger a flip.
The question is: Why it behaves differently when I am using basic react-native elements? How can I fix that so clicking would always work for the inside click?
I tested this component on my side and it works well. I think there is no problem with the Card component. Please check the parent component of the Card.
I only changed "right" value from -115 to 0 in the style of innerContainerBack.
innerContainerBack: {
position: 'absolute',
right: 0,
bottom: 0,
justifyContent: 'center',
alignItems: 'center',
}
And you'd better use only one Pressable Component and remove the View component in the Pressable. So my ultimate solution is
import { View, StyleSheet, Text, Pressable, Animated } from 'react-native';
import { FontAwesome } from '#expo/vector-icons';
import { GlobalStyles } from '../../constants/styles';
import { useTranslation } from 'react-i18next';
export default Card = ({ isSpy, guessingItem, onPress }) => {
const { t } = useTranslation();
let currentValue = 0;
const animatedValue = new Animated.Value(0);
animatedValue.addListener((v) => (currentValue = v.value));
const frontInterpolate = animatedValue.interpolate({
inputRange: [0, 180],
outputRange: ['0deg', '180deg'],
});
const backInterpolate = animatedValue.interpolate({
inputRange: [0, 180],
outputRange: ['180deg', '360deg'],
});
const frontAnimatedStyles = {
transform: [{ rotateY: frontInterpolate }],
};
const backAnimatedStyles = {
transform: [{ rotateY: backInterpolate }],
};
const flipCard = () => {
console.log(currentValue);
if (currentValue >= 90) {
Animated.spring(animatedValue, {
toValue: 0,
tension: 10,
friction: 8,
useNativeDriver: false,
}).start();
setTimeout(() => onPress(), 600);
} else {
Animated.spring(animatedValue, {
toValue: 180,
tension: 10,
friction: 8,
useNativeDriver: false,
}).start();
}
};
return (
<View style={styles.constainer}>
<Pressable onPress={flipCard} style={{ backgroundColor: 'red' }}>
<Animated.View style={[styles.innerContainer, frontAnimatedStyles]}>
<FontAwesome name="question" size={160} />
</Animated.View>
<Animated.View style={[backAnimatedStyles, styles.innerContainer, styles.innerContainerBack]}>
<View style={styles.constainer}>
{!isSpy && (
<>
<FontAwesome name={guessingItem.section.icon} size={60} />
<Text style={styles.itemName}>{guessingItem.name}</Text>
</>
)}
{isSpy && (
<>
<FontAwesome name="user-secret" size={60} />
<Text style={styles.placeName}>{t('youAreSpy')}</Text>
</>
)}
</View>
</Animated.View>
</Pressable>
</View>
);
};
const styles = StyleSheet.create({
constainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
innerContainer: {
height: 300,
width: 230,
marginVertical: 50,
padding: 60,
borderWidth: 6,
borderColor: GlobalStyles.colors.primary50,
borderRadius: 20,
justifyContent: 'center',
alignItems: 'center',
backfaceVisibility: 'hidden',
},
innerContainerBack: {
position: 'absolute',
right: 0,
bottom: 0,
justifyContent: 'center',
alignItems: 'center',
},
itemName: {
marginTop: 20,
fontSize: 18,
alignItems: 'center',
color: GlobalStyles.colors.primary50,
},
pressed: {},
});

Center button at bottom center of view

I'm trying to center the next button at the bottom of the page. Instead of being at the bottom of the page it's stick in the middle of the page. Any help?
Screen shot:
Screen Shot
export default class Type extends Component {
constructor(props) {
super(props)
this.state = {
selected: 'user'
}
}
_select(selected) {
this.setState({ selected })
}
_renderButton(type, photo, width, height, buttonStyles) {
const { selected } = this.state
if (selected === type)
return (
<TouchableOpacity style={ styles.buttonSelected } onPress={ e => this._select(type) }>
<Image source={ photo } style={[ styles.buttonPhoto, buttonStyles ]} width={ width } height={ height } />
</TouchableOpacity>
)
return (
<TouchableOpacity style={ styles.button } onPress={ e => this._select(type) }>
<Image source={ photo } style={[ styles.buttonPhoto, buttonStyles ]} width={ width } height={ height } />
</TouchableOpacity>
)
}
_renderText(text, type, textStyles) {
const { selected } = this.state
if (selected === type)
return <Text style={[ styles.text, styles.textSelected, textStyles ]}>{ text }</Text>
return <Text style={[ styles.text, textStyles ]}>{ text }</Text>
}
render() {
return (
<ScrollView style={ styles.container }>
<Text style={ styles.question }>Who are you?</Text>
<View style={ styles.buttons }>
{ this._renderButton('user', boy, 64, 64, { top: 15, left: 20 }) }
{ this._renderButton('carnival', ticket, 72, 72, { top: 10, left: 15 })}
</View>
<View style={ styles.texts }>
{ this._renderText('Attendee', 'user', { left: -12 }) }
{ this._renderText('Carnival', 'carnival', { left: 8 }) }
</View>
<TouchableOpacity style={ styles.nextButton }>
<Text style={ styles.nextText }>
Next Step
</Text>
</TouchableOpacity>
</ScrollView>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1
},
question: {
paddingTop: '30%',
textAlign: 'center',
color: '#ccc',
fontSize: 24,
marginBottom: 30
},
buttons: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center'
},
button: {
width: width/3,
height: width/3,
borderRadius: (width/3)/2,
borderWidth: 1,
borderColor: '#e6e6e6',
marginLeft: 10,
marginRight: 10
},
buttonPhoto: {
position: 'relative'
},
buttonSelected: {
width: width/3,
height: width/3,
borderRadius: (width/3)/2,
borderWidth: 1,
borderColor: '#ff9972',
marginLeft: 10,
marginRight: 10
},
texts: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
paddingTop: 12
},
text: {
width: width/3,
color: '#b5b5b5',
textAlign: 'center',
},
textSelected: {
color: '#ff9972'
},
nextButton: {
position: 'absolute',
left: (width/1.5)/2,
bottom: 5,
paddingTop: 10,
backgroundColor: '#ff6b5d',
width: width/1.5,
height: 48,
borderRadius: 5,
borderBottomWidth: 2,
borderBottomColor: '#de5244',
},
nextText: {
fontSize: 16,
color: '#fff',
textAlign: 'center'
}
})
This has been giving me issues for hours now. Looking for a simple solution that is what professional developers use.
Ignore:
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
Instead of using <ScrollView> as Parent, you can use <ScrollView> inside of <View> and have something similar to the below structure.
<View>
<ScrollView style={{flex:1}}>
{/*All of your screen */}
</ScrollView>
<View>
<TouchableOpacity style={ styles.nextButton }>
<Text style={ styles.nextText }>
Next Step
</Text>
</TouchableOpacity>
</View>
</View>
The button will always stay at bottom of the page.

How to fix marginHorizontal property in Flexbox not working?

I'm setting up some screens for an app using React-Native, and I want to fully understand how Flexbox works.
I'm trying to set the marginHorizontal property in style of textinput and button, but nothing happens.
If I set the specific value of width I do not have any problem.
Why marginHorizontal does not work properly?
The first image is what I get using marginHorizontal (the size of the button doesn't change and the margin from board is not 10);
The second image is what I get when I use width prop (the button size changes according the value of width).
I just wonder why with the marginHorizontal prop, nothing happens.
import React, { Component } from 'react'
import {Text, StyleSheet, View, TextInput, TouchableOpacity} from 'react-native'
import Swiper from 'react-native-swiper';
import {Button} from 'react-native-elements'
const formInputColor = 'rgba(255, 255, 255, 0.2)'
const formInputPlaceholderColor = 'rgba(255, 255, 255, 0.7)'
export default class RegisterFormComponent extends Component{
render(){
return(
<Swiper
style={styles.wrapper}
loop = {false}
>
<View style={styles.slide1}>
<View style={styles.topContainer1}>
<Text
style={styles.text}>What's you mail?
</Text>
<TextInput
placeholder = "Email"
placeholderTextColor = {formInputPlaceholderColor}
returnKeyType = "next"
style = {styles.formInput}
/>
<Text
style={styles.underText}
multiline={true}>blablablablablablablablablablablablablablablablablablablablablablablablablablablablablablabla
</Text>
<Button
style={styles.buttonStyle}
//textStyle = {styles.buttonTextStyle}
//loading={false}
>
</Button>
</View>
<View style={styles.bottomContainer1}>
</View>
</View>
<View style={styles.slide2}>
<View style={styles.topContainer1}>
<Text
style={styles.text}>Choose your password
</Text>
<TextInput
placeholder = "Password"
placeholderTextColor = {formInputPlaceholderColor}
secureTextEntry
returnKeyType = "go"
style = {styles.formInput}
/>
</View>
<View style={styles.bottomContainer1}>
</View>
</View>
<View style={styles.slide3}>
<Text style={styles.text}>And simple</Text>
</View>
</Swiper>
)
}
}
const styles = StyleSheet.create({
wrapper: {
flex: 1
},
slide1: {
flex: 1,
backgroundColor: '#3498db',
},
buttonStyle: {
backgroundColor: '#2980b9',
marginTop: 10,
height: 25,
marginHorizontal: 10
},
buttonTextStyle: {
fontSize: 10
},
topContainer1: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
},
logoStyle: {
width: 100,
height: 100,
},
bottomContainer1: {
flex: 1,
},
formInput:{
height: 40,
backgroundColor: formInputColor,
color: '#FFF',
marginHorizontal: 10,
paddingHorizontal: 10,
textAlignVertical: 'top'
},
slide2: {
flex: 1,
backgroundColor: '#97CAE5'
},
slide3: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#92BBD9'
},
text: {
color: '#000',
fontSize: 20,
padding: 10,
fontWeight: 'bold'
},
underText: {
color: 'black',
fontSize: 12,
marginTop: 8,
textAlign: 'center',
width: 300
}
})

Flexbox in react native : How to align 2 items at the center of the screen?

I discovered flexbox recently and I'm struggling to make it work, I'm surely missed some concept that make me hard time to understands it's mechanics so here is what I have:
It's a preview camera screen
with a back button on the top right
A text in the middle
and a record button to shoot some images
Here is what I have at the moment:
this is done with this React native component (style included)
import React from "react";
import { RNCamera } from "react-native-camera";
import { StyleSheet, TouchableOpacity, View, Platform} from "react-native";
import {Icon, Text} from "native-base";
import RequestPermissions from "../components/Permissions/RequestPermissions";
import I18n from "../i18n/i18n";
/**
* This is the component which allows the user to film his own film
*/
export default class CameraScreen extends React.Component
{
constructor(props) {
super(props);
this.camera = null;
}
state = {
isRecording: false,
iconVid: "record",
iconMode: null,
overlay: true
};
/**
* With RNCamera, it seems that permission is always asked to the user... Maybe this code is then irrelevant
*/
componentWillMount() {
if (Platform.OS === "android") {
RequestPermissions().then(() => {
console.log("granted");
}).then((err) => {
console.log(err)
});
}
}
componentWillUnmount() {
this.stopRecording();
};
stopRecording = () => {
if (this.camera) {
this.camera.stopRecording();
this.setState({
isRecording: false,
iconVid: "record"
});
}
};
renderCamera = () => {
return (
<View style={styles.container}>
<RNCamera
ref={cam => {
this.camera = cam;
}}
style={styles.preview}
>
<View style={styles.controlsContainer}>
<View style={styles.topRightButton}>
<TouchableOpacity onPress={() => this.props.navigation.goBack()}>
<Icon name={"arrow-left"} type={"Feather"} style={styles.iconFurtive}/>
</TouchableOpacity>
</View>
<View style={styles.middleContainer}>
<Text style={styles.actionText}>{I18n.t("action_text").toUpperCase()}</Text>
</View>
<View style={styles.leftContainer}>
<TouchableOpacity onPress={() => this.recordVideo()}>
<Icon name={this.state.iconVid} type={"MaterialCommunityIcons"} style={styles.iconCamera}/>
</TouchableOpacity>
</View>
</View>
</RNCamera>
</View>
);
};
/**
* For more options
* https://github.com/react-native-community/react-native-camera/blob/master/docs/RNCamera.md#recordasyncoptions-promise
*/
recordVideo = () => {
if (this.camera) {
this.setState({ isRecording: true, iconVid: "stop" });
// Show the overlay
console.log("Device is Recording");
this.camera.recordAsync({maxDuration: 15}).then(data => {
this.stopRecording();
console.log("Stop Recording");
console.log(data);
}).catch((err) => {
console.log(err);
this.stopRecording();
});
}
};
render() {
return this.renderCamera()
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop:30,
},
controlsContainer: {
flex: 1,
flexDirection: "column"
},
topRightButton: {
flex: 1,
justifyContent: 'flex-start',
alignItems: 'flex-start',
},
middleContainer: {
flex: 0.5,
justifyContent: 'center',
alignItems: 'center',
},
leftContainer: {
flex: 0.5,
justifyContent: 'center',
alignItems: 'flex-end',
},
actionText: {
color: "#fff",
fontSize: 72
},
preview: {
flex: 1,
},
iconCamera: {
color: "#ff4459",
marginBottom: 50,
padding: 25,
backgroundColor: "#fff",
borderRadius: 50,
},
iconFurtive: {
color: "#fff",
marginTop: 50,
marginLeft: 50,
}
});
Here is what I want:
How to do that with flexbox? What am I missing?
Code changed at View with {styles.topRightButton}
return (
<View style={styles.container}>
<RNCamera
ref={cam => {
this.camera = cam;
}}
style={styles.preview}
>
<View style={styles.controlsContainer}>
<View style={{justifyContent: 'flex-start', alignItems: 'flex-start',}}>
<TouchableOpacity onPress={() => this.props.navigation.goBack()}>
<Icon name={"arrow-left"} type={"Feather"} style={styles.iconFurtive}/>
</TouchableOpacity>
</View>
<View style={{flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-around'}}>
<View style ={{height: 50, width: 50, backgroundColor: 'transparent'}} />
<Text style={styles.actionText}>{I18n.t("action_text").toUpperCase()}</Text>
<TouchableOpacity onPress={() => this.recordVideo()}>
<Icon name={this.state.iconVid} type={"MaterialCommunityIcons"}/>
</TouchableOpacity>
</View>
</View>
</RNCamera>
</View>
);
For middle and left the content should be in the same div with that div having a flexDrirection: 'row'. This puts them in the same row.
The controls container can have justifyContent: 'center', and alignItems: 'center'.
The topRightButton should override the parents style.

React Native NavigatorIOS Does not Render component

I am having a problem rendering my component inside of a navigatorIOS, I am sure it is a style issue but I can't pinpoint where.
I have given flex : 1
removed backgroundColor
and I have given a margin
as suggested in other stack overflow questions.
If I throw MessageBoardTopics outside of the navigator it renders fine.
import MessageBoardTopics from './messageBoardTopics.js';
class MessageBoards extends React.Component{
constructor(props){
super(props);
}
componentDidMount(){
}
render() {
return (
<View style={styles.container}>
<NavigatorIOS
style={{flex: 1}}
initialRoute={{
component: MessageBoardTopics,
title: 'Forum',
}}/>
</View>
);
}
};
module.exports = MessageBoards;
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
var screenWidth = Dimensions.get('window').width;
class MessageBoardTopics extends React.Component{
constructor(props){
super(props);
var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
var data = PostStore.getState().posts;
this.state={sortText: 'Sort by: Old',
dataSource: ds.cloneWithRows(data)};
}
componentDidMount() {
PostStore.listen(this.onChange);
}
componentWillUnmount() {
PostStore.unlisten(this.onChange);
}
onChange(state) {
this.setState(state);
}
replyToMessage(){
}
removeMessage(){
}
sortMessages(){
}
editMessage(){
}
pressRow(rowData){
this.props.navigator.push({
title: rowData.title,
component: Topic
});
}
render() {
return (
<View style={styles.container}>
<Text>fasfasdfafasdf</Text>
<View style={{flex: .2}}></View>
<View style={styles.buttonBar}>
<TouchableHighlight style={styles.centerButton} underlayColor={"lightred"} onPress={this.sortMessages}>
<Text>{this.state.sortText}</Text>
</TouchableHighlight>
<View style={styles.centerButton} underlayColor={"lightred"} onPress={this.newMessage}>
<ComposeModal reply={this.replyToMessage} index={null}/>
</View>
</View>
<ListView
dataSource={this.state.dataSource}
style={{borderTopWidth: 2}}
renderRow={(rowData) =>
<TouchableHighlight underlayColor="lightgrey" onPress={()=>this.pressRow(rowData)}>
<View style={styles.message}>
<Text style={styles.messageTitle}>{rowData.title}</Text>
<Text style={styles.messageAuthor}>By: <Text style={{color: 'blue', fontStyle: 'italic'}}>{rowData.author}</Text></Text>
</View>
</TouchableHighlight>}/>
</View>
);
}
};
module.exports = MessageBoardTopics;
var styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 80,
},
message: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
borderWidth: 1,
borderColor: "lightblue",
padding: 15,
},
messageTitle: {
color: 'grey',
textDecorationLine: 'underline',
fontWeight: 'bold',
},
messageAuthor: {
fontSize: 10,
},
buttonBar: {
flex: .1,
alignSelf: 'stretch',
alignItems: 'center',
flexDirection: 'row',
},
centerButton: {
flex: 1,
width: (screenWidth/2),
alignItems: 'center',
},
button: {
flex: 1,
textAlign: 'center',
},
});
I needed to set a width to a wrapper component for the navigatorIOS
Edit: When I upgraded from react-native 0.16 to 0.17 flex:1 was not working on the navigatorIOS. I had to create a wrapper component and give that a flex as well.
This did not work. This was in my index.ios.js file, which rendered the navigatorIOS on 0.16.
render() {
return (
<View style={styles.container}>
<NavigatorIOS
style={{flex: 1, alignSelf: 'stretch'}}
initialRoute={{
component: MessageBoardTopics,
title: 'Forum',
}}/>
</View>
);
}
};
on react-native 0.17 I had to create a wrapper component and give that a flex attribute. I had to change my index.ios.js to render this instead.
var forumComponent = React.createClass({
render: function() {
return (
<View style={styles.container}>
<MessageBoards style={{flex: 1}}/>
</View>
);
}
});

Resources