Giter Club home page Giter Club logo

composenepalidatepicker's Introduction

Nepali Date picker Converter - Re in Compose

This is a re-work of Nepali Date Picker Converter in jetpack compose and kotlin.

English Locale Nepali Locale

Setup

Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:

   allprojects {
	repositories {
	    ...
	    maven { url "https://jitpack.io" }
	}
    }

Add the dependency

 dependencies {
     implementation 'com.github.keyrunHORNET:composeNepaliDatePicker:$version'
}

Using Date Picker

var showDialog by remember { mutableStateOf(false) }

if (showDialog) {
    NepaliDatePicker(
        onDateSelected = { date ->
            // selected date 
        },
        onDismiss = {
            showDialog = false
        }
    ) 
}

NepaliDate is a data class used to hold value of year, month, day and weekday in date converters and in callbacks of date picker.

onDismiss is mandatory for callback on dismiss of picker dialog.

onDateSelected is mandatory for callback on date selected. Returns selectedNepaliDate

Picker Options

NepaliDatePicker can take additional arguments to customise picker to your needs

  • startDate of type NepaliDate for the date you want to start with, in picker. It's default value is current instance.

  • showYearPickerFirst of type Boolean to show year picker first when picker is displayed. Its true by default and set it to false if you want month view as default view. Especially if you have limited date for selection in picker.

  • minDate of type NepaliDate to set the lower limit of date in picker.

  • maxDate of type NepaliDate to set upper limit of date in picker.

  • highlightDays of type List<NepaliDate>. This will highlight the given list of dates in picker.

  • disableDays of type List<NepaliDate>. This will disable selection of the given dates in picker.

Using Date Converter

value when passed beyond the conversion range throws an IllegalArgumentException. Make sure you catch them.

  • Converting english Date to Nepali date (i.e A.D to B.S):
NepaliDateUtils.adToBs(engYY,engMM,engDD)

you can also pass the calendar instance as an argument

  • Converting Nepali Date to English date (i.e B.S to A.D):
NepaliDateUtils.bsToAd(nepYY,nepMM,nepDD)

you can also pass NepaliDate as an argument

Additional Options

Accessible from NepaliDateUtils

  • NepaliDateUtils.isEngDateInRange(int yy,int mm,int dd) returns true if english date is within the range of conversion.

  • NepaliDateUtils.isNepDateInRange(int yy,int mm,int dd) returns true if nepali date is within the range of conversion.

  • NepaliDateUtils.getInstance() returns current instance of Nepali date

  • NepaliDateUtils.fillMissingWeekDayValue(nepaliDate: NepaliDate) will add missing dayOfWeek for a given NepaliDate.

License

MIT License

Copyright (c) 2022 Kiran Gyawali

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

composenepalidatepicker's People

Contributors

keyrunhornet avatar shivathapaa avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

shivathapaa

composenepalidatepicker's Issues

Date Display Issue and doesnot support below minSDK 26

Hello,
In this lib, there is issue while displaying date of every month of date 12. Instead of 12 there is 22 date is displayed.
1659938684786
Also, why doesn't it support below minSDK 26. I need to support my app from 23 so.

Thank you!!

Max Date Issue.

Thank for this great lib.

I have got a issue while using max date only. Here is sample code:
maxDate.value = NepaliDateUtils.getInstance()

Log: max NepaliDate(year=2079, month=4, day=30, dayOfWeek=2)

NepaliDatePicker(
showYearPickerFirst=false,
// minDate = minDate.value,
maxDate = maxDate.value,)

pic

Changing month and displaying month it's a issue while using max date.

calendar open but doesnot show circle for todays or selected date by default

Suppose if we start using with todays date 2080-08-15, the calendar will open in the mention month but the missing part is it doesn't highlight(select day) the date day with circle 15 by default.Could you show it by default like we select the day from the calendar.This seems like a minor issue but from user perspective its a kind of odd situation or major issue as user is complaining about this.Please fix it as soon as possible and Thank you for your great Library.

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.