Giter Site home page Giter Site logo

rghorbani / react-native-general-calendars Goto Github PK

View Code? Open in Web Editor NEW
94.0 3.0 16.0 4.31 MB

React Native Calendar Components 📆

License: MIT License

JavaScript 93.88% Python 1.64% Java 1.20% Objective-C 3.28%
react-native android ios calendar gregorian jalaali ui-components

react-native-general-calendars's Introduction

React Native General Calendars ✨ 🗓️ 📆

NPM Version Build Status

This module includes various customizable react native calendar components.

The package is both Android and iOS compatible.

Installation

$ yarn add react-native-general-calendars

or

$ npm install react-native-general-calendars --save

The solution is implemented in JavaScript so no native module linking is required.

Usage

import { Calendar, CalendarList, Agenda } from 'react-native-general-calendars';

All parameters for components are optional. By default the month of current local date will be displayed.

Event handler callbacks are called with calendar objects like this:

{
  day: 1,     // day of month (1-31)
  month: 1,   // month of year (1-12)
  year: 2017, // year
  timestamp,   // UTC timestamp representing 00:00 AM of this date
  dateString: '2016-05-13' // date formatted as 'YYYY-MM-DD' string
}

Parameters that require date types accept YYYY-MM-DD formated datestrings (in gregorian), JavaScript date objects, calendar objects and UTC timestamps.

Calendar Types

The package implements different type of calendars through type parameter. By setting the type="jalaali", you can use the calendar as Jalaali.

RTL support

The package has independent RTL implementations. But if you want to use the react's I18Manager, you should set the rtl parameter to false rtl={false}.

Moment

Calendars can be localized by adding custom locales using Moment's i18n functions:

import Moment from 'moment';

Moment.locales('fr', {
  months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
    monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
    monthsParseExact : true,
    weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
    weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
    weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
    weekdaysParseExact : true,
});

Calendar

Basic parameters

<Calendar
  // Calendar type (gregorian, jalaali). Default = gregorian
  type="gregorian"
  // Initially visible month. Default = Date()
  current="2012-03-01"
  // Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined
  minDate="2012-05-10"
  // Maximum date that can be selected, dates after maxDate will be grayed out. Default = undefined
  maxDate="2012-05-30"
  // Handler which gets executed on day press. Default = undefined
  onDayPress={(day, localDay) => {console.log('selected day', day, localDay)}}
  // Handler which gets executed on day long press. Default = undefined
  onDayLongPress={(day) => {console.log('selected day', day)}}
  // Month format in calendar title. Formatting values: http://arshaw.com/xdate/#Formatting
  monthFormat="YYYY MM"
  // Handler which gets executed when visible month changes in calendar. Default = undefined
  onMonthChange={(month) => {console.log('month changed', month)}}
  // Hide month navigation arrows. Default = false
  hideArrows={true}
  // Replace default arrows with custom ones (direction can be 'left' or 'right')
  renderArrow={(direction) => (<Arrow />)}
  // Do not show days of other months in month page. Default = false
  hideExtraDays={true}
  // If hideArrows=false and hideExtraDays=false do not switch month when tapping on greyed out
  // day from another month that is visible in calendar page. Default = false
  disableMonthChange={true}
  // If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday.
  firstDay={1}
  // Hide day names. Default = false
  hideDayNames={true}
  // Show week numbers to the left. Default = false
  showWeekNumbers={true}
  // Handler which gets executed when press arrow icon left. It receive a callback can go back month
  onPressArrowLeft={substractMonth => substractMonth()}
  // Handler which gets executed when press arrow icon left. It receive a callback can go next month
  onPressArrowRight={addMonth => addMonth()}
/>

Date marking

!Disclaimer! Make sure that markedDates param is immutable. If you change markedDates object content but the reference to it does not change calendar update will not be triggered.

Dot marking

<Calendar
  // Collection of dates that have to be marked. Default = {}
  markedDates={{
    '2012-05-16': {selected: true, marked: true, selectedColor: 'blue'},
    '2012-05-17': {marked: true},
    '2012-05-18': {marked: true, dotColor: 'red', activeOpacity: 0},
    '2012-05-19': {disabled: true, disableTouchEvent: true}
  }}
