View goes hidden when status bar is set - android

I have a component it has a view of flex: 1 with a status bar component and a child component, when the status bar element isn't there the indicator shows, but when I add the status bar element, the indicator goes hidden, Please how can i make the indicator show while the status bar is added, what is making it go hidden
With the StatusBar(The indicator goes hidden)
Without the StatusBar(The Indicator shows)
THE CODE
CHILD COMPONENT(On)
import {BoxShadow} from 'react-native-shadow';
export default class On extends Component {
render() {
const shadowOpt = {
width: Dimensions.get('window').width,
height: Dimensions.get('window').height / 10,
color: "#000",
border: 10,
opacity: '0.15',
radius: 20,
x: 0,
y: 5,
}
const dimensions = Dimensions.get('window');
const Height = (dimensions.height);
const Width = dimensions.width;
return (
<View style={{flex: 1}}><View name="indicator" style={{flexDirection: 'row',}}>
<View style={{backgroundColor: '#cbcdda', width: Width, height: Height / 60}}>
</View>
<View style={{
backgroundColor: '#EFB879',
width: (this.state.width),
height: Height / 60,
position: 'absolute'
}}>
</View>
</View>
<ViewPagerAndroid
onPageSelected={this.onPageSelected.bind(this)}
ref={(viewPager) => {
this.viewPager = viewPager
}}
style={{height: Height - ((Height / 30) + (Height / 10))}}
initialPage={0}>
<View style={{
backgroundColor: 'white',
alignItems: 'center',
alignSelf: 'center',
justifyContent: 'center',
flexDirection: 'column'
}} key="1">
<Image style={{marginBottom: 50,}} source={require('../on1.png')}/>
<Text style={{
fontFamily: 'mont',
color: '#000',
fontSize: 22,
letterSpacing: 0.5,
marginBottom: 12
}}>
Welcome to Sẹlẹ
</Text>
<Text style={{
fontFamily: 'mont',
color: '#615D5D',
fontSize: 16,
letterSpacing: 1,
textAlign: 'center'
}}>
Hire services and buy and sell {'\n'} on Sẹlẹ
</Text>
</View>
<View style={{
backgroundColor: 'white',
alignItems: 'center',
alignSelf: 'center',
justifyContent: 'center',
flexDirection: 'column'
}} key="2">
<Image style={{marginBottom: 50, width: '35%', height: '35%'}}
source={require('../sele2.png')}/>
<Text style={{
fontFamily: 'mont',
color: '#000',
fontSize: 22,
letterSpacing: 0.5,
marginBottom: 12
}}>
With Sẹlẹ, you can
</Text>
<Text style={{
fontFamily: 'mont',
color: '#615D5D',
fontSize: 16,
letterSpacing: 1,
textAlign: 'center'
}}>
Hire services and buy and sell {'\n'} on Sẹlẹ
</Text>
</View>
<View style={{
backgroundColor: 'white',
alignItems: 'center',
alignSelf: 'center',
justifyContent: 'center',
flexDirection: 'column'
}} key="3">
<Text style={{
fontFamily: 'mont',
color: '#000',
fontSize: 22,
letterSpacing: 0.5,
marginBottom: 12
}}>
Select your School
</Text>
<Text style={{
fontFamily: 'mont',
color: '#615D5D',
fontSize: 16,
letterSpacing: 1,
textAlign: 'center'
}}>
You've made it this far {'\n'} select your school on the next page {'\n'} and let's get
started
</Text>
</View>
</ViewPagerAndroid>
<BoxShadow setting={shadowOpt}>
<View style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
flex: 1,
backgroundColor: 'white',
}}>
<TouchableNativeFeedback>
<Text style={{
fontSize: 18,
marginLeft: 25,
fontFamily: 'mont',
color: '#615D5D',
marginBottom: 10
}}>Skip</Text>
</TouchableNativeFeedback>
<View style={{flexDirection: 'row'}}><View
style={{marginRight: 14, alignSelf: 'center'}}>
<View style={this.state.no == "0" ? styles.selected : styles.unselected}>
</View>
</View>
<View style={{marginRight: 14}}>
<View
style={this.state.no == "1" ? styles.selected : styles.unselected}>
</View>
</View>
<View
style={this.state.no == "2" ? styles.selected : styles.unselected}>
</View></View>
<TouchableNativeFeedback onPress={this.update.bind(this)}>
<Text style={{
fontFamily: 'mont',
color: '#EFB879',
fontSize: 18,
marginRight: 25,
marginBottom: 10
}}>Next</Text>
</TouchableNativeFeedback>
</View>
</BoxShadow>
</View>
);
}
}
PARENT ELEMENT
export default class Parent extends Component {
constructor(props) {
super(props);
this.state = {
timePassed: false,
};
}
render() {
return (
<View style={{flex: 1}}>
<StatusBar backgroundColor='#EE8F62' translucent={true} barStyle='light-content'/><On/>
</View>
);
}
}

