Setting class when calling createLabel - titanium

I'm using Titanium Studio and Titanium SDK. In this case I'm developing for Android but I have an installation on OSX too.
When using Alloy, I can specify
<Label class="header" id="someId">Week 50</Label>
and then specify the colors,fonts etc in the TSS file like this
".header": {
color: "blue"
}
However when I use the SDK version:
var l = Ti.UI.createLabel({class:"header", text:"sometext"});
The color from the TSS file isnt picked up???
What am I doing wrong. Isn't 'class' a valid property? (I cant seem to find it in the docs).

Alloy style are applied automatically to views created through xml. If you want to keep that effect while you are creating objects inside controller you have to use $.UI.create() method instead of Titanium API. In your case your code will look like this:
var l = $.UI.create('Label', {
title: "sometext",
classes: ["header"],
});
For more read Dynamic Styles guide. It's not very well documented and some parts of it were unclear for me when I read it but it's good starting point to experiment with the code and learn Alloy behaviour.

Encountered you question while I was searching for something similar. The chosen answer was unfortunately not the solution I was looking for, since I was writing a commonJS and needed the same this. If you are writing a commonJS (but still under an Alloy project) you can use the following solution:
var l = Alloy.UI.create("index", "Label", {
title: "sometext",
classes: ["header"],
});
Where "index" is what being generated by Alloy from you app.tss file.

Related

How do I use fonts in Jetpack Compose for Desktop?

I'm trying to use some font ttf files placed in src/main/resources/fonts/ in JetBrains Compose for Desktop. How do I use the font files in the function androidx.compose.ui.text.font.Font()? I tried using the R.fonts.font_file mentioned in many online articles, but it seems like it only works on Android.
I know that there's this. He's facing the exact same problem I'm having here. I've tried this. Unfortunately, it didn't work. The only answer in the question I linked above says that the solution was to put the font files in src/main/resources and use:
Font(
resource = "font.ttf",
weight = FontWeight.W400,
style = FontStyle.Normal,
)
But it doesn't work. The androidx.compose.ui.text.font.Font() function on my machine requires 3 params, resId, weight, and style.
public fun Font(
resId: Int,
weight: FontWeight,
style: FontStyle,
)
(copied from the Idea tooltip)
As you can see, it requires a resId: Int. How am I supposed to specify it in an Int?
Since JetBrains Compose for Desktop is still in its early beta stage, resources I could find on the web is really scarce. I tried searching for "kotlin resource id" to find the way to refer to the font file as an ID, but all I could find are really Android-targeted things. I also tried searching for "jetpack compose desktop font" and "jetbrains compose font", and the results I get are also flooded with Android things. Yes, I tried using "-android" in the search query, but all that's left in the results are irrelevant. The question I linked is the only thing I could find about Jetpack Compose for Desktop font.
Here's most of my project structure.
Here is the tooltip that IntelliJ Idea shows when I hover over Font(). It isn't that useful, is it?
Kotlin version: 1.5.10
Jetpack compose version: 0.5.0-build225 (latest pre-release)
By the way, I'm using Manjaro Linux on a MacBook if it matters.
You can't use androidx.compose.ui.text.font.Font for this. Import androidx.compose.ui.text.platform.Font instead.
Perhaps counter-intuitively, androidx.compose.ui.text.platform.Font is a valid parameter type in a androidx.compose.ui.text.font.FontFamily, and supports resource, weight and style.

Documentation for Xcode Source Editor Extension

I'm looking for some documentation of the new Xcode Source Editor Extensions in Xcode 8.
As far as I can see there is only the "documentation" found in the header file for XcodeKit. Would be great to get something that's more detailed and more official.
Very preliminary XcodeKit reference documentation is now available.
Our WWDC 2016 presentation introducing Xcode Source Editor Extensions remains the best walkthrough.
The very shortest version, however, is: Because App Extensions need to be embedded in an application, you need to first create a new macOS Cocoa Application, and then add a new Xcode Source Editor Extension to that application. Then the XcodeKit reference should help some in implementing that.
Not really a documentation but a good reference also
https://developer.apple.com/videos/play/wwdc2016/414/
Extensions, at the moment, are poorly documented. There are a lot of assumptions made (for example, did you know that you can execute the container app? Yup, it’s really nice for settings GUI - see this How To Execute Container App - Second Answer)
At the moment, there are a lot of things missing: for example, there isn’t a structure that shows the corresponding lines with the data object - though this is quickly created with the following code:
var matches: [NSTextCheckingResult] = []
do {
let regex = try NSRegularExpression(pattern: "\n", options: [])
matches = regex.matches(in: completeBuffer,
options: [],
range: NSMakeRange(0, completeBuffer.count))
}
catch {
}
This gives you the location of all the \n’s - you should be able to fill out the rest to give you starting and ending positions which should match up to the lines.
All in all, there is a lot to like about the extension, but there are quite a few things missing as well.
Currently the only available documentation is in the headers; there's nothing "unofficial" about them. If you have specific questions, please ask.

How do I make a build profile reference modules that are within a "black box" library layer?

