How can i use NavigationBar shoutemui - react-native

I'm trying to use NavigationBar from the Shoutem UI toolkit.
My code:
<Screen>
<NavigationBar centerComponent={<Title>TITLE</Title>}/>
<ListView
data={groupedData}
renderRow={this.renderRow}
loading ={this.state.loading}
onRefresh={this.getAllNewsfeed.bind(this)}
onLoadMore ={this.loadMoreData.bind(this)}
loadMoreSpinner={<Spinner/>} />
<Button onPress={this.onLogout.bind(this)}>
<Text>
LOGOUT
</Text>
</Button>
</Screen>
But NavigationBar always hidden, listview above NavigationBar. But when I try replace it to Title. It still work. But I don't want use Title because I want add button back or something else same that.

This PR solves it https://github.com/shoutem/ui/pull/104/files but somehow we have removed it from the theme. We are going to fix that in next release but until then you can help yourself by this:
<Screen>
<NavigationBar
style={{
container: {
position: 'relative',
width: Dimensions.get('window').width,
}
}}
centerComponent={<Title>TITLE</Title>}
/>
<ListView
data={groupedData}
renderRow={this.renderRow}
loading ={this.state.loading}
onRefresh={this.getAllNewsfeed.bind(this)}
onLoadMore ={this.loadMoreData.bind(this)}
loadMoreSpinner={<Spinner/>}
/>
<Button onPress={this.onLogout.bind(this)}>
<Text>
LOGOUT
</Text>
</Button>
</Screen>
After release you will just have to change style prop to:
<NavigationBar
styleName="inline"
centerComponent={<Title>TITLE</Title>}
/>

Related

UI Kitten - Modal - How to style and set size, color etc?

I'm tyring to implement the UI Kitten modal into my app. I have the modal working just fine. The issue I am having in setting the stle, size and color of the modal.
<Modal
visible={visible}
backdropStyle={styles.backdrop}
style={styles.modalContainer}
ViewProps={styles.modalSize}>
<Card disabled={true} header={modalHeader} footer={modalFooter}>
{selectedType ? renderItemSelectedDetails() : ''}
</Card>
</Modal>
I am passing this CSS style to the modal ViewProps.
modalSize: {
width: '250px',
height: '200px',
backgroundColor: '#58B83E',
},
No matter what I pass in this CSS, its not affecting the style or size of the modal. What am I doing wrong?
You need to pass styles to Modals' style prop.
<Modal
backdropStyle={styles.backdrop}
style={styles.modalSize}
visible={visible}>
<Something />
</Modal>
Also, you can add Layout as a child and style that layout how you wanted to style modal. (I prefer this solution)
<Modal
backdropStyle={styles.backdrop}
visible={visible}>
<Layout
level='3'
style={styles.modalSize}>
<Something />
</Layout>
</Modal>

React-Native Text input prevents scrolling

I have react native screen with single line TextInput:
<ScrollView>
...
<TextInput />
...
</ScrollView>
When I try to scroll the through the screen and my initial tap lands on TextInput, screen scrolling doesn't work. It almost tries to scroll inside the TextInput, but there is nothing to scroll. Here is what the text input looks like:
<TextInput
style={{...styles.rowInput, color: theme.textColor}}
onChangeText={(text) => this.setState({name: text})}
selectTextOnFocus={false}
autoCapitalize="words"
numberOfLines={1}
underlineColorAndroid="transparent"
autoCorrect={false}
placeholder="Enter Your Name"
placeholderTextColor={borderColor}
maxLength={24} />
Any ideas why it is happening?
It related to ScrollView and you can fix this by setting keyboardShouldPersistTaps to 'Handled'. Try this..
<ScrollView
keyboardShouldPersistTaps={'handled'}>
...
<TextInput />
...
</ScrollView>

how to overlap one view on another view in react native android

I want to put Search Input between two View border,but half input hides behind another View.
Click Here To Show Image.
There are two views. One View's backgroundColor is purple and another view's backgroundColor is white.And half Input type is hide behind another view.
<Container>
<Header style={{ backgroundColor: "#635DB7" }}>
<Left>
<Button
transparent
onPress={() => this.props.navigation.navigate("DrawerOpen")}
>
<Icon name="ios-menu" />
</Button>
</Left>
<Right />
</Header>
<View style={{flex:1,zIndex:2}}>
<View style={{height:192,backgroundColor: "#635DB7"}}>
<View style={{position:'absolute',opacity: 1,flex:1,flexDirection:"row",marginTop:160}}>
<Input style={{flexDirection:"row",borderRadius:20,marginLeft:30,marginRight:30,backgroundColor:"#434353", zIndex: 2,opacity: 1}} placeholder="Search" />
</View>
</View>
<View style={{height:448,backgroundColor: "#ffffff",zIndex:1}}>
</View>
</View>
</Container>
Try to put the search bar as a last item in the container, and with absolute position. If that does not work, then you might have hit a bug in RN android, which does not support overflow:
https://github.com/facebook/react-native/issues/6802
https://github.com/facebook/react-native/issues/3198

