New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pantrist/capacitor-date-picker

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pantrist/capacitor-date-picker

Native DateTime Picker Plugin for Capacitor Apps

  • 6.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-16.67%
Maintainers
1
Weekly downloads
 
Created
Source


Capacitor Date Picker

@pantrist/capacitor-date-picker

Plugin for native Date Picker


Installation

Using npm:

npm install @pantrist/capacitor-date-picker

Using yarn:

yarn add @pantrist/capacitor-date-picker

Sync native files:

npx cap sync

ios

  • present
  • config
    • style
    • format
    • locale
    • date
    • mode
    • theme
    • timezone
    • min
    • max
    • doneText
    • cancelText
    • is24h
    • titleFontColor
    • titleBgColor
    • bgColor
    • fontColor
    • buttonBgColor
    • buttonFontColor
    • mergedDateAndTime

android

  • present
  • config
    • format
    • locale
    • date
    • mode
    • theme
    • timezone
    • min
    • max
    • doneText
    • cancelText
    • is24h

web

  • present
  • config
    • format
    • locale
    • mode
    • theme
    • background
    • min
    • max
    • doneText
    • cancelText
    • timezone
    • title

API

  • present(DatePickerOptions): Promise<{ value:string }>

Config for iOS (DatePickerOptions)

These options can be used through the present method and/or within capacitor.config.json

nametypedefault
formatstring"yyyy-MM-dd'T'HH:mm:ss.sssZ"
stylestringif iOS 14 "inline" else only "wheels"
localestringcurrent device
datestringcurrent date
modeDatePickerMode"dateAndTime"
themeDatePickerThemecurrent device
timezonestringcurrent device
minstringnull
maxstringnull
doneTextstring"OK"
cancelTextstring"Cancel"
is24hbooleanfalse
titleFontColorstringnull
titleBgColorstringnull
bgColorstringnull
fontColorstringnull
buttonBgColorstringnull
buttonFontColorstringnull

Config for Android (DatePickerOptions)

These options can be used through the present method and/or within capacitor.config.json

nametypedefault
formatstring"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
localestringcurrent device
datestringcurrent date
modeDatePickerMode"dateAndTime"
themeDatePickerTheme"light"
timezonestringcurrent device
minstringnull
maxstringnull
doneTextstring"OK"
cancelTextstring"Cancel"
is24hbooleanfalse

For more information check the definitions file

Date Format

For format, we defined the old config deprecated because we have a inconsistence between Android and iOS platforms

now you need define your forma config in android.format and ios.format

iOS

For format in iOS, you need to follow this documentation

Android

For format in Android, you need to follow this documentation

Android Theme

You can define your personalized themes in android via resources styles check example app

How you see in example, just define your picker theme in global assets your app and send via android.theme prop in your capacitor.config file or your options.android.theme in present call.

Demo

Usage

import { DatePicker } from '@pantrist/capacitor-date-picker';
import type { DatePickerTheme } from '@pantrist/capacitor-date-picker/src';
const selectedTheme: DatePickerTheme = 'light';

DatePicker.present({
  mode: 'date',
  locale: 'pt_BR',
  date: '13/07/2019',
  theme: selectedTheme,
  ios: {
    format: 'dd/MM/yyyy',
  },
  android: {
    format: 'dd/MM/yyyy',
  },
}).then(date => alert(date.value));

Capacitor Config

{
  //...
  "plugins": {
    "DatePickerPlugin": {
      "mode": "date",
      "locale": "pt_BR",
      "current": "13/07/2019",
      "format": "dd/MM/yyyy",
      "android": {
        "theme": "MyCustomeTheme"
      },
      "ios": {
        "style": "wheels"
      }
    }
  }
}

iOS setup

  • ionic start my-cap-app --capacitor
  • cd my-cap-app
  • npm install --save @pantrist/capacitor-date-picker
  • mkdir www && touch www/index.html
  • sudo gem install cocoapods (only once)
  • npx cap add ios
  • npx cap sync ios (every time you run npm install)
  • npx cap open ios

Tip: every time you change a native code you may need to clean up the cache (Product > Clean build folder) and then run the app again.

Android setup

  • ionic start my-cap-app --capacitor
  • cd my-cap-app
  • npm install --save @pantrist/capacitor-date-picker
  • mkdir www && touch www/index.html
  • npx cap add android
  • npx cap sync android (every time you run npm install)
  • npx cap open android
  • [extra step] OPTIONAL in android case we need to tell Capacitor to initialise the plugin:

on your MainActivity.java file add com.getcapacitor.community.datepicker.DatePicker; and then inside the init callback add(DatePicker.class);

Now you should be set to go. Try to run your client using ionic cap run android --livereload --address=0.0.0.0.

Tip: every time you change a native code you may need to clean up the cache (Build > Clean Project | Build > Rebuild Project) and then run the app again.

Updating

For existing projects you can upgrade all capacitor related packages (including this plugin) with this single command

npx npm-upgrade '*capacitor*' && npm install

Example

https://github.com/capacitor-community/date-picker/tree/master/example

License

MIT

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Stew

💻 📖

Daniel Pereira

💻 📖 🚧

Caroline Oliva

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Keywords

FAQs

Package last updated on 29 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc