flipkart-incubator / proteus Goto Github PK
View Code? Open in Web Editor NEWProteus : A JSON based LayoutInflater for Android
License: Apache License 2.0
Proteus : A JSON based LayoutInflater for Android
License: Apache License 2.0
{
"type": "TextView",
"data": {
"var-1": "@{a.b.c}",
"var-2": "@{fn:func(@{var-1})}"
}
}
Here var-2
is a variable which is referring to var-1
which was declared before it. Basically standard block level variable scoping.
Unable to find any example of recyclerview implementation with Proteus. Could you please provide an example of how to write the adapter class with viewholder using Proteus? Any sort of hint would also help.
Thanks.
Textview.textColor accepts colorstatelist. But resource reference parser gives drawables.
offset
is currently being calculated from the size of the attributes map. If a module overrides a preregistered attribute the calculation goes for a toss; because the processors
array length will be increased by 1 by the entry in the map will be just overridden.
The offset
should be calculated using the processors
array instead.
Move it to the ProteusView.Manager
instead. This will ease implementing the ProteusView
interface.
ex. try and inflate a Button
and set a text
attribute on it.
What Exactly Value class does in Event
override fun onEvent(view: ProteusView?, eventType: EventType?, value: Value?) { }
How can i able to get Json fields from Value class
And You examples Says You using Retrofit and Casting all layouts into Layout class , Is Layout class can you used for Casting any Layout
Handle top and bottom padding independently. Right now its together.
Is there any Plans for Something Similar for IOS.
Is there any maven and jcenter repository is available to include this library as dependency?
As mentioned in the usage docs, I am initiating the command 'npm start' into the project root and Server running at http://1XX.X.X.X:8080/ , but after sometime getting error like 404 : ./index.html
{
"type": "TextView",
"data": {
"var": {
"@": {
"key": "@{some.binding}"
}
}
}
}
Here var
is a variable declared in the data scope which has nested binding.
When overriding AttributeProcessor.compile() we should not return a default
value if we are unable to compile the input. Instead, we should return super.compile();
to properly handle inherited implementations and custom value types in input.
This should be added to the JavaDoc as well as the FAQ section
The fix for #86 has broken the update flow in proteus,
Can you please make a docs on onClick as you Docs says onClick is Supported for View types
The DataBinding
class should have a method say:
public void assign(Value value, Value data, int dataIndex)
which can be used to assign a value
at the binding path in the data
. Example
data:
{
"user": {
"name": "John Doe"
}
}
code:
DataBinding binding = DataBinding.valueOf("user.name");
Value name = new Primitive("Jane Doe");
binding.assign(name, data, 0); // where `data` is the above json
The data should now be:
{
"user": {
"name": "Jane Doe"
}
}
Hi,
This might be a very silly question to ask but I am really unable to figure out a way on how to get the text from an EditText and pass the text to a button click event listener.
For example, I have the below layout json
{
"type": "LinearLayout",
"layout_height": "match_parent",
"layout_width": "match_parent",
"padding": "8dp",
"orientation": "vertical",
"children": [
{
"type": "EditText",
"id": "etUsername",
"layout_height": "wrap_content",
"layout_width": "match_parent",
"hint": "Username"
},
{
"type": "EditText",
"id": "etPassword",
"layout_height": "wrap_content",
"layout_width": "match_parent",
"layout_marginTop": "4dp",
"hint": "Password"
},
{
"type": "Button",
"id": "btnLogin",
"layout_height": "wrap_content",
"layout_width": "match_parent",
"layout_marginTop": "4dp",
"text": "Login",
"onClick": {
"action": "apiCall",
"extras": {
"endpoint": "www.someapi.com/api/v1/login",
"method": "POST",
"body": {
"username": "",
"password": ""
}
}
}
}
]
}
As you can see, I have a form containing username and password fields and a button. Now I am trying to set the text from etUsername and etPassword to username and password fields respectively in the onClick event object of the button whenever user clicks the button, but I am unable to figure out how to do that.
It would be a great help if anyone can help me in sorting this out as soon as possible.
Thanks,
Rajesh
instead of throwing exceptions. It can return a Result
object as follows
public class Result {
@Nullable;
String error;
int code;
@Nullable;
JsonElement result;
}
For e.g rukmini urls need this overriding ability.
If a LayoutHandler
is wrapped by multiple LayoutHandler
it's LayoutHandler.prepare()
is called every time the wrapped LayoutHandler
is registered with a LayoutBuilder
.
This will make the handler logic independent of the order of attributes.
Implement the proteus equivalent of the include
tag
<include layout="layout_to_include" />
In order to handle the update flows correctly the Manager's of Views with Adapters
like RecyclerView
and ViewPager
etc should have another implementation of the Manager
.
based on answers and comments on this stackoverflow question we are removing all logging guards from the library.
It only checks for primitive and object type. It should at least check for Binding
, Resource
, AttributeResource
, StyleResource
.
The data-driven children logic was buggy and convoluted. It needs to be refactored, to be consistent with the AttributeHandler
principle. New usage of data-driven children is as follows:
{
"children": {
"data": "$path.to.data.set",
"layout": {
"type": "YourLayout"
}
}
}
So no more special attribute handling for children
and no more special attributes called childType
, childDataContext
. The children
attribute handler should be moved to ViewGroupParser
and LayoutBuilder
code has to be cleaned up.
It is good to have such a support like
{ "visible" : "$data == null ? visible : gone" }
Amazing work here. Started exploring proteus and had a quick question.
From the demo I can see that Bitmaploader is used to download image from a network. I was wondering what needs to be done to use libraries like Picasso or Glide with the network images so caching is handled by them.
We should not insert parent data into a child scope. This will leak the parent data into the child scope, and also breaks the layout-data interface. Removing this will also improve performance by avoiding the copying loop per scope object.
Data
{
"user": {
"dt": "2017 04 22",
"ll": "01, XZY, AB"
}
}
Layout
{
"type": "TextView",
"layout_width": "wrap_content",
"layout_height": "wrap_content",
"textSize": "14sp",
"data": {
"date": "@{fn:date(@{user.dt},'E, d MMM')}"
},
"text": "@{fn:format('last login: %s from %s',@{date},@{user.ll})}"
}
Here in the layout user.ll
is not added to the data
scope of the layout and is only accessible from the outer scope. user.ll
should be added to the data scope instead. As follows:
{
"type": "TextView",
"layout_width": "wrap_content",
"layout_height": "wrap_content",
"textSize": "14sp",
"data": {
"date": "@{fn:date(@{user.dt},'E, d MMM')}",
"loc": "@{user.ll}"
},
"text": "@{fn:format('last login: %s from %s',@{date},@{loc})}"
}
Let the parser find out whether a view type exists in the registered handlers.
If not, it should use reflection to find out the view. If this is the case, the view should also specify parent parser.
If reflection also does not fetch the view, then we throw onUnknownViewType.
There is no document or comment for any method. Its very hard to understand how it works..
Is custom Views Supported
i have tried to use proteus in my app.But its not working. i want change color and other attributes in the textview.But it is not working. will proteous support existing ids which is inflated by LayoutInflator
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.