GithubHelp home page GithubHelp logo

flake's Introduction

โ„๏ธ Flake

Flake is a lightweight Fragment alternative.
The library is written in Kotlin, and it can be used both with Kotlin and Java.
No reflection is involved.

It goes well with XML layouts. It goes well with Anko. It is awesome!

๐Ÿšง This document is in construction. You would probably better to take a look at an example project.

A small example

A flake is a simple class that extends Flake. It is quite similar to the Fragment class in Android, except that it does not hold any UI state by itself and it does not being re-created auto:tophat:ally.

SimpleFlake inflates the R.layout.flake_simple layout and sets a listener to the button.

class SimpleFlake : XmlFlake<SimpleFlake.Holder>() {
    override val layoutResource = R.layout.flake_simple
    override fun createHolder(root: View) = Holder(root)

    override fun setup(h: Holder, manager: FlakeManager) {
        h.button.setOnClickListener { /* some code! */ }
    }
    
    class Holder(root: View) : IdHolder(root) {
        val button: Button by id(R.id.button)
    }
}

Why not Fragment?

Android fragments are said to be over-complicated. If you do not think so, you probably should read this amazing article by Square: Advocating Against Android Fragments. In short, fragments have lots of state transitions, and sometimes it is really hard to figure out what is going wrong.

Project status

Flake is in its early stages right now, but all the basic functionality seems to work.

Features currently supported:

  • Flake back stack;
  • Transition animations;
  • Nested flakes;
  • Handling configuration changes.

TODO

  • Replace animations
  • Unit tests

flake's People

Contributors

yanex 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.