npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-weekly-calendar

v0.2.0

Published

Weekly Calendar component for React Native

Downloads

427

Readme

react-native-weekly-calendar

React Native Weekly Calendar component with customization

Installation

yarn add react-native-weekly-calendar

Usage

import React from 'react';
import { StyleSheet, View } from 'react-native';
import WeeklyCalendar from 'react-native-weekly-calendar';

export default function App() {
  const sampleEvents = [
    { 'start': '2020-03-23 09:00:00', 'duration': '00:20:00', 'note': 'Walk my dog' },
    { 'start': '2020-03-24 14:00:00', 'duration': '01:00:00', 'note': 'Doctor\'s appointment' },
    { 'start': '2020-03-25 08:00:00', 'duration': '00:30:00', 'note': 'Morning exercise' },
    { 'start': '2020-03-25 14:00:00', 'duration': '02:00:00', 'note': 'Meeting with client' },
    { 'start': '2020-03-25 19:00:00', 'duration': '01:00:00', 'note': 'Dinner with family' },
    { 'start': '2020-03-26 09:30:00', 'duration': '01:00:00', 'note': 'Schedule 1' },
    { 'start': '2020-03-26 11:00:00', 'duration': '02:00:00', 'note': 'Schedule 2' },
    { 'start': '2020-03-26 15:00:00', 'duration': '01:30:00', 'note': 'Schedule 3' },
    { 'start': '2020-03-26 18:00:00', 'duration': '02:00:00', 'note': 'Schedule 4' },
    { 'start': '2020-03-26 22:00:00', 'duration': '01:00:00', 'note': 'Schedule 5' }
  ]

  return (
    <View style={styles.container}>
      <WeeklyCalendar events={sampleEvents} style={{ height: 400 }} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  }
});

Select Date

select_dates

Change Week

change_weeks

Pick Date (iOS & Android)

pick_dates_ios pick_dates_android

Properties

All properties are optional. | Prop | Default | PropTypes | Description | | :------------ |:---------------:| :---------------:| :-----| | selected | moment() | string or Date or Moment | Set initially selected day. Format for string: 'YYYY-MM-DD'. Date and Moment instance are allowed as well. Default provides Moment instance of today| | startWeekday | 7 | number | Set which weekday to render first. If firstDay = 1, week starts from Monday. If firstDay = 7, week starts from Sunday. | | titleFormat | undefined | string | Set format to display title (e.g. titleFormat='MMM YYYY' displays "Jan 2020") | | weekdayFormat | 'ddd' | string | Set format to display weekdays (e.g. weekdayFormat='dd' displays "Mo" and weekdayFormat='ddd' displays "Mon") | | locale | 'en' | string | Set locale (e.g. Korean='ko', English='en', Chinese(Mandarin)='zh-cn', etc.) | | events | [] | array | Set list of events you want to display below weekly calendar. Default is empty array []. | | renderEvent | undefined | func | Specify how each event should be rendered below weekly calendar. Event & index are given as parameters. | | renderFirstEvent | undefined | func | Specify how first event should be rendered below weekly calendar. Event & index are given as parameters. | | renderLastEvent | undefined | func | Specify how last event should be rendered below weekly calendar. Event & index are given as parameters. | | renderDay | undefined | func | Specify how day should be rendered below weekly calendar. Event Views, day (Moment object), index are given as parameters. | | renderFirstDay | undefined | func | Specify how first day should be rendered below weekly calendar. Event Views, day (Moment object), index are given as parameters. | | renderLastDay | undefined | func | Specify how last day should be rendered below weekly calendar. Event Views, day (Moment object), index are given as parameters. | | onDayPress | undefined | func | Handler which gets executed on day press. Default = undefined | | themeColor | '#46c3ad' | string | Set theme color. Either color code or color name that is registered in RN StyleSheet works. | | style | {} | object | Set style of WeeklyCalendar component | | titleStyle | {} | object | Set text style of calendar title | | dayLabelStyle | {} | object | Set text style of weekday labels |

Customization

<View style={styles.container}>
  <WeeklyCalendar
    events={sampleEvents} 
    selected='2020-03-23'
    startWeekday={7}
    weekdayFormat='ddd'
    locale='ko'
    renderEvent={(event, j) => {
      let startTime = moment(event.start).format('LT').toString()
      let duration = event.duration.split(':')
      let seconds = parseInt(duration[0]) * 3600 + parseInt(duration[1]) * 60 + parseInt(duration[2])
      let endTime = moment(event.start).add(seconds, 'seconds').format('LT').toString()
      return (
        <View key={j}>
          <View style={styles.event}>
            <View style={styles.eventDuration}>
              <View style={styles.durationContainer}>
                <View style={styles.durationDot} />
                <Text style={styles.durationText}>{startTime}</Text>
              </View>
              <View style={{ paddingTop: 10 }} />
              <View style={styles.durationContainer}>
                <View style={styles.durationDot} />
                <Text style={styles.durationText}>{endTime}</Text>
              </View>
              <View style={styles.durationDotConnector} />
            </View>
            <View style={styles.eventNote}>
              <Text style={styles.eventText}>{event.note}</Text>
            </View>
          </View>
          <View style={styles.lineSeparator} />
        </View>
      )
    }}
    renderLastEvent={(event, j) => {
      let startTime = moment(event.start).format('LT').toString()
      let duration = event.duration.split(':')
      let seconds = parseInt(duration[0]) * 3600 + parseInt(duration[1]) * 60 + parseInt(duration[2])
      let endTime = moment(event.start).add(seconds, 'seconds').format('LT').toString()
      return (
        <View key={j}>
          <View style={styles.event}>
            <View style={styles.eventDuration}>
              <View style={styles.durationContainer}>
                <View style={styles.durationDot} />
                <Text style={styles.durationText}>{startTime}</Text>
              </View>
              <View style={{ paddingTop: 10 }} />
              <View style={styles.durationContainer}>
                <View style={styles.durationDot} />
                <Text style={styles.durationText}>{endTime}</Text>
              </View>
              <View style={styles.durationDotConnector} />
            </View>
            <View style={styles.eventNote}>
              <Text style={styles.eventText}>{event.note}</Text>
            </View>
          </View>
        </View>
      )
    }}
    renderDay={(eventViews, weekdayToAdd, i) => (
      <View key={i.toString()} style={styles.day}>
        <View style={styles.dayLabel}>
          <Text style={[styles.monthDateText, { color: 'pink' }]}>{weekdayToAdd.format('M/D').toString()}</Text>
          <Text style={[styles.dayText, { color: 'pink' }]}>{weekdayToAdd.format('ddd').toString()}</Text>
        </View>
        <View style={[styles.allEvents, eventViews.length === 0 ? { width: '100%', backgroundColor: 'pink' } : {}]}>
          {eventViews}
        </View>
      </View>
    )}
    onDayPress={(weekday, i) => {
      console.log(weekday.format('ddd') + ' is selected! And it is day ' + (i+1) + ' of the week!')
    }}
    themeColor='pink'
    style={{ height: 400 }}
    titleStyle={{ color: 'blue' }}
    dayLabelStyle={{ color: 'green' }}
  />
</View>

customized