All Projects → code-mc → Linear Time Picker

code-mc / Linear Time Picker

Licence: other
Gorgeous Android Time and Date picker library inspired by the Timely app

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Linear Time Picker

React Picky Date Time
A react component for date time picker. Online demo examples
Stars: ✭ 31 (-94.94%)
Mutual labels:  time, date, picker
Date Picker
📅 Custom responsive date picker widget for Android, written in Kotlin.
Stars: ✭ 146 (-76.18%)
Mutual labels:  time, date, picker
Singledateandtimepicker
You can now select a date and a time with only one widget !
Stars: ✭ 921 (+50.24%)
Mutual labels:  time, date, picker
Vue Ctk Date Time Picker
VueJS component to select dates & time, including a range mode
Stars: ✭ 707 (+15.33%)
Mutual labels:  time, date, picker
popoPicker
popoPicker是一个移动端3D滚轮日期时间和单项的选择器,支持无限循环滚动,不依赖第三方库
Stars: ✭ 26 (-95.76%)
Mutual labels:  time, date, picker
Md Date Time Picker
An implementation of Material Design Picker components in vanilla CSS, JS, and HTML
Stars: ✭ 272 (-55.63%)
Mutual labels:  time, date, picker
Pickadate.js
The mobile-friendly, responsive, and lightweight jQuery date & time input picker.
Stars: ✭ 7,753 (+1164.76%)
Mutual labels:  time, date, picker
Brpickerview
BRPickerView 封装的是iOS中常用的选择器组件,主要包括:日期选择器(支持年月日、年月等15种日期样式选择,支持设置星期、至今等)、地址选择器(支持省市区、省市、省三种地区选择)、自定义字符串选择器(支持单列、多列、二级联动、三级联动选择)。支持自定义主题样式,适配深色模式,支持将选择器组件添加到指定容器视图。
Stars: ✭ 2,149 (+250.57%)
Mutual labels:  time, date, picker
Datepicker
A Date Picker with Calendar for iPhone and iPad Apps.
Stars: ✭ 103 (-83.2%)
Mutual labels:  library, date, picker
React Native Modal Datetime Picker
A React-Native datetime-picker for Android and iOS
Stars: ✭ 2,412 (+293.47%)
Mutual labels:  time, date, picker
vue-timeselector
🕒 Simply customizable powerful time picker for Vue.js
Stars: ✭ 41 (-93.31%)
Mutual labels:  time, date, picker
react-picky-date-time
A react component for date time picker. Online demo examples
Stars: ✭ 41 (-93.31%)
Mutual labels:  time, date, picker
Angular Moment Picker
Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
Stars: ✭ 536 (-12.56%)
Mutual labels:  time, date, picker
React Native Calendar Select
A component to select period from calendar like Airbnb
Stars: ✭ 279 (-54.49%)
Mutual labels:  date, picker
Awesome Falsehood
😱 Falsehoods Programmers Believe in
Stars: ✭ 16,614 (+2610.28%)
Mutual labels:  time, date
Timestamp
⏰ A better macOS menu bar clock.
Stars: ✭ 296 (-51.71%)
Mutual labels:  time, date
Bottomsheet Imagepicker
Modern image picker for Android
Stars: ✭ 267 (-56.44%)
Mutual labels:  library, picker
React Datetime Picker
A datetime picker for your React app.
Stars: ✭ 294 (-52.04%)
Mutual labels:  time, date
Maya
Datetimes for Humans™
Stars: ✭ 3,298 (+438.01%)
Mutual labels:  time, date
Time
Simple time handling in Rust
Stars: ✭ 334 (-45.51%)
Mutual labels:  time, date

Linear Time Picker Library

Gorgeous Time and Date picker library inspired by the Timely app

Demo

Stats

  • MinSdk 11
  • Unique and intuitive Time and Date pickers
  • Gorgeous "grow" effect on the linear dial
  • Automated short 10 second tutorial to onboard users
  • Customizable to fit your application design
  • Occlusion detection
  • 24 hour and AM/PM modes based on the device's time settings
  • Public API you can use to create your own Linear Picker View

