titanium mobile | jssを使わずstyleを共通化

titanium復帰1日目
jss入れても反映されないし、jsとキーが違うし・・・とりあえず使うの止めようと
なんか無いかなと思ったら、普通にjsデータとして持たせるというのを見て、参照ではなくコピーして使いたかったので、こんな感じにしました。
node.jsもtitaniumもほぼ1日目なので、実際のところわかりませんが、ぱっと見は良い感じになりました。

スタイル用js

var base_style = {
label: function( _params ){
var style = {
fontFamily: ‘”Hiragino Kaku Gothic ProN”, Verdana’,
backgroundColor:’transparent’,
color: ‘#fff’,
width:Ti.UI.FILL,
height:30,
left:10,
fontSize:14
};
for( key in _params){
style[key] = _params[key];
}
return style;
}
};
module.exports = base_style;

メインウインドウ js

function ApplicationWindow() {
var style;
if( Ti.Platform.osname === ‘android’ ){
style = resuire(‘/ui/style/base_android’);
}else{
style = require(‘/ui/style/base’);
}
var self = Ti.UI.createWindow({
title:’aucru next’,
activity:{
}
});
var title = Ti.UI.createLabel(style.label({
top:60,
text:’aucru.com’
}));
var title2 = Ti.UI.createLabel(style.label({
top:10,
text:’てすとだよーん’
}));
self.add(title);
self.add(title2);
return self;
};

module.exports = ApplicationWindow;

初日、半日経過して、チュートリアルをざっとみてから、ここでつまづいて全然進んでませんが、とりあえずこんな感じで。

This entry was posted on 土曜日, 3月 23rd, 2013 at 10:00 AM and is filed under Javascript, Titanium. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。