1.3.8 • Published 18 days ago

roko-date-picker v1.3.8

Weekly downloads
-
License
ISC
Repository
github
Last release
18 days ago

roko-date-picker

  1. Install
npm i roko-date-picker
  1. Usage
import { StyleSheet, Switch, View } from "react-native";
import React, { useCallback, useState } from "react";
import Header from "./Header";
import { materialColors, RokoCalendar, Theme, Range } from "../../../src/";
import { previousDay } from "date-fns";

const calendarStyle: Theme = {
  colors: {
    primary: "#FF5733",
    onPrimary: "white",
    secondary: "#FFF9C4",
    onSecondary: "#9E9E9E",
    background: "#DAF7A6",
    onBackground: "#000000",
  },
  font: {},
};

const DatePicker = () => {
  // #region States
  const [mode, toggleMode] = useState<"single" | "range">("range");
  const [range, setRange] = useState<Range>([new Date()]);
  // #endregion
  // #region Functions
  const handleToggleMode = useCallback(() => {
    switch (mode) {
      case "range":
        toggleMode("single");
        break;
      default:
        toggleMode("range");
        break;
    }
  }, [mode]);
  // #endregion
  return (
    <View style={styles.root}>
      <Header {...{ title: "Single Picker", range, onPress: () => {}, mode }} />
      <View style={{ height: 360, backgroundColor: materialColors.grey._200, borderRadius: 16, overflow: "hidden", padding: 8 }}>
        <RokoCalendar {...{ mode, range, setRange, blockedDates: [previousDay(new Date(), 4)], blockPast: true, theme: calendarStyle }} />
      </View>
      <Switch value={mode === "range"} onChange={() => handleToggleMode()} />
    </View>
  );
};

export default DatePicker;

const styles = StyleSheet.create({ root: { gap: 16, flex: 1 } });
1.3.7

18 days ago

1.3.8

18 days ago

1.3.6

2 months ago

1.3.5

2 months ago

1.3.4

2 months ago

1.3.2

2 months ago

1.3.1

2 months ago

1.2.8

5 months ago

1.2.7

5 months ago

1.2.6

6 months ago

1.2.5

6 months ago

1.2.4

6 months ago

1.2.3

6 months ago

1.2.2

6 months ago

1.3.0

5 months ago

1.2.1

7 months ago

1.2.9

5 months ago

1.2.0

7 months ago

1.1.9

7 months ago

1.1.8

8 months ago

1.1.7

8 months ago

1.1.6

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.0

9 months ago