/>

You can customise a dot color for each day independently.

Multi-Dot marking

Use markingType = 'multi-dot' if you want to display more than one dot. Both the Calendar and CalendarList control support multiple dots by using 'dots' array in markedDates. The property 'color' is mandatory while 'key' and 'selectedColor' are optional. If key is omitted then the array index is used as key. If selectedColor is omitted then 'color' will be used for selected dates.

const vacation = {key:'vacation', color: 'red', selectedDotColor: 'blue'};
const massage = {key:'massage', color: 'blue', selectedDotColor: 'blue'};
const workout = {key:'workout', color: 'green'};

<Calendar
  markedDates={{
    '2017-10-25': {dots: [vacation, massage, workout], selected: true, selectedColor: 'red'},
    '2017-10-26': {dots: [massage, workout], disabled: true},
  }},
  markingType="multi-dot"
/>

Period marking

<Calendar
  // Collection of dates that have to be colored in a special way. Default = {}
   markedDates={
    {'2012-05-20': {textColor: 'green'},
     '2012-05-22': {startingDay: true, color: 'green'},
     '2012-05-23': {selected: true, endingDay: true, color: 'green', textColor: 'gray'},
     '2012-05-04': {disabled: true, startingDay: true, color: 'green', endingDay: true}
    }}
  // Date marking style [simple/period/multi-dot/custom]. Default = 'simple'
  markingType="period"
/>

Multi-period marking

CAUTION: This marking is only fully supported by the <Calendar /> component because it expands its height. Usage with <CalendarList /> might lead to overflow issues.

<Calendar
  markedDates={{  
    '2017-12-14': {  
      periods: [  
        { startingDay: false, endingDay: true, color: '#5f9ea0' },
        { startingDay: false, endingDay: true, color: '#ffa500' },
        { startingDay: true, endingDay: false, color: '#f0e68c' },
      ]
    },
    '2017-12-15': {  
      periods: [  
        { startingDay: true, endingDay: false, color: '#ffa500' },
        { color: 'transparent' },
        { startingDay: false, endingDay: false, color: '#f0e68c' },
      ]
    },
  }}
  // Date marking style [simple/period/multi-dot/custom]. Default = 'simple'
  markingType="multi-period"
/>

Custom marking allows you to customize each marker with custom styles.

<Calendar
  // Date marking style [simple/period/multi-dot/single]. Default = 'simple'
  markingType="custom"
  markedDates={{
    '2018-03-28': {
      customStyles: {
        container: {
          backgroundColor: 'green',
        },
        text: {
          color: 'black',
          fontWeight: 'bold'
        },
      },
    },
    '2018-03-29': {
      customStyles: {
        container: {
          backgroundColor: 'white',
          elevation: 2
        },
        text: {
          color: 'blue',
        },
      }
    }}}
/>

Keep in mind that different marking types are not compatible. You can use just one marking style for calendar.

Displaying data loading indicator

The loading indicator next to month name will be displayed if <Calendar /> has displayLoadingIndicator property and markedDays collection does not have a value for every day of the month in question. When you load data for days, just set [] or special marking value to all days in markedDates collection.

Customizing look & feel

<Calendar
  // Specify style for calendar container element. Default = {}
  style={{
    borderWidth: 1,
    borderColor: 'gray',
    height: 350
  }}
  // Specify theme properties to override specific styles for calendar parts. Default = {}
  theme={{
    backgroundColor: '#ffffff',
    calendarBackground: '#ffffff',
    textSectionTitleColor: '#b6c1cd',
    selectedDayBackgroundColor: '#00adf5',
    selectedDayTextColor: '#ffffff',
    todayTextColor: '#00adf5',
    dayTextColor: '#2d4150',
    textDisabledColor: '#d9e1e8',
    dotColor: '#00adf5',
    selectedDotColor: '#ffffff',
    arrowColor: 'orange',
    monthTextColor: 'blue',
    textDayFontFamily: 'monospace',
    textMonthFontFamily: 'monospace',
    textDayHeaderFontFamily: 'monospace',
    textMonthFontWeight: 'bold',
    textDayFontSize: 16,
    textMonthFontSize: 16,
    textDayHeaderFontSize: 16
  }}