The tutorials got me going with the Dojo build system. However I'm left with a question that'll make or break the possibility of deploying a fully built release in my case. It is possible that the tutorial explains it, but that I didn't get it. Apologies if that was the case !
I use a library that lives inside an AMD layer ; let's call it blackboxLayer.js. There are several packages inside that layer, but I suppose the question would be the same if there was only one. So let's say that blackboxLayer.js contains a single package called blackbox, with modules blackbox/A and blackbox/B. To be sure that things are fun, that layer is bootable. And of course it's closed source stuff.
My app modules reference blackbox/A or blackbox/B. How do I make my build profile go look for the blackbox package inside that blackboxLayer.js file, rather than in a directory ?
Thanks for any input. :)
If built file blackboxLayer.js is in relative path /release/blackbox/layers, there is a separate dojo layer
<script type="text/javascript" src="path to dojoLayer.js"></script>
and
var dojoConfig = {
packages: [
{ name: 'blackbox', location: 'release/blackbox' }
]
};
then code inside this function can reference modules A and B,
require(['blackbox/layers/blackboxLayer'],
function () {
require(['dojo/parser', 'dojo/ready'],
function (parser, ready) {
ready(function () {
require(['blackbox/A', 'blackbox/B'],
function (blackboxA, blackboxB) {
// call blackboxA and blackboxB
});
});
});
});
If there is no separate dojo layer, you can reference blackboxLayer.js in the script tag, and omit the package def and requiring blackboxLayer.
The interim solution I've been using since this question has been posted is NOT to use dojo's builder... Instead I use a lightweight grunt pattern that concatenates AMD sources into a layer, and then I reference the layer from dojoConfig's deps property. The concatenation process is visible here : https://github.com/gruntjs-updater/grunt-amd-concat

Sencha Touch testing build not working

I've finished my first app using sencha touch 2.2.1. Now I uploaded it onto my server and tried to access it with my phone. Everything works well. My Dashboard contains 6 buttons, but only 1 of them is working. Each other throws the following error
TypeError: 'undefined' is not an object (evaluating 'name.substring')
The error occurs in the function parseNamespace. But I don't know what is wrong. I build the app using Sencha Architect and in the preview everything was fine. The testing package was created using the build-button from architect. If anyone could help me, the app is located here: app.ttv-rees-groin.de
Many thanks
This may be issue with class loading. The classes which are referred in the event of button events may not be loaded at the time.
Those classes may be missed when packaging application.
My experience found that Architect's build and package tools created a bloated mess of unnecessary files far exceeding what was required. Technical details: Architect 2 - all builds, Sencha Touch 2.0-2.2.x including all versions in between, Sencha Cmd 3.x
The cleanest and leanest build technique for developing in Architect was to save then fire the build using Sencha Cmd.
sencha app build
This performs the default "production" build.
The difference in output in this case went from a 32MB dump of files in the production folder with all resources, library, extensions etc, to the minimum required files totalling 0.8MB, and no longer requiring the touch library as only the classes needed were compiled into the app.
As for the error at hand, this error has something to do with class namespace, alias and xtype.
(Quick thanks to http://ruidevnotes.wordpress.com/2013/07/25/sencha-ext-js-4-common-typeerror/, saving me quite a lot of typing for these 4 things to check).
Possible solutions:
If class has controller, make sure the controller’s views config match the namespace specified on the class view’s Ext.define. Example: (controller)
views : ['namespace.of.my.View']
When using class on other view as xtype, make sure view’s alias is
widget.[customXtype]
so when adding it as an item to other viems, use
xtype : [customXtype]
Make sure view’s controller is added on app.js controllers.
When class view has no controller and you wanted to use it on other views, make sure to add the namespace of that view on
Ext.require(['class.view.namespace.name']);
and specify the xtype config instead of alias.
On top of these points, I recall an issue with list plugins, that I believe behaves identical to the error you are encountering. Prebuild - would work. Post build, issues and errors. The way I was able to get around this error was via this technique:
requires: [
'Ext.XTemplate',
'Ext.plugin.ListPaging'
],
config: {
..., // other standard configs removed for brevity
plugins: [
{
xclass: 'Ext.plugin.ListPaging',
autoPaging: true,
type: 'listpaging'
}
]
}
The thing to note is the exaggerated plugins declaration. Without this comprehensive declaration, the ListPaging plugin caused all manner of pain and chaos, and solely after a build.
EDIT: spelling.

dojo require different js files

recently I have a problem about including other js files using dojo. e.g. :
In my 1.js file, I wrote:
require(["dijit/form/Button"], function(Button){
addButton(someWidget);});
and in my 1a.js file, I wrote the function addButton:
function addButton(target){
var b1=new Button({
style: "border: 1px solid green",
label: "xxxxx"
});
target.addChild(b1);
return b1;
}
for 1a.js there must be an error, because I did not require that module, but i add require, the biggest
problem is that returned value, I can not get the return value, because of nested funciton.
how can i wrote a js file, which i wrote all my functions, and in another js file, i just call these functions with dojo require("xxxx", function(x){})
Thanks for help!
dojo.require is the legacy (<=1.6) loader for the toolkit. Using dojo.require in one file, made the code available to all files.
Dojo has moved to using the AMD API for loading modules. In 1a.js, you will also need to add the require statement.
My answers to the following questions will provide a better understanding of the AMD API and the require statement:
What is the main difference between require() and define() function in dojo and when would we use either?
Dojo Builds...? What now?
What is the purpose of function in the dojo require?