GithubHelp home page GithubHelp logo

datalink747 / carpaccio Goto Github PK

View Code? Open in Web Editor NEW

This project forked from florent37/carpaccio

0.0 2.0 0.0 21.14 MB

Data Mapping & Smarter Views framework for android

License: Apache License 2.0

Java 100.00%

carpaccio's Introduction

Carpaccio

Developed to facilitate integration on Android ( Designers can thanks me :D )

logo

Data Mapping & Smarter Views framework for android

With Carpaccio, your views became smarter, instead of calling functions on views, now your views can call functions ! You no longer need to extend a view to set a custom behavior

Carpaccio also come with a beautiful mapping engine !

#This is kind of magic !

You can preview custom fonts & image loaded from url directly from Android Studio Preview !

font url

#Usage

<com.github.florent37.carpaccio.Carpaccio
        android:id="@+id/carpaccio"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:register="
            com.github.florent37.carpacciocontrollers.ImageViewController;
            com.github.florent37.carpacciocontrollers.TextViewController
        ">

        <ImageView
               android:layout_width="match_parent"
               android:layout_height="150dp"
               android:scaleType="centerCrop"
               android:tag="url(http://i.imgur.com/DSjXNox.jpg)" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:tag="
                font(Roboto-Thin.ttf);
                setText($user.name);"/>

</com.github.florent37.carpaccio.Carpaccio>

url

#Download

Add into your build.gradle

Download Download

compile ('com.github.florent37:carpaccio:1.0.0'){
    transitive=true
}
compile ('com.github.florent37:carpacciocontrollers:1.0.0'){
    transitive=true
}

#DataBinding

<TextView
       android:tag="
            setText($user)
       "/>

( Which will call user.toString )

In your activity / fragment :

Carpaccio carpaccio = (Carpaccio)findViewById("R.id.carpaccio");
carpaccio.mapObject("user",new User("florent"));

set_text

You can also specify a method (must return a String)

<TextView
       android:tag="
            setText($user.getName())
       "/>

And simplify the method name

<TextView
       android:tag="
            setText($user.name)
       "/>

##RecyclerView Mapping

You dreamed it, Carpaccio did it ! You can now bind a List with a RecyclerView !

recycler

R.layout.activity_main_recyclerview_mapping

<com.github.florent37.carpaccio.Carpaccio
        android:id="@+id/carpaccio"
        app:register="
            com.github.florent37.carpacciocontrollers.CommonViewController;
            com.github.florent37.carpacciocontrollers.ImageViewController;
            com.github.florent37.carpacciocontrollers.TextViewController;
        ">

        <android.support.v7.widget.RecyclerView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"

                    android:tag="
                        adapter(user,R.layout.cell_user)
                    "
                    />

</com.github.florent37.carpaccio.Carpaccio>

R.layout.cell_user

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <ImageView
        android:layout_width="100dp"
        android:layout_height="match_parent"
        android:tag="url($user.image);"
        android:layout_marginRight="20dp" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:tag="setText($user.name)" />

</LinearLayout>

Finally, in your activiy/fragment you just have to indicate the List to map !

setContentView(R.layout.activity_main_recyclerview_mapping);
Carpaccio carpaccio = (Carpaccio)findViewById("R.id.carpaccio");
carpaccio.mapList("user", this.users);

Video


#Customize

You can add you own functions to Carpaccio, simply create a custom ViewControllers, for example MyViewController

public class MyViewController{

    public void myFunction(View view, String argument1){
        //your usage
    }

}

Then you can use it into your layout

<com.github.florent37.carpaccio.Carpaccio
        app:register="
            com.mypackage.MyViewController
        ">

        <View
            android:tag="
               myFunction(theValueOfMyArgument)
            "/>

</com.github.florent37.carpaccio.Carpaccio>

#ViewControllers

Carpaccio provide some awesome ViewControllers, you can import them directly into your project

Add into your build.gradle

compile ('com.github.florent37:carpacciocontrollers:1.0.0'){
    transitive=true
}

##TextViewController

TextViewController can set a custom font (from assets/fonts/) to a TextView

WORKS WITH ANDROID STUDIO PREVIEW !!!

font

Usage : font(fontName)

<com.github.florent37.carpaccio.Carpaccio
        app:register="
            com.github.florent37.carpacciocontrollers.TextViewController;
        ">

        <TextView
             android:tag="
                 font(Roboto-Light.ttf)
             "/>
</com.github.florent37.carpaccio.Carpaccio>