/>

Advanced styling

If you want to have complete control over calendar styles you can do it by overriding default style.js files. For example, if you want to override calendar header style first you have to find stylesheet id for this file:

https://github.com/rghorbani/react-native-general-calendars/blob/master/src/calendar/header/style.js#L4

In this case it is 'stylesheet.calendar.header'. Next you can add overriding stylesheet to your theme with this id.

https://github.com/rghorbani/react-native-general-calendars/blob/master/example/src/screens/calendars.js#L56

theme={{
  arrowColor: 'white',
  'stylesheet.calendar.header': {
    week: {
      marginTop: 5,
      flexDirection: 'row',
      justifyContent: 'space-between'
    }
  }
}}

Disclaimer: issues that arise because something breaks after using stylesheet override will not be supported. Use this option at your own risk.

Overriding day component

If you need custom functionality not supported by current day component implementations you can pass your own custom day component to the calendar.

<Calendar
  style={[styles.calendar, {height: 300}]}
  dayComponent={({date, state}) => {
    return (<View style={{flex: 1}}><Text style={{textAlign: 'center', color: state === 'disabled' ? 'gray' : 'black'}}>{date.day}</Text></View>);
  }}
/>

The dayComponent prop has to receive a RN component or function that receive props. The day component will receive such props:

  • state - disabled if the day should be disabled (this is decided by base calendar component)
  • marking - markedDates value for this day
  • date - the date object representing this day

Tip: Don't forget to implement shouldComponentUpdate for your custom day component to make calendar perform better

If you implement an awesome day component please make a PR so that other people could use it :)

CalendarList

<CalendarList /> is scrollable semi-infinite calendar composed of <Calendar /> components. Currently it is possible to scroll 4 years back and 4 years to the future. All paramters that are available for <Calendar /> are also available for this component. There are also some additional params that can be used:

<CalendarList
  // Callback which gets executed when visible months change in scroll view. Default = undefined
  onVisibleMonthsChange={(months) => {console.log('now these months are visible', months);}}
  // Max amount of months allowed to scroll to the past. Default = 50
  pastScrollRange={50}
  // Max amount of months allowed to scroll to the future. Default = 50
  futureScrollRange={50}
  // Enable or disable scrolling of calendar list
  scrollEnabled={true}
  // Enable or disable vertical scroll indicator. Default = false
  showScrollIndicator={true}
  ...calendarParams
/>

Horizontal CalendarList

You can also make the CalendarList scroll horizontally. To do that you need to pass specific props to the CalendarList:

<CalendarList
  // Enable horizontal scrolling, default = false
  horizontal={true}
  // Enable paging on horizontal, default = false
  pagingEnabled={true}
  // Set custom calendarWidth.
  calendarWidth={320}
  ...calendarListParams
  ...calendarParams
/>

Agenda

An advanced agenda component that can display interactive listings for calendar day items.

