Giter VIP home page Giter VIP logo

compose-date-text-field's Introduction

DateTextField for Jetpack Compose

Date text field with on the fly validation built with Jetpack Compose.

The input is validated while the user is typing it, so it is impossible to enter an incorrect value.

Made in LANARS.


Download

repositories {
    ...
    maven { url 'https://jitpack.io' }
}
dependencies {
    implementation 'com.github.LanarsInc:compose-date-text-field:{latest version}'
}

Preview

User can only enter existing dates

User can only enter dates that are in the allowed range

Input is being validated even though some fields are not complete

Usage

Basic implementation

DateTextField(
    onValueChanged = {}
)

You can set the exact date boundaries or leave it by default, from 1/1/1900 to 12/31/2100. Date format by default will be MM/DD/YYYY

DateTextField(
    // Detect focus changes
    modifier = Modifier.onFocusChanged { Log.d("DateInput", it.toString()) },
    // Set the desired date format
    format = Format.MMDDYYYY,
    // Set min and max date
    minDate = LocalDate.now().minusYears(1),
    maxDate = LocalDate.now().plusYears(1),
    // Get notified about value changes
    onValueChanged = { Log.d("DateInput", it.toString()) },
    // Preset date value
    initialValue = LocalDate.now(),
    // Apply text style to input text
    textStyle = TextStyle(fontSize = 25.sp, color = Color.Black),
    // Apply text style to hint
    hintTextStyle = TextStyle(fontSize = 25.sp, color = Color.Gray),
    // Apply style to cursor
    cursorBrush = SolidColor(Color.Red),
    // Set custom delimiter
    delimiter = '.',
    // Set horizontal delimiter margin
    delimiterSpacing = 4.dp,
    // Set field to be readonly
    readOnly = true
)

compose-date-text-field's People

Contributors

gsrocks-lanars avatar vizhan-lanars avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

nonproto

compose-date-text-field's Issues

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.