Element with absolute position is cut off by other component

I have a toolbar in my RN app. That toolbar has a button that is oversized on purpose and is overflowing from the component.
The oversized button is covered by an other component in the same page.
touchable:{
backgroundColor:'#3d3d3d',
borderRadius:27.5,
position:'absolute',
left:width/2 -25,
bottom:10,
alignItems:'center',
borderColor:'black',
width:55,
height:55,
justifyContent:'center',
}
Mark up:
render() {
return (
<View style={{flex: 1}}>
<View style={{position:'absolute', width:42,height:42,left:20,top:(height-42)/3,zIndex:3}}>
<Image style={{}} source={require('./Images/Ellipse 36.png')} />
<Image style={{position:'absolute',top:14,left:14}} source={require('./Images/Asset 65.png')} />
</View>
<View style={{position:'absolute', width:42,height:42,right:20,top:(height-42)/3,zIndex:3}}>
<Image style={{}} source={require('./Images/Ellipse 36.png')} />
<Image style={{position:'absolute',top:10,left:12}} source={require('./Images/Asset 66.png')} />
</View>
<View><TopToolbar text='Swipe' navigator={this.props.navigator} user={this.props.user}/></View>
<ScrollView style={{zIndex:1,}}><Inders style={{flex: 1}} navigator={this.props.navigator} credentials={this.props.credentials}/></ScrollView>
<View style={{zIndex:0,}}><BottomToolbar user={this.props.user} navigator={this.props.navigator} credentials={this.props.credentials}/></View>
</View>
)
}
Where Inders is a component.
I tried changing the order of the components but it didn't work.
What is the way to make a button "float" from another component?
Open inspector in the Dev tools menu and find out who cut your component, I also like to set backgroundColor to see their position, it make solve this type of bugs mack more easy.
The solution is to wrap the toolbar in another View, so that the new View is the parent of the element that you want to "float".

titanium alloy Widget not working

The widget that I have is working on other xml files..except for one...
The process goes like this...There's a view that when clicked, a window will open..
<Alloy>
<View class="vertical hsize">
<View class="hsize">
<Require src="actionbar" type="widget" />
</View>
<ScrollView class="container vertical whitebg">
<View class="downloadRowContainer horizontal">
<View class="downloadRow horizontal">
<View id="itemDl" onClick="viewItem" class="downloadItem graybg" />
<View class="divider" />
<View class="downloadItem graybg" />
</View>
</View>
<View class="downloadRowContainer horizontal">
<View class="downloadRow horizontal">
<View class="downloadItem graybg" />
<View class="divider" />
<View class="downloadItem graybg" />
</View>
</View>
</ScrollView>
</View>
</Alloy>
Here's the js:
function viewItem(e){
var showItem = Alloy.createController('viewdl').getView().open();
}
It works it opens viewdl.xml but the widget ain't working anymore on viewdl.xml alone.Any idea why?
Here's viewdl.xml(viewdl.js is blank):
<Alloy><Window class="vertical">
<View class="vertical hsize">
<View class="hsize"><Require src="actionbar" type="widget"/></View>
<ScrollView class="container vertical blackbg">
<View class="imgContainer"></View>
<View class="division"></View>
<Label>DOWNLOAD THIS WALLPAPER</Label>
</ScrollView>
</View></Window></Alloy>
Let me elaborate some points which I think are creating issues:
The root of the UI is Window or TabGroup or NavigationWindow/NavigationGroup : So these elements are responsible for opening and closing of the content/container in screen.
You can add some other View or its sub-element(Label,TableView,etc) to a window using add method.
IMO the widget should be added to the main container.
A simple example, let say we want 2 window application.
1st Window has a button which opens 2nd window.
2nd Window has 2 buttons
1st button close the current window.
2nd button loads some other view ( xml file ) to current window.
index.xml
<Alloy>
<Window id="first" layout="vertical" >
<Require src="actionbar" type="widget" />
<Button onClick="openWin2" title="Open" />
</Window>
</Alloy>
index.js
function openWin2() {
Alloy.createController('window2').getView().open({fullscreen:false});
}
window2.xml
<Alloy>
<Window id="second" layout="vertical" >
<Require src="actionbar" type="widget" />
<Button onClick="closeWin" title="Close" />
<Button onClick="loadData" title="Load Data" />
<View id="dynamicView" height="100px" width="100px"></View>
</Window>
</Alloy>
window2.js
function closeWin() {
$.second.close();
}
function loadData() {
$.dynamicView.add(Alloy.createController('dynamicData').getView());
}
dynamicData.xml
<Alloy>
<Label >Winter is coming !!</Label>
</Alloy>
Hope it is helpful.