<Agenda
  // the list of items that have to be displayed in agenda. If you want to render item as empty date
  // the value of date key kas to be an empty array []. If there exists no value for date key it is
  // considered that the date in question is not yet loaded
  items={
    {'2012-05-22': [{text: 'item 1 - any js object'}],
     '2012-05-23': [{text: 'item 2 - any js object'}],
     '2012-05-24': [],
     '2012-05-25': [{text: 'item 3 - any js object'},{text: 'any js object'}],
    }}
  // callback that gets called when items for a certain month should be loaded (month became visible)
  loadItemsForMonth={(month) => {console.log('trigger items loading')}}
  // callback that fires when the calendar is opened or closed
  onCalendarToggled={(calendarOpened) => {console.log(calendarOpened)}}
  // callback that gets called on day press
  onDayPress={(day)=>{console.log('day pressed')}}
  // callback that gets called when day changes while scrolling agenda list
  onDayChange={(day)=>{console.log('day changed')}}
  // initially selected day
  selected={'2012-05-16'}
  // Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined
  minDate={'2012-05-10'}
  // Maximum date that can be selected, dates after maxDate will be grayed out. Default = undefined
  maxDate={'2012-05-30'}
  // Max amount of months allowed to scroll to the past. Default = 50
  pastScrollRange={50}
  // Max amount of months allowed to scroll to the future. Default = 50
  futureScrollRange={50}
  // specify how each item should be rendered in agenda
  renderItem={(item, firstItemInDay) => {return (<View />);}}
  // specify how each date should be rendered. day can be undefined if the item is not first in that day.
  renderDay={(day, item) => {return (<View />);}}
  // specify how empty date content with no items should be rendered
  renderEmptyDate={() => {return (<View />);}}
  // specify how agenda knob should look like
  renderKnob={() => {return (<View />);}}
  // specify what should be rendered instead of ActivityIndicator
  renderEmptyData = {() => {return (<View />);}}
  // specify your item comparison function for increased performance
  rowHasChanged={(r1, r2) => {return r1.text !== r2.text}}
  // Hide knob button. Default = false
  hideKnob={true}
  // By default, agenda dates are marked if they have at least one item, but you can override this if needed
  markedDates={{
    '2012-05-16': {selected: true, marked: true},
    '2012-05-17': {marked: true},
    '2012-05-18': {disabled: true}
  }}
  // If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make sure to also set the refreshing prop correctly.
  onRefresh={() => console.log('refreshing...')}
  // Set this true while waiting for new data from a refresh
  refreshing={false}
  // Add a custom RefreshControl component, used to provide pull-to-refresh functionality for the ScrollView.
  refreshControl={null}
  // agenda theme
  theme={{
    ...calendarTheme,
    agendaDayTextColor: 'yellow',
    agendaDayNumColor: 'green',
    agendaTodayColor: 'red',
    agendaKnobColor: 'blue'
  }}
  // agenda container style
  style={{}}
/>

Authors

See also the list of contributors who participated in this project.

Contributing

Pull requests are welcome. npm run test and npm run lint before push.

react-native-general-calendars's People

Contributors

ghorbani-m avatar ialirezakml avatar rghorbani avatar saeedzhiany avatar sm2017 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-native-general-calendars's Issues

null is not an object

installed library with react-native 61.2 , and userd sample
but gets error

below is the code

import * as React from 'react';
import { View, TouchableOpacity, Image, Text, StyleSheet } from 'react-native';
import { Calendar, CalendarList, Agenda } from 'react-native-general-calendars';

class App extends React.Component {
constructor() {
super()

}

render() {
return (



);
}
}
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 40,
},
});

DatePicker

Can you show me how can I use DatePicker?
How can I set default value?

افزودن agenda

سلام و خیلی متشکر از زحمتی که کشیدی بابت شمسی کردن تقویم این کامپوننت

اگر ممکن هست زود تر agenda رو هم اضافه کن

Update on the Unexpected reserved type string (26:30) error ?

Hello I would like to know if there are any update on this issue with RN 0.62.2 ?

Thank you a lot for your package

