React-native set colour to radio button's label - react-native

I am usingreact-native-radio-buttons-group for radio buttons in my app. I have a bit of difficulty to paint the labels of the radio buttons in some colors. I tried the example:
{
label: 'option one',
color: '#FFFFFF',
},
but only the bullets were painted. I want to paint the labels as well.
Now I got this:

I found a solution to my problem. It is a bit hacky but works. I wrapped the labels in <Text> tags whit inline style as follows:
deliveryRadioData: [
{
id: 1,
label: (
<Text style={{color: '#FFFFFF'}}>{'option one'}</Text>
),
selected: true,
color: '#FFFFFF',
size: 16,
},
{
id: 2,
label: (
<Text style={{color: '#FFFFFF'}}>
{'option two'}
</Text>
),
selected: false,
color: '#FFFFFF',
size: 16,
},
],
};
Now the radio buttons look like this:

Check if there is labelStyle prop.
Otherwise, try react-native-btr
NOTE: This package is updated and actively maintained in
react-native-btr library. Hence, we recommend you to use this
component from react-native-btr library.

Related

Highcharts - How to set Pie Chart's background color dynamically

I'm using the following line to change some visual properties based on some conditions
this.$refs.pieChart.chart.series[0].update({ dataLabels: { color: 'blue' }, chart: { backgroundColor: 'yellow' } })
This works fine for the dataLabels part, but I'm unable to change the backgroundColor one.
I tried this:
this.$refs.pieChart.chart.series[0].update({ dataLabels: { color: 'blue' }, backgroundColor: 'yellow' })
and this
this.$refs.pieChart.chart.series[0].update({ backgroundColor: 'yellow' })
With no luck, I searched everywhere else in my code, nothing is overriding or setting the backgroundColor
side.
You should do an update on the whole chart config, not on the series:
chart.update({
chart: {
backgroundColor: 'red'
}
})
API: https://api.highcharts.com/highcharts/chart.backgroundColor
API: https://api.highcharts.com/class-reference/Highcharts.Chart#update
Demo: https://jsfiddle.net/BlackLabel/p7yg386x/

Make a chart clickable when placed under another SVG <View>

