pocorall / scaloid

Scaloid makes your Android code easy to understand and maintain.
Other
2.09k stars 163 forks source link

Support for multiple devices and standard resources #37

Open rxx opened 11 years ago

rxx commented 11 years ago

Hello, I've looked on scaloid layouts without xml and I have some questions:

pocorall commented 11 years ago

The approach that Scaloid advocate is ui-layout-without-xml, not replacing every kind of xml descriptions. Use your resources as described in Android developer guide.

Although I suggest that marking up layout with normal Scala code, Scaloid is fully compatible with xml layout. If your project's layouts are already written in xml, you can freely access it from Scala code:

val button = find[Button](R.id.mybutton)

rxx commented 11 years ago

@pocorall But we could create some template engine for resources. It will be compiled to xml on runtime or on request. Crazy idea, of course.

pocorall commented 11 years ago

Every great ideas is looked crazy at first. I think your idea is worthwhile. I will reopen this issue until I rewrite this idea to be more detailed.

rxx commented 11 years ago

@pocorall I think it could be like haml or jade We will decide perfomance issues for games, for example Resource's id will be auto generated and synchronised with layouts.

Can we do it? We'll name it - Scaloml template language (scaloid + xml)

pocorall commented 11 years ago

Before completely replace all of the XMLs, I will firstly focus on "supporting multiple devices". Because Scaloid layout is ordinary Scala code, there are almost nothing to do to adapt multiple devices, except some if statements.

However, because many peoples requested explicit example about this, I will write some helper doing this.

rxx commented 11 years ago

@pocorall I requested too :smile: I just think we must separate resources variables and layouts with other code

rxx commented 11 years ago

@pocorall One more thing for dsl - support IDE. For now, eclipse and intellij idea help us with build android resources and write xml-layouts. If we will use only dynamic resources, we will have to build all for ourselves. If we have some standard rules for build layouts with scala we can create custom plugins for idea and eclipse for example. It is a not first-priority goal but we can look out it

pocorall commented 11 years ago

For statical analysis purpose, declarative language (e.g. XML and JSON) is better than procedural language (e.g. Java and Scala). For some alternative methods replacing XMLs, such as SBT and Spring Java Config, difficulty of IDE support is a major weakness.

As we don't have much workforce, plugin development will be an issue of someday in the future.