node_modules\react-native-common\src\components\other\SegmentedControl.js: Unexpected reserved type string (26:30)

  24 |   static propTypes: {
  25 |     values: PropTypes.array,
> 26 |     selectionColor: PropTypes.string,
     |                               ^
  27 |     selectedIndex: PropTypes.number,
  28 |     onChange: PropTypes.func,
  29 |     titleStyle: PropTypes.any,

horizontal CalendarList problem with modal

The vertical version works just fine inside my <Modal> without any weird behavior.
But when i set horizontal={true}, at first the Calendar gets rendered for a brief moment and i can see it but then it suddenly disappears.

Here's my code:

import React, { Component } from 'react';
import { Modal, View, ... } from 'react-native';
import { Container, Button, ... } from 'native-base';

class Archive extends Component<Props> {
  ...
  render() {
    return (
      <Container>
         <View>
           <Modal
              animationType="fade"
              transparent={true}
              visible={this.state.modalToDateVisible}
              onRequestClose={() => {
              this.setState({modalToDateVisible:false})
            }}>
            <View style={{alignItems:'center', justifyContent:'center', flex: 1, flexDirection: 'column', backgroundColor:'rgba(0, 0, 0, 0.5)'}}>
              <View style={{width:'95%', backgroundColor:'#F6F7F9', padding: 20 }}>
                <CalendarList
                  horizontal={true}
                  pagingEnabled={true}
                  type='jalaali'
                />
                <View style={{marginTop:20}}>
                  <Button onPress={()=>this.closeToDateModal()}
                    <Text style={{fontSize:20}}>Close</Text>
                  </Button>
                </View>
              </View>
            </View>
         ...
     );
   }
}

i tried :

  • changing its parent from <View> to horizontal <ScrollView>
  • all permutation of styling (absolute fill parent, zIndex and other stuff)

BTW: it works outside my Modal and the normal <Calendar> works too.

Thanks in advance

Selected Date Style

I can't seem to get the current selected date to show a blue (or any color) dot around the date. My code is:

`
class AddChildForm extends Component<Props, State> {
constructor(props) {
super(props);
this.state = { dob: new Date(), dobModal: true };
}

handleDateChange = (dob) => {
this.setState({ dob, dobModal: false });
}

handleDOBModal = () => {
this.setState({ dobModal: true });
}

render() {
const { name, dob, gender, dobModal } = this.state;

return (
  <KeyboardAvoidingView behavior="position" enabled contentContainerStyle={styles.keyboardContainer}>
    <View style={styles.bottomHalfContainer}>
      <View style={styles.formContainer}>
        {/* DOB MODAL */}
        <Modal
          animationType="slide"
          transparent={false}
          visible={dobModal}
        >
          <View style={{ marginTop: 22, flex: 1 }}>
            <Calendar
              markingStyle="period"
              monthFormat="MMMM YYYY"
              current={dob}
              onDayPress={this.handleDateChange}
              firstDay={1}
            />
          </View>
        </Modal>
      </View>
    </View>
  </KeyboardAvoidingView>
);

}
}
`

The currently selected date doesn't seem to work with no styles defined or with this:

theme={{ textSectionTitleColor: '#b6c1cd', selectedDayBackgroundColor: '#00adf5', selectedDayTextColor: '#ffffff', }}

jalaali wrong result

@rghorbani type="gregorian" works well but , jalaali is not

<Calendar
  type="jalaali"
  onDayPress={(day, localDay) => {console.log('selected day', day.dateString, localDay.dateString)}}
  onDayLongPress={(day, localDay) => {console.log('selected day', day.dateString, localDay.dateString)}}
/>

logged console is :

selected day ۰۶۲۱-۰۳-۲۱ ۰۰۰۰-۰۱-۰۱

next & previous month issue

Dear Reza
When I have configured type="jalaali" in the calendar component, In some situations, next month stop working.
I have traced code and found below expression in updateMonth method cause unwanted response:
if (day.format('YYYY MM') === this.state.currentMonth.format('YYYY MM')) { return; }
when I removed above code in updateMonth my problem was solved.
Could you say what is this code for?

Error while running command npm install

I am trying to run provided example but gives this error while executing npm install command
npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "link:": link:..

Issue with re-render

After onDayPress and changing component state, the calendar list does not re-render.

Video example
https://monosnap.com/file/XIqCU55VnNFNtsqnsf5hs5WZ9J52EY

I try'ed in several ways to paste the code in a way that you could see, but looks like github WYSYWYG is not prepared to accept code 🌊

`

onDayPress(date) {
console.log('Selected day : ')
console.log(date)
const selectedDate = date.dateString

    let marked = true
    if (this.state.markedDates[selectedDate]) {
        // Already in marked dates, so reverse current marked state
        marked = !this.state.markedDates[selectedDate].selected
    }

    // Create a new object using object property spread since it should be immutable
    // Reading: https://davidwalsh.name/merge-objects
    const updatedMarkedDates = { ...this.state.markedDates, ...{ [selectedDate]: { 'selected': marked } } }

    this.setState({
        selectedDate: selectedDate,
        markedDates: updatedMarkedDates,
    })
}`

How to use localization?

I can not change calendar localization, please provide more detail on this subject, in your wiki.

where exactly I must put this code?

import Moment from 'moment';

Moment.locales('fr', {
  months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
    monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
    monthsParseExact : true,
    weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
    weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
    weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
    weekdaysParseExact : true,
});

How to use `RN-General-Calendars` for Shamsi/Jalali Date ?

Hello and say Thank u for this powerful package.
I've just develop a reservation application for Android and IOS.
I need a clean and fast datePicker like this package, but i want to use Shamsi/Jalali date.
How can i set RN-General-Calendars to jalali moment ?

agenda support?

I can not use agenda with type="jalaali" and it is english. Is agenda supported?

this calendar is not designed for selecting Birthday ??

hello

is possible to surf between years fast in this Calendar ??

my user wanna select birthday but how with this component ???

<CalendarList // Calendar type (gregorian, jalaali). Default = gregorian type='jalaali' onDayPress={(day, localDay) => this.onDateChange(day)} // Max amount of months allowed to scroll to the past. Default = 50 pastScrollRange={50} // Max amount of months allowed to scroll to the future. Default = 50 futureScrollRange={50} // Enable or disable scrolling of calendar list scrollEnabled={true} // Enable or disable vertical scroll indicator. Default = false showScrollIndicator={true} />

install your libarary but it has error

error: bundling failed: SyntaxError: D:\mobileProject\sample_project\node_modules\react-native-jalali-date-picker-rtl\WeekDaysLabels.js: Unexpected reserved type number (24:27)

22 | class WeekDaysLabels extends React.Component {
23 | static propTypes: {

24 | screenWidth: PropTypes.number,
| ^
25 | textStyle: Text.propTypes.style
26 | };

in react native 0.61

npm ERR! code ELIFECYCLE

E:\manager>npm install react-native-general-calendars

> [email protected] postinstall E:\manager\node_modules\react-native-interactable
> ln -sf lib/{ios,android} .

'ln' is not recognized as an internal or external command,
operable program or batch file.
npm WARN [email protected] requires a peer of eslint@^3.17.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-native@^0.51 || ^0.52 || ^0.53 || ^0.54 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-native-web@* but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^0.14.6 || ^15.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules\@expo\ngrok-bin-freebsd-ia32):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"freebsd","arch":"ia32"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules\@expo\ngrok-bin-darwin-ia32):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"darwin","arch":"ia32"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules\@expo\ngrok-bin-darwin-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"darwin","arch":"x64"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules\@expo\ngrok-bin-freebsd-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"freebsd","arch":"x64"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules\@expo\ngrok-bin-linux-arm):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"linux","arch":"arm"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules\@expo\ngrok-bin-linux-ia32):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"linux","arch":"ia32"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules\@expo\ngrok-bin-linux-arm64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"linux","arch":"arm64"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules\@expo\ngrok-bin-sunos-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"sunos","arch":"x64"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules\@expo\ngrok-bin-linux-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"linux","arch":"x64"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules\@expo\ngrok-bin-win32-ia32):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"win32","arch":"ia32"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `ln -sf lib/{ios,android} .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\shaha\AppData\Roaming\npm-cache\_logs\2018-07-02T10_08_25_856Z-debug.log

upon npm install
could you please address this Mr. Ghorbani ?

this is my package.json file :

"dependencies": {
    "@types/react": "^16.4.6",
    "@types/react-native": "^0.55.26",
    "download": "^7.0.0",
    "expo": "^27.0.1",
    "mobx": "^4.3.1",
    "mobx-react": "^5.2.3",
    "native-base": "^2.6.1",
    "parse": "^1.11.1",
    "react": "^16.4.1",
    "react-native": "~0.55.2",
    "react-native-animatable": "^1.3.0",
    "react-native-elements": "^0.19.1",
    "react-native-router-flux": "^4.0.0-beta.31"
  }
}

Jalaali calendar does not work correctly when "current" props set by jalaali date

Here is my code,
when I set correspond gregorian date or not set the current props, calendar is working properly and it set to current date of system in jalaali mode. but it doesn't when I manually set the date in props.

export default class App extends Component<Props> {
  render() {
    return (
      <View style={styles.container}>
          <Calendar
              type="jalaali"
              current="1397-05-28"
              onDayPress={(day, localDay) => {console.log('selected day', day, localDay)}}
              // Handler which gets executed when press arrow icon left. It receive a callback can go back month
              onPressArrowLeft={substractMonth => substractMonth()}
              // Handler which gets executed when press arrow icon left. It receive a callback can go next month
              onPressArrowRight={addMonth => addMonth()}
              style={{
                  borderWidth: 1,
                  borderColor: 'black',
                  height: 350
              }}
              // Specify theme properties to override specific styles for calendar parts. Default = {}
              theme={{
                  backgroundColor: '#ffffff',
                  calendarBackground: '#ffffff',
                  textSectionTitleColor: '#b6c1cd',
                  selectedDayBackgroundColor: '#00adf5',
                  selectedDayTextColor: '#ffffff',
                  todayTextColor: '#00adf5',
                  dayTextColor: '#2d4150',
                  textDisabledColor: '#d9e1e8',
                  dotColor: '#00adf5',
                  selectedDotColor: '#ffffff',
                  arrowColor: 'orange',
                  monthTextColor: 'blue',
                  textDayFontFamily: 'monospace',
                  textMonthFontFamily: 'monospace',
                  textDayHeaderFontFamily: 'monospace',
                  textMonthFontWeight: 'bold',
                  textDayFontSize: 16,
                  textMonthFontSize: 16,
                  textDayHeaderFontSize: 16
              }}
          />
      </View>
    );
  }
}

screenshot_1534678076

for more details, I bring here result of onDayPress function.

result of press on day 1

'selected day', { year: 1397,
                   month: 5,
                   day: 21,
                   timestamp: -18069955200000,
                   dateString: '1397-05-21' }, { year: 776,
                   month: 3,
                   day: 1,
                   timestamp: -18069955200000,
                   dateString: '0776-03-01' }

result of press on day 15

'selected day', { year: 1397,
                   month: 6,
                   day: 4,
                   timestamp: -18068745600000,
                   dateString: '1397-06-04' }, { year: 776,
                   month: 3,
                   day: 15,
                   timestamp: -18068745600000,
                   dateString: '0776-03-15' }

Is it a bug or I am doing something wrong in my code?

Unexpected reserved type string

I upgraded to react-native 0.59.10 but bundling is failed:

`react-native-common\src\components\SegmentedControl.js: Unexpected reserved type string (20:30)