We had similar problem for android, This is how we handle it was, may be this will help you to find a better solution.
You need to create a const and assign status bar size as a value.
const NAVBAR_HEIGHT = Platform.select({
ios: { marginTop: 0 },
android: { marginTop: window.height / 8 }
});
Then in the style section should add this line,
marginTop: NAVBAR_HEIGHT.marginTop
Like this,
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#E7EBF0",
marginTop: NAVBAR_HEIGHT.marginTop
}
});
This is how we create status bar for our application,
<View style={styles.container}>
{/* if ios status bar will be added to the screen */}
{Platform.OS === "ios" ? (
<Statusbar backgroundColor="#000000" barStyle="light-content" />
) : null}
</View>

Related

Why shadows on Android are covered by other component?

I have an issue with setting up shadows in Android.
When add element exactly after my element with shadows is, shadows are being covered by them. I have no this issue in iOS.
I will post some code and screenshots to explain the situation.
Here's how it looks on iOS:
Here's how it looks on Android:
This is my render function in Screen component:
render() {
const ticket = this.props.navigation.getParam("ticket", {});
return (
<Fragment>
<SafeAreaView style={{ flex: 0 }} />
<SafeAreaView style={{ flex: 1 }}>
<View style={{ flex: 0.6 }}>
<TopSmallCroppedComponent />
</View>
<ScrollView style={styles.overlayComponent}>
<Text style={baseStyles.screenTitle}>
{strings.YouSetPaymentPickUp}
</Text>
<TicketCardComponent ticket={ticket} />
</ScrollView>
<View
style={[
baseStyles.bottom,
{
flex: 0.4,
marginLeft: 35,
marginRight: 35,
bottom: 10
}
]}
>
<Text style={styles.notAtHomeText}>{strings.NotBeAtHome}</Text>
<ButtonGreenComponent
text={strings.PayOnlineButton}
pressed={() => this._onPressPayOnlineButton(ticket)}
/>
</View>
<LoadingView
size="large"
spinnerColor={theme.WHITE_COLOR}
backgroundColor="#0000005f"
visible={this.state.modalVisible}
/>
</SafeAreaView>
</Fragment>
);
}
Screen component styles:
export default StyleSheet.create({
overlayComponent: {
position: "absolute",
top: 0,
bottom: 0,
width: "100%",
height: "100%",
alignSelf: "center"
},
notAtHomeText: {
alignSelf: "center",
fontFamily: theme.FONT_REGULAR,
color: theme.LABEL_COLOR,
fontSize: theme.FONT_SIZE_LARGE,
marginBottom: 10
}
});
TicketCardComponent:
render() {
const { ticket } = this.props;
return (
<View style={[styles.cardBox, baseStyle.shadow]}>
<View
style={[styles.cardBoxEventOverlayIcon, baseStyle.shadow]}
elevation={5}
>
<Image
source={this.cardImages.eventIcon}
style={{ height: 30, width: 30, alignSelf: "center" }}
/>
</View>
<View style={[styles.cardBoxUserTicket]}>
<Text style={styles.cardBoxTicketUserLabel}>
{strings.YourPaymentCollector}
</Text>
<View style={styles.cardBoxUserInfoWrapper}>
<Image
source={this.cardImages.userIcon}
style={styles.cardUserIcon}
/>
<View style={styles.cardUserInfoTextsWrapper}>
<Text style={styles.userNameText}>
{this._renderTicketAssignee(ticket)}
</Text>
<Text style={styles.ticketCreationTimeText}>
{this._renderRelativeDate(ticket.creationDate)}
</Text>
</View>
</View>
</View>
</View>
);
}
TicketCardComponent styles:
export default StyleSheet.create({
cardBox: {
backgroundColor: theme.WHITE_COLOR,
borderTopLeftRadius: 6,
borderTopRightRadius: 6,
borderBottomRightRadius: 6,
borderBottomLeftRadius: 6,
paddingLeft: 22,
paddingRight: 22,
paddingTop: 35,
marginLeft: 35,
marginRight: 35
},
cardBoxEventOverlayIcon: {
width: 56,
height: 56,
position: "absolute",
backgroundColor: "white",
top: -(56 / 2),
left: 56 / 2,
justifyContent: "center",
borderRadius: 56 / 2
},
cardHeading: {
fontSize: theme.FONT_SIZE_LARGER,
fontFamily: theme.FONT_MEDIUM
},
cardBoxUserTicket: {
paddingTop: 10,
paddingBottom: 20
},
cardBoxTicketUserLabel: {
fontFamily: theme.FONT_MEDIUM,
color: theme.LABEL_COLOR,
fontSize: theme.FONT_SIZE_MEDIUM_LARGE
},
cardBoxUserInfoWrapper: {
flexWrap: "wrap",
alignItems: "flex-start",
flexDirection: "row",
height: 50,
marginTop: 15,
marginBottom: 15
},
cardUserIcon: {
width: 50,
height: 50,
flexDirection: "column"
},
cardUserInfoTextsWrapper: {
height: 50,
flexDirection: "column",
marginLeft: 10,
justifyContent: "space-between",
paddingTop: 4,
paddingBottom: 4
},
userNameText: {
fontFamily: theme.FONT_BLACK,
color: theme.LABEL_COLOR,
fontSize: theme.FONT_SIZE_LARGE
},
ticketCreationTimeText: {
fontFamily: theme.FONT_MEDIUM,
color: theme.LABEL_COLOR,
fontSize: theme.FONT_SIZE_SMALL
}
});

