Giter Club home page Giter Club logo

persian-datetime-picker's Introduction

📆 A persian (farsi,shamsi) datetime picker for flutter, inspired by material datetime picker.

pub package APK

Persian DateTime Picker Banner

Persian datetime picker inspired by material datetime picker and based on shamsi_date.

The Banner designed by Nader Mozaffari.

Usage

Add it to your pubspec.yaml file:

dependencies:

persian_datetime_picker: version

In your library add the following import:

import  'package:persian_datetime_picker/persian_datetime_picker.dart';

Here is many examples how to use:

/////////////////////////Example 1////////////////////////////
Jalali picked = await showPersianDatePicker(
    context: context,
    initialDate: Jalali.now(),
    firstDate: Jalali(1385, 8),
    lastDate: Jalali(1450, 9),
);
var label = picked.formatFullDate();
/////////////////////////Example 2////////////////////////////
var picked = await showTimePicker(
  context: context,
  initialTime: TimeOfDay.now(),
);
var label = picked.persianFormat(context);
/////////////////////////Example 3////////////////////////////
  Jalali pickedDate = await showModalBottomSheet<Jalali>(
    context: context,
    builder: (context) {
      Jalali tempPickedDate;
      return Container(
        height: 250,
        child: Column(
          children: <Widget>[
            Container(
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  CupertinoButton(
                    child: Text(
                      'لغو',
                      style: TextStyle(
                        fontFamily: 'Dana',
                      ),
                    ),
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                  ),
                  CupertinoButton(
                    child: Text(
                      'تایید',
                      style: TextStyle(
                        fontFamily: 'Dana',
                      ),
                    ),
                    onPressed: () {
                      Navigator.of(context).pop(tempPickedDate ?? Jalali.now());
                    },
                  ),
                ],
              ),
            ),
            Divider(
              height: 0,
              thickness: 1,
            ),
            Expanded(
              child: Container(
                child: CupertinoTheme(
                  data: CupertinoThemeData(
                    textTheme: CupertinoTextThemeData(
                      dateTimePickerTextStyle: TextStyle(fontFamily: "Dana"),
                    ),
                  ),
                  child: PCupertinoDatePicker(
                    mode: PCupertinoDatePickerMode.dateAndTime,
                    onDateTimeChanged: (Jalali dateTime) {
                      tempPickedDate = dateTime;
                    },
                  ),
                ),
              ),
            ),
          ],
        ),
      );
    },
  );
  
 /////////////////////////Example 4//////////////////////////// 
var picked = await showPersianDateRangePicker(
    context: context,
    initialEntryMode: PDatePickerEntryMode.input,
    initialDateRange: JalaliRange(
      start: Jalali(1400, 1, 2),
      end: Jalali(1400, 1, 10),
    ),
    firstDate: Jalali(1385, 8),
    lastDate: Jalali(1450, 9),
  );
  

Donation

Zarinpal donation link.

All the money will be spent on charity.
تمامی مبالغ پرداخت شده صرف امور خیریه خواهد شد.

##Pull request and feedback are always appreciated. ###Contact me with [email protected].

persian-datetime-picker's People

Contributors

alirezabeitari avatar amirrezamarzban avatar hasanm08 avatar m-amir-m avatar mhbdev avatar prooshani avatar real-john-doe avatar

Stargazers

 avatar  avatar

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.