And provides a data binding setText

Usage : setText($variable) or setText($variable.function())

<TextView
     android:tag="
         setText($user)
     "/>

Or directly on the android:text

Usage : android:text="$variable"

<TextView
     android:text="$user"/>

##ImageViewController

###Url

ImageViewController can directly set an image source from an url

Usage : url(imageUrl)

<com.github.florent37.carpaccio.Carpaccio
        app:register="
            com.github.florent37.carpacciocontrollers.ImageViewController;
        ">

        <ImageView
             android:tag="
                 url(http://i.imgur.com/DvpvklR.png)
             " />
</com.github.florent37.carpaccio.Carpaccio>

url

WORKS WITH ANDROID STUDIO PREVIEW !!!

Preview an url image

Usage : enablePreview();url(imageUrl);

<com.github.florent37.carpaccio.Carpaccio
        app:register="
            com.github.florent37.carpacciocontrollers.ImageViewController;
        ">

        <ImageView
             android:tag="
                enablePreview();
                 url(http://i.imgur.com/DvpvklR.png);
             " />
</com.github.florent37.carpaccio.Carpaccio>

url

Usage : kenburns()

<ImageView
      android:tag="
           kenburns();
           url(http://i.imgur.com/DvpvklR.png);
      " />

Video

###Blur You can blur an ImageView

Usage :

  • willBlur() if use url(www...)
  • blur() else
<ImageView
      android:tag="
           willBlur();
           url(http://i.imgur.com/DvpvklR.png);
      " />

<ImageView
      android:src="@drawable/my_image"
      android:tag="
           blur()
      " />

blur

###GreyScale

Usage :

  • willGreyScale() if use url(www...)
  • greyScale() else
<ImageView
      android:tag="
           willGreyScale();
           url(http://i.imgur.com/DvpvklR.png);
      " />

<ImageView
      android:src="@drawable/my_image"
      android:tag="
           greyScale()
      " />

greyscale

###AnimateMaterial

Display your image with a material animation Usage : animateMaterial(duration)

<ImageView
      android:tag="
           animateMaterial(6000);
           url(http://i.imgur.com/DvpvklR.png);
      " />

Video


##ParallaxViewController

ParallaxViewController can add a parallax effect on ScrollView childs

Usage :

  • ScrollView : registerParallax()
  • ScrollView childs : parallaxY(float)
<com.github.florent37.carpaccio.Carpaccio
        app:register="
            com.github.florent37.carpacciocontrollers.ParallaxViewController;
        ">

        <ScrollView
                    android:tag="registerParallax()">

              <View
                    android:tag="
                        parallaxY(0.5);
                    " />

              <View
                    android:tag="
                        parallaxY(1.5);
                    " />

        </ScrollView

</com.github.florent37.carpaccio.Carpaccio>

Video


##CommonViewController

Bind a RecyclerView (see DataBinding)

Usage :

  • adapter(listMappedName,cellLayoutName)
<android.support.v7.widget.RecyclerView
     android:layout_width="match_parent"
     android:layout_height="match_parent"

     android:tag="
         adapter(user,R.layout.cell_user)
     "
     />

Open an activity onClick

  • **clickStartActivity(activityName) **
<Button
      android:tag="clickStartActivity(.MainActivitySample)"
      />

<Button
      android:tag="clickStartActivity(com.github.florent37.carpaccio.sample.MainActivitySample)"
      />

<Button
      android:tag="clickStartActivity($activity1)"
      />

Replace by another View class

<ScrollView
      android:layout_width="match_parent"
      android:layout_height="match_parent"

      android:tag="
          replace(com.github.ksoichiro.android.observablescrollview.ObservableScrollView);
      "
      />
  • margin(top,right,bottom,left) & padding(top,right,bottom,left)
<View
      android:layout_width="match_parent"
      android:layout_height="match_parent"

      android:tag="
          margin(0,10,0,0);
          padding(5,0,5,0);
      "
      />

##AnimationViewController

Easings :

  • easeIn : accelerate
  • easeOut : descelerate
  • easeInOut : accelerate then descelerate

Functions :

  • animateAphaIn(duration,easing)
  • animateScaleUp(duration,easing)
  • animateEnterY(translationY,duration,easing)
  • animateEnterX(translationX,duration,easing)
  • animateEnter(translationX,translationY,duration,easing)

carpaccio's People

Contributors

florent37 avatar

Watchers

James Cloos avatar Soussi  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.