React Native Keyboard pushing the header(Android)

When the TextInput is onFocus the keyboard keeps pushing the content and the header outside the screen, with or without the KeyboardAvoidingView Component, the behaviour is the same.
I tried the following in the manifest:
android:windowSoftInputMode="adjustPan"
when I changed the above to
android:windowSoftInputMode="adjustResize"
it works fine the header is not being pushed but it pushes all the views which is found under the TextInput above the keyboard which is not desired
android:windowSoftInputMode="adjustNothing"
it shows no effect even if i added the KeyboardAvoidingView Component
My Code
<SafeAreaView style={{ flex: 1 }} forceInset={{ top: 'never' }}>
<StatusBarPlaceHolder />
<StatusBar barStyle="light-content" hidden={false} backgroundColor="#A4395A" translucent={true} />
<Header title={'ارسال دعوة'} />
<View style={{ flex: 1, backgroundColor: '#fff' }}>
<Text style={{ fontSize: 15, fontWeight: 'bold', textAlign: 'right', marginHorizontal: 15, marginTop: 5, fontFamily: Fonts.Cairo }}>نوع المناسبة</Text>
<View style={{ flexDirection: 'row', justifyContent: 'center', marginVertical: 5 }}>
<TouchableOpacity style={{ borderRadius: 8, width: width / 6, backgroundColor: this.state.bgGe, marginHorizontal: 2.5 }} onPress={() => this.setType(require('../../assets/T-General.png'))} >
<Image resizeMode='stretch' style={{ borderRadius: 5, height: height / 8, width: width / 6 }} source={require('../../assets/T-General.png')} />
</TouchableOpacity>
<TouchableOpacity style={{ borderRadius: 8, width: width / 6, backgroundColor: this.state.bgG, marginHorizontal: 2.5 }} onPress={() => this.setType(require('../../assets/T-Grad.png'))} >
<Image resizeMode='stretch' style={{ height: height / 8, width: width / 6 }} source={require('../../assets/T-Grad.png')} />
</TouchableOpacity>
<TouchableOpacity style={{ borderRadius: 8, width: width / 6, backgroundColor: this.state.bgE, marginHorizontal: 2.5 }} onPress={() => this.setType(require('../../assets/T-Eng.png'))}>
<Image resizeMode='stretch' style={{ height: height / 8, width: width / 6 }} source={require('../../assets/T-Eng.png')} />
</TouchableOpacity>
<TouchableOpacity style={{ borderRadius: 8, width: width / 6, backgroundColor: this.state.bgB, marginHorizontal: 2.5 }} onPress={() => this.setType(require('../../assets/T-Birthday.png'))}>
<Image resizeMode='stretch' style={{ height: height / 8, width: width / 6 }} source={require('../../assets/T-Birthday.png')} />
</TouchableOpacity>
<TouchableOpacity style={{ borderRadius: 8, width: width / 6, backgroundColor: this.state.bgW, marginHorizontal: 2.5 }} onPress={() => this.setType(require('../../assets/T-Wedding.png'))}>
<Image resizeMode='stretch' style={{ height: height / 8, width: width / 6 }} source={require('../../assets/T-Wedding.png')} />
</TouchableOpacity>
</View>
<KeyboardAvoidingView style={{flex:1}}>
<ScrollView style={{flex:1, backgroundColor: 'white' }} ref={scrollView => this.scrollView = scrollView}>
<View style={{ justifyContent: 'space-between', flexDirection: 'row', marginHorizontal: 5 }}>
<View style={{ flex: 1, marginHorizontal: 5 }}>
<Text style={{ fontSize: 15, fontWeight: '700', textAlign: 'right', marginBottom: 5, fontFamily: Fonts.Cairo }} >يوافق الهجري</Text>
<View style={{ flex: 1, backgroundColor: '#F3F3F3', borderRadius: 5 }}>
<TextInput
underlineColorAndroid='transparent'
value={this.state.dateH}
onChangeText={(value) => this.setState({ dateH: value })}
style={{
flex: 1, paddingBottom: 7,
textAlign: 'right', marginHorizontal: 10
}} placeholder={'الهجري'} />
</View>
</View>
<View style={{ flex: 1, marginHorizontal: 5 }}>
<Text style={{ fontSize: 15, fontWeight: '700', textAlign: 'right', marginBottom: 5, fontFamily: Fonts.Cairo }} >التاريخ ميلادي</Text>
<View style={{ flex: 1, backgroundColor: '#F3F3F3', borderRadius: 5 }}>
<DatePicker
date={this.state.date}
mode="date"
placeholder="اختار التاريخ"
format="YYYY-MM-DD"
minDate="2019-1-1"
maxDate="2020-1-1"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
locale={"ar"}
customStyles={{
dateIcon: {
height: 0,
width: 0
},
dateInput: {
marginLeft: 45,
paddingBottom: 10,
borderWidth: 0,
}
// ../.. You can check the source to find the other keys.
}}
onDateChange={(date) => this.setDate(date)}
/>
</View>
</View>
</View>
<View style={{ flex: 1, justifyContent: 'space-between', flexDirection: 'row', marginHorizontal: 5, marginTop: 5 }}>
<View style={{ flex: 1, marginHorizontal: 5 }}>
<Text style={{ fontSize: 15, fontWeight: '700', textAlign: 'right', marginBottom: 5, fontFamily: Fonts.Cairo }} >موقع المناسبة</Text>
<View style={{ flex: 1, backgroundColor: '#F3F3F3', borderRadius: 5 }}>
<TextInput
underlineColorAndroid='transparent'
multiline
blurOnSubmit
onChangeText={(value) => this.setState({ location: value })}
style={{
flex: 1, paddingBottom: 7,
textAlign: 'right', marginHorizontal: 10
}} placeholder={'الشارع الحي'} />
</View>
</View>
<View style={{ flex: 1, marginHorizontal: 5 }}>
<Text style={{ fontSize: 15, fontWeight: '700', textAlign: 'right', marginBottom: 5, fontFamily: Fonts.Cairo }} >الداعي</Text>
<View style={{ flex: 1, padding: 8, backgroundColor: '#F3F3F3', borderRadius: 5 }}>
<TextInput
underlineColorAndroid='transparent'
multiline
blurOnSubmit
onChangeText={(value) => this.setState({ fromD: value })}
style={{
flex: 1, paddingBottom: 7,
textAlign: 'right', marginHorizontal: 10
}} placeholder={'اسم الداعي'} />
</View>
</View>
</View>
<Text style={{ fontSize: 15, fontWeight: '700', textAlign: 'right', marginTop: 5, marginHorizontal: 10, fontFamily: Fonts.Cairo }} >نص الدعوة</Text>
<View style={{ flex: 1, marginHorizontal: 10, marginTop: 5, backgroundColor: '#F3F3F3', borderRadius: 5 }}>
<TextInput
underlineColorAndroid='transparent'
multiline
onBlur={() => this.scrollView.scrollTo({ x: 0, y: 0, animated: true })}
onFocus={Platform.OS=='ios'? () => this.scrollView.scrollTo({ x: 0, y: 90, animated: true }):null}
blurOnSubmit
onChangeText={(value) => this.setState({ body: value })}
style={{
flex: 1, paddingBottom: 7, height: height / 7,
textAlign: 'right', marginHorizontal: 10
}} placeholder={'نتشرف بحضوركم لحفل تخرج ولدنا عثمان الصفادي'} />
</View>
<Text style={{ fontSize: 15, fontWeight: '700', textAlign: 'right', marginTop: 5, marginHorizontal: 10, fontFamily: Fonts.Cairo }} >ملحاظات</Text>
<View style={{ flex: 1, alignItems: 'flex-end', marginHorizontal: 10, marginTop: 5, }}>
<TextInput
underlineColorAndroid='transparent'
multiline
blurOnSubmit
onBlur={() => this.scrollView.scrollTo({ x: 0, y: 0, animated: true })}
onFocus={Platform.OS=='ios'? () => this.scrollView.scrollTo({ x: 0, y: 195, animated: true }):null}
onChangeText={(value) => this.setState({ notes: value })}
style={{
width: width / 2, paddingHorizontal: 10,
paddingBottom: 7, height: height / 10,
textAlign: 'right', backgroundColor: '#F3F3F3', borderRadius: 5
}} placeholder={'ممنوع اصطحاب الاطفال..'} />
</View>
</ScrollView>
</KeyboardAvoidingView>
<View style={{ alignItems: 'center', justifyContent: 'flex-end' }}>
<View style={{ flexDirection: 'row' }}>
<TouchableOpacity onPress={() => this.designCard()} style={{
justifyContent: 'center', width: width / 3, backgroundColor: '#753C4C', padding: 7,
borderTopLeftRadius: 5, borderBottomLeftRadius: 5, height: 45, marginVertical: 20, marginHorizontal: 1, alignSelf: 'center'
}}>
<Text style={{ color: 'white', textAlign: 'center', fontSize: 18, fontFamily: Fonts.Cairo }}>تصميم كرت</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.takephoto()} style={{
justifyContent: 'center', borderTopRightRadius: 5, borderBottomRightRadius: 5,
backgroundColor: '#753C4C', height: 45, width: width / 3, padding: 7, marginVertical: 20, marginHorizontal: 1, alignSelf: 'center'
}}>
<Text style={{ color: 'white', textAlign: 'center', fontFamily: Fonts.Cairo, fontSize: 18 }}>ادراج كرت</Text>
</TouchableOpacity>
</View>
</View>
</View>
</SafeAreaView>
try
<KeyboardAvoidingView behavior='padding'>

