GithubHelp home page GithubHelp logo

hhy5277 / stepper-touch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danielmartinus/stepper-touch

0.0 1.0 0.0 675 KB

Stepper Touch for Android based on MaterialUp submission

License: Apache License 2.0

Kotlin 100.00%

stepper-touch's Introduction

Stepper-Touch

Twitter API Awesome Kotlin Badge CircleCI

For more updates on this and other open-source projects, follow me on twitter ๐Ÿ‘‰ here


Stepper Touch for Android based on a Material Up showcase designed by Oleg Frolov

In the latest version of the support library (25.3.0) a new class SpringAnimation was made available. I wanted to test this out and not long after that I found Stepper Touch, a concept made in FramerJS, on Material Up. I took this oppertunity to play with SpringAnimations.

Try it yourself:

Gradle

  • Step 1. Add the JitPack repository to your build file
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  • Step 2. Add the dependency (only for androidx projects)
dependencies {
    implementation 'com.github.DanielMartinus:Stepper-Touch:1.0.1'
}

If you haven't migrated your project to AndroidX use:

dependencies {
    implementation 'com.github.DanielMartinus:Stepper-Touch:0.6'
}

More info about it here: #24

Implement

<nl.dionsegijn.steppertouch.StepperTouch
        android:id="@+id/stepperTouch"
        android:layout_width="100dp"
        android:layout_height="40dp" />

Kotlin

val stepperTouch = findViewById<StepperTouch>(R.id.stepperTouch)
stepperTouch.minValue = 0
stepperTouch.minValue = 10
stepperTouch.sideTapEnabled = true
stepperTouch.addStepCallback(object : OnStepCallback {
	override fun onStep(value: Int, positive: Boolean) {
    		Toast.makeText(applicationContext, value.toString(), Toast.LENGTH_SHORT).show()
	}
})

Java

StepperTouch stepperTouch = findViewById(R.id.stepperTouch);
stepperTouch.setMinValue(0);
stepperTouch.setMaxValue(3);
stepperTouch.setSideTapEnabled(true);
stepperTouch.addStepCallback(new OnStepCallback() {
    @Override
    public void onStep(int value, boolean positive) {
        Toast.makeText(getApplicationContext(), value + "", Toast.LENGTH_SHORT).show();
    }
});

You're able to further customize or set initial values with styled attributes:

  1. Add res-auto to your xml layout if you haven't yet
xmlns:app="http://schemas.android.com/apk/res-auto"
  1. After that the following attributes will become available:
app:stepperBackgroundColor=""
app:stepperButtonColor=""
app:stepperActionsColor=""
app:stepperActionsDisabledColor=""
app:stepperTextColor=""
app:stepperTextSize=""
app:app:stepperAllowNegative=""
app:app:stepperAllowPositive=""

stepper-touch's People

Contributors

danielmartinus avatar imanneo avatar javacafe01 avatar

Watchers

 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.