Currently I am using NativeBase in my React Native expo project. However I don't understand style of NativeBase components.
For example this is the code I have.
<Box style={{ marginLeft: 20 }}>
// image here
</Box>
<Box marginLeft={20}>
// image here
</Box>
<Box style={{ marginLeft: 50 }}>
// image here
</Box>
<Box marginLeft={50}>
// image here
</Box>
And this is the result
https://imgur.com/2doj3kQ
Can someone explain this to me. Thank you
NativeBase does not have token 50 for spacing. You can refer this to read about design tokens in NativeBase.
You must differentiate between styling using
the style prop that is available for every React Native core component and also in NativeBase components because they implement React Native's View (used for Box 1 and 3 in your example)
utility props exposed by NativeBase (used for Box 2 and 4 in your example)
When using the style prop, you're stating absolute values. Using the utility props exposed by NativeBase, you're stating design tokens that translate to a specific absolute value. The design system has the advantage of customization: adapting the design tokens propagates to your whole application.
Related
I'm new to the redux form. I try to leverage the benefit it offers for one text input field in my react native app written in Typescript, literally just one text input field.
<Field name="payoutInput" type="text" component={this.renderPayout}/>
private renderPayout = (field: any) => (
<View style={{flexDirection: "row", flex: 0.22, justifyContent: "flex-end"}}>
<Text style={{fontSize: 17}}>
$
</Text>
<TextInput style={{fontSize: 17}} defaultValue={String(this.props.balance)} autoFocus={true} keyboardType={'number-pad'} onEndEditing={this.calculatePayout}/>
</View>
)
What I notice is when I monitor the state in reactotron, I can't actually see the value in the form state. Using formValueSelector will also just give me undefined. So I'm wondering that if it's necessary to wrap the Field in a form?
Happy to provide more context on requested.
Yes; that's how it connects inputs to the redux form state.
This is noted in the redux-form docs.
The redux-form docs note on React Native also says to follow this tutorial to get started, and neither resource indicates it works differently under React Native.
Hello i'm new on react native. I am using react native elements slider in my project but want to select range with two marker. It is working with one marker.
Here is my code :
<View style={{backgroundColor: "#fff"}}>
<Slider
style={{ width: '90%',marginLeft:20,marginRight:20 }}
minimumValue={0}
maximumValue={100}
step={1}
value={this.state.cost}
onValueChange={cost => console.log(cost)}
/>
<Text style={{marginLeft:20,marginRight:20}}>{this.state.cost}</Text>
</View>
React Native Elements slider doesn't support multiple marker. However you can use this library if you need multiple markers
I've used deckSwiper of native-base in react native project. I want the users to be able to zoom the image in it as well. I didn't find anything to do that. How can I zoom the image of deck swiper in native base?
Code:
<DeckSwiper
ref={(c) => this._deckSwiper = c}
dataSource={cards}
renderEmpty={() =>
<View style={{alignSelf: "center"}}>
<Text>Over</Text>
</View>}
renderItem={item =>
<Card style={{elevation: 3}}>
<CardItem cardBody>
<Image style={{height: 300, flex: 1}} source={item.image}/>
</CardItem>
</Card>
}
/>
No, DeckSwiper doesn't provide zoom functionality. However you can use 3rd party library for that feature instead of using <Image>
Here are few 3rd party libraries which i have used in my applications.
1) react-native-image-zoom
2) react-native-image-viewer
But still, before using any of this library, you should check your requirement and check which one is best suited for you.
Its not about Deck Swiper supporting Image zoom feature
If React Native Image provides zoom feature by default, then NativeBase will obviously support this
I can't find if it's possible to create tabs in screen in React Native. IS there any way to do this? I mean, I already use StackNavigator and I can't understand how to add TabNavigator to screen from StackNavigator.
Update! Solution for this question is really simple, but for me, totally it wasn't obvious at all! Just set flex style to your view
Example:
<View style={{ flex: 1 }}> // <- this is main screen
<View> // <- this is screen header, you don't change this when click on Tab
Some header
</View>
<View style={{ flex: 2 }}>
<YourTabNavigator /> // <- your tabs (imported from external or same file)
</View>
</View>
Yes, you can create tabs, as it is common design used in mobile applications.
As I can't use comments to get some neccessary information.
However I'll try to provide a generic answer.
If you are using react-navigation then you can create tabs with TabNavigator provided by react-navigation. Documentation contains the neccessary code as well.
You can also use some pure JS component like react-native-tabs
And if you are using some other navigation library, you can see the corresponding documentation.
Using android-specific style rule, elevation, I get a nasty "halo" effect when using. for example, this image shows elevation: 20:
Even a small elevation 1,2, or 3 gives the appearance that the element is "haloed"/has a border (bad)
How can I add more customization to the android-specific shadow to get rid of halo effect. iOS has specific rules like shadowOpactiy, shadowRadius, shadowOffset–but I don't see anything for android.
According to the official documentation there is no such thing as shadowopacity or any way to change the default shadow since is there
by design, by "material design"
Source: https://developer.android.com/training/material/shadows-clipping
But what you can do is to use a component with a dummy view that has the desired border and then just use it in your render function like
render(){
<View style={{flex:1}}>
<Viewwithborder>
//pass the item you want to have custom elevation here
</Viewwithborder>
</View>
}
and in your custom "viewwithborder" you just do this
render(){
<View style={{styles.CustomElevationStyle}}>
{this.props.children}
</View>
}