in without debug mode my flatlist is not execute completely

i am working on a app by react native.i have a problem.when my app has a debug mode work very well.but in without debug mode my flat list not execute completely.
for example :
when render my flat list date is invalid.
<FlatList
style={{ flex: 1 }}
extraData={this.state}
data={this.state.data}
renderItem={this.renderItem.bind(this)}
keyExtractor={item => item._id.toString()}
ListFooterComponent = { this.Render_Footer.bind(this) }
/>
and Render Item by :
renderItem({item}) {
console.log(item)
return <View
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<Text style={{fontFamily: Font.main, fontSize: 12}}>{I18n.t('Type')}</Text>
<Text style={{fontSize: 12, fontFamily: Font.main}}>{I18n.t(item.type)}</Text>
</View>
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<Text style={{fontFamily: Font.main, fontSize: 12}}>{I18n.t('OrderDate')}</Text>
<Text style={{
fontFamily: this.state.isrtl ? Font.main_persian_digit : Font.main, color: Color.Gray
, fontSize: 12
}}>{this.state.isrtl ? getshamsidate(item.effective_time) : getmiladdate(item.effective_time)}</Text>
</View>
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<Text style={{
fontFamily: Font.main,
color: item.status === 'pardakht' ? Color.green : Color.primarycolor,
fontSize: 12
}}>{I18n.t('TotalAmount')}</Text>
<Text style={{
fontFamily: this.state.isrtl ? Font.main_persian_digit : Font.main,
color: item.status === 'pardakht' ? Color.green : Color.primarycolor
,
fontSize: 12
}}>{addCommas(item.amount)} {I18n.t('Toman')}</Text>
</View>
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<Text style={{fontFamily: Font.main, fontSize: 12}}>{I18n.t('Status')}</Text>
{
item.status === 'SUCCESS' ?
<View style={{flexDirection: 'row', justifyContent: 'center', alignItems: 'center'}}>
<Icon
style={{fontSize: 10}}
name='checkmark'
/>
<Text style={{
fontFamily: this.state.isrtl ? Font.main_persian_digit : Font.main,
paddingLeft: 5,
paddingRight: 5
,
fontSize: 12
}}>{I18n.t(item.status)}</Text>
</View>
:
<View style={{flexDirection: 'row', justifyContent: 'center', alignItems: 'center'}}>
<Icon
style={{fontSize: 10, color: 'red'}}
name='close'
/>
<Text style={{
fontFamily: this.state.isrtl ? Font.main_persian_digit : Font.main,
color: Color.Red,
paddingLeft: 5,
paddingRight: 5
,
fontSize: 12
}}>{I18n.t(item.status)}</Text>
</View>
}
</View>
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<Text style={{fontFamily: Font.main, fontSize: 12}}>{I18n.t('PreviousCredit')}</Text>
<View style={{flexDirection: 'row', justifyContent: 'center', alignItems: 'center'}}>
<Text style={{
fontFamily: this.state.isrtl ? Font.main_persian_digit : Font.main,
paddingLeft: 5,
paddingRight: 5
,
fontSize: 12
}}>{item.balance_before !== null ?
addCommas(item.balance_before.toString()) : 0
} {I18n.t('Toman')}
</Text>
</View>
</View>
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<Text style={{fontFamily: Font.main, fontSize: 12}}>{I18n.t('NextCredit')}</Text>
<View style={{flexDirection: 'row', justifyContent: 'center', alignItems: 'center'}}>
<Text style={{
fontFamily: this.state.isrtl ? Font.main_persian_digit : Font.main,
paddingLeft: 5,
paddingRight: 5
,
fontSize: 12
}}>{item.balance_after !== null ?
addCommas(item.balance_after.toString()) : 0
} {I18n.t('Toman')}
</Text>
</View>
</View>
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<Text style={{fontFamily: Font.main, fontSize: 12}}>{I18n.t('bankcorrelationid')}</Text>
<View style={{flexDirection: 'row', justifyContent: 'center', alignItems: 'center'}}>
{item.debit !== undefined ?
<Text style={{
fontFamily: this.state.isrtl ? Font.main_persian_digit : Font.main,
color: Color.linkcolor,
paddingLeft: 5,
paddingRight: 5
,
fontSize: 12
}}>{item.debit.bank_corelation_id}
</Text> : null}
</View>
</View>
{
Object.keys(item.cart).length !== 0 ?
<TouchableOpacity style={{flexDirection: 'row', justifyContent: 'space-between', paddingTop: 5}}
onPress={() => {
this.props.navigation.navigate('TransAction', {product: item.cart})
}
}
>
<Text style={{
fontFamily: Font.main,
color: Color.circleblu,
fontSize: 12
}}>{I18n.t('Orderdetails')}</Text>
<View style={{flexDirection: 'row', justifyContent: 'center', alignItems: 'center'}}>
<Icon
style={{fontSize: 14, color: Color.circleblu}}
name={this.state.isrtl ? 'arrow-back' : 'arrow-forward'}
/>
</View>
</TouchableOpacity>
: null
}
</View>
}
The above code ,render my item in flatlist .in debug mode working very good,but in release mode date in undefinedNaN:Nan showed
react native has nothing to do with your data in different modes.
from your code it seems that you have problem with datetime rendering. react-native has problem with datetime rendering sometimes.
make sure that date string in your new Date("your_date") is in ISO format with 'T' in string like "2018-05-02T12:00:00)". that way you date function should work.
i findeed solutions,this problem for javascript in android .i am solved problem using moment.js