Usage

Step 1

Gradle

dependencies {
    compile 'net.codecrafted:lineartimepicker:1.0.0'
}

Step 2

LinearTimePickerDialog

To construct a dialog, the builder pattern is used. The following scaffold contains the minimum code required to construct a dialog.

LinearTimePickerDialog dialog = LinearTimePickerDialog.Builder.with(context)
    /* methods to further customize the dialog go here */
    .build();

Showing the dialog is identical to any other Android AlertDialog:

dialog.show();

To further customize the LinearTimePickerDialog, the following builder methods are available:

// Set the background color of the dialog (1)
setDialogBackgroundColor(int color)

// Set the background color of the picker inside the dialog (2)
setPickerBackgroundColor(int color)

// Set the color of the unselected lines in the linear dial (3)
setLineColor(int color)

// Set the color of all the displayed text
setTextColor(int color)

// Show a short 10 second automated tutorial to onboard the user
setShowTutorial(boolean showTutorial)

// Set the background color of the "handle" (4)
setTextBackgroundColor(int color)

// Set the color of the two buttons at the top of the dialog (5)
setButtonColor(int color)

// Register a callback when the selection process is completed or canceled
setButtonCallback(new LinearTimePickerDialog.ButtonCallback() {
    @Override
    public void onPositive(DialogInterface dialog, int hour, int minutes) {
        Toast.makeText(MainActivity.this, "" + hour + ":" + minutes, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onNegative(DialogInterface dialog) {

    }
})

LinearDatePickerDialog

To construct a dialog, the builder pattern is used. The following scaffold contains the minimum code required to construct a dialog.

LinearDatePickerDialog dialog = LinearDatePickerDialog.Builder.with(context)
    /* methods to further customize the dialog go here */
    .build();

Showing the dialog is identical to any other Android AlertDialog:

dialog.show();

To further customize the LinearDatePickerDialog, the following builder methods are available:

// Year that will be selected when the dialog is shown
setYear(int year)

// Minimum year that is allowed to be selected (inclusive)
setMinYear(int year)

// Maximum year that is allowed to be selected (inclusive)
setMaxYear(int year)

// Set the background color of the dialog (1)
setDialogBackgroundColor(int color)

// Set the background color of the picker inside the dialog (2)
setPickerBackgroundColor(int color)

// Set the color of the unselected lines in the linear dial (3)
setLineColor(int color)

// Set the color of all the displayed text
setTextColor(int color)

// Show a short 10 second automated tutorial to onboard the user
setShowTutorial(boolean showTutorial)

// Set the background color of the "handle" (4)
setTextBackgroundColor(int color)

// Set the color of the two buttons at the top of the dialog (5)
setButtonColor(int color)

// Register a callback when the selection process is completed or canceled
setButtonCallback(new LinearDatePickerDialog.ButtonCallback() {
    @Override
    public void onPositive(DialogInterface dialog, int year, int month, int day) {
        Toast.makeText(MainActivity.this, "" + year + " - " + month + " - " + day, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onNegative(DialogInterface dialog) {

    }
})

Advanced Usage

For those who want to code their own "Linear Picker View" there is a public API available to build upon:

LinearPickerView

This view can be inflated and appended to a layout. To control what the view draws to the screen a LinearPickerAdapter should be provided. There are currently 2 ways to create your own adapter.

LinearPickerAdapter interface

This is the most barebones and also most complex way of the two methods. But it allows for the highest level of customization and can provide stunning results. Following methods have to be implemented:

// Should provide the number of large pips to display (constant value)
int getLargePipCount();

// Should provide the number of small pips between 2 large pips to display (constant value)
int getSmallPipCount();

// Should provide the number of "invisible pips" or substeps between any 2 visible pips (can vary between pips)
// For more info on the visiblePipIndex, see the pip section below
int getInvisiblePipCount(int visiblePipIndex);

// This method is called once by the LinearPickerView every time it draws itself
// You can use this to draw a custom background as all the other elements will be drawn on top
//
// The array elementBounds contains the exact space and location that every element on the linear dial may use
void onDraw(Canvas canvas, Rect[] elementBounds, Gravity gravity);

// This method is called by the LinearPickerView every time a dial element has to be drawn
// index denotes the visible pip index of the dial element (see pip section)
// bounds gives a hint to where you should draw the dial element and also the size of the element
// yOffset An yOffset of 1f corresponds to a dial element that is located the distance between
//     2 big pips from the handle. In the picker examples this is used to fade out the small pips
// gravity Currently unused, part of a future API
void onDrawElement(int index, Canvas canvas, Rect bounds, float yOffset, Gravity gravity);

// This method is called last. Draw the handle here.
// index corresponds to the currently selected visible pip index.
// intermediate corresponds to the invisible pip step (0 -> visible pip selected, > 0 -> invisible pip selected)
// bounds The bounds inside which you should draw the handle (once again just a hint)
// occluded Which half of the screen the user's finger is currently touching
// gravity Currently unused, part of a future API
void onDrawHandle(int index, int intermediate, Canvas canvas, Rect bounds, Gravity gravity, ScreenHalf occluded);

BaseTextAdapter abstract class

This abstract class implements the required LinearPickerAdapter and provides a complete solution for getting similar results as the two provided pickers. In case you just want to display a handle with text that scrolls through a linear dial in which the pips also contain just text, this is an optimal solution.

There's only 5 methods that need to be implemented:

// This method provides a pip index (of all visible pips) and expects the
// text value to display next to this pip.
protected abstract String getLabelText(int index)

// This method provides the index of the currently selected pip and the index of the selected invisible pip.
// It expects the string to display on the handle.
protected abstract String getHandleText(int index, int step)

// The following 3 methods originate from the LinearPickerAdapter interface

// Should provide the number of large pips to display (constant value)
int getLargePipCount();

// Should provide the number of small pips between 2 large pips to display (constant value)
int getSmallPipCount();

// Should provide the number of "invisible pips" or substeps between any 2 visible pips (can vary between pips)
// For more info on the visiblePipIndex, see the pip section below
int getInvisiblePipCount(int visiblePipIndex);

pip

To make use of the adapter in this library it is important you have a good understanding of what the different pip types are and how each type is addressed.

There are in total 3 pip types:

  1. Large pip: This is the largest visible pip that signifies a top level entry (e.g. a full hour in the time picker)
  2. Small pip: This is the smaller visible pip kind that signifies a sub entry (e.g. 30 minute increments in the time picker)
  3. Invisible pip: These are further sub entries between the different visible pips (e.g. 5 minute increments in the time picker)

Let's assume the following example:

// The visiblePipIndex argument is the relative index to the total visible pip count.
//
//  Large pip count = 4
//  Small pip count = 2
//  => total visible pip count = 2 * (4-1) + 4 = 10
//
//  -- (0)
//  -  (1)
//  -  (2)
//  -- (3)
//  -  (4)
//  -  (5)
//  -- (6)
//  -  (7)
//  -  (8)
//  -- (9)
//
//  If now a visiblePipIndex of 2 is passed you know this is located inside (floor(2/(2+1)) == 0) the first large pip
//  on the (2 % (2+1) == 2) second small pip. (0 would be the large pip itself)

Visible pips are always addressed by using an index relative to the total visible pip count. Above example illustrates how one would derive the relevant pip from this index.

When an invisible pip is addressed it is always by both the visible pip index described above, and a second step index that indicates the index of the invisible pip (or step) relative to the visible pip index. It is important to note that invisible pips do not use an index that is relative to the total amount of pips, as that would be extremely complex to derive a position from.

License

Released under the Apache 2.0 License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].