I am having trouble working with some SVG in React Native.
I have a chart that is clickable and works well, I then needed to place another SVG on top of the chart in order to draw a line that would represent a limit score value. The problem that I am now facing is that I cannot click on the chart anymore since the view of the SVG is placed on top of it.
I made the background color of the SVG to be transparent so that I can at least see the chart behind it but, I do not know how to make it clickable again.
Is there any work around where I can maybe make the chart clickable trough a transparent view that is place on top?
It might be a stupid question but I am pretty new to both react and JS in general, so I could really use any type of help. :)
Here is the picture of the chart:
Polar Chart and Svg circle
And here the same Svg with a non-transparent background that, as you can see, covers almost the hole chart.
Svg covering the chart
Here's the Svg code:
export class NutritionChartSvg extends Component {
render() {
return (
<View style={styles.container} >
<Svg height={height * 0.5} width={width * 0.5} viewBox="0 0 100 100">
<Svg.Circle
id="circle"
cx="50"
cy="13"
r="40"
stroke="gray"
strokeWidth="0.6"
fill="none"
/>
<Text fill="black" fontSize="8" dy="-2">
<TextPath href="#circle" startOffset='181'>
100
</TextPath>
</Text>
</Svg>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignContent: 'center',
justifyContent: 'center' ,
position: 'absolute',
left: '25%',
height: 'auto',
width: 'auto',
},
});'
This is the chart form chartjs:
export const NutritionChart = (props) => {
return (
<Chart
chartConfiguration={
{
type: 'polarArea',
data: {
labels: ['Fiber', 'Protein', 'Healthy Oil', 'Good Energy', 'Immune
Defense'],
datasets: [
{
label: '# of Votes',
data: [
50,
140,
90,
120,
100,
],
backgroundColor: backgroundColor,
borderColor: borderColor,
borderWidth: datasets.border,
hoverBackgroundColor: hoverBackgroundColor,
},
],
},
options: {
layout: {
padding: {
top: options.layout.padding.top,
bottom: options.layout.padding.bottom,
}
},
legend: {
display: false,
fullWidth: false,
labels: {
fontSize: options.legend.labels.fontSize,
boxWidth: options.legend.labels.boxWidth,
padding: options.legend.labels.padding,
}
},
scale: {
display: false,
ticks: {
min:0,
max:200,
}
},
responsive: true,
maintainAspectRatio: false,
},
}
}
defaultFontSize={10}
/>
);
};
and they are together in a view :
<View style={styles.nutritionChart} key={3}>
<NutritionChart/>
<NutritionChartSvg/>
</View>
Either:
Move the limit line into the chart SVG, instead of laying it separately on top, or
Set pointer-events: none on the top SVG. This will make clicks pass right through it.

Multiline window title in titanium

I am feverishly trying to make the title of a window multiline.
I have a fairly long title and need to be able to see the whole title.
Right now the title just gets cut of and has three dots if it is longer than the window allows
But I need it to break into two lines if it is too long
My current markup looks like:
/////// create first starting window ////////
var startWin = Titanium.UI.createWindow({
title: 'Some really long title that has to be wrapped',
navBarHidden: false,
exitOnClose: true,
barImage: '/images/header_background.png',
titleAttributes: {
color: '#FFF',
font: {
fontSize: 20,
minFontSize: 15,
fontWeight: 'bold',
wordWrap: true
}
}
});
Or can I maybe use a multiline label?
Anyone an idea ?
Thanx
My working code thanx to Sebastian
page_title = Ti.UI.createLabel({
text: 'Algorithmen',
height: 80,
left: 60,
right: 60,
textAlign: 'center',
color: '#fff',
font: {
fontSize: 18,
fontWeight: 'bold',
wordWrap: true
}
}),
startWin = Titanium.UI.createWindow({
titleControl: page_title,
navBarHidden: false,
exitOnClose: true,
barImage: '/images/header_background.png'
});
You can set the window.titleControl with a label
var startWin = Titanium.UI.createWindow({
titleControl: Ti.UI.createLabel({
text:'Some really long title that has to be wrapped'
font:{
fontSize: 20,
minFontSize: 15,
fontWeight: 'bold'
}
}),
navBarHidden: false,
exitOnClose: true,
barImage: '/images/header_background.png',
});
I have never managed to do this, so I have always hidden the title bar and created my own, with android you will need to create a custom theme to hide the title bar, also there is no title bar on iOS.
I use alloy mainly and created a nav control view that I added by reference to each page, then set the title and menu options in that.

Setting a border for react native TextInput

Using React native 0.26,
My component is something like this
const Search = () => {
return (
<View style={styles.backgroundImage}>
<TextInput style={styles.textInput} onChangeText={(text) => console.log(text)} placeholder={"Enter Search Term"}/>
</View>
)
}
And my styles :
const styles = StyleSheet.create({
backgroundImage: {
flex : 1,
flexDirection: "column",
justifyContent: 'center',
alignItems: 'center'
},
textInput: {
justifyContent: "center",
alignItems: "stretch",
borderRightWidth: 30,
borderLeftWidth: 30,
height: 50,
borderColor: "#FFFFFF",
}
})
The problems that I am facing are
The border right width and left width do not seem to have any effect and the placeholder text just begins on the left edge.
The background of TextInput is "grey" its the same as the View's background. I was expecting it to be white by default, (Feels transparent).
With iOS simulator how to bring up the keyboard, I would like to set returnKeyType and see how the keyboard looks (and have some code on onSubmitEditing and test).
Screenshot below :
1 You cannot declare a specific border directly on the TextInput unless multiline is enabled (For example borderLeftWidth will not work unless multiline={true} is enabled but borderWidth will work), but you can just wrap the TextInput in a View and give it a border.
inputContainer: {
borderLeftWidth: 4,
borderRightWidth: 4,
height: 70
},
input: {
height: 70,
backgroundColor: '#ffffff',
paddingLeft: 15,
paddingRight: 15
}
2 You need to declare a backgroundColor for the TextInput.
3 To make the native keyboard show up, you need to go to the simulator menu and disconnect your hardware. Go to Hardware -> Keyboard -> Connect Hardware Keyboard, toggle it off.
As of react-native: 0.61.5 you can directly set the borderBottomWidth on TextInput. Like below in inline style or if you want in separate style object.
style = {{borderBottomWidth : 1.0}}
By default the boderWidth will be set for 0. So use borderWidth : 5 defaults for (Top, Right, Bottom, Left).
If you want to asign width individually you have options like,
style = {{
borderStartWidth : 2
borderEndWidth : 3
borderTopWidth : 1
boderLeftWidth: 2
borderRightWidth: 3
borderBottomWidth : 4
}}

Appcelerator: How to create a proper Back Button image?

I purchase a theme from AppVaultDesign and it comes with a back button image that looks like this http://cl.ly/2h3x0j0p2v262k0k2U0e
However, when I add it to the code, the alignment looks wrong. The text is too close to the button. http://cl.ly/393s2D0f0v3P0m3H150O
When I tried to use textAlign: 'right', it looks like this http://cl.ly/0Z2d1Y0f3q1O100c0b3f No idea why is like that. Frustrating. It doesn't goes up when I do textAlign: 'center' or textAlign: 'left'.
So here's the code, I'm using. Any help?
var backButton = Ti.UI.createButton({
backgroundImage: 'images/back.png',
font: { fontSize: 13, fontWeight: 'bold' },
height: 28,
title: "Back",
width: 51
});
backButton.addEventListener('click', function(){
navGroup.close(self);
});
self.leftNavButton = backButton;
I think it should be an easy one. It just frustrating that I can't get it working right. It will be much appreciated, if someone can post me the working code for the button and the image. That way, I can try to see where went wrong as well.
Many thanks, Mickey
The simplest way, probably, is to add a whitespace before " Back"
var backButton = Ti.UI.createButton({
backgroundImage: 'images/back.png',
font: { fontSize: 13, fontWeight: 'bold' },
height: 28,
title: " Back",
width: 51
});