TextInput not showing on focus

I have a text input named email or user name when i click on it, it doesn't show the values I type,I think it's because of the screen size, is there anyway I can adjust the Textinput so that when I click on it, the full text input show and I can see my values typed.
The other text inputs underneath it shows, but it doesn't show, should i wrap it in a scrollview, please any help will be nice, Thanks.
This is the page
when i click on email or username
wrapping the view in a scroll view brings this
MY CODE
<View style={{
height: 42, width: 72,
backgroundColor: '#EFB879', marginTop: '15.15%',
alignSelf: 'center'
}}>
<Text style={{
fontFamily: 'mont-bold',
fontSize: 34,
color: '#fff'
}}>
sẹlẹ
</Text>
</View>
<View style={{
width: '83.33%',
height: this.state.visible? 240 : 180,
backgroundColor: '#fff',
position: 'absolute',
bottom: 0,
alignSelf: 'center',
borderTopRightRadius: 20,
borderTopLeftRadius: 20,
}}>
<View style={{
width: '100%',
height: 60,
backgroundColor: '#fff',
borderBottomWidth: 0.7,
borderColor: '#d9d8d8',
borderTopRightRadius: 6,
borderTopLeftRadius: 6,
}}>
<TextInput placeholder="Email or mobile number"
placeholderStyle={{fontSize: 14, fontFamily: 'mont'}}
placeholderTextColor="#615D5D"
underlineColorAndroid={'transparent'}
style={{
alignSelf: 'center',
flex: 1,
paddingTop: 10,
paddingRight: 10,
paddingBottom: 10,
width: '85%',
paddingLeft: 0,
padding: 4,
backgroundColor: '#fff',
fontSize: 14, fontFamily: 'mont', color: '#615D5D',
}}/>
</View>
<View style={{
width: '100%',
height: 60,
backgroundColor: '#fff',
borderBottomWidth: 0.7,
borderColor: '#d9d8d8',
}}>
<TextInput placeholder={picked}
value={this.state.text}
onChangeText={(text) => this.handleChange(text)}
onFocus={() => this.setState({visible: true})}
onBlur={() => this.setState({visible: false})}
placeholderStyle={{fontSize: 14, fontFamily: 'mont'}}
placeholderTextColor="#615D5D"
underlineColorAndroid={'transparent'}
style={{
alignSelf: 'center',
flex: 1,
paddingTop: 10,
paddingRight: 10,
paddingBottom: 10,
width: '85%',
paddingLeft: 0,
padding: 4,
backgroundColor: '#fff',
fontSize: 14, fontFamily: 'mont', color: '#615D5D',
}}
contextMenuHidden={true}/>
</View>
{this.state.visible ? <View style={{
justifyContent: 'flex-end',
height: 200,
width: '100%',
}}>
<Text style={styles.textHead}>
Select your Institute
</Text>
{view}
</View> : <View hide={true} style={{
width: '100%',
height: 60,
backgroundColor: '#fff',
justifyContent: 'center'
}}>
<TextInput placeholder="Password"
placeholderStyle={{fontSize: 14, fontFamily: 'mont'}}
placeholderTextColor="#615D5D"
underlineColorAndroid={'transparent'}
secureTextEntry={true}
style={{
alignSelf: 'center',
flex: 1,
paddingTop: 10,
paddingRight: 25,
paddingBottom: 10,
width: '85%',
paddingLeft: 0,
padding: 4,
backgroundColor: '#fff',
fontSize: 14, fontFamily: 'mont', color: '#615D5D',
}}/><View style={{
width: 18, height: 11,
position: 'absolute', right: 25
}}>
<Image resizeMode="contain" style={{alignSelf: 'center', flex: 1}}
source={require('../eye.png')}/>
</View>
</View>}
</View>
</View>
<View style={{
width: '83.36%',
height: 60,
backgroundColor: '#EFB879',
alignSelf: 'center',
justifyContent: 'center',
alignItems: 'center',
borderBottomRightRadius: 6,
borderBottomLeftRadius: 6,
}}>
<Text style={{
fontFamily: 'mont-semi',
fontSize: 16,
color: '#fff'
}}>
SIGN UP
</Text>
</View>
<View
style={{
height: 0,
width: 120,
borderBottomWidth: 1.2,
borderColor: '#d9d8d8',
alignSelf: 'center',
marginTop: '50%'
}}>
</View>
<View style={{width: '100%',
height: 2,flexDirection: 'row',
// alignSelf: 'center',
justifyContent: 'center',
marginTop: '5%'}}>
<Text style={{
color: '#615D5D',
fontFamily: 'mont-medium',
fontSize: 14,
alignSelf: 'center',
}}>
Already have an account? </Text>
<TouchableNativeFeedback
onPressIn={() => this.setState({pressed: !this.state.pressed})}
onPressOut={() => this.setState({pressed: !this.state.pressed})}
onPress={this.onP.bind(this)}>
<Text
style={{
color: '#EFB779',
fontFamily: 'mont-medium',
fontSize: this.state.pressed? 16: 14,
alignSelf: 'center',}}>
SIGN IN
</Text>
</TouchableNativeFeedback>
</View>
</View>
This works to me:
Use the Keyboard API from React Native to set listeners on keyboard.
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow);
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
Use a state variable to set scrollEnabled prop of the ScrollView (that wrap your content) to true or false according to the keyboard is shown or not. So when the keyboard is shown the scroll will be enabled.
At the bottom of your content add a conditional View with some height that is active when the keyboard is shown thus you will be able to scroll.
Remember this:
componentWillUnmount () {
this.keyboardDidShowListener.remove();
this.keyboardDidHideListener.remove();
}
Place your entire code inside ScrollView and use fixed positions for your views. Try it.
There is no onchangetext() event in first and last textInput.try to add it in your code.
constructor(props) {
super(props);
this.state = { email:'',text:'',password:'' };
}
...
<TextInput
onChangeText={(email) => this.setState({email})}
value={this.state.email}
/>
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
onChangeText={(text) => this.setState({text})}
value={this.state.text}
/>
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
onChangeText={(password) => this.setState({password})}
value={this.state.password}
/>
i hope this helps you

