Skip to content

Commit

Permalink
fix header empty children bug
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-satija committed Nov 4, 2016
1 parent a6d0a81 commit 0bf8d6f
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion Components/Widgets/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default class Header extends NativeBaseComponent {
</View>)
}
}
else {
else if (buttons.length > 1) {
if (Platform.OS === 'ios') {
newChildren.push(<View key='title' style={{position: 'absolute', left: 0, right: 0, top: 13, bottom: 0, alignSelf: 'center', justifyContent: 'center'}}>
{[title[0],subtitle[0]]}
Expand Down Expand Up @@ -171,6 +171,31 @@ export default class Header extends NativeBaseComponent {
}

}
else {
if (Platform.OS === 'ios') {
newChildren.push(<View key='title' style={{position: 'absolute', left: 0, right: 0, top: 13, bottom: 0, alignSelf: 'center', justifyContent: 'center'}}>
{[title[0],subtitle[0]]}
</View>)

if (childrenArray.length>1) {
for (let i = 1; i < childrenArray.length; i++) {
newChildren.push(<View key={'btn' + (i+1)} style={{alignItems: 'center', justifyContent: 'flex-start', flexDirection: 'row', marginRight: -14}}>
{React.cloneElement(childrenArray[i], {})}
</View>)
}
}
}
else {
newChildren.push(<View key='title' style={{flex: 3, alignSelf: 'stretch', justifyContent: 'center'}}>
{[title[0]]}
</View>)
for (let i = 1; i < childrenArray.length; i++) {
newChildren.push(<View key={'btn' + (i+1)} style={{alignItems: 'center', justifyContent: 'flex-start', flexDirection: 'row', marginRight: -7}}>
{React.cloneElement(childrenArray[i], {})}
</View>)
}
}
}
return newChildren;
}
}
Expand Down

0 comments on commit 0bf8d6f

Please sign in to comment.