项目作者: agrosner

项目描述 :
A Small, Kotlin Android Databinding Library
高级语言: Kotlin
项目地址: git://github.com/agrosner/KBinding.git
创建时间: 2017-04-04T20:06:08Z
项目社区:https://github.com/agrosner/KBinding

开源协议:MIT License

下载


KBinding

KBinding is a Kotlin databinding library best used with Anko to enable databinding in a fluent, easy to understand syntax.

We can represent our UI in ways such as:

  1. verticalLayout {
  2. textView {
  3. bindSelf { it.name }.toText(this)
  4. }
  5. editText {
  6. hint = "Email"
  7. bindSelf { it.emailInput }
  8. .toText(this)
  9. .twoWay(
  10. .toFieldFromText()
  11. }.lparams {
  12. width = MATCH_PARENT
  13. }
  14. textView {
  15. bindSelf { it.emailInput } // mirrors input for example
  16. .toText(this)
  17. }
  18. }

Including in your project

  1. buildscript {
  2. ext {
  3. kbinding_version = "1.0.0"
  4. }
  5. }
  6. allProjects {
  7. repositories {
  8. // required to find the project's artifacts
  9. maven { url "https://www.jitpack.io" }
  10. }
  11. }
  1. compile "com.github.agrosner.kbinding:kbinding:$kbinding_version"
  2. // to use with Anko, separate artifact.
  3. compile 'org.jetbrains.anko:anko-sdk15:0.10.3' // current version of anko used
  4. compile "com.github.agrosner.KBinding:kbinding-anko:$kbinding_version"

Documentation

We support three kind of bindings:

  1. One Way (ViewModel to View)
  2. Two Way (ViewModel <-> View)
  3. One Way to Source (View to ViewModel)

Read more in the docs below:

Supported Bindings

Getting Started

KBinding By Example

Pull Requests

I welcome and encourage all pull requests. Here are some basic rules to follow to ensure timely addition of your request:

  1. Match coding style (braces, spacing, etc.) This is best achieved using CMD+Option+L (Reformat code) on Mac (not sure for Windows) with Android Studio defaults.
  2. If its a feature, bugfix, or anything please only change code to what you specify.
  3. Please keep PR titles easy to read and descriptive of changes, this will make them easier to merge :)
  4. Pull requests must be made against develop branch. Any other branch (unless specified by the maintainers) will get rejected.
  5. Have fun!

Maintained By

agrosner (@agrosner)