Alloy proper way for tableviewrow color - styles

I'm trying to set the color of my TableViewRow to red ( just for testing ).
The thing is that i create the tablerow dynamically with the following code:
$.mainData.appendRow(Ti.UI.createTableViewRow({ title: data[i].txt, uid: data[i].uid}));
My app.tss looks like this:
"TableViewRow":{
color: "#FF0000"
},
".testing": {
color: "#FF0000"
}
But the color isn't applied to the rows.
I even tried to append the class to the row with this line of code:
$.mainData.appendRow(Ti.UI.createTableViewRow({ title: data[i].txt, uid: data[i].uid, 'class': 'testing'}));
But that also didn't work.
The only way to make it work is like this:
$.mainData.appendRow(Ti.UI.createTableViewRow({ title: data[i].txt, uid: data[i].uid, color: "#FF0000"}));
But that just doesn't feel like it is the right way. How can i make it work with the .tss file like it should work?

You can create style from .tss classes. And apply them to the view. More here http://docs.appcelerator.com/titanium/3.0/#!/guide/Dynamic_Styles

Related

How to set custom background color for selected rows in igx-grid

I am using Infragistics igxGridComponent. I am trying to style the look of selected rows.
I have tried setting my own css classes:
.selected-row {
background-clor:red;
color:white;
font:bold;
}
However, I am not really sure how to apply them conditionally. Should I be using ngClass or there is another syntax to this?
You can use the igx-grid-theme SASS function to create a custom theme:
$custom-theme: igx-grid-theme(
$row-selected-background: green,
$row-selected-text-color: #000,
$row-selected-hover-background: red
);
And then pass it to the igx-grid SASS mixin:
::ng-deep {
#include igx-grid($custom-theme);
}
Here you can find an example.

How to decorate a parent node with background coloured title like a panel style with cytoscape.js

I'm working with compound graphs library cytoscape.js for some days and familiar with its demo and basic APIs.
But I wonder if it is possible to decorate a parent node with style like the following screenshoot.
The defaults style of parent node is just a rectangle frame. Is it possible to render it with a background coloured title ?
Any help is greatly appreciated.
I finally resolve my issue with the following snippet.
{
selector: ':parent',
style: {
'background-image': function(){
return "title.jpg";
},
'padding-top' : '25px',
'background-position-x' : '0',
'background-position-y' : '0',
'background-width' : '100%',
'background-height' : '25px',
'background-fit' : 'contain',
}
}
Use a background image for the coloured title.

access svg element in a arearange HighCharts chart

The last line of the following code (brutally copied from a HighCharts demo chart page) changes the opacity of a arearange series:
var chart=Highcharts.chart('container', {
series: [{
name: 'Temperature',
data: averages,
zIndex: 1,
marker: {
fillColor: 'white',
lineWidth: 2,
lineColor: Highcharts.getOptions().colors[0]
}
}, {
name: 'Range',
data: ranges,
type: 'arearange',
lineWidth: 0,
linkedTo: ':previous',
color: Highcharts.getOptions().colors[0],
fillOpacity: 0.3,
zIndex: 0,
marker: {
enabled: false
}
}]
});
chart.series[1].update({fillOpacity:0.7},true);
JSFiddle here.
(the opacity could be set directly inside the chart object, but I need to modify it after the chart creation, the code is a toy example to simulate my needs)
My real chart has several arearange series, and updating them is heavy. Is there a way to modify such property avoiding the .update method? that it, is there a way to directly access the svg element corresponding to the arearange series?
I've tried to check the series .graph property, as previously suggested in an answer to a similar question, but in this case arearange series has no .graph property.
It can be done exactly the same as in the answer mentioned in your question but instead of modifying the graph you have to modify the area property.
Code:
chart.series[1].area.attr({
fill: 'rgba(124,181,236,0.7)'
});
Demo:
https://jsfiddle.net/BlackLabel/abohcq4x/

Arabic font in Phaser.js

Hi I wanted to add some Arabic text to my Phaser game. I have the following in the update() function:
this.scoreText = this.add.text( this.world.centerX, this.world.height/5,
"",{nsize: "32px", fill: "#FFF", align: "center"});
this.scoreText.setText("تُفاحة");
This produces strange letters on the screen which are not Arabic. Any ideas?
First off, you shouldn't be adding text in the update() method - this would cause it to be added multiple times (once for each frame, ideally 60 times per second). Move it to the create() method so that it's only added once. You also have a typo in the parameters: nsize should be just size.
function create() {
this.scoreText = this.add.text( this.world.centerX, this.world.height / 5, "", { size: "32px", fill: "#FFF", align: "center" });
this.scoreText.setText("تُفاحة");
}
You can try something like
Import the font in the CSS part in index.html
#import url(https://fonts.googleapis.com/earlyaccess/amiri.css);
Then just declare the style as a variable
var style = { font: "32px Amiri", fill: "#333", align: "center" };
Then in the create function add the text like in this jsfiddle https://jsfiddle.net/albator2018/r2zLtoqd/
There is another manner to do it but like what i've just explained it works fine

How to set the text size of a LabelView in SproutCore

This may be obvious, but I can't find how to enlarge the font size of an SC.LabelView. What I have now is
title: SC.LabelView.design({
layout: { centerX: 0, centerY: 0, height: 36, width: 200 },
tagName: "h1",
value: "Contacts"
})
Although it is an h1, it stays 'normal' text, but it is a title, as suggested by the property name.
SproutCore includes a CSS reset so that you can style your page and make it look the same across all browsers.
The best way to edit your styles is to add some CSS to my_app/resources/main_page.css using the font-size property.
$theme h1 {
font-size: 30px;
}
There are some comments and links to additional resources in the main_page.css file, but you can learn more from the Chance guide.

Resources