18 | static propTypes: {
19 | values: PropTypes.array,

20 | selectionColor: PropTypes.string,
| ^
21 | selectedIndex: PropTypes.number,
22 | onChange: PropTypes.func,
23 | titleStyle: PropTypes.any,
at Object.raise (@react-native-community\cli\node_modules\metro-react-native-babel-transformer\node_modules@babel\parser\lib\index.js:7012:17)`

Element type is invalid

Description

After updating react-native to 0.61.4, the following error appears:

Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Reproducible Demo

import { Calendar } from 'react-native-general-calendars';

const Component = () => {
  return (
    <Calendar
      markedDates={{ '2012-05-17': { marked: true } }}
    />
  );
};

Environment

  • react-native 0.61.4 (Expo SDK 36.0.0)
  • react-native-general-calendars 1.11.0

error when install react-native-general-calendars

hi
when install react-native-general-calendars
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: ln -sf lib/{ios,android} .
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

Requiring unknown module "./locale/fa"

Android 4.2.2 in release mode i got this runTime error:
com.facebook.react.common.JavascriptException: Requiring unknown module "./locale/fa"., stack:

"react-native-general-calendars": "^1.8.0",
"react-native": "0.51.0",

 <Calendar
                    type='jalaali'
                    hideExtraDays={true}
                    onDayPress={this.onDateChoose}
                    theme={{
                        textSectionTitleColor: '#b6c1cd',
                        selectedDayBackgroundColor: '#2b8ce5',
                        todayTextColor: '#2b8ce5',
                        dayTextColor: '#2d4150',
                        monthTextColor: '#0037a9',
                        textDayFontFamily: 'IRANSansMobileFaNum',
                        textMonthFontFamily: 'IRANSansMobileFaNum',
                        textDayHeaderFontFamily: 'IRANSansMobileFaNum',
                        textDayFontSize: fontSize36,
                        textMonthFontSize: fontSize36,
                        textDayHeaderFontSize: 12
                    }}
                />

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.