how to bring ProgressBar in center of the screen and remove warning message in react native

how to bring the progress bar to the center of the screen like we do in android center in parent in relative layout and how to remove the warning message.How to change the visibility(invisible or gone or visible) in progressbar.
MyScreen
var ProgressBar = require('ProgressBarAndroid');
<View style={{ flex: 1, backgroundColor: 'steelblue', padding: 10, justifyContent: 'center' }}>
<Text style={{
backgroundColor: 'steelblue', justifyContent: 'center', alignItems: 'center', fontSize: 40, textAlign: 'center',
color: 'white', marginBottom: 30
}}>LOGIN</Text>
<ProgressBar style={{justifyContent:'center',alignItems:'center',styleAttr:'LargeInverse', color:'white'}} />
<View style={{ justifyContent: 'center' }}>
<TextInput
style={{ height: 50, marginLeft: 30, marginRight: 30, marginBottom: 20, color: 'white', fontSize: 20 }}
placeholder='Username' placeholderTextColor='white'
autoFocus={true}
returnKeyType='next'
keyboardType='email-address'
onChangeText={(valUsername) => _values.username = valUsername}
/>
<TextInput
secureTextEntry={true}
style={{ height: 50, marginLeft: 30, marginRight: 30, marginBottom: 20, color: 'white', fontSize: 20 }}
placeholder='Password' placeholderTextColor='white'
onChangeText={(valPassword) => _values.password = valPassword}
/>
</View>
<Button onPress={() => { _handlePress() } } label='Login' />
<View>
<Text style={{ color: 'white', justifyContent: 'center', textAlign: 'center', alignItems: 'center', fontSize: 20, textDecorationLine: 'underline', textDecorationStyle: 'solid' }}>
Forgot Password
</Text>
<Text style={{ color: 'white', marginTop: 10, justifyContent: 'center', textAlign: 'center', alignItems: 'center', fontSize: 20, textDecorationLine: 'underline', textDecorationStyle: 'solid' }}>
SignUp
</Text>
</View>
</View>
As noted by #ravi-teja, use absolute positioning. Also, your warning arises because styleAttr is not a style attribute (the name is misleading) but a prop. You can also show and hide it programmatically using a boolean (myCondition) (that you can maybe store in your state). You should do something like this:
var ProgressBar = require('ProgressBarAndroid');
// ...
render(){
const {width, heigth} = Dimensions.get('window'); // The dimensions may change due to the device being rotated, so you need to get them in each render.
return (
//...
{this.state.myCondition && <ProgressBar styleAttr={'LargeInverse'} style={{position: 'absolute', left: width/2, height: height/2, justifyContent:'center',alignItems:'center', color:'white'}} />}
//...
}
In addition to that and as others said, you should give a try to ActivityIndicator, since it works for both iOS and Android.

Categories

Resources