NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

Date Picker

Open SupriyaKalghatgi opened this issue 9 years ago • 37 comments

SupriyaKalghatgi avatar May 26 '17 08:05 SupriyaKalghatgi

I'm so happy to see this is enhancement tasks but I have a suggestion. Please use same approach as http://www.material-ui.com/#/components/date-picker so we can simply use localization support for any language and calendar systems. For example it's a code snippet from MaterialUI:

import React from 'react';
import DatePicker from 'material-ui/DatePicker';
import areIntlLocalesSupported from 'intl-locales-supported';
import persianUtils from 'material-ui-persian-date-picker-utils';

let DateTimeFormat;

/**
 * Use the native Intl.DateTimeFormat if available, or a polyfill if not.
 */
if (areIntlLocalesSupported(['fr', 'fa-IR'])) {
  DateTimeFormat = global.Intl.DateTimeFormat;
} else {
  const IntlPolyfill = require('intl');
  DateTimeFormat = IntlPolyfill.DateTimeFormat;
  require('intl/locale-data/jsonp/fr');
  require('intl/locale-data/jsonp/fa-IR');
}

/**
 *  `DatePicker` can be localised using the `locale` property. The first example is localised in French.
 *  Note that the buttons must be separately localised using the `cancelLabel` and `okLabel` properties.
 *
 *  The second example shows `firstDayOfWeek` set to `0`, (Sunday), and `locale` to `en-US` which matches the
 *  behavior of the Date Picker prior to 0.15.0. Note that the 'en-US' locale is built in, and so does not require
 *  `DateTimeFormat` to be supplied.
 *
 *  The final example displays the resulting date in a custom format using the `formatDate` property.
 */
const DatePickerExampleInternational = () => (
  <div>
    <DatePicker
      hintText="fr locale"
      DateTimeFormat={DateTimeFormat}
      okLabel="OK"
      cancelLabel="Annuler"
      locale="fr"
    />
    <DatePicker
      hintText="fa-IR locale"
      DateTimeFormat={DateTimeFormat}
      okLabel="تایید"
      cancelLabel="لغو"
      locale="fa-IR"
      firstDayOfWeek={6}
      utils={persianUtils}
    />
    <DatePicker
      hintText="en-US locale"
      locale="en-US"
      firstDayOfWeek={0}
    />
    <DatePicker
      hintText="Custom date format"
      firstDayOfWeek={0}
      formatDate={new DateTimeFormat('en-US', {
        day: 'numeric',
        month: 'long',
        year: 'numeric',
      }).format}
    />
  </div>
);

export default DatePickerExampleInternational;

and simply use custom calendar and custom language.

/CC: @SupriyaKalghatgi @sankhadeeproy007

cyclops24 avatar Jul 09 '17 16:07 cyclops24

I'm just curious why an important component is in low priority. It would be perfect if it has it own DatePicker.

rabin111 avatar Jul 27 '17 07:07 rabin111

Agreed, in need of a cool native-base datapicker

vgabdala avatar Sep 09 '17 19:09 vgabdala

+1

miguelocarvajal avatar Nov 07 '17 11:11 miguelocarvajal

+1

mtebele avatar Nov 16 '17 19:11 mtebele

+1

MedinaGitHub avatar Nov 28 '17 20:11 MedinaGitHub

+1

drewmcdonald1337 avatar Nov 29 '17 21:11 drewmcdonald1337

+1

pimvernooij avatar Dec 12 '17 08:12 pimvernooij

+1

ChadTaljaardt avatar Dec 19 '17 21:12 ChadTaljaardt

+1, it's a must for any app UI framework. Date is common data in all applications. What are the ways to achieve date picking functionality in ReactNative right now ?

gauravdhiman avatar Dec 28 '17 22:12 gauravdhiman

+1

namnguyentat avatar Jan 30 '18 12:01 namnguyentat

+1

maxto024 avatar Feb 06 '18 10:02 maxto024

+1

anil1712 avatar Feb 06 '18 11:02 anil1712

+1

hanssonfredrik avatar Feb 08 '18 17:02 hanssonfredrik

+1

jLynx avatar Mar 05 '18 00:03 jLynx

+1

anil1712 avatar Mar 07 '18 15:03 anil1712

+1

PetrVasilev avatar Mar 14 '18 08:03 PetrVasilev

+1

muttonblue avatar Mar 15 '18 01:03 muttonblue

+1

mataiaslev avatar Mar 20 '18 14:03 mataiaslev

+1

vasilgramov avatar Mar 24 '18